@solexllc/usx-react 0.1.5 → 0.1.6

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.
Files changed (29) hide show
  1. package/dist/index.cjs +92 -1264
  2. package/dist/index.js +94 -1266
  3. package/package.json +4 -4
  4. package/src/components/accordion/Accordion.tsx +105 -0
  5. package/src/components/accordion/accordion.django.html +1 -1
  6. package/src/components/accordion/config.json +6 -1
  7. package/src/components/banner/Banner.tsx +35 -27
  8. package/src/components/banner/banner.django.html +1 -1
  9. package/src/components/banner/config.json +4 -0
  10. package/src/components/date-picker/{DatePicker.jsx → DatePicker.tsx} +12 -17
  11. package/src/components/date-range-picker/{DateRangePicker.jsx → DateRangePicker.tsx} +21 -21
  12. package/src/components/fieldset/Fieldset.tsx +1 -1
  13. package/src/components/file-input/{FileInput.jsx → FileInput.tsx} +31 -34
  14. package/src/components/file-list/{FileList.jsx → FileList.tsx} +24 -24
  15. package/src/components/header/{HeaderBranding.jsx → HeaderBranding.tsx} +0 -1
  16. package/src/components/hero/Hero.tsx +49 -7
  17. package/src/components/hero/config.json +45 -0
  18. package/src/components/hero/hero.django.html +16 -5
  19. package/src/components/hero/hero.html +19 -0
  20. package/src/components/in-page-nav/{InPageNav.jsx → InPageNav.tsx} +14 -18
  21. package/src/components/language-selector/{LanguageSelector.jsx → LanguageSelector.tsx} +40 -69
  22. package/src/components/legend/Legend.tsx +1 -1
  23. package/src/components/memorable-date/{MemorableDate.jsx → MemorableDate.tsx} +27 -27
  24. package/src/components/page/{Page.jsx → Page.tsx} +7 -11
  25. package/src/components/range-slider/{RangeSlider.jsx → RangeSlider.tsx} +13 -21
  26. package/src/components/select/Select.tsx +2 -2
  27. package/src/components/time-picker/{TimePicker.jsx → TimePicker.tsx} +14 -19
  28. package/src/index.js +11 -11
  29. package/src/components/accordion/Accordion.jsx +0 -170
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solexllc/usx-react",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "React component library for USX.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -25,9 +25,9 @@
25
25
  "dist"
26
26
  ],
27
27
  "dependencies": {
28
- "@solexllc/usx": "0.1.5",
29
- "@solexllc/usx-theme": "0.2.1",
30
- "@solexllc/usx-uswds-fixes": "0.1.3",
28
+ "@solexllc/usx": "0.1.6",
29
+ "@solexllc/usx-theme": "0.2.2",
30
+ "@solexllc/usx-uswds-fixes": "0.1.4",
31
31
  "classnames": "^2.5.1",
32
32
  "prop-types": "^15.8.1"
33
33
  },
