@solexllc/usx-react 0.1.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/README.md +45 -0
- package/dist/index.cjs +6017 -0
- package/dist/index.js +6015 -0
- package/package.json +48 -0
- package/src/components/accordion/Accordion.jsx +170 -0
- package/src/components/accordion/accordion.django.html +47 -0
- package/src/components/accordion/accordion.html +304 -0
- package/src/components/accordion/config.json +31 -0
- package/src/components/alert/Alert.tsx +88 -0
- package/src/components/alert/alert.django.html +45 -0
- package/src/components/alert/alert.html +192 -0
- package/src/components/alert/config.json +70 -0
- package/src/components/attribution/Attribution.tsx +40 -0
- package/src/components/attribution/attribution.django.html +21 -0
- package/src/components/attribution/attribution.html +26 -0
- package/src/components/attribution/config.json +32 -0
- package/src/components/avatar/Avatar.tsx +85 -0
- package/src/components/avatar/avatar.django.html +27 -0
- package/src/components/avatar/avatar.html +101 -0
- package/src/components/avatar/config.json +59 -0
- package/src/components/avatar-group/AvatarGroup.tsx +43 -0
- package/src/components/avatar-group/avatar-group.django.html +8 -0
- package/src/components/avatar-group/avatar-group.html +208 -0
- package/src/components/avatar-group/config.json +60 -0
- package/src/components/back-to-top/BackToTop.tsx +60 -0
- package/src/components/back-to-top/back-to-top.django.html +38 -0
- package/src/components/back-to-top/back-to-top.html +107 -0
- package/src/components/back-to-top/config.json +44 -0
- package/src/components/banner/Banner.tsx +111 -0
- package/src/components/banner/banner.django.html +80 -0
- package/src/components/banner/banner.html +411 -0
- package/src/components/banner/config.json +47 -0
- package/src/components/block/Block.tsx +78 -0
- package/src/components/block/block.django.html +26 -0
- package/src/components/block/block.html +162 -0
- package/src/components/block/config.json +88 -0
- package/src/components/breadcrumb/Breadcrumb.tsx +83 -0
- package/src/components/breadcrumb/breadcrumb.django.html +24 -0
- package/src/components/breadcrumb/breadcrumb.html +108 -0
- package/src/components/breadcrumb/config.json +74 -0
- package/src/components/button/Button.tsx +121 -0
- package/src/components/button/button.django.html +58 -0
- package/src/components/button/button.html +363 -0
- package/src/components/button/config.json +103 -0
- package/src/components/button-group/ButtonGroup.tsx +33 -0
- package/src/components/button-group/button-group.django.html +9 -0
- package/src/components/button-group/button-group.html +159 -0
- package/src/components/button-group/config.json +25 -0
- package/src/components/calendar-date/CalendarDate.tsx +40 -0
- package/src/components/calendar-date/calendar-date.django.html +8 -0
- package/src/components/calendar-date/calendar-date.html +17 -0
- package/src/components/calendar-date/config.json +17 -0
- package/src/components/card/Card.tsx +137 -0
- package/src/components/card/card.django.html +40 -0
- package/src/components/card/card.html +67 -0
- package/src/components/card/config.json +115 -0
- package/src/components/card-group/CardGroup.tsx +23 -0
- package/src/components/card-group/card-group.django.html +6 -0
- package/src/components/card-group/card-group.html +164 -0
- package/src/components/card-group/config.json +21 -0
- package/src/components/carousel/Carousel.tsx +101 -0
- package/src/components/carousel/carousel.django.html +41 -0
- package/src/components/carousel/carousel.html +64 -0
- package/src/components/carousel/config.json +38 -0
- package/src/components/character-count/CharacterCount.tsx +77 -0
- package/src/components/character-count/character-count.django.html +19 -0
- package/src/components/character-count/character-count.html +110 -0
- package/src/components/character-count/config.json +78 -0
- package/src/components/checkbox/Checkbox.tsx +90 -0
- package/src/components/checkbox/checkbox.django.html +16 -0
- package/src/components/checkbox/checkbox.html +266 -0
- package/src/components/checkbox/config.json +71 -0
- package/src/components/checkbox-group/CheckboxGroup.tsx +67 -0
- package/src/components/checkbox-group/checkbox-group.django.html +12 -0
- package/src/components/checkbox-group/checkbox-group.html +36 -0
- package/src/components/checkbox-group/config.json +50 -0
- package/src/components/clickable/Clickable.tsx +78 -0
- package/src/components/clickable/clickable.django.html +5 -0
- package/src/components/clickable/clickable.html +133 -0
- package/src/components/clickable/config.json +26 -0
- package/src/components/code/Code.tsx +60 -0
- package/src/components/code/code.django.html +21 -0
- package/src/components/code/code.html +71 -0
- package/src/components/code/config.json +40 -0
- package/src/components/collection/Collection.tsx +99 -0
- package/src/components/collection/collection.django.html +48 -0
- package/src/components/collection/collection.html +384 -0
- package/src/components/collection/config.json +60 -0
- package/src/components/combobox/Combobox.tsx +114 -0
- package/src/components/combobox/combobox.django.html +61 -0
- package/src/components/combobox/combobox.html +509 -0
- package/src/components/combobox/config.json +80 -0
- package/src/components/copy-to-clipboard/CopyToClipboard.tsx +48 -0
- package/src/components/copy-to-clipboard/config.json +30 -0
- package/src/components/copy-to-clipboard/copy-to-clipboard.django.html +16 -0
- package/src/components/copy-to-clipboard/copy-to-clipboard.html +68 -0
- package/src/components/date-picker/DatePicker.jsx +83 -0
- package/src/components/date-picker/config.json +71 -0
- package/src/components/date-picker/date-picker.django.html +67 -0
- package/src/components/date-picker/date-picker.html +104 -0
- package/src/components/date-range-picker/DateRangePicker.jsx +113 -0
- package/src/components/date-range-picker/config.json +92 -0
- package/src/components/date-range-picker/date-range-picker.django.html +66 -0
- package/src/components/date-range-picker/date-range-picker.html +190 -0
- package/src/components/error-message/ErrorMessage.tsx +23 -0
- package/src/components/error-message/config.json +19 -0
- package/src/components/error-message/error-message.django.html +2 -0
- package/src/components/error-message/error-message.html +2 -0
- package/src/components/eyebrow/Eyebrow.tsx +15 -0
- package/src/components/eyebrow/config.json +15 -0
- package/src/components/eyebrow/eyebrow.django.html +4 -0
- package/src/components/eyebrow/eyebrow.html +4 -0
- package/src/components/fieldset/Fieldset.tsx +54 -0
- package/src/components/fieldset/config.json +47 -0
- package/src/components/fieldset/fieldset.django.html +22 -0
- package/src/components/fieldset/fieldset.html +17 -0
- package/src/components/file-input/FileInput.jsx +174 -0
- package/src/components/file-input/config.json +80 -0
- package/src/components/file-input/file-input.django.html +57 -0
- package/src/components/file-input/file-input.html +258 -0
- package/src/components/file-list/FileList.jsx +105 -0
- package/src/components/file-list/config.json +43 -0
- package/src/components/file-list/file-list.django.html +30 -0
- package/src/components/file-list/file-list.html +61 -0
- package/src/components/footer/Footer.tsx +365 -0
- package/src/components/footer/config.json +83 -0
- package/src/components/footer/footer.django.html +260 -0
- package/src/components/footer/footer.html +392 -0
- package/src/components/form-group/FormGroup.tsx +26 -0
- package/src/components/form-group/config.json +22 -0
- package/src/components/form-group/form-group.django.html +4 -0
- package/src/components/form-group/form-group.html +17 -0
- package/src/components/header/Branding.tsx +101 -0
- package/src/components/header/Header.tsx +229 -0
- package/src/components/header/HeaderBranding.jsx +4 -0
- package/src/components/header/config.json +58 -0
- package/src/components/header/header.django.html +194 -0
- package/src/components/header/header.html +823 -0
- package/src/components/hero/Hero.tsx +64 -0
- package/src/components/hero/config.json +70 -0
- package/src/components/hero/hero.django.html +22 -0
- package/src/components/hero/hero.html +75 -0
- package/src/components/hint/Hint.tsx +23 -0
- package/src/components/hint/config.json +19 -0
- package/src/components/hint/hint.django.html +2 -0
- package/src/components/hint/hint.html +2 -0
- package/src/components/icon/Icon.tsx +46 -0
- package/src/components/icon/config.json +60 -0
- package/src/components/icon/icon.django.html +26 -0
- package/src/components/icon/icon.html +289 -0
- package/src/components/icon/icons_list.json +247 -0
- package/src/components/icon-list/IconList.tsx +59 -0
- package/src/components/icon-list/config.json +86 -0
- package/src/components/icon-list/icon-list.django.html +17 -0
- package/src/components/icon-list/icon-list.html +227 -0
- package/src/components/identifier/Identifier.tsx +193 -0
- package/src/components/identifier/config.json +133 -0
- package/src/components/identifier/identifier.django.html +99 -0
- package/src/components/identifier/identifier.html +737 -0
- package/src/components/image/Image.tsx +106 -0
- package/src/components/image/config.json +64 -0
- package/src/components/image/image.django.html +62 -0
- package/src/components/image/image.html +53 -0
- package/src/components/in-page-nav/InPageNav.jsx +76 -0
- package/src/components/in-page-nav/config.json +69 -0
- package/src/components/in-page-nav/in-page-nav.django.html +28 -0
- package/src/components/in-page-nav/in-page-nav.html +183 -0
- package/src/components/indicator/Indicator.tsx +32 -0
- package/src/components/indicator/README.md +1 -0
- package/src/components/indicator/config.json +19 -0
- package/src/components/indicator/indicator.django.html +10 -0
- package/src/components/indicator/indicator.html +42 -0
- package/src/components/input/Input.tsx +85 -0
- package/src/components/input/config.json +73 -0
- package/src/components/input/input.django.html +55 -0
- package/src/components/input/input.html +59 -0
- package/src/components/label/Label.tsx +42 -0
- package/src/components/label/config.json +39 -0
- package/src/components/label/label.django.html +23 -0
- package/src/components/label/label.html +23 -0
- package/src/components/language-selector/LanguageSelector.jsx +224 -0
- package/src/components/language-selector/config.json +107 -0
- package/src/components/language-selector/language-selector.django.html +40 -0
- package/src/components/language-selector/language-selector.html +85 -0
- package/src/components/layout/Layout.tsx +131 -0
- package/src/components/layout/config.json +36 -0
- package/src/components/layout/layout.django.html +28 -0
- package/src/components/layout/layout.html +29 -0
- package/src/components/legend/Legend.tsx +34 -0
- package/src/components/legend/config.json +27 -0
- package/src/components/legend/legend.django.html +11 -0
- package/src/components/legend/legend.html +12 -0
- package/src/components/link/Link.tsx +45 -0
- package/src/components/link/config.json +39 -0
- package/src/components/link/link.django.html +8 -0
- package/src/components/link/link.html +47 -0
- package/src/components/list/List.tsx +82 -0
- package/src/components/list/_list-items.django.html +17 -0
- package/src/components/list/config.json +25 -0
- package/src/components/list/list.django.html +11 -0
- package/src/components/list/list.html +26 -0
- package/src/components/memorable-date/MemorableDate.jsx +167 -0
- package/src/components/memorable-date/config.json +104 -0
- package/src/components/memorable-date/memorable-date.django.html +86 -0
- package/src/components/memorable-date/memorable-date.html +275 -0
- package/src/components/misc-banner/MiscBanner.tsx +112 -0
- package/src/components/misc-banner/config.json +57 -0
- package/src/components/misc-banner/misc-banner.django.html +63 -0
- package/src/components/misc-banner/misc-banner.html +191 -0
- package/src/components/modal/Modal.tsx +71 -0
- package/src/components/modal/config.json +57 -0
- package/src/components/modal/modal.django.html +43 -0
- package/src/components/modal/modal.html +222 -0
- package/src/components/page/Page.jsx +34 -0
- package/src/components/page/config.json +34 -0
- package/src/components/page/page.django.html +5 -0
- package/src/components/page/page.html +23 -0
- package/src/components/pagination/Pagination.tsx +112 -0
- package/src/components/pagination/config.json +135 -0
- package/src/components/pagination/container/PaginationContainer.tsx +38 -0
- package/src/components/pagination/navigation/PaginationNavigation.tsx +219 -0
- package/src/components/pagination/navigation/pagination-navigation.django.html +64 -0
- package/src/components/pagination/pagination.django.html +48 -0
- package/src/components/pagination/pagination.html +613 -0
- package/src/components/pagination/step-options/PaginationStepOptions.tsx +43 -0
- package/src/components/pagination/step-options/pagination-step-options.django.html +7 -0
- package/src/components/pagination/summary/PaginationSummary.tsx +33 -0
- package/src/components/pagination/summary/pagination-summary.django.html +12 -0
- package/src/components/process-list/ProcessList.tsx +52 -0
- package/src/components/process-list/config.json +15 -0
- package/src/components/process-list/process-list.django.html +15 -0
- package/src/components/process-list/process-list.html +90 -0
- package/src/components/prose/Prose.tsx +32 -0
- package/src/components/prose/config.json +28 -0
- package/src/components/prose/prose.django.html +35 -0
- package/src/components/prose/prose.html +91 -0
- package/src/components/radio-buttons/RadioButtons.tsx +82 -0
- package/src/components/radio-buttons/config.json +57 -0
- package/src/components/radio-buttons/radio-buttons.django.html +28 -0
- package/src/components/radio-buttons/radio-buttons.html +189 -0
- package/src/components/range-slider/RangeSlider.jsx +84 -0
- package/src/components/range-slider/config.json +89 -0
- package/src/components/range-slider/range-slider.django.html +65 -0
- package/src/components/range-slider/range-slider.html +106 -0
- package/src/components/required/Required.tsx +25 -0
- package/src/components/required/config.json +20 -0
- package/src/components/required/required.django.html +2 -0
- package/src/components/required/required.html +6 -0
- package/src/components/search/Search.tsx +92 -0
- package/src/components/search/config.json +69 -0
- package/src/components/search/search.django.html +59 -0
- package/src/components/search/search.html +76 -0
- package/src/components/section/Section.tsx +28 -0
- package/src/components/section/config.json +27 -0
- package/src/components/section/section.django.html +5 -0
- package/src/components/section/section.html +16 -0
- package/src/components/select/Select.tsx +107 -0
- package/src/components/select/config.json +80 -0
- package/src/components/select/select.django.html +64 -0
- package/src/components/select/select.html +62 -0
- package/src/components/sidenav/SideNav.tsx +74 -0
- package/src/components/sidenav/config.json +45 -0
- package/src/components/sidenav/sidenav.django.html +29 -0
- package/src/components/sidenav/sidenav.html +84 -0
- package/src/components/site-alert/SiteAlert.tsx +101 -0
- package/src/components/site-alert/config.json +62 -0
- package/src/components/site-alert/site-alert.django.html +34 -0
- package/src/components/site-alert/site-alert.html +312 -0
- package/src/components/skipnav/Skipnav.tsx +41 -0
- package/src/components/skipnav/config.json +29 -0
- package/src/components/skipnav/skipnav.django.html +11 -0
- package/src/components/skipnav/skipnav.html +1 -0
- package/src/components/spinner/Spinner.tsx +46 -0
- package/src/components/spinner/config.json +44 -0
- package/src/components/spinner/spinner.django.html +8 -0
- package/src/components/spinner/spinner.html +219 -0
- package/src/components/status/Status.tsx +28 -0
- package/src/components/status/config.json +47 -0
- package/src/components/status/status.django.html +2 -0
- package/src/components/status/status.html +31 -0
- package/src/components/step-indicator/StepIndicator.tsx +80 -0
- package/src/components/step-indicator/config.json +54 -0
- package/src/components/step-indicator/step-indicator.django.html +29 -0
- package/src/components/step-indicator/step-indicator.html +243 -0
- package/src/components/summary-box/SummaryBox.tsx +41 -0
- package/src/components/summary-box/config.json +30 -0
- package/src/components/summary-box/summary-box.django.html +19 -0
- package/src/components/summary-box/summary-box.html +210 -0
- package/src/components/swap/Swap.tsx +47 -0
- package/src/components/swap/config.json +61 -0
- package/src/components/swap/swap.django.html +14 -0
- package/src/components/swap/swap.html +163 -0
- package/src/components/switch/Switch.tsx +73 -0
- package/src/components/switch/config.json +55 -0
- package/src/components/switch/switch.django.html +28 -0
- package/src/components/switch/switch.html +56 -0
- package/src/components/table/Table.tsx +334 -0
- package/src/components/table/TableBody.tsx +253 -0
- package/src/components/table/TableCell.tsx +37 -0
- package/src/components/table/TableContext.tsx +87 -0
- package/src/components/table/TableFoot.tsx +68 -0
- package/src/components/table/TableGroup.tsx +69 -0
- package/src/components/table/TableHead.tsx +139 -0
- package/src/components/table/TableRow.tsx +56 -0
- package/src/components/table/__pycache__/table_helper.cpython-312.pyc +0 -0
- package/src/components/table/config.json +297 -0
- package/src/components/table/hooks/useRowDetails.ts +34 -0
- package/src/components/table/hooks/useTableGroups.ts +61 -0
- package/src/components/table/hooks/useTableSelect.ts +82 -0
- package/src/components/table/hooks/useTableSort.ts +60 -0
- package/src/components/table/table-body.django.html +68 -0
- package/src/components/table/table-detail-row.django.html +14 -0
- package/src/components/table/table-foot.django.html +31 -0
- package/src/components/table/table-group.django.html +40 -0
- package/src/components/table/table-head.django.html +85 -0
- package/src/components/table/table-row.django.html +98 -0
- package/src/components/table/table.django.html +60 -0
- package/src/components/table/table.html +1186 -0
- package/src/components/table/table_helper.py +298 -0
- package/src/components/table/types.ts +68 -0
- package/src/components/tag/Tag.tsx +75 -0
- package/src/components/tag/config.json +54 -0
- package/src/components/tag/tag.django.html +39 -0
- package/src/components/tag/tag.html +45 -0
- package/src/components/tag-group/TagGroup.tsx +35 -0
- package/src/components/tag-group/config.json +24 -0
- package/src/components/tag-group/tag-group.django.html +11 -0
- package/src/components/tag-group/tag-group.html +36 -0
- package/src/components/task-list/TaskList.tsx +40 -0
- package/src/components/task-list/config.json +41 -0
- package/src/components/task-list/task-list.django.html +21 -0
- package/src/components/task-list/task-list.html +24 -0
- package/src/components/text-area/TextArea.tsx +78 -0
- package/src/components/text-area/config.json +78 -0
- package/src/components/text-area/text-area.django.html +53 -0
- package/src/components/text-area/text-area.html +59 -0
- package/src/components/theme-picker/ThemePicker.tsx +106 -0
- package/src/components/theme-picker/config.json +39 -0
- package/src/components/theme-picker/theme-picker.django.html +32 -0
- package/src/components/theme-picker/theme-picker.html +67 -0
- package/src/components/time-picker/TimePicker.jsx +87 -0
- package/src/components/time-picker/config.json +76 -0
- package/src/components/time-picker/time-picker.django.html +67 -0
- package/src/components/time-picker/time-picker.html +123 -0
- package/src/components/toggle/Toggle.tsx +80 -0
- package/src/components/toggle/config.json +69 -0
- package/src/components/toggle/toggle.django.html +19 -0
- package/src/components/toggle/toggle.html +85 -0
- package/src/components/tooltip/Tooltip.tsx +33 -0
- package/src/components/tooltip/config.json +33 -0
- package/src/components/tooltip/tooltip.django.html +5 -0
- package/src/components/tooltip/tooltip.html +57 -0
- package/src/components/villain/Villain.tsx +47 -0
- package/src/components/villain/config.json +44 -0
- package/src/components/villain/villain.django.html +19 -0
- package/src/components/villain/villain.html +39 -0
- package/src/declarations.d.ts +1 -0
- package/src/index.js +82 -0
- package/src/styles/core.scss +12 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import Label from '../label/Label';
|
|
5
|
+
import Hint from '../hint/Hint';
|
|
6
|
+
import ErrorMessage from '../error-message/ErrorMessage';
|
|
7
|
+
import FormGroup from '../form-group/FormGroup';
|
|
8
|
+
|
|
9
|
+
export default function TimePicker({
|
|
10
|
+
id = 'appointment-time',
|
|
11
|
+
name,
|
|
12
|
+
label = null,
|
|
13
|
+
hint = null,
|
|
14
|
+
error = null,
|
|
15
|
+
disabled = false,
|
|
16
|
+
ariaDisabled = false,
|
|
17
|
+
required = false,
|
|
18
|
+
defaultValue = null,
|
|
19
|
+
minTime = null,
|
|
20
|
+
maxTime = null,
|
|
21
|
+
step = null,
|
|
22
|
+
formGroup = true,
|
|
23
|
+
className = '',
|
|
24
|
+
...props
|
|
25
|
+
}) {
|
|
26
|
+
const labelId = `${id}-label`;
|
|
27
|
+
const hintId = hint ? `${id}-hint` : undefined;
|
|
28
|
+
const errorId = error ? `${id}-error` : undefined;
|
|
29
|
+
const describedBy = [label ? labelId : undefined, hintId, errorId].filter(Boolean).join(' ') || undefined;
|
|
30
|
+
|
|
31
|
+
const content = (
|
|
32
|
+
<>
|
|
33
|
+
{label && (
|
|
34
|
+
<Label id={labelId} htmlFor={id} required={required} error={!!error}>
|
|
35
|
+
{label}
|
|
36
|
+
</Label>
|
|
37
|
+
)}
|
|
38
|
+
{hint && <Hint id={hintId}>{hint}</Hint>}
|
|
39
|
+
{error && <ErrorMessage id={errorId}>{error}</ErrorMessage>}
|
|
40
|
+
<div
|
|
41
|
+
className={
|
|
42
|
+
classNames(
|
|
43
|
+
'usa-time-picker',
|
|
44
|
+
'usx-time-picker',
|
|
45
|
+
{'usx-combo-box--error': !!error},
|
|
46
|
+
className
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
{...(minTime ? { 'data-min-time': minTime } : {})}
|
|
50
|
+
{...(maxTime ? { 'data-max-time': maxTime } : {})}
|
|
51
|
+
{...(step ? { 'data-step': step } : {})}
|
|
52
|
+
>
|
|
53
|
+
<input
|
|
54
|
+
className={`usa-input usx-input${error ? ' usa-input--error' : ''}`}
|
|
55
|
+
id={id}
|
|
56
|
+
name={name || id}
|
|
57
|
+
type="text"
|
|
58
|
+
aria-describedby={describedBy}
|
|
59
|
+
defaultValue={defaultValue || undefined}
|
|
60
|
+
disabled={disabled}
|
|
61
|
+
aria-disabled={!disabled && ariaDisabled ? 'true' : undefined}
|
|
62
|
+
required={required}
|
|
63
|
+
{...props}
|
|
64
|
+
/>
|
|
65
|
+
</div>
|
|
66
|
+
</>
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
return formGroup ? <FormGroup error={!!error}>{content}</FormGroup> : content;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
TimePicker.propTypes = {
|
|
73
|
+
id: PropTypes.string,
|
|
74
|
+
name: PropTypes.string,
|
|
75
|
+
label: PropTypes.node,
|
|
76
|
+
hint: PropTypes.node,
|
|
77
|
+
error: PropTypes.node,
|
|
78
|
+
disabled: PropTypes.bool,
|
|
79
|
+
ariaDisabled: PropTypes.bool,
|
|
80
|
+
required: PropTypes.bool,
|
|
81
|
+
defaultValue: PropTypes.string,
|
|
82
|
+
minTime: PropTypes.string,
|
|
83
|
+
maxTime: PropTypes.string,
|
|
84
|
+
step: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
85
|
+
formGroup: PropTypes.bool,
|
|
86
|
+
className: PropTypes.string,
|
|
87
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "time-picker",
|
|
3
|
+
"template": "time-picker/time-picker.django.html",
|
|
4
|
+
"version": 1,
|
|
5
|
+
"default": {
|
|
6
|
+
"id": "appointment-time",
|
|
7
|
+
"name": "appointment-time",
|
|
8
|
+
"label": "Appointment time",
|
|
9
|
+
"hint": "Select a time from the dropdown. Type into the input to filter options."
|
|
10
|
+
},
|
|
11
|
+
"props": {
|
|
12
|
+
"id": {
|
|
13
|
+
"type": "string",
|
|
14
|
+
"default": "appointment-time",
|
|
15
|
+
"description": "id for the input. Label and hint ids are derived from this."
|
|
16
|
+
},
|
|
17
|
+
"name": {
|
|
18
|
+
"type": "string",
|
|
19
|
+
"description": "name attribute for the input. Defaults to id."
|
|
20
|
+
},
|
|
21
|
+
"label": {
|
|
22
|
+
"type": "string",
|
|
23
|
+
"description": "Label text for the field."
|
|
24
|
+
},
|
|
25
|
+
"hint": {
|
|
26
|
+
"type": "string",
|
|
27
|
+
"default": "Select a time from the dropdown. Type into the input to filter options.",
|
|
28
|
+
"description": "Hint text displayed below the label."
|
|
29
|
+
},
|
|
30
|
+
"error": {
|
|
31
|
+
"type": "string",
|
|
32
|
+
"description": "Error message. Renders aria-describedby and error styling."
|
|
33
|
+
},
|
|
34
|
+
"disabled": {
|
|
35
|
+
"type": "boolean",
|
|
36
|
+
"default": false,
|
|
37
|
+
"description": "Disables the time picker."
|
|
38
|
+
},
|
|
39
|
+
"ariaDisabled": {
|
|
40
|
+
"type": "boolean",
|
|
41
|
+
"default": false,
|
|
42
|
+
"description": "Marks the time picker aria-disabled without preventing interaction."
|
|
43
|
+
},
|
|
44
|
+
"required": {
|
|
45
|
+
"type": "boolean",
|
|
46
|
+
"default": false,
|
|
47
|
+
"description": "Marks the field as required."
|
|
48
|
+
},
|
|
49
|
+
"defaultValue": {
|
|
50
|
+
"type": "string",
|
|
51
|
+
"description": "Initial value shown in the time picker (e.g. \"1:00pm\"). Sets the value attribute on the input."
|
|
52
|
+
},
|
|
53
|
+
"minTime": {
|
|
54
|
+
"type": "string",
|
|
55
|
+
"description": "Earliest time option in hh:mm 24-hour format. Sets data-min-time on the wrapper. USWDS default: 00:00."
|
|
56
|
+
},
|
|
57
|
+
"maxTime": {
|
|
58
|
+
"type": "string",
|
|
59
|
+
"description": "Latest time option in hh:mm 24-hour format. Sets data-max-time on the wrapper. USWDS default: 23:59."
|
|
60
|
+
},
|
|
61
|
+
"step": {
|
|
62
|
+
"type": "string",
|
|
63
|
+
"description": "Number of minutes between options (minimum 1). Sets data-step on the wrapper. USWDS default: 30."
|
|
64
|
+
},
|
|
65
|
+
"formGroup": {
|
|
66
|
+
"type": "boolean",
|
|
67
|
+
"default": true,
|
|
68
|
+
"description": "Whether to wrap the label/hint/error/control in a `.usa-form-group`. Set to `false` when composing inside another form group."
|
|
69
|
+
},
|
|
70
|
+
"className": {
|
|
71
|
+
"type": "string",
|
|
72
|
+
"default": "",
|
|
73
|
+
"description": "Additional classes for the usa-time-picker wrapper."
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{# Django template for TimePicker #}
|
|
2
|
+
{% load components %}
|
|
3
|
+
{% with formGroup|default_if_none:True as wrap_group %}
|
|
4
|
+
{% if wrap_group %}
|
|
5
|
+
{% form_group error=error %}
|
|
6
|
+
{% if label %}
|
|
7
|
+
{% label id=id|add:"-label" htmlFor=id required=required error=error %}{{ label }}{% endlabel %}
|
|
8
|
+
{% endif %}
|
|
9
|
+
|
|
10
|
+
{% if hint %}
|
|
11
|
+
{% hint id=id|add:"-hint" %}{{ hint }}{% endhint %}
|
|
12
|
+
{% endif %}
|
|
13
|
+
|
|
14
|
+
{% if error %}
|
|
15
|
+
{% error_message id=id|add:"-error" %}{{ error }}{% enderror_message %}
|
|
16
|
+
{% endif %}
|
|
17
|
+
|
|
18
|
+
<div
|
|
19
|
+
class="usa-time-picker usx-time-picker{% if error %} usx-combo-box--error{% endif %}{% if className %} {{ className }}{% endif %}"
|
|
20
|
+
{% if minTime %} data-min-time="{{ minTime }}"{% endif %}
|
|
21
|
+
{% if maxTime %} data-max-time="{{ maxTime }}"{% endif %}
|
|
22
|
+
{% if step %} data-step="{{ step }}"{% endif %}
|
|
23
|
+
>
|
|
24
|
+
<input
|
|
25
|
+
class="usa-input usx-input"
|
|
26
|
+
id="{{ id }}"
|
|
27
|
+
name="{{ name|default:id }}"
|
|
28
|
+
type="text"
|
|
29
|
+
{% if label or hint or error %} aria-describedby="{% if label %}{{ id }}-label{% endif %}{% if label and hint %} {% endif %}{% if hint %}{{ id }}-hint{% endif %}{% if hint and error %} {% endif %}{% if not hint and label and error %} {% endif %}{% if error %}{{ id }}-error{% endif %}"{% endif %}
|
|
30
|
+
{% if defaultValue %} value="{{ defaultValue }}"{% endif %}
|
|
31
|
+
{% if disabled %} disabled{% elif ariaDisabled %} aria-disabled="true"{% endif %}
|
|
32
|
+
{% if required %} required{% endif %}
|
|
33
|
+
/>
|
|
34
|
+
</div>
|
|
35
|
+
{% endform_group %}
|
|
36
|
+
{% else %}
|
|
37
|
+
{% if label %}
|
|
38
|
+
{% label id=id|add:"-label" htmlFor=id required=required error=error %}{{ label }}{% endlabel %}
|
|
39
|
+
{% endif %}
|
|
40
|
+
|
|
41
|
+
{% if hint %}
|
|
42
|
+
{% hint id=id|add:"-hint" %}{{ hint }}{% endhint %}
|
|
43
|
+
{% endif %}
|
|
44
|
+
|
|
45
|
+
{% if error %}
|
|
46
|
+
{% error_message id=id|add:"-error" %}{{ error }}{% enderror_message %}
|
|
47
|
+
{% endif %}
|
|
48
|
+
|
|
49
|
+
<div
|
|
50
|
+
class="usa-time-picker usx-time-picker{% if className %} {{ className }}{% endif %}"
|
|
51
|
+
{% if minTime %} data-min-time="{{ minTime }}"{% endif %}
|
|
52
|
+
{% if maxTime %} data-max-time="{{ maxTime }}"{% endif %}
|
|
53
|
+
{% if step %} data-step="{{ step }}"{% endif %}
|
|
54
|
+
>
|
|
55
|
+
<input
|
|
56
|
+
class="usa-input usx-input"
|
|
57
|
+
id="{{ id }}"
|
|
58
|
+
name="{{ name|default:id }}"
|
|
59
|
+
type="text"
|
|
60
|
+
{% if label or hint or error %} aria-describedby="{% if label %}{{ id }}-label{% endif %}{% if label and hint %} {% endif %}{% if hint %}{{ id }}-hint{% endif %}{% if hint and error %} {% endif %}{% if not hint and label and error %} {% endif %}{% if error %}{{ id }}-error{% endif %}"{% endif %}
|
|
61
|
+
{% if defaultValue %} value="{{ defaultValue }}"{% endif %}
|
|
62
|
+
{% if disabled %} disabled{% elif ariaDisabled %} aria-disabled="true"{% endif %}
|
|
63
|
+
{% if required %} required{% endif %}
|
|
64
|
+
/>
|
|
65
|
+
</div>
|
|
66
|
+
{% endif %}
|
|
67
|
+
{% endwith %}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
<h3 class="site-preview-heading">Default</h3>
|
|
2
|
+
<div class="usa-form-group usx-form-group">
|
|
3
|
+
<label class="usa-label usx-label" id="appointment-time-label" for="appointment-time"
|
|
4
|
+
>Appointment time</label
|
|
5
|
+
>
|
|
6
|
+
<div class="usa-hint usx-hint" id="appointment-time-hint">Select a time from the dropdown. Type into the input to filter options.</div>
|
|
7
|
+
<div class="usa-time-picker usx-time-picker">
|
|
8
|
+
<input
|
|
9
|
+
class="usa-input usx-input"
|
|
10
|
+
id="appointment-time"
|
|
11
|
+
name="appointment-time"
|
|
12
|
+
type="text"
|
|
13
|
+
aria-describedby="appointment-time-label appointment-time-hint"
|
|
14
|
+
/>
|
|
15
|
+
</div>
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
<h3 class="site-preview-heading">Disabled</h3>
|
|
19
|
+
<div class="usa-form-group usx-form-group">
|
|
20
|
+
<label class="usa-label usx-label" id="appointment-time-disabled-label" for="appointment-time-disabled"
|
|
21
|
+
>Appointment time</label
|
|
22
|
+
>
|
|
23
|
+
<div class="usa-hint usx-hint" id="appointment-time-disabled-hint">Select a time from the dropdown. Type into the input to filter options.</div>
|
|
24
|
+
<div class="usa-time-picker usx-time-picker">
|
|
25
|
+
<input
|
|
26
|
+
class="usa-input usx-input"
|
|
27
|
+
id="appointment-time-disabled"
|
|
28
|
+
name="appointment-time-disabled"
|
|
29
|
+
type="text"
|
|
30
|
+
aria-describedby="appointment-time-disabled-label appointment-time-disabled-hint"
|
|
31
|
+
disabled
|
|
32
|
+
/>
|
|
33
|
+
</div>
|
|
34
|
+
</div>
|
|
35
|
+
|
|
36
|
+
<h3 class="site-preview-heading">Aria Disabled</h3>
|
|
37
|
+
<div class="usa-form-group usx-form-group">
|
|
38
|
+
<label class="usa-label usx-label" id="appointment-time-aria-disabled-label" for="appointment-time-aria-disabled"
|
|
39
|
+
>Appointment time</label
|
|
40
|
+
>
|
|
41
|
+
<div class="usa-hint usx-hint" id="appointment-time-aria-disabled-hint">Select a time from the dropdown. Type into the input to filter options.</div>
|
|
42
|
+
<div class="usa-time-picker usx-time-picker">
|
|
43
|
+
<input
|
|
44
|
+
class="usa-input usx-input"
|
|
45
|
+
id="appointment-time-aria-disabled"
|
|
46
|
+
name="appointment-time-aria-disabled"
|
|
47
|
+
type="text"
|
|
48
|
+
aria-describedby="appointment-time-aria-disabled-label appointment-time-aria-disabled-hint"
|
|
49
|
+
aria-disabled="true"
|
|
50
|
+
/>
|
|
51
|
+
</div>
|
|
52
|
+
</div>
|
|
53
|
+
|
|
54
|
+
<h3 class="site-preview-heading">Required</h3>
|
|
55
|
+
<div class="usa-form-group usx-form-group">
|
|
56
|
+
<label class="usa-label usx-label" id="appointment-time-required-label" for="appointment-time-required">
|
|
57
|
+
<abbr title="required" class="usx-required">*</abbr>Appointment time
|
|
58
|
+
</label>
|
|
59
|
+
<div class="usa-hint usx-hint" id="appointment-time-required-hint">Select a time from the dropdown. Type into the input to filter options.</div>
|
|
60
|
+
<div class="usa-time-picker usx-time-picker">
|
|
61
|
+
<input
|
|
62
|
+
class="usa-input usx-input"
|
|
63
|
+
id="appointment-time-required"
|
|
64
|
+
name="appointment-time-required"
|
|
65
|
+
type="text"
|
|
66
|
+
aria-describedby="appointment-time-required-label appointment-time-required-hint"
|
|
67
|
+
required
|
|
68
|
+
/>
|
|
69
|
+
</div>
|
|
70
|
+
</div>
|
|
71
|
+
|
|
72
|
+
<h3 class="site-preview-heading">With default value</h3>
|
|
73
|
+
<div class="usa-form-group usx-form-group">
|
|
74
|
+
<label class="usa-label usx-label" id="appointment-time-default-value-label" for="appointment-time-default-value"
|
|
75
|
+
>Appointment time</label
|
|
76
|
+
>
|
|
77
|
+
<div class="usa-hint usx-hint" id="appointment-time-default-value-hint">Select a time from the dropdown. Type into the input to filter options.</div>
|
|
78
|
+
<div class="usa-time-picker usx-time-picker">
|
|
79
|
+
<input
|
|
80
|
+
class="usa-input usx-input"
|
|
81
|
+
id="appointment-time-default-value"
|
|
82
|
+
name="appointment-time-default-value"
|
|
83
|
+
type="text"
|
|
84
|
+
aria-describedby="appointment-time-default-value-label appointment-time-default-value-hint"
|
|
85
|
+
value="1:00pm"
|
|
86
|
+
/>
|
|
87
|
+
</div>
|
|
88
|
+
</div>
|
|
89
|
+
|
|
90
|
+
<h3 class="site-preview-heading">With error</h3>
|
|
91
|
+
<div class="usa-form-group usx-form-group usa-form-group--error">
|
|
92
|
+
<label class="usa-label usx-label usa-label--error" id="appointment-time-error-label" for="appointment-time-error"
|
|
93
|
+
>Appointment time</label
|
|
94
|
+
>
|
|
95
|
+
<div class="usa-hint usx-hint" id="appointment-time-error-hint">Select a time from the dropdown. Type into the input to filter options.</div>
|
|
96
|
+
<span class="usa-error-message usx-error-message" id="appointment-time-error-error" role="alert">Select a valid appointment time.</span>
|
|
97
|
+
<div class="usa-time-picker usx-time-picker usx-combo-box--error">
|
|
98
|
+
<input
|
|
99
|
+
class="usa-input usx-input"
|
|
100
|
+
id="appointment-time-error"
|
|
101
|
+
name="appointment-time-error"
|
|
102
|
+
type="text"
|
|
103
|
+
aria-describedby="appointment-time-error-label appointment-time-error-hint appointment-time-error-error"
|
|
104
|
+
/>
|
|
105
|
+
</div>
|
|
106
|
+
</div>
|
|
107
|
+
|
|
108
|
+
<h3 class="site-preview-heading">Min/max/step</h3>
|
|
109
|
+
<div class="usa-form-group usx-form-group">
|
|
110
|
+
<label class="usa-label usx-label" id="appointment-time-min-max-step-label" for="appointment-time-min-max-step"
|
|
111
|
+
>Appointment time</label
|
|
112
|
+
>
|
|
113
|
+
<div class="usa-hint usx-hint" id="appointment-time-min-max-step-hint">Select a time from the dropdown. Type into the input to filter options.</div>
|
|
114
|
+
<div class="usa-time-picker usx-time-picker" data-min-time="09:00" data-max-time="17:00" data-step="15">
|
|
115
|
+
<input
|
|
116
|
+
class="usa-input usx-input"
|
|
117
|
+
id="appointment-time-min-max-step"
|
|
118
|
+
name="appointment-time-min-max-step"
|
|
119
|
+
type="text"
|
|
120
|
+
aria-describedby="appointment-time-min-max-step-label appointment-time-min-max-step-hint"
|
|
121
|
+
/>
|
|
122
|
+
</div>
|
|
123
|
+
</div>
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import React, { useRef } from 'react';
|
|
2
|
+
import Icon from '../icon/Icon';
|
|
3
|
+
|
|
4
|
+
export interface ToggleOption {
|
|
5
|
+
value?: string | number;
|
|
6
|
+
label?: React.ReactNode;
|
|
7
|
+
icon?: string;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface ToggleProps extends React.HTMLAttributes<HTMLUListElement> {
|
|
12
|
+
options?: (ToggleOption | string | number)[];
|
|
13
|
+
value?: string | number;
|
|
14
|
+
defaultValue?: string | number;
|
|
15
|
+
onChange?: (value: string | number) => void;
|
|
16
|
+
name?: string;
|
|
17
|
+
id?: string;
|
|
18
|
+
variant?: 'text' | 'icon';
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
className?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const Toggle: React.FC<ToggleProps> = ({
|
|
24
|
+
options = [],
|
|
25
|
+
value,
|
|
26
|
+
defaultValue,
|
|
27
|
+
onChange,
|
|
28
|
+
name,
|
|
29
|
+
id,
|
|
30
|
+
variant = 'text',
|
|
31
|
+
disabled = false,
|
|
32
|
+
className = '',
|
|
33
|
+
...props
|
|
34
|
+
}) => {
|
|
35
|
+
const idRef = useRef(id || name || `toggle-${Math.random().toString(36).substr(2, 8)}`);
|
|
36
|
+
const generatedName = idRef.current;
|
|
37
|
+
const classes = [
|
|
38
|
+
'usa-button-group',
|
|
39
|
+
'usx-button-group',
|
|
40
|
+
'usa-button-group--segmented',
|
|
41
|
+
'usx-toggle',
|
|
42
|
+
variant === 'icon' ? 'usx-toggle--icon' : '',
|
|
43
|
+
className
|
|
44
|
+
].filter(Boolean).join(' ');
|
|
45
|
+
return (
|
|
46
|
+
<ul className={classes} role="radiogroup" aria-disabled={disabled} {...props}>
|
|
47
|
+
{options.map((opt, i) => {
|
|
48
|
+
const optValue = typeof opt === 'object' ? opt.value ?? opt : opt;
|
|
49
|
+
const optLabel = typeof opt === 'object' ? opt.label ?? opt : opt;
|
|
50
|
+
const optIcon = typeof opt === 'object' ? opt.icon : undefined;
|
|
51
|
+
const optDisabled = typeof opt === 'object' ? !!opt.disabled : false;
|
|
52
|
+
const inputId = `${generatedName}-${i}`;
|
|
53
|
+
return (
|
|
54
|
+
<li key={inputId} className={`usa-button-group__item usx-toggle__item${optDisabled ? ' usx-toggle__item--disabled' : ''}`}>
|
|
55
|
+
<input
|
|
56
|
+
className="usx-toggle__input"
|
|
57
|
+
type="radio"
|
|
58
|
+
id={inputId}
|
|
59
|
+
name={name || generatedName}
|
|
60
|
+
value={optValue}
|
|
61
|
+
checked={value === optValue ? true : undefined}
|
|
62
|
+
defaultChecked={defaultValue === optValue ? true : undefined}
|
|
63
|
+
disabled={disabled ? true : optDisabled ? true : undefined}
|
|
64
|
+
onChange={onChange ? () => onChange(optValue as string | number) : undefined}
|
|
65
|
+
/>
|
|
66
|
+
<label htmlFor={inputId} className="usa-button usx-button usa-button--outline">
|
|
67
|
+
{variant === 'icon' && optIcon ? (
|
|
68
|
+
<Icon name={optIcon} className="usx-toggle__label" ariaHidden />
|
|
69
|
+
) : (
|
|
70
|
+
<span className="usx-toggle__label">{optLabel}</span>
|
|
71
|
+
)}
|
|
72
|
+
</label>
|
|
73
|
+
</li>
|
|
74
|
+
);
|
|
75
|
+
})}
|
|
76
|
+
</ul>
|
|
77
|
+
);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export default Toggle;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "toggle",
|
|
3
|
+
"template": "toggle/toggle.django.html",
|
|
4
|
+
"version": 1,
|
|
5
|
+
"required": [
|
|
6
|
+
"options"
|
|
7
|
+
],
|
|
8
|
+
"props": {
|
|
9
|
+
"id": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"description": "ID for the control (used as prefix for option IDs)"
|
|
12
|
+
},
|
|
13
|
+
"options": {
|
|
14
|
+
"type": "array",
|
|
15
|
+
"description": "Array of option objects: {value,label,icon?,disabled?}",
|
|
16
|
+
"items": {
|
|
17
|
+
"type": "object",
|
|
18
|
+
"description": "Toggle option.",
|
|
19
|
+
"properties": {
|
|
20
|
+
"value": {
|
|
21
|
+
"type": "string",
|
|
22
|
+
"description": "Option value."
|
|
23
|
+
},
|
|
24
|
+
"label": {
|
|
25
|
+
"type": "string",
|
|
26
|
+
"description": "Option display label."
|
|
27
|
+
},
|
|
28
|
+
"icon": {
|
|
29
|
+
"type": "string",
|
|
30
|
+
"description": "Optional icon name."
|
|
31
|
+
},
|
|
32
|
+
"disabled": {
|
|
33
|
+
"type": "boolean",
|
|
34
|
+
"description": "Disable this option."
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"value": {
|
|
40
|
+
"type": "string",
|
|
41
|
+
"description": "Controlled selected value"
|
|
42
|
+
},
|
|
43
|
+
"defaultValue": {
|
|
44
|
+
"type": "string",
|
|
45
|
+
"description": "Uncontrolled initial value"
|
|
46
|
+
},
|
|
47
|
+
"name": {
|
|
48
|
+
"type": "string",
|
|
49
|
+
"description": "Name attribute for radio inputs"
|
|
50
|
+
},
|
|
51
|
+
"variant": {
|
|
52
|
+
"type": "select",
|
|
53
|
+
"options": [
|
|
54
|
+
"text",
|
|
55
|
+
"icon"
|
|
56
|
+
],
|
|
57
|
+
"description": "Visual variant"
|
|
58
|
+
},
|
|
59
|
+
"disabled": {
|
|
60
|
+
"type": "boolean",
|
|
61
|
+
"description": "Disable the whole control",
|
|
62
|
+
"default": false
|
|
63
|
+
},
|
|
64
|
+
"className": {
|
|
65
|
+
"type": "string",
|
|
66
|
+
"description": "Additional classes"
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{# Django template for Toggle using USWDS segmented button group #}
|
|
2
|
+
{% load components %}
|
|
3
|
+
|
|
4
|
+
<ul class="usa-button-group usx-button-group usa-button-group--segmented usx-toggle{% if variant == 'icon' %} usx-toggle--icon{% endif %}{% if className %} {{ className }}{% endif %}" role="radiogroup"{% if name %} aria-label="{{ name }}"{% endif %}>
|
|
5
|
+
{% for option in options %}
|
|
6
|
+
{% with optValue=option.value|default:option optLabel=option.label|default:option optDisabled=option.disabled|default:False %}
|
|
7
|
+
<li class="usa-button-group__item usx-toggle__item{% if optDisabled %} usx-toggle__item--disabled{% endif %}">
|
|
8
|
+
<input class="usx-toggle__input" type="radio" id="{{ id }}-{{ forloop.counter }}" name="{{ name|default:id }}" value="{{ optValue }}" {% if optValue == value or optValue == defaultValue %}checked{% endif %}{% if disabled or optDisabled %} disabled{% endif %}>
|
|
9
|
+
<label for="{{ id }}-{{ forloop.counter }}" class="usa-button usx-button usa-button--outline">
|
|
10
|
+
{% if variant == 'icon' and option.icon %}
|
|
11
|
+
{% icon name=option.icon className="usx-toggle__label" %}{% endicon %}
|
|
12
|
+
{% else %}
|
|
13
|
+
<span class="usx-toggle__label">{{ optLabel }}</span>
|
|
14
|
+
{% endif %}
|
|
15
|
+
</label>
|
|
16
|
+
</li>
|
|
17
|
+
{% endwith %}
|
|
18
|
+
{% endfor %}
|
|
19
|
+
</ul>
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
<div class="usa-alert usa-alert--warning usx-alert usx-alert--warning">
|
|
2
|
+
<div class="usa-alert__body usx-alert__body">
|
|
3
|
+
<h4 class="usa-alert__heading usx-alert__heading">Accessibility Notice</h4>
|
|
4
|
+
<p class="usa-alert__text usx-alert__text">
|
|
5
|
+
Please note: The toggle component is undergoing maintenance for accessibility issues.
|
|
6
|
+
</p>
|
|
7
|
+
</div>
|
|
8
|
+
</div>
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
<h3 class="site-preview-heading">Default</h3>
|
|
12
|
+
<ul class="usa-button-group usx-button-group usa-button-group--segmented usx-toggle" role="radiogroup" aria-label="alignment">
|
|
13
|
+
<li class="usa-button-group__item usx-toggle__item">
|
|
14
|
+
<input class="usx-toggle__input" type="radio" id="toggle-left" name="toggle-example" value="left">
|
|
15
|
+
<label for="toggle-left" class="usa-button usx-button usa-button--outline"><span class="usx-toggle__label">Left</span></label>
|
|
16
|
+
</li>
|
|
17
|
+
<li class="usa-button-group__item usx-toggle__item">
|
|
18
|
+
<input class="usx-toggle__input" type="radio" id="toggle-center" name="toggle-example" value="center" checked>
|
|
19
|
+
<label for="toggle-center" class="usa-button usx-button usa-button--outline"><span class="usx-toggle__label">Center</span></label>
|
|
20
|
+
</li>
|
|
21
|
+
<li class="usa-button-group__item usx-toggle__item">
|
|
22
|
+
<input class="usx-toggle__input" type="radio" id="toggle-right" name="toggle-example" value="right">
|
|
23
|
+
<label for="toggle-right" class="usa-button usx-button usa-button--outline"><span class="usx-toggle__label">Right</span></label>
|
|
24
|
+
</li>
|
|
25
|
+
</ul>
|
|
26
|
+
|
|
27
|
+
<h3 class="site-preview-heading">Icons</h3>
|
|
28
|
+
<ul class="usa-button-group usx-button-group usa-button-group--segmented usx-toggle usx-toggle--icon" role="radiogroup" aria-label="alignment">
|
|
29
|
+
<li class="usa-button-group__item usx-toggle__item">
|
|
30
|
+
<input class="usx-toggle__input" type="radio" id="toggle-left-icon" name="toggle-icon-example" value="left">
|
|
31
|
+
<label for="toggle-left-icon" class="usa-button usx-button usa-button--outline">
|
|
32
|
+
<svg class="usa-icon usx-toggle__label" aria-hidden="true" focusable="false" role="img">
|
|
33
|
+
<use href="./img/sprite.svg#directions_bike"></use>
|
|
34
|
+
</svg>
|
|
35
|
+
</label>
|
|
36
|
+
</li>
|
|
37
|
+
<li class="usa-button-group__item usx-toggle__item">
|
|
38
|
+
<input class="usx-toggle__input" type="radio" id="toggle-center-icon" name="toggle-icon-example" value="center" checked>
|
|
39
|
+
<label for="toggle-center-icon" class="usa-button usx-button usa-button--outline">
|
|
40
|
+
<svg class="usa-icon usx-toggle__label" aria-hidden="true" focusable="false" role="img">
|
|
41
|
+
<use href="./img/sprite.svg#directions_bus"></use>
|
|
42
|
+
</svg>
|
|
43
|
+
</label>
|
|
44
|
+
</li>
|
|
45
|
+
<li class="usa-button-group__item usx-toggle__item">
|
|
46
|
+
<input class="usx-toggle__input" type="radio" id="toggle-right-icon" name="toggle-icon-example" value="right">
|
|
47
|
+
<label for="toggle-right-icon" class="usa-button usx-button usa-button--outline">
|
|
48
|
+
<svg class="usa-icon usx-toggle__label" aria-hidden="true" focusable="false" role="img">
|
|
49
|
+
<use href="./img/sprite.svg#flight"></use>
|
|
50
|
+
</svg>
|
|
51
|
+
</label>
|
|
52
|
+
</li>
|
|
53
|
+
</ul>
|
|
54
|
+
|
|
55
|
+
<h3 class="site-preview-heading">Disabled</h3>
|
|
56
|
+
<ul class="usa-button-group usx-button-group usa-button-group--segmented usx-toggle" role="radiogroup" aria-label="alignment">
|
|
57
|
+
<li class="usa-button-group__item usx-toggle__item">
|
|
58
|
+
<input class="usx-toggle__input" type="radio" id="toggle-left-disabled" name="toggle-disabled-example" value="left" disabled>
|
|
59
|
+
<label for="toggle-left-disabled" class="usa-button usx-button usa-button--outline"><span class="usx-toggle__label">Left</span></label>
|
|
60
|
+
</li>
|
|
61
|
+
<li class="usa-button-group__item usx-toggle__item">
|
|
62
|
+
<input class="usx-toggle__input" type="radio" id="toggle-center-disabled" name="toggle-disabled-example" value="center" disabled>
|
|
63
|
+
<label for="toggle-center-disabled" class="usa-button usx-button usa-button--outline"><span class="usx-toggle__label">Center</span></label>
|
|
64
|
+
</li>
|
|
65
|
+
<li class="usa-button-group__item usx-toggle__item">
|
|
66
|
+
<input class="usx-toggle__input" type="radio" id="toggle-right-disabled" name="toggle-disabled-example" value="right" disabled>
|
|
67
|
+
<label for="toggle-right-disabled" class="usa-button usx-button usa-button--outline"><span class="usx-toggle__label">Right</span></label>
|
|
68
|
+
</li>
|
|
69
|
+
</ul>
|
|
70
|
+
|
|
71
|
+
<h3 class="site-preview-heading">Partially Disabled</h3>
|
|
72
|
+
<ul class="usa-button-group usx-button-group usa-button-group--segmented usx-toggle" role="radiogroup" aria-label="alignment">
|
|
73
|
+
<li class="usa-button-group__item usx-toggle__item">
|
|
74
|
+
<input class="usx-toggle__input" type="radio" id="toggle-left-partial-disabled" name="toggle-partial-disabled-example" value="left">
|
|
75
|
+
<label for="toggle-left-partial-disabled" class="usa-button usx-button usa-button--outline"><span class="usx-toggle__label">Left</span></label>
|
|
76
|
+
</li>
|
|
77
|
+
<li class="usa-button-group__item usx-toggle__item">
|
|
78
|
+
<input class="usx-toggle__input" type="radio" id="toggle-center-partial-disabled" name="toggle-partial-disabled-example" value="center" disabled>
|
|
79
|
+
<label for="toggle-center-partial-disabled" class="usa-button usx-button usa-button--outline"><span class="usx-toggle__label">Center</span></label>
|
|
80
|
+
</li>
|
|
81
|
+
<li class="usa-button-group__item usx-toggle__item">
|
|
82
|
+
<input class="usx-toggle__input" type="radio" id="toggle-right-partial-disabled" name="toggle-partial-disabled-example" value="right">
|
|
83
|
+
<label for="toggle-right-partial-disabled" class="usa-button usx-button usa-button--outline"><span class="usx-toggle__label">Right</span></label>
|
|
84
|
+
</li>
|
|
85
|
+
</ul>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
|
|
4
|
+
export interface TooltipProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
5
|
+
label: string;
|
|
6
|
+
position?: 'top' | 'bottom' | 'left' | 'right';
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
className?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const Tooltip: React.FC<TooltipProps> = ({
|
|
12
|
+
label,
|
|
13
|
+
position = 'top',
|
|
14
|
+
children,
|
|
15
|
+
className = '',
|
|
16
|
+
...props
|
|
17
|
+
}) => {
|
|
18
|
+
const validPositions = ['top', 'bottom', 'left', 'right'] as const;
|
|
19
|
+
const normalizedPosition = validPositions.includes(position) ? position : 'top';
|
|
20
|
+
return (
|
|
21
|
+
<span className={classNames('usx-tooltip', className)} {...props}>
|
|
22
|
+
{children}
|
|
23
|
+
<span
|
|
24
|
+
className={`usa-tooltip__body usa-tooltip__body--${normalizedPosition}`}
|
|
25
|
+
role="tooltip"
|
|
26
|
+
>
|
|
27
|
+
{label}
|
|
28
|
+
</span>
|
|
29
|
+
</span>
|
|
30
|
+
);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export default Tooltip;
|