Skip to content

Commit cee0dbc

Browse files
committed
feat: autocomplete
1 parent 0a49f8d commit cee0dbc

File tree

4 files changed

+26
-4
lines changed

4 files changed

+26
-4
lines changed

examples/auth/src/components/user-auth-form.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ export function UserAuthForm(props: React.ComponentPropsWithoutRef<typeof Contai
99
<Container flexDirection="column" gap={24} {...props}>
1010
<Container flexDirection="column" gap={8}>
1111
<Container flexDirection="column" gap={4}>
12-
<Input placeholder="name@example.com" />
13-
<Input type="password" placeholder="password" />
12+
<Input autocomplete="email" placeholder="name@example.com" />
13+
<Input autocomplete="current-password" type="password" placeholder="password" />
1414
</Container>
1515
<Button>
1616
<Text>Sign In with Email</Text>

packages/kits/apfel/src/input.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export const Input: (props: InputProperties & RefAttributes<ContainerRef>) => Re
3030
tabIndex,
3131
disabled,
3232
type,
33+
autocomplete,
3334
...props
3435
},
3536
ref,
@@ -79,6 +80,7 @@ export const Input: (props: InputProperties & RefAttributes<ContainerRef>) => Re
7980
)}
8081
<InputImpl
8182
ref={setInternal}
83+
autocomplete={autocomplete}
8284
height="100%"
8385
width="100%"
8486
verticalAlign="center"

packages/kits/default/src/input.tsx

+13-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,18 @@ type _InputProperties = InputProperties
1818

1919
export const Input: (props: InputProperties & RefAttributes<ContainerRef>) => ReactNode = forwardRef(
2020
(
21-
{ panelMaterialClass, value, defaultValue, onValueChange, tabIndex, disabled, placeholder, type, ...props },
21+
{
22+
autocomplete,
23+
panelMaterialClass,
24+
value,
25+
defaultValue,
26+
onValueChange,
27+
tabIndex,
28+
disabled,
29+
placeholder,
30+
type,
31+
...props
32+
},
2233
ref,
2334
) => {
2435
const [internal, setInternal] = useState<InputInternals | null>(null)
@@ -43,6 +54,7 @@ export const Input: (props: InputProperties & RefAttributes<ContainerRef>) => Re
4354
>
4455
<InputImpl
4556
ref={setInternal}
57+
autocomplete={autocomplete}
4658
borderRadius={borderRadius.md}
4759
backgroundColor={colors.background}
4860
borderColor={colors.input}

packages/uikit/src/components/input.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ export type InheritableInputProperties = WithClasses<
6868
DisabledProperties &
6969
VisibilityProperties &
7070
UpdateMatrixWorldProperties &
71-
PointerEventsProperties
71+
PointerEventsProperties &
72+
AutocompleteProperties
7273
>
7374
>
7475
>
@@ -79,6 +80,10 @@ export type DisabledProperties = {
7980
disabled?: boolean
8081
}
8182

83+
export type AutocompleteProperties = {
84+
autocomplete?: AutoFill
85+
}
86+
8287
const cancelSet = new Set<unknown>()
8388

8489
function cancelBlur(event: unknown) {
@@ -363,6 +368,7 @@ export function setupInput<EM extends ThreeEventMap = ThreeEventMap>(
363368
state.type,
364369
state.disabled,
365370
computedNonInheritableProperty(style, properties, 'tabIndex', 0),
371+
computedNonInheritableProperty<AutoFill>(style, properties, 'autocomplete', ''),
366372
abortSignal,
367373
)
368374

@@ -507,6 +513,7 @@ function setupHtmlInputElement(
507513
type: Signal<InputType>,
508514
disabled: Signal<boolean>,
509515
tabIndex: Signal<number>,
516+
autocomplete: Signal<AutoFill>,
510517
abortSignal: AbortSignal,
511518
) {
512519
document.body.appendChild(element)
@@ -515,6 +522,7 @@ function setupHtmlInputElement(
515522
abortableEffect(() => void (element.value = value.value), abortSignal)
516523
abortableEffect(() => void (element.disabled = disabled.value), abortSignal)
517524
abortableEffect(() => void (element.tabIndex = tabIndex.value), abortSignal)
525+
abortableEffect(() => void (element.autocomplete = autocomplete.value), abortSignal)
518526
abortableEffect(() => element.setAttribute('type', type.value), abortSignal)
519527
}
520528

0 commit comments

Comments
 (0)