@molecule/app-join-code-react 1.0.0 → 1.0.2
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.
- package/README.md +160 -0
- package/package.json +16 -9
package/README.md
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
AUTO-GENERATED — DO NOT EDIT THIS FILE.
|
|
3
|
+
Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
|
|
4
|
+
Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
|
|
5
|
+
To change this document, edit the module-level JSDoc in src/index.ts.
|
|
6
|
+
Generated: 2026-08-04T01:51:08.777Z
|
|
7
|
+
-->
|
|
8
|
+
|
|
9
|
+
# @molecule/app-join-code-react
|
|
10
|
+
|
|
11
|
+
> **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
|
|
12
|
+
> It is written to be read by coding agents as much as by people, and is generated from this
|
|
13
|
+
> package's source — edit `src/index.ts` JSDoc, not this file.
|
|
14
|
+
|
|
15
|
+
React multi-slot join-code input.
|
|
16
|
+
|
|
17
|
+
Exports:
|
|
18
|
+
|
|
19
|
+
- `<JoinCode>` — N-slot single-character input with auto-advance, paste-to-fill,
|
|
20
|
+
alphabet validation, and `onComplete` notification.
|
|
21
|
+
- `JoinCodeProps`, `JoinCodeAlphabet` — public types.
|
|
22
|
+
|
|
23
|
+
Companion locale bond: `@molecule/app-locales-join-code`.
|
|
24
|
+
|
|
25
|
+
## Quick Start
|
|
26
|
+
|
|
27
|
+
```tsx
|
|
28
|
+
import { JoinCode } from '@molecule/app-join-code-react'
|
|
29
|
+
|
|
30
|
+
;<JoinCode
|
|
31
|
+
length={6}
|
|
32
|
+
alphabet="alphanumeric"
|
|
33
|
+
onChange={(code) => setCode(code)}
|
|
34
|
+
onComplete={(code) => verifyCode(code)}
|
|
35
|
+
/>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Type
|
|
39
|
+
|
|
40
|
+
`feature`
|
|
41
|
+
|
|
42
|
+
## Installation
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
npm install @molecule/app-join-code-react @molecule/app-i18n @molecule/app-react @molecule/app-ui react
|
|
46
|
+
npm install -D @types/react
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## API
|
|
50
|
+
|
|
51
|
+
### Interfaces
|
|
52
|
+
|
|
53
|
+
#### `JoinCodeProps`
|
|
54
|
+
|
|
55
|
+
Props for the `<JoinCode>` component.
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
interface JoinCodeProps {
|
|
59
|
+
/** Number of slots / characters in the code. Defaults to `6`. */
|
|
60
|
+
length?: number
|
|
61
|
+
/**
|
|
62
|
+
* Controlled value. When provided, the component is controlled and ignores
|
|
63
|
+
* `defaultValue`. The value may be shorter than `length`; missing slots
|
|
64
|
+
* render empty.
|
|
65
|
+
*/
|
|
66
|
+
value?: string
|
|
67
|
+
/**
|
|
68
|
+
* Initial value when uncontrolled. Ignored when `value` is provided.
|
|
69
|
+
*/
|
|
70
|
+
defaultValue?: string
|
|
71
|
+
/**
|
|
72
|
+
* Called whenever the code changes (typing, paste, backspace).
|
|
73
|
+
* The argument is the *current* code (may be shorter than `length`).
|
|
74
|
+
*/
|
|
75
|
+
onChange?: (code: string) => void
|
|
76
|
+
/**
|
|
77
|
+
* Called when the code reaches the configured `length` and every character
|
|
78
|
+
* passes alphabet validation. Fires once per completion (re-fires when the
|
|
79
|
+
* code is cleared and re-completed).
|
|
80
|
+
*/
|
|
81
|
+
onComplete?: (code: string) => void
|
|
82
|
+
/**
|
|
83
|
+
* Whether to fire `onComplete` automatically when `length` is reached.
|
|
84
|
+
* Defaults to `true`.
|
|
85
|
+
*/
|
|
86
|
+
autoSubmit?: boolean
|
|
87
|
+
/** Allowed character set. Defaults to `'alphanumeric'`. */
|
|
88
|
+
alphabet?: JoinCodeAlphabet
|
|
89
|
+
/** Whether the input is disabled. */
|
|
90
|
+
disabled?: boolean
|
|
91
|
+
/** Optional className applied to the outer wrapper. */
|
|
92
|
+
className?: string
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Types
|
|
97
|
+
|
|
98
|
+
#### `JoinCodeAlphabet`
|
|
99
|
+
|
|
100
|
+
Alphabet a join code may use.
|
|
101
|
+
|
|
102
|
+
- `'numeric'` — `0-9` only.
|
|
103
|
+
- `'letters'` — `A-Z` only (case-insensitive on input, normalised to upper-case).
|
|
104
|
+
- `'alphanumeric'` — `A-Z` + `0-9` (case-insensitive, normalised to upper-case).
|
|
105
|
+
|
|
106
|
+
```typescript
|
|
107
|
+
type JoinCodeAlphabet = 'numeric' | 'letters' | 'alphanumeric'
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Functions
|
|
111
|
+
|
|
112
|
+
#### `JoinCode(props)`
|
|
113
|
+
|
|
114
|
+
Multi-slot join-code input. Renders one single-character `<input>` per slot
|
|
115
|
+
with auto-advance focus, backspace-to-previous, and paste-to-fill behaviour.
|
|
116
|
+
|
|
117
|
+
- **Controlled** when `value` is provided; the parent must update it via
|
|
118
|
+
`onChange`. The displayed code is clamped to `length` characters.
|
|
119
|
+
- **Uncontrolled** otherwise; `defaultValue` seeds the initial state.
|
|
120
|
+
|
|
121
|
+
Calls `onComplete(code)` once the code reaches `length` characters and every
|
|
122
|
+
character matches `alphabet`. The fire is suppressed while `autoSubmit`
|
|
123
|
+
is `false`.
|
|
124
|
+
|
|
125
|
+
All user-visible text (label, slot aria-labels) flows through `t()` so
|
|
126
|
+
apps can localise via the companion `@molecule/app-locales-join-code`
|
|
127
|
+
bond.
|
|
128
|
+
|
|
129
|
+
Styling is delegated to `getClassMap()` — no Tailwind utility strings live
|
|
130
|
+
in this package.
|
|
131
|
+
|
|
132
|
+
```typescript
|
|
133
|
+
function JoinCode(props: JoinCodeProps): ReactElement<unknown, string | JSXElementConstructor<any>>
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
- `props` — See `JoinCodeProps`.
|
|
137
|
+
|
|
138
|
+
**Returns:** The rendered join-code input.
|
|
139
|
+
|
|
140
|
+
## Injection Notes
|
|
141
|
+
|
|
142
|
+
### Requirements
|
|
143
|
+
|
|
144
|
+
Peer dependencies:
|
|
145
|
+
|
|
146
|
+
- `@molecule/app-i18n` ^1.0.1
|
|
147
|
+
- `@molecule/app-react` ^1.0.1
|
|
148
|
+
- `@molecule/app-ui` ^1.0.1
|
|
149
|
+
- `react` ^18.0.0 || ^19.0.0
|
|
150
|
+
|
|
151
|
+
### Runtime Dependencies
|
|
152
|
+
|
|
153
|
+
- `@molecule/app-i18n`
|
|
154
|
+
- `@molecule/app-react`
|
|
155
|
+
- `@molecule/app-ui`
|
|
156
|
+
- `react`
|
|
157
|
+
|
|
158
|
+
## Translations
|
|
159
|
+
|
|
160
|
+
Translation strings are provided by `@molecule/app-locales-join-code`.
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molecule/app-join-code-react",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Multi-slot join-code input with auto-advance, paste-to-fill, and alphabet validation. Used for live quiz join, virtual classroom room codes, and similar short-code entry UX.",
|
|
5
|
+
"homepage": "https://www.molecule.dev/packages/app-join-code-react",
|
|
5
6
|
"type": "module",
|
|
6
7
|
"main": "dist/index.js",
|
|
7
8
|
"types": "dist/index.d.ts",
|
|
@@ -17,7 +18,8 @@
|
|
|
17
18
|
}
|
|
18
19
|
},
|
|
19
20
|
"files": [
|
|
20
|
-
"dist"
|
|
21
|
+
"dist",
|
|
22
|
+
"README.md"
|
|
21
23
|
],
|
|
22
24
|
"keywords": [
|
|
23
25
|
"molecule",
|
|
@@ -25,16 +27,21 @@
|
|
|
25
27
|
"react"
|
|
26
28
|
],
|
|
27
29
|
"license": "Apache-2.0",
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "https://github.com/molecule-dev/molecule.git",
|
|
33
|
+
"directory": "packages/app/features/join-code-react"
|
|
34
|
+
},
|
|
28
35
|
"peerDependencies": {
|
|
29
|
-
"@molecule/app-i18n": "^1.0.
|
|
30
|
-
"@molecule/app-react": "^1.0.
|
|
31
|
-
"@molecule/app-ui": "^1.0.
|
|
36
|
+
"@molecule/app-i18n": "^1.0.1",
|
|
37
|
+
"@molecule/app-react": "^1.0.1",
|
|
38
|
+
"@molecule/app-ui": "^1.0.1",
|
|
32
39
|
"react": "^18.0.0 || ^19.0.0"
|
|
33
40
|
},
|
|
34
41
|
"devDependencies": {
|
|
35
|
-
"@molecule/app-i18n": "1.0.
|
|
36
|
-
"@molecule/app-react": "1.
|
|
37
|
-
"@molecule/app-ui": "1.
|
|
42
|
+
"@molecule/app-i18n": "1.0.2",
|
|
43
|
+
"@molecule/app-react": "1.5.1",
|
|
44
|
+
"@molecule/app-ui": "1.1.1",
|
|
38
45
|
"@testing-library/react": "16.3.2",
|
|
39
46
|
"@types/node": "26.1.2",
|
|
40
47
|
"@types/react": "19.2.17",
|
|
@@ -42,6 +49,6 @@
|
|
|
42
49
|
"react": "19.2.8",
|
|
43
50
|
"react-dom": "19.2.8",
|
|
44
51
|
"typescript": "6.0.3",
|
|
45
|
-
"vitest": "4.1.
|
|
52
|
+
"vitest": "4.1.11"
|
|
46
53
|
}
|
|
47
54
|
}
|