@duro-app/ui 0.27.0 → 0.28.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@duro-app/ui",
3
- "version": "0.27.0",
3
+ "version": "0.28.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -53,7 +53,7 @@
53
53
  }
54
54
  },
55
55
  "dependencies": {
56
- "@duro-app/tokens": "^0.27.0"
56
+ "@duro-app/tokens": "^0.28.0"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@babel/preset-typescript": "^7.28.0",
@@ -29,6 +29,7 @@ interface InputProps {
29
29
  value?: string
30
30
  defaultValue?: string
31
31
  disabled?: boolean
32
+ autoFocus?: boolean
32
33
  onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void
33
34
  onBlur?: () => void
34
35
  ref?: React.Ref<HTMLInputElement>
@@ -46,6 +47,7 @@ export function Input({
46
47
  value,
47
48
  defaultValue,
48
49
  disabled,
50
+ autoFocus,
49
51
  onChange,
50
52
  onBlur,
51
53
  ref,
@@ -62,9 +64,11 @@ export function Input({
62
64
  const effectiveDisabled = disabled ?? ctx?.disabled
63
65
  const effectiveVariant = ctx?.invalid ? 'error' : variant
64
66
 
65
- // react-strict-dom omits web-only `pattern` from its types, but the
66
- // underlying DOM element supports it. Type-assert to pass it through.
67
- const extraProps = pattern !== undefined ? {pattern} : undefined
67
+ // react-strict-dom omits some web-only props from its types, but the
68
+ // underlying DOM element supports them. Type-assert to pass them through.
69
+ const extraProps: Record<string, unknown> = {}
70
+ if (pattern !== undefined) extraProps.pattern = pattern
71
+ if (autoFocus) extraProps.autoFocus = true
68
72
 
69
73
  return (
70
74
  <html.input
@@ -86,7 +90,7 @@ export function Input({
86
90
  onBlur={effectiveOnBlur as StrictInputProps['onBlur']}
87
91
  ref={effectiveRef as React.Ref<HTMLInputElement>}
88
92
  style={[styles.base, styles[effectiveVariant], groupCtx?.inGroup && styles.inGroup]}
89
- {...(extraProps as Record<string, unknown>)}
93
+ {...extraProps}
90
94
  />
91
95
  )
92
96
  }
@@ -15,6 +15,7 @@ interface TextareaProps {
15
15
  value?: string
16
16
  defaultValue?: string
17
17
  disabled?: boolean
18
+ autoFocus?: boolean
18
19
  onChange?: (e: React.ChangeEvent<HTMLTextAreaElement>) => void
19
20
  onBlur?: () => void
20
21
  ref?: React.Ref<HTMLTextAreaElement>
@@ -29,6 +30,7 @@ export function Textarea({
29
30
  value,
30
31
  defaultValue,
31
32
  disabled,
33
+ autoFocus,
32
34
  onChange,
33
35
  onBlur,
34
36
  ref,
@@ -44,6 +46,9 @@ export function Textarea({
44
46
  const effectiveDisabled = disabled ?? ctx?.disabled
45
47
  const effectiveVariant = ctx?.invalid ? 'error' : variant
46
48
 
49
+ const extraProps: Record<string, unknown> = {}
50
+ if (autoFocus) extraProps.autoFocus = true
51
+
47
52
  return (
48
53
  <html.textarea
49
54
  id={ctx?.controlId}
@@ -62,6 +67,7 @@ export function Textarea({
62
67
  onBlur={effectiveOnBlur as StrictTextareaProps['onBlur']}
63
68
  ref={effectiveRef as React.Ref<HTMLTextAreaElement>}
64
69
  style={[styles.base, styles[effectiveVariant]]}
70
+ {...extraProps}
65
71
  />
66
72
  )
67
73
  }