@@ -0,0 +1,105 @@
1
+ import React from 'react';
2
+ import classnames from 'classnames';
3
+
4
+ export type AccordionHeadingLevel = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
5
+
6
+ export interface AccordionItemProps {
7
+ title: React.ReactNode;
8
+ id: string;
9
+ content: React.ReactNode;
10
+ expanded?: boolean;
11
+ className?: string;
12
+ headingLevel?: AccordionHeadingLevel;
13
+ handleToggle?: React.MouseEventHandler<HTMLButtonElement>;
14
+ }
15
+
16
+ export interface AccordionProps extends React.HTMLAttributes<HTMLDivElement> {
17
+ bordered?: boolean;
18
+ items?: AccordionItemProps[];
19
+ multiselectable?: boolean;
20
+ headingLevel?: AccordionHeadingLevel;
21
+ iconPosition?: 'start' | 'end';
22
+ }
23
+
24
+ function AccordionItem({
25
+ title,
26
+ id,
27
+ content,
28
+ expanded = false,
29
+ className,
30
+ headingLevel = 'h3',
31
+ handleToggle,
32
+ }: AccordionItemProps) {
33
+ const headingClasses = classnames('usa-accordion__heading', className)
34
+ const contentClasses = classnames(
35
+ 'usa-accordion__content',
36
+ 'usa-prose',
37
+ className
38
+ )
39
+
40
+ const Heading = headingLevel
41
+
42
+ return (
43
+ <>
44
+ <Heading id={`${id}-heading`} className={headingClasses}>
45
+ <button
46
+ type="button"
47
+ className="usa-accordion__button"
48
+ aria-expanded={expanded}
49
+ aria-controls={`${id}-content`}
50
+ data-testid={`accordionButton_${id}`}
51
+ onClick={handleToggle}>
52
+ {title}
53
+ </button>
54
+ </Heading>
55
+ <div
56
+ id={`${id}-content`}
57
+ aria-labelledby={`${id}-heading`}
58
+ data-testid={`accordionItem_${id}`}
59
+ className={contentClasses}
60
+ hidden={!expanded}>
61
+ {content}
62
+ </div>
63
+ </>
64
+ )
65
+ };
66
+
67
+ export function Accordion({
68
+ id,
69
+ bordered = false,
70
+ items = [],
71
+ multiselectable = false,
72
+ headingLevel = 'h3',
73
+ iconPosition,
74
+ className = '',
75
+ ...props
76
+ }: AccordionProps) {
77
+ const accordionClasses = classnames(
78
+ 'usa-accordion',
79
+ 'usx-accordion',
80
+ bordered && 'usa-accordion--bordered',
81
+ (iconPosition === 'start' || iconPosition === 'end') && `usa-accordion--icon-${iconPosition}`,
82
+ className
83
+ )
84
+
85
+
86
+ return (
87
+ <div
88
+ id={id}
89
+ className={accordionClasses}
90
+ data-allow-multiple={multiselectable ? true : undefined}
91
+ {...props}
92
+ >
93
+ {items.map((item) => (
94
+ <AccordionItem
95
+ key={item.id}
96
+ {...item}
97
+ headingLevel={headingLevel}
98
+ className={className}
99
+ />
100
+ ))}
101
+ </div>
102
+ );
103
+ }
104
+
105
+ export default Accordion;
@@ -1,6 +1,6 @@
1
1
  <div
2
2
  id="{{ id }}"
3
- class="usa-accordion usx-accordion {% if bordered %}usa-accordion--bordered{% endif %} {{ className }}"
3
+ class="usa-accordion usx-accordion {% if bordered %}usa-accordion--bordered{% endif %} {% if iconPosition == 'start' %}usa-accordion--icon-start{% elif iconPosition == 'end' %}usa-accordion--icon-end{% endif %} {{ className }}"
4
4
  {% if multiselectable %}
5
5
  data-allow-multiple="true"
6
6
  {% endif %}
@@ -22,10 +22,15 @@
22
22
  "default": false,
23
23
  "description": "Whether multiple accordion items can be expanded at the same time."
24
24
  },
25
+ "iconPosition": {
26
+ "type": "select",
27
+ "options": ["start", "end"],
28
+ "description": "Position of the expand/collapse icon. Omit to use the global USWDS or theme setting."
29
+ },
25
30
  "className": {
26
31
  "type": "string",
27
32
  "default": "",
28
- "description": "Additional CSS classes to apply to the accordion. Use usa-accordion--icon-start or usa-accordion--icon-end to set icon position for this accordion. For live global theming, set --usx-accordion-icon-position to 1.25rem auto (start) or auto 1.25rem (end)."
33
+ "description": "Additional CSS classes to apply to the accordion. Use iconPosition to set the icon position for this accordion. For live global theming, set --usx-accordion-icon-position to 1.25rem auto (start) or auto 1.25rem (end)."
29
34
  }
30
35
  }
31
36
  }
@@ -1,10 +1,11 @@
1
- import React, { useState } from 'react';
1
+ import React from 'react';
2
2
  import Icon from '../icon/Icon';
