@pharos-ds/core 1.0.3 → 1.0.4-canary.f55713e

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": "@pharos-ds/core",
3
- "version": "1.0.3",
3
+ "version": "1.0.4-canary.f55713e",
4
4
  "displayName": "Pharos Core",
5
5
  "description": "Pharos component library. Accessible, themeable React components with spacing, dark mode, and StyleX styling.",
6
6
  "author": "Caio Silvestre",
@@ -140,6 +140,12 @@ export const docs = {
140
140
  description:
141
141
  'The HTML name attribute for the input, useful for form submissions.',
142
142
  },
143
+ {
144
+ name: 'autoComplete',
145
+ type: 'HTMLInputAutoCompleteAttribute',
146
+ description:
147
+ "The HTML autocomplete attribute (e.g. 'email', 'current-password', 'one-time-code'), so browsers and password managers can fill the field.",
148
+ },
143
149
  {
144
150
  name: 'width',
145
151
  type: 'SizeValue',
@@ -312,6 +318,12 @@ export const docsZh = {
312
318
  description:
313
319
  '输入框的 HTML name 属性,用于表单提交。',
314
320
  },
321
+ {
322
+ name: 'autoComplete',
323
+ type: 'HTMLInputAutoCompleteAttribute',
324
+ description:
325
+ "输入框的 HTML autocomplete 属性(如 'email'、'current-password'、'one-time-code'),便于浏览器和密码管理器自动填充。",
326
+ },
315
327
  ],
316
328
  theming: {
317
329
  targets: [
@@ -392,5 +404,6 @@ export const docsDense = {
392
404
  hasClear: 'Shows clear button when input has value. Clears value on click.',
393
405
  hasAutoFocus: 'Auto-focus input on mount.',
394
406
  htmlName: 'HTML name attr for form submissions.',
407
+ autoComplete: "HTML autocomplete attr ('email', 'current-password'…) for browser/password-manager fill.",
395
408
  },
396
409
  };
@@ -99,6 +99,26 @@ describe('TextInput', () => {
99
99
  expect(screen.getByRole('textbox')).toHaveValue('Controlled value');
100
100
  });
101
101
 
102
+ it('forwards autoComplete to the input', () => {
103
+ render(
104
+ <TextInput
105
+ label="Senha"
106
+ type="password"
107
+ autoComplete="current-password"
108
+ value=""
109
+ />,
110
+ );
111
+ expect(screen.getByLabelText('Senha')).toHaveAttribute(
112
+ 'autocomplete',
113
+ 'current-password',
114
+ );
115
+ });
116
+
117
+ it('does not set autocomplete when the prop is omitted', () => {
118
+ render(<TextInput label="Nome" value="" />);
119
+ expect(screen.getByLabelText('Nome')).not.toHaveAttribute('autocomplete');
120
+ });
121
+
102
122
  it('forwards ref correctly', () => {
103
123
  const ref = vi.fn();
104
124
  render(<TextInput ref={ref} label="Name" value="" onChange={() => {}} />);
@@ -258,6 +258,11 @@ export interface TextInputProps extends Omit<
258
258
  * Useful for form submissions.
259
259
  */
260
260
  htmlName?: string;
261
+ /**
262
+ * The HTML autocomplete attribute (e.g. `'email'`, `'current-password'`,
263
+ * `'one-time-code'`). Lets browsers and password managers fill the field.
264
+ */
265
+ autoComplete?: React.HTMLInputAutoCompleteAttribute;
261
266
  /**
262
267
  * Callback fired when the user presses the Enter key.
263
268
  */
@@ -299,6 +304,7 @@ export function TextInput({
299
304
  hasClear = false,
300
305
  hasAutoFocus = false,
301
306
  htmlName,
307
+ autoComplete,
302
308
  onEnter,
303
309
  onKeyDown,
304
310
  width,
@@ -425,6 +431,7 @@ export function TextInput({
425
431
  ref={mergeRefs(ref, inputRef)}
426
432
  id={id}
427
433
  name={htmlName}
434
+ autoComplete={autoComplete}
428
435
  type={type}
429
436
  value={optimisticValue}
430
437
  onChange={handleChange}