141 lines
11 KiB
Plaintext
141 lines
11 KiB
Plaintext
page PinInputcomponent {
|
|
seo {
|
|
title = "PinInput component"
|
|
description = "Secure multi-cell PIN and verification-code input with regex and paste support."
|
|
}
|
|
|
|
view {
|
|
<div class="docs-shell">
|
|
<SkipLink label="Skip to content" href="#main" class="docs-skip-link" />
|
|
<header class="topbar">
|
|
<a class="brand" href="/"><span>W</span> WRNexusJS</a>
|
|
<nav aria-label="Primary"><a href="/getting-started">Get started</a><a href="/packages">Packages</a><a href="/components">Components</a><a href="/language">Language</a><a href="/architecture">Architecture</a></nav>
|
|
<div class="topbar-actions"><a class="preview-pill" href="/access">Private preview · v0.3.5</a><button data-wire-theme-toggle class="theme-button" aria-label="Toggle color theme" title="Toggle color theme">◐</button></div>
|
|
</header>
|
|
<div class="mobile-doc-nav"><details><summary>Browse documentation</summary><nav><a href="/getting-started">Get started</a><a href="/packages">Packages</a><a href="/components">Components</a><a href="/language">Language</a><a href="/architecture">Architecture</a><a href="/tutorial">Tutorial</a><a href="/guides/project-structure">Guides</a><a href="/examples">Examples</a><a href="/search">Search</a></nav></details></div>
|
|
<main class="portal-main docs-layout component-detail-page"><article id="main" class="documentation prose standalone"><nav class="breadcrumbs" aria-label="Breadcrumb"><a href="/">Home</a><span>/</span><a href="/components">Components</a><span>/</span><span aria-current="page">PinInput</span></nav><section class="doc-intro"><span class="eyebrow">advanced-forms component</span><h1>PinInput</h1><p>Secure multi-cell PIN and verification-code input with regex and paste support.</p><div class="doc-meta"><span>@wrnexus/ui 0.3.5</span><span>26 props</span><span>0 slots</span><span>6 events</span></div></section><section id="usage"><h2>Usage</h2><p>Components are auto-discovered. Use the component directly in any <code>.wrn</code> view:</p><pre data-language="wrn"><code><PinInput
|
|
size="default"
|
|
color="primary"
|
|
label="Verification code"
|
|
name="pin"
|
|
value="value"
|
|
/></code></pre><p>Legacy mount name: <code>data-component="PinInput"</code>.</p></section><section id="props"><h2>Props and attributes</h2><div class="table-wrap"><table><thead><tr><th>Prop</th><th>Type</th><th>Requirement</th><th>Default</th></tr></thead><tbody><tr><td><code>size</code></td><td><code>string</code></td><td>Optional</td><td><code>"default"</code></td></tr><tr><td><code>color</code></td><td><code>string</code></td><td>Optional</td><td><code>"primary"</code></td></tr><tr><td><code>label</code></td><td><code>string</code></td><td>Optional</td><td><code>"Verification code"</code></td></tr><tr><td><code>name</code></td><td><code>string</code></td><td>Optional</td><td><code>"pin"</code></td></tr><tr><td><code>value</code></td><td><code>string</code></td><td>Optional</td><td><code>""</code></td></tr><tr><td><code>length</code></td><td><code>number</code></td><td>Optional</td><td><code>4</code></td></tr><tr><td><code>pattern</code></td><td><code>string</code></td><td>Optional</td><td><code>"[0-9]"</code></td></tr><tr><td><code>type</code></td><td><code>string</code></td><td>Optional</td><td><code>"text"</code></td></tr><tr><td><code>inputMode</code></td><td><code>string</code></td><td>Optional</td><td><code>"numeric"</code></td></tr><tr><td><code>placeholder</code></td><td><code>string</code></td><td>Optional</td><td><code>"○"</code></td></tr><tr><td><code>autocomplete</code></td><td><code>string</code></td><td>Optional</td><td><code>"one-time-code"</code></td></tr><tr><td><code>masked</code></td><td><code>boolean</code></td><td>Optional</td><td><code>false</code></td></tr><tr><td><code>disabled</code></td><td><code>boolean</code></td><td>Optional</td><td><code>false</code></td></tr><tr><td><code>readonly</code></td><td><code>boolean</code></td><td>Optional</td><td><code>false</code></td></tr><tr><td><code>required</code></td><td><code>boolean</code></td><td>Optional</td><td><code>false</code></td></tr><tr><td><code>autoFocus</code></td><td><code>boolean</code></td><td>Optional</td><td><code>false</code></td></tr><tr><td><code>autoSubmit</code></td><td><code>boolean</code></td><td>Optional</td><td><code>false</code></td></tr><tr><td><code>allowPaste</code></td><td><code>boolean</code></td><td>Optional</td><td><code>true</code></td></tr><tr><td><code>clearable</code></td><td><code>boolean</code></td><td>Optional</td><td><code>true</code></td></tr><tr><td><code>clearLabel</code></td><td><code>string</code></td><td>Optional</td><td><code>"Clear code"</code></td></tr><tr><td><code>separator</code></td><td><code>string</code></td><td>Optional</td><td><code>""</code></td></tr><tr><td><code>groupSize</code></td><td><code>number</code></td><td>Optional</td><td><code>0</code></td></tr><tr><td><code>helpText</code></td><td><code>string</code></td><td>Optional</td><td><code>""</code></td></tr><tr><td><code>invalid</code></td><td><code>boolean</code></td><td>Optional</td><td><code>false</code></td></tr><tr><td><code>validationMessage</code></td><td><code>string</code></td><td>Optional</td><td><code>""</code></td></tr><tr><td><code>class</code></td><td><code>string</code></td><td>Optional</td><td><code>""</code></td></tr></tbody></table></div></section><section id="slots"><h2>Slots</h2><p>This component does not declare a slot.</p></section><section id="events"><h2>Events</h2><ul><li><code>input</code></li><li><code>change</code></li><li><code>complete</code></li><li><code>paste</code></li><li><code>clear</code></li><li><code>error</code></li></ul></section><section id="source"><h2>Source contract</h2><p>Installed source: <code>components/PinInput.wrn</code></p><pre data-language="wrn"><code>component PinInput {
|
|
props {
|
|
size = "default"
|
|
color = "primary"
|
|
label = "Verification code"
|
|
name = "pin"
|
|
value = ""
|
|
length = 4
|
|
pattern = "[0-9]"
|
|
type = "text"
|
|
inputMode = "numeric"
|
|
placeholder = "○"
|
|
autocomplete = "one-time-code"
|
|
masked = false
|
|
disabled = false
|
|
readonly = false
|
|
required = false
|
|
autoFocus = false
|
|
autoSubmit = false
|
|
allowPaste = true
|
|
clearable = true
|
|
clearLabel = "Clear code"
|
|
separator = ""
|
|
groupSize = 0
|
|
helpText = ""
|
|
invalid = false
|
|
validationMessage = ""
|
|
class = ""
|
|
@event input = function
|
|
@event change = function
|
|
@event complete = function
|
|
@event paste = function
|
|
@event clear = function
|
|
@event error = function
|
|
}
|
|
|
|
functions {
|
|
function inputIndexes() {
|
|
return [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11].slice(
|
|
0,
|
|
Math.max(1, Math.min(12, Number(length)))
|
|
)
|
|
}
|
|
}
|
|
|
|
view {
|
|
<fieldset
|
|
{...attrs}
|
|
class="wire-next wire-next--color-{color} wire-next--size-{size} wire-next--pin-input {invalid ? 'wire-next--invalid' : ''} {disabled ? 'wire-next--disabled' : ''} {class}"
|
|
data-wrn-pin-input
|
|
data-length="{length}"
|
|
data-pattern="{pattern}"
|
|
data-allow-paste="{allowPaste ? 'true' : 'false'}"
|
|
data-auto-submit="{autoSubmit ? 'true' : 'false'}"
|
|
data-value="{value}"
|
|
disabled="{disabled}"
|
|
aria-describedby="{validationMessage ? `${name}-validation` : helpText ? `${name}-help` : ''}"
|
|
>
|
|
<div class="wire-next__pin-heading">
|
|
<legend>{label}</legend>
|
|
<button
|
|
type="button"
|
|
class="wire-next__pin-clear"
|
|
data-pin-clear
|
|
aria-label="{clearLabel}"
|
|
title="{clearLabel}"
|
|
style="{clearable && value ? '' : 'display: none'}"
|
|
>
|
|
<span class="icon-[lucide--rotate-ccw]" aria-hidden="true">
|
|
</span>
|
|
<span>{clearLabel}</span>
|
|
</button>
|
|
</div>
|
|
<div class="wire-next__pin-cells" role="group" aria-label="{label}">
|
|
{#each inputIndexes() as index}
|
|
<input
|
|
data-pin-cell
|
|
data-pin-index="{index}"
|
|
id="{name}-{index}"
|
|
type="{masked ? 'password' : type}"
|
|
inputmode="{inputMode}"
|
|
maxlength="1"
|
|
value="{value[index] || ''}"
|
|
placeholder="{placeholder}"
|
|
autocomplete="{index === 0 ? autocomplete : 'off'}"
|
|
aria-label="{label} digit {index + 1} of {length}"
|
|
aria-required="{required ? 'true' : 'false'}"
|
|
readonly="{readonly}"
|
|
disabled="{disabled}"
|
|
autofocus="{autoFocus && index === 0}"
|
|
/>
|
|
{#if separator && groupSize !== 0 && (index + 1) % groupSize === 0 && index + 1 !== length}
|
|
<span class="wire-next__pin-separator" aria-hidden="true">{separator}</span>
|
|
{/if}
|
|
{/each}
|
|
</div>
|
|
<input
|
|
type="hidden"
|
|
name="{name}"
|
|
value="{value}"
|
|
required="{required}"
|
|
data-pin-value
|
|
/>
|
|
|
|
{#if helpText && !validationMessage}<small id="{name}-help">{helpText}</small>{/if}
|
|
<small
|
|
id="{name}-validation"
|
|
class="wire-next__validation"
|
|
data-error="{name}"
|
|
>{validationMessage}</small>
|
|
</fieldset>
|
|
}
|
|
}
|
|
</code></pre></section></article><aside class="on-this-page"><h2>On this page</h2><nav><a href="#usage">Usage</a><a href="#props">Props and attributes</a><a href="#slots">Slots</a><a href="#events">Events</a><a href="#source">Source contract</a></nav></aside></main>
|
|
<footer><div class="footer-brand"><span class="footer-mark" aria-hidden="true">W</span><p><strong>WRNexusJS 0.3.5</strong><span>Complete API documentation generated from installed package declarations.</span></p></div><nav aria-label="Footer"><a href="/packages">All packages</a><a href="/getting-started">Get started</a><a href="/security">Security</a><a href="/support">Support</a><a href="/llms.txt">AI guide</a></nav><p class="footer-meta">Private Developer Preview · Bun-native</p></footer>
|
|
<BackToTop />
|
|
</div>
|
|
}
|
|
}
|