3
3
  import ClassNames from 'classnames';
4
4
 
5
5
  export interface BannerProps extends React.HTMLAttributes<HTMLElement> {
6
6
  id?: string;
7
7
  ariaLabel?: string;
8
+ flagSrc?: string;
8
9
  tld?: string;
9
10
  bannerText?: string;
10
11
  bannerActionText?: string;
@@ -18,6 +19,7 @@ export interface BannerProps extends React.HTMLAttributes<HTMLElement> {
18
19
  export default function Banner({
19
20
  id = 'gov-banner',
20
21
  ariaLabel = 'Official government website',
22
+ flagSrc = ((typeof window !== 'undefined' && (window as { usxBaseUrl?: string }).usxBaseUrl) || '/') + 'img/us_flag_small.png',
21
23
  tld = '.gov',
22
24
  bannerText = 'An official website of the United States government',
23
25
  bannerActionText = "Here's how you know",
@@ -33,18 +35,7 @@ export default function Banner({
33
35
  className = '',
34
36
  ...props
35
37
  }: BannerProps) {
36
- const [expanded, setExpanded] = useState(false);
37
-
38
- const toggleExpanded = (e: React.MouseEvent<HTMLButtonElement>) => {
39
- // USWDS's own usa-banner behavior also delegates clicks on this same
40
- // aria-controls button (see @uswds/uswds's usa-banner/src/index.js) —
41
- // stop it from also firing so the two toggles don't cancel each other
42
- // out, the same guard Accordion uses.
43
- e.preventDefault();
44
- e.stopPropagation();
45
- setExpanded(!expanded);
46
- };
47
-
38
+ const assetBaseUrl = (typeof window !== 'undefined' && (window as { usxBaseUrl?: string }).usxBaseUrl) || '/';
48
39
  const classes = ClassNames(
49
40
  'usa-banner',
50
41
  'usx-banner',
@@ -59,7 +50,7 @@ export default function Banner({
59
50
  <img
60
51
  aria-hidden="true"
61
52
  className="usa-banner__header-flag"
62
- src={((typeof window !== 'undefined' && (window as { usxBaseUrl?: string }).usxBaseUrl) || '/') + 'img/us_flag_small.png'}
53
+ src={flagSrc}
63
54
  alt=""
64
55
  />
65
56
  </div>
@@ -75,9 +66,8 @@ export default function Banner({
75
66
  <button
76
67
  type="button"
77
68
  className="usa-accordion__button usa-banner__button"
78
- aria-expanded={expanded}
69
+ aria-expanded="false"
79
70
  aria-controls={`${id}-content`}
80
- onClickCapture={toggleExpanded}
81
71
  >
82
72
  <span className="usa-banner__button-text">{bannerActionText}</span>
83
73
  </button>
@@ -86,22 +76,40 @@ export default function Banner({
86
76
  <div
87
77
  id={`${id}-content`}
88
78
  className="usa-banner__content usa-accordion__content"
89
- hidden={!expanded}
79
+ hidden
90
80
  >
91
81
  <div className="grid-row grid-gap-lg">
92
82
  <div className="usa-banner__guidance tablet:grid-col-6">
93
- <p>
94
- <strong>{domainHeading}</strong>
95
- <br />
96
- {domainText}
97
- </p>
83
+ <img
84
+ className="usa-banner__icon usa-media-block__img"
85
+ src={`${assetBaseUrl}img/icon-dot-gov.svg`}
86
+ role="img"
87
+ alt=""
88
+ aria-hidden="true"
89
+ />
90
+ <div className="usa-media-block__body">
91
+ <p>
92
+ <strong>{domainHeading}</strong>
93
+ <br />
94
+ {domainText}
95
+ </p>
96
+ </div>
98
97
  </div>
99
98
  <div className="usa-banner__guidance tablet:grid-col-6">
100
- <p>
101
- <strong>{httpsHeading}</strong>
102
- <br />
103
- {httpsText}
104
- </p>
99
+ <img
100
+ className="usa-banner__icon usa-media-block__img"
101
+ src={`${assetBaseUrl}img/icon-https.svg`}
102
+ role="img"
103
+ alt=""
104
+ aria-hidden="true"
105
+ />
106
+ <div className="usa-media-block__body">
107
+ <p>
108
+ <strong>{httpsHeading}</strong>
109
+ <br />
110
+ {httpsText}
111
+ </p>
112
+ </div>
105
113
  </div>
106
114
  </div>
107
115
  </div>
@@ -14,7 +14,7 @@
14
14
  <img
15
15
  aria-hidden="true"
16
16
  class="usa-banner__header-flag"
17
- src="{% static 'img/us_flag_small.png' %}"
17
+ src="{% if flagSrc %}{{ flagSrc }}{% else %}{% static 'img/us_flag_small.png' %}{% endif %}"
18
18
  alt=""
19
19
  />
20
20
  </div>
@@ -11,6 +11,10 @@
11
11
  "type": "string",
12
12
  "description": "The custom aria label users can override."
13
13
  },
14
+ "flagSrc": {
15
+ "type": "string",
16
+ "description": "URL for the decorative banner flag image. Defaults to img/us_flag_small.png under the configured asset base."
17
+ },
14
18
  "tld": {
15
19
  "type": "string",
16
20
  "description": "The top level domain for the site. Defaults to `.gov`"
@@ -1,11 +1,21 @@
1
1
  import React from 'react';
2
- import PropTypes from 'prop-types';
3
2
  import classNames from 'classnames';
4
3
  import Label from '../label/Label';
5
4
  import Hint from '../hint/Hint';
6
5
  import ErrorMessage from '../error-message/ErrorMessage';
7
6
  import FormGroup from '../form-group/FormGroup';
8
7
 
8
+ export interface DatePickerProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'defaultValue'> {
9
+ label?: React.ReactNode;
10
+ hint?: React.ReactNode;
11
+ error?: React.ReactNode;
12
+ defaultValue?: string | null;
13
+ minDate?: string | null;
14
+ maxDate?: string | null;
15
+ rangeDate?: string | null;
16
+ formGroup?: boolean;
17
+ }
18
+
9
19
  export default function DatePicker({
10
20
  id = 'date-picker',
11
21
  name,
@@ -21,7 +31,7 @@ export default function DatePicker({
21
31
  formGroup = true,
22
32
  className = '',
23
33
  ...props
24
- }) {
34
+ }: DatePickerProps) {
25
35
  const labelId = `${id}-label`;
26
36
  const hintId = hint ? `${id}-hint` : undefined;
27
37
  const errorId = error ? `${id}-error` : undefined;
@@ -66,18 +76,3 @@ export default function DatePicker({
66
76
  return formGroup ? <FormGroup error={!!error}>{content}</FormGroup> : content;
67
77
  }
68
78
 
69
- DatePicker.propTypes = {
70
- id: PropTypes.string,
71
- name: PropTypes.string,
72
- label: PropTypes.node,
73
- hint: PropTypes.node,
74
- error: PropTypes.node,
75
- disabled: PropTypes.bool,
76
- required: PropTypes.bool,
77
- defaultValue: PropTypes.string,
78
- minDate: PropTypes.string,
79
- maxDate: PropTypes.string,
80
- rangeDate: PropTypes.string,
81
- formGroup: PropTypes.bool,
82
- className: PropTypes.string,
83
- };
@@ -1,11 +1,30 @@
1
1
  import React from 'react';
2
- import PropTypes from 'prop-types';
3
2
  import classNames from 'classnames';
4
3
  import Label from '../label/Label';
5
4
  import Hint from '../hint/Hint';
6
5
  import ErrorMessage from '../error-message/ErrorMessage';
7
6
  import FormGroup from '../form-group/FormGroup';
8
7
 
8
+ export interface DateRangePickerProps {
9
+ startId?: string;
10
+ endId?: string;
11
+ startName?: string;
12
+ endName?: string;
13
+ startLabel?: React.ReactNode;
14
+ endLabel?: React.ReactNode;
15
+ startHint?: React.ReactNode;
16
+ endHint?: React.ReactNode;
17
+ startError?: React.ReactNode;
18
+ endError?: React.ReactNode;
19
+ disabled?: boolean;
20
+ required?: boolean;
21
+ defaultStartDate?: string | null;
22
+ defaultEndDate?: string | null;
23
+ minDate?: string | null;
24
+ maxDate?: string | null;
25
+ className?: string;
26
+ }
27
+
9
28
  export default function DateRangePicker({
10
29
  startId = 'event-date-start',
11
30
  endId = 'event-date-end',
@@ -24,7 +43,7 @@ export default function DateRangePicker({
24
43
  minDate = null,
25
44
  maxDate = null,
26
45
  className = '',
27
- }) {
46
+ }: DateRangePickerProps) {
28
47
  const startLabelId = `${startId}-label`;
29
48
  const startHintId = startHint ? `${startId}-hint` : undefined;
30
49
  const startErrorId = startError ? `${startId}-error` : undefined;
@@ -92,22 +111,3 @@ export default function DateRangePicker({
92
111
  );
93
112
  }
94
113
 
95
- DateRangePicker.propTypes = {
96
- startId: PropTypes.string,
97
- endId: PropTypes.string,
98
- startName: PropTypes.string,
99
- endName: PropTypes.string,
100
- startLabel: PropTypes.node,
101
- endLabel: PropTypes.node,
102
- startHint: PropTypes.node,
103
- endHint: PropTypes.node,
104
- startError: PropTypes.node,
105
- endError: PropTypes.node,
106
- disabled: PropTypes.bool,
107
- required: PropTypes.bool,
108
- defaultStartDate: PropTypes.string,
109
- defaultEndDate: PropTypes.string,
110
- minDate: PropTypes.string,
111
- maxDate: PropTypes.string,
112
- className: PropTypes.string,
113
- };
@@ -5,7 +5,7 @@ import Hint from '../hint/Hint';
5
5
  import ErrorMessage from '../error-message/ErrorMessage';
6
6
 
7
7
  export interface FieldsetProps extends React.FieldsetHTMLAttributes<HTMLFieldSetElement> {
8
- legend?: string | null;
8
+ legend?: React.ReactNode;
9
9
  largeLegend?: boolean;
10
10
  required?: boolean;
11
11
  disabled?: boolean;
@@ -1,10 +1,32 @@
1
1
  import React, { useRef, useState } from 'react';
2
- import PropTypes from 'prop-types';
2
+
3
3
  import Label from '../label/Label';
4
4
  import Hint from '../hint/Hint';
5
5
  import ErrorMessage from '../error-message/ErrorMessage';
6
6
  import FormGroup from '../form-group/FormGroup';
7
7
  import FileList from '../file-list/FileList';
8
+ import type { FileListEntry } from '../file-list/FileList';
9
+
10
+ export interface FileInputDefaultFile {
11
+ key?: React.Key;
12
+ name: string;
13
+ size?: number;
14
+ url?: string;
15
+ onRemove?: (entry: FileListEntry) => void;
16
+ }
17
+
18
+ export interface FileInputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'accept'> {
19
+ label?: React.ReactNode;
20
+ hint?: React.ReactNode;
21
+ fileListHint?: React.ReactNode;
22
+ error?: React.ReactNode;
23
+ accept?: string | null;
24
+ manageIndividualFiles?: boolean;
25
+ invalidFileTypeMessage?: string | null;
26
+ onFilesChange?: ((files: File[]) => void) | null;
27
+ defaultFiles?: FileInputDefaultFile[];
28
+ formGroup?: boolean;
29
+ }
8
30
 
9
31
  // Mirrors USWDS's own default aria-label text (see updateVisibleInstructions
10
32
  // in @uswds/uswds's usa-file-input source) so we can restore it after each
@@ -37,7 +59,7 @@ export default function FileInput({
37
59
  defaultFiles = [],
38
60
  formGroup = true,
39
61
  ...props
40
- }) {
62
+ }: FileInputProps) {
41
63
  const hintId = hint ? `${id}-hint` : undefined;
42
64
  const errorId = error ? `${id}-error` : undefined;
43
65
  const describedBy = [hintId, errorId].filter(Boolean).join(' ') || undefined;
@@ -52,16 +74,16 @@ export default function FileInput({
52
74
  // defaultFiles seeds rows for files that already exist on the server (no
53
75
  // File object) — e.g. previously-submitted uploads. Uncontrolled: only read
54
76
  // once, like defaultValue.
55
- const [managedFiles, setManagedFiles] = useState(() =>
77
+ const [managedFiles, setManagedFiles] = useState<FileListEntry[]>(() =>
56
78
  defaultFiles.map((entry) => ({ key: nextFileId.current++, file: null, ...entry })),
57
79
  );
58
80
 
59
81
  // Only entries backed by a real File are reported — preloaded/server-side
60
82
  // entries are already stored and aren't meant to be resubmitted.
61
- const notify = (files) => onFilesChange && onFilesChange(files.filter((entry) => entry.file).map((entry) => entry.file));
83
+ const notify = (files: FileListEntry[]) => onFilesChange && onFilesChange(files.filter((entry): entry is FileListEntry & { file: File } => !!entry.file).map((entry) => entry.file));
62
84
 
63
- const addFiles = (e) => {
64
- const files = Array.from(e.target.files || []);
85
+ const addFiles = (event: React.ChangeEvent<HTMLInputElement>) => {
86
+ const files = Array.from(event.target.files || []);
65
87
  if (files.length === 0) return;
66
88
  setManagedFiles((prev) => {
67
89
  const next = [...prev, ...files.map((file) => ({ key: nextFileId.current++, file }))];
@@ -74,11 +96,11 @@ export default function FileInput({
74
96
  // can't be reliably cleared from here). USWDS also permanently rewrites
75
97
  // aria-label to "Change file(s)" once any file is added and never resets
76
98
  // it, so restore it to its default text ourselves.
77
- e.target.value = '';
78
- e.target.setAttribute('aria-label', getDefaultFileInputAriaLabel());
99
+ event.target.value = '';
100
+ event.target.setAttribute('aria-label', getDefaultFileInputAriaLabel());
79
101
  };
80
102
 
81
- const removeFile = (entry) => {
103
+ const removeFile = (entry: FileListEntry) => {
82
104
  setManagedFiles((prev) => {
83
105
  const next = prev.filter((e) => e.key !== entry.key);
84
106
  notify(next);
@@ -147,28 +169,3 @@ export default function FileInput({
147
169
 
148
170
  return formGroup ? <FormGroup error={!!error}>{content}</FormGroup> : content;
149
171
  }
150
-
151
- FileInput.propTypes = {
152
- id: PropTypes.string,
153
- name: PropTypes.string,
154
- label: PropTypes.node,
155
- hint: PropTypes.node,
156
- fileListHint: PropTypes.node,
157
- error: PropTypes.node,
158
- disabled: PropTypes.bool,
159
- required: PropTypes.bool,
160
- accept: PropTypes.string,
161
- multiple: PropTypes.bool,
162
- manageIndividualFiles: PropTypes.bool,
163
- invalidFileTypeMessage: PropTypes.string,
164
- className: PropTypes.string,
165
- onFilesChange: PropTypes.func,
166
- defaultFiles: PropTypes.arrayOf(
167
- PropTypes.shape({
168
- name: PropTypes.string.isRequired,
169
- size: PropTypes.number,
170
- url: PropTypes.string,
171
- }),
172
- ),
173
- formGroup: PropTypes.bool,
174
- };
@@ -1,11 +1,28 @@
1
1
  import React from 'react';
2
- import PropTypes from 'prop-types';
2
+
3
3
  import Icon from '../icon/Icon';
4
4
  import Link from '../link/Link';
5
5
  import Button from '../button/Button';
6
6
 
7
+ export type FileListEntry = {
8
+ key: React.Key;
9
+ url?: string;
10
+ onRemove?: (entry: FileListEntry) => void;
11
+ } & (
12
+ | { file: File; name?: string; size?: number }
13
+ | { file?: null; name: string; size?: number }
14
+ );
15
+
16
+ export interface FileListProps {
17
+ files?: FileListEntry[] | null;
18
+ hint?: React.ReactNode;
19
+ onRemove?: ((entry: FileListEntry) => void) | null;
20
+ disabled?: boolean;
21
+ className?: string;
22
+ }
23
+
7
24
  // Matches VA.gov's "X KB"/"X MB" display for selected-file rows.
8
- function formatFileSize(bytes) {
25
+ function formatFileSize(bytes: number) {
9
26
  if (bytes < 1024) return `${bytes} B`;
10
27
  const kb = bytes / 1024;
11
28
  if (kb < 1024) return `${Math.round(kb)} KB`;
@@ -13,7 +30,7 @@ function formatFileSize(bytes) {
13
30
  }
14
31
 
15
32
  // e.g. "report.pdf" -> "PDF" — shown alongside the size, VA.gov-style.
16
- function getFileExtension(name) {
33
+ function getFileExtension(name: string) {
17
34
  const match = /\.([^.]+)$/.exec(name);
18
35
  return match ? match[1].toUpperCase() : null;
19
36
  }
@@ -21,15 +38,15 @@ function getFileExtension(name) {
21
38
  // A row's display name/size can come from a real File (just added/changed in
22
39
  // this session) or from a preloaded entry describing a file already on the
23
40
  // server (no File object available) — normalize both shapes for rendering.
24
- function getEntryDisplay(entry) {
41
+ function getEntryDisplay(entry: FileListEntry) {
25
42
  if (entry.file) return { name: entry.file.name, size: entry.file.size, url: entry.url };
26
43
  return { name: entry.name, size: entry.size, url: entry.url };
27
44
  }
28
45
 
29
46
  // A standalone list of files with a per-row Delete action — used by
30
- // FileInput's managed-multiple mode (see FileInput.jsx), but reusable
47
+ // FileInput's managed-multiple mode (see FileInput.tsx), but reusable
31
48
  // anywhere a parent already owns the file array.
32
- export default function FileList({ files, hint = 'Selected files', onRemove = null, disabled = false, className = '' }) {
49
+ export default function FileList({ files, hint = 'Selected files', onRemove = null, disabled = false, className = '' }: FileListProps) {
33
50
  if (!files || files.length === 0) return null;
34
51
 
35
52
  const lastEntry = getEntryDisplay(files[files.length - 1]);
@@ -69,7 +86,7 @@ export default function FileList({ files, hint = 'Selected files', onRemove = nu
69
86
  type="button"
70
87
  variant="secondary"
71
88
  className="usx-file-input__delete-button"
72
- tooltip="Delete this file"
89
+ extraAttributes={{ tooltip: 'Delete this file' }}
73
90
  ghost={true}
74
91
  disabled={disabled}
75
92
  onClick={() => handleRemove(entry)}
@@ -86,20 +103,3 @@ export default function FileList({ files, hint = 'Selected files', onRemove = nu
86
103
  </div>
87
104
  );
88
105
  }
89
-
90
- FileList.propTypes = {
91
- files: PropTypes.arrayOf(
92
- PropTypes.shape({
93
- key: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
94
- file: PropTypes.object,
95
- name: PropTypes.string,
96
- size: PropTypes.number,
97
- url: PropTypes.string,
98
- onRemove: PropTypes.func,
99
- }),
100
- ),
101
- hint: PropTypes.node,
102
- onRemove: PropTypes.func,
103
- disabled: PropTypes.bool,
104
- className: PropTypes.string,
105
- };
@@ -1,4 +1,3 @@
1
1
  // HeaderBranding is kept for backward compatibility.
2
2
  // New code should import Branding from '../branding/Branding' directly.
3
3
  export { default, brandingShape } from './Branding';
4
-