@syscore/ui-library 2.0.0-beta-publish-workflow-beta.15 → 2.0.0-beta-publish-workflow-beta.17
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/client/components/icons/IconUtility.tsx +353 -0
- package/client/components/icons/X.tsx +4 -3
- package/client/components/ui/alert-v02.tsx +2 -6
- package/client/components/ui/button-v01.tsx +2 -12
- package/client/components/ui/button.tsx +39 -3
- package/client/components/ui/dropdown.tsx +10 -12
- package/client/components/ui/form.tsx +1 -1
- package/client/components/ui/label.tsx +21 -4
- package/client/components/ui/navigation.tsx +25 -4
- package/client/components/ui/radio-v01.tsx +84 -0
- package/client/components/ui/search-field-v01.tsx +10 -28
- package/client/components/ui/section-heading.tsx +1 -1
- package/client/components/ui/sign-in-field-v01.tsx +150 -0
- package/client/global.css +358 -73
- package/client/lib/system-icons.ts +1583 -0
- package/client/lib/utility-icons.ts +121 -0
- package/client/ui/Button.stories.tsx +63 -0
- package/client/ui/Colors.stories.tsx +34 -31
- package/client/ui/Icons.stories.tsx +179 -0
- package/client/ui/RadioGroup/RadioGroup.stories.tsx +1 -1
- package/client/ui/RadioV01/RadioV01.stories.tsx +136 -0
- package/client/ui/SearchField/SearchField.stories.tsx +4 -1
- package/client/ui/TextAreaV01/TextAreaV01.stories.tsx +23 -2
- package/client/ui/TextFieldV01/PasswordFieldV01.stories.tsx +25 -11
- package/client/ui/TextFieldV01/SignInFieldV01.stories.tsx +196 -0
- package/dist/client/assets/alert/icon-clear.svg.js +4 -0
- package/dist/client/assets/alert/icon-done.svg.js +4 -0
- package/dist/client/assets/avatar-identity/placeholder-icon.svg.js +4 -0
- package/dist/client/assets/breadcrumb/icon-ellipsis.svg.js +4 -0
- package/dist/client/assets/breadcrumb/icon-home.svg.js +4 -0
- package/dist/client/assets/breadcrumb/icon-separator.svg.js +4 -0
- package/dist/client/assets/button-v01/icon-back.svg.js +4 -0
- package/dist/client/assets/button-v01/icon-check.svg.js +4 -0
- package/dist/client/assets/button-v01/icon-close.svg.js +4 -0
- package/dist/client/assets/button-v01/icon-delete.svg.js +4 -0
- package/dist/client/assets/button-v01/icon-device.svg.js +4 -0
- package/dist/client/assets/dropdown/icon-carrot-contract.svg.js +4 -0
- package/dist/client/assets/dropdown/icon-carrot-expand.svg.js +4 -0
- package/dist/client/assets/dropdown/icon-clear.svg.js +4 -0
- package/dist/client/assets/dropdown/icon-enter.svg.js +4 -0
- package/dist/client/components/icons/AlphaIcon.js +129 -0
- package/dist/client/components/icons/ConceptIcons.js +905 -0
- package/dist/client/components/icons/IconUtility.js +410 -0
- package/dist/client/components/icons/NavAccount.js +37 -0
- package/dist/client/components/icons/NavBullet.js +17 -0
- package/dist/client/components/icons/NavLogo.js +48 -0
- package/dist/client/components/icons/StandardLogo.js +93 -0
- package/dist/client/components/icons/UtilityAccordion.js +27 -0
- package/dist/client/components/icons/UtilityChangeType.js +26 -0
- package/dist/client/components/icons/UtilityCheck.js +28 -0
- package/dist/client/components/icons/UtilityChevronDown.js +39 -0
- package/dist/client/components/icons/UtilityClassification.js +53 -0
- package/dist/client/components/icons/UtilityClearRegular.js +51 -0
- package/dist/client/components/icons/UtilityClose.js +49 -0
- package/dist/client/components/icons/UtilityCompare.js +91 -0
- package/dist/client/components/icons/UtilityDrag.js +89 -0
- package/dist/client/components/icons/UtilityEdit.js +50 -0
- package/dist/client/components/icons/UtilityFeedback.js +38 -0
- package/dist/client/components/icons/UtilityHome.js +34 -0
- package/dist/client/components/icons/UtilityMessage.js +41 -0
- package/dist/client/components/icons/UtilityOptions.js +53 -0
- package/dist/client/components/icons/UtilityPortfolio.js +116 -0
- package/dist/client/components/icons/UtilityReset.js +49 -0
- package/dist/client/components/icons/UtilityRevisionsHide.js +76 -0
- package/dist/client/components/icons/UtilityRevisionsShow.js +56 -0
- package/dist/client/components/icons/UtilitySave.js +38 -0
- package/dist/client/components/icons/UtilityScopeLarge.js +123 -0
- package/dist/client/components/icons/UtilityScoring.js +51 -0
- package/dist/client/components/icons/UtilitySearch.js +46 -0
- package/dist/client/components/icons/UtilityShow.js +49 -0
- package/dist/client/components/icons/UtilitySort.js +63 -0
- package/dist/client/components/icons/UtilityTarget.js +29 -0
- package/dist/client/components/icons/UtilityTargetActive.js +48 -0
- package/dist/client/components/icons/UtilityText.js +59 -0
- package/dist/client/components/icons/UtilityTrash.js +66 -0
- package/dist/client/components/icons/UtilityTriangleInfo.js +38 -0
- package/dist/client/components/icons/X.js +40 -0
- package/dist/client/components/icons/achievement-badges/BadgeCertificationBronze.js +144 -0
- package/dist/client/components/icons/achievement-badges/BadgeCertificationGold.js +144 -0
- package/dist/client/components/icons/achievement-badges/BadgeCertificationPlatinum.js +144 -0
- package/dist/client/components/icons/achievement-badges/BadgeCertificationSilver.js +144 -0
- package/dist/client/components/icons/achievement-badges/BadgeRatingCoworking.js +91 -0
- package/dist/client/components/icons/achievement-badges/BadgeRatingDesign.js +91 -0
- package/dist/client/components/icons/achievement-badges/BadgeRatingEquity.js +91 -0
- package/dist/client/components/icons/achievement-badges/BadgeRatingHealthySafety.js +93 -0
- package/dist/client/components/icons/achievement-badges/BadgeRatingOperations.js +93 -0
- package/dist/client/components/icons/achievement-badges/BadgeRatingPerformance.js +93 -0
- package/dist/client/components/icons/achievement-badges/BadgeRatingRealEstate.js +93 -0
- package/dist/client/components/icons/achievement-badges/BadgeRatingResidential.js +93 -0
- package/dist/client/components/icons/achievement-badges/BadgeRatingWorkforce.js +91 -0
- package/dist/client/components/icons/imperative-badges/BadgeImperativePrimary.js +58 -0
- package/dist/client/components/icons/imperative-badges/BadgeImperativeSecondary.js +69 -0
- package/dist/client/components/icons/provider-badges/BadgeEnterpriseProvider.js +117 -0
- package/dist/client/components/icons/provider-badges/BadgePerformanceTestingProvider.js +124 -0
- package/dist/client/components/icons/provider-badges/BadgeProductProvider.js +117 -0
- package/dist/client/components/icons/provider-badges/BadgeSurveyProvider.js +117 -0
- package/dist/client/components/icons/provider-seals/SealEnterpriseProvider.js +100 -0
- package/dist/client/components/icons/provider-seals/SealPerformanceTestingProvider.js +100 -0
- package/dist/client/components/icons/provider-seals/SealProductProvider.js +98 -0
- package/dist/client/components/icons/provider-seals/SealProviders.js +98 -0
- package/dist/client/components/icons/provider-seals/SealSurveyProvider.js +98 -0
- package/dist/client/components/icons/seals/IWBILogo.js +301 -0
- package/dist/client/components/icons/seals/SealCertification.js +206 -0
- package/dist/client/components/icons/seals/SealCertificationBronze.js +140 -0
- package/dist/client/components/icons/seals/SealCertificationGold.js +140 -0
- package/dist/client/components/icons/seals/SealCertificationPlatinum.js +140 -0
- package/dist/client/components/icons/seals/SealCertificationSilver.js +140 -0
- package/dist/client/components/icons/seals/SealIwbiMember.js +134 -0
- package/dist/client/components/icons/seals/SealRating.js +157 -0
- package/dist/client/components/icons/seals/SealRatingCoworking.js +89 -0
- package/dist/client/components/icons/seals/SealRatingDesign.js +89 -0
- package/dist/client/components/icons/seals/SealRatingEquity.js +89 -0
- package/dist/client/components/icons/seals/SealRatingHealthSafety.js +91 -0
- package/dist/client/components/icons/seals/SealRatingOperations.js +89 -0
- package/dist/client/components/icons/seals/SealRatingPerformance.js +91 -0
- package/dist/client/components/icons/seals/SealRatingRealEstate.js +89 -0
- package/dist/client/components/icons/seals/SealRatingWorkforce.js +89 -0
- package/dist/client/components/icons/seals/SealWell.js +132 -0
- package/dist/client/components/icons/seals/SealWellCertification.js +225 -0
- package/dist/client/components/icons/seals/SealWellCommunity.js +197 -0
- package/dist/client/components/icons/seals/SealWellResidence.js +197 -0
- package/dist/client/components/icons/seals/SealWorksWithWell.js +227 -0
- package/dist/client/components/icons/seals/WaterMarkWWWProducts.js +27 -0
- package/dist/client/components/icons/seals/WaterMarkWellProjects.js +36 -0
- package/dist/client/components/icons/seals/WatermarkMemberOrg.js +24 -0
- package/dist/client/components/ui/accordion.js +326 -0
- package/dist/client/components/ui/alert-dialog-panel.js +156 -0
- package/dist/client/components/ui/alert-dialog.js +103 -0
- package/dist/client/components/ui/alert-v02.js +157 -0
- package/dist/client/components/ui/alert.js +55 -0
- package/dist/client/components/ui/app-bar.js +203 -0
- package/dist/client/components/ui/aspect-ratio.js +5 -0
- package/dist/client/components/ui/avatar-identity.js +93 -0
- package/dist/client/components/ui/avatar.js +56 -0
- package/dist/client/components/ui/back-link.js +27 -0
- package/dist/client/components/ui/banner.js +75 -0
- package/dist/client/components/ui/bottom-navigation.js +127 -0
- package/dist/client/components/ui/breadcrumb-trail.js +137 -0
- package/dist/client/components/ui/breadcrumb.js +91 -0
- package/dist/client/components/ui/button-v01.js +173 -0
- package/dist/client/components/ui/button.js +99 -0
- package/dist/client/components/ui/calendar.js +62 -0
- package/dist/client/components/ui/card.js +177 -0
- package/dist/client/components/ui/carousel.js +198 -0
- package/dist/client/components/ui/centered-page.js +10 -0
- package/dist/client/components/ui/chart.js +239 -0
- package/dist/client/components/ui/checkbox-field.js +39 -0
- package/dist/client/components/ui/checkbox.js +18 -0
- package/dist/client/components/ui/code-badge.js +29 -0
- package/dist/client/components/ui/collapsible.js +9 -0
- package/dist/client/components/ui/command.js +79 -0
- package/dist/client/components/ui/context-menu.js +138 -0
- package/dist/client/components/ui/copy.js +39 -0
- package/dist/client/components/ui/credit-card-preview.js +74 -0
- package/dist/client/components/ui/data-grid.js +156 -0
- package/dist/client/components/ui/date-picker.js +142 -0
- package/dist/client/components/ui/dialog.js +179 -0
- package/dist/client/components/ui/drawer.js +95 -0
- package/dist/client/components/ui/drop-zone.js +87 -0
- package/dist/client/components/ui/dropdown-menu.js +139 -0
- package/dist/client/components/ui/dropdown.js +339 -0
- package/dist/client/components/ui/empty-state.js +76 -0
- package/dist/client/components/ui/field-group.js +32 -0
- package/dist/client/components/ui/file-upload-trigger.js +70 -0
- package/dist/client/components/ui/file-upload.js +171 -0
- package/dist/client/components/ui/footer.js +97 -0
- package/dist/client/components/ui/form.js +109 -0
- package/dist/client/components/ui/height-container.js +41 -0
- package/dist/client/components/ui/hero-section.js +44 -0
- package/dist/client/components/ui/hero-split-image.js +45 -0
- package/dist/client/components/ui/hover-card.js +22 -0
- package/dist/client/components/ui/icon-button.js +30 -0
- package/dist/client/components/ui/inline-notice.js +19 -0
- package/dist/client/components/ui/input-otp.js +46 -0
- package/dist/client/components/ui/input.js +37 -0
- package/dist/client/components/ui/label.js +31 -0
- package/dist/client/components/ui/labeled-divider.js +23 -0
- package/dist/client/components/ui/layout.js +724 -0
- package/dist/client/components/ui/menubar.js +157 -0
- package/dist/client/components/ui/meta-row.js +19 -0
- package/dist/client/components/ui/mobile-nav.js +230 -0
- package/dist/client/components/ui/modal-panel.js +116 -0
- package/dist/client/components/ui/navigation-menu.js +89 -0
- package/dist/client/components/ui/navigation.js +452 -0
- package/dist/client/components/ui/outline-node.js +57 -0
- package/dist/client/components/ui/page-header.js +79 -0
- package/dist/client/components/ui/pagination-v01.js +124 -0
- package/dist/client/components/ui/pagination.js +105 -0
- package/dist/client/components/ui/password-field-v01.js +46 -0
- package/dist/client/components/ui/pill-button.js +34 -0
- package/dist/client/components/ui/popover.js +22 -0
- package/dist/client/components/ui/price-tag.js +20 -0
- package/dist/client/components/ui/profile-avatar.js +92 -0
- package/dist/client/components/ui/progress.js +23 -0
- package/dist/client/components/ui/radio-card.js +30 -0
- package/dist/client/components/ui/radio-group.js +32 -0
- package/dist/client/components/ui/radio-v01.js +58 -0
- package/dist/client/components/ui/resizable.js +32 -0
- package/dist/client/components/ui/resource-thumbnail.js +24 -0
- package/dist/client/components/ui/scroll-area.js +37 -0
- package/dist/client/components/ui/search-field-v01.js +111 -0
- package/dist/client/components/ui/search.js +109 -0
- package/dist/client/components/ui/section-badge.js +22 -0
- package/dist/client/components/ui/section-heading.js +21 -0
- package/dist/client/components/ui/select.js +96 -0
- package/dist/client/components/ui/separator.js +24 -0
- package/dist/client/components/ui/sheet.js +106 -0
- package/dist/client/components/ui/side-nav.js +173 -0
- package/dist/client/components/ui/sidebar.js +580 -0
- package/dist/client/components/ui/sign-in-field-v01.js +107 -0
- package/dist/client/components/ui/skeleton.js +17 -0
- package/dist/client/components/ui/slider.js +20 -0
- package/dist/client/components/ui/social-button.js +34 -0
- package/dist/client/components/ui/standard-navigation.js +454 -0
- package/dist/client/components/ui/status-pill.js +42 -0
- package/dist/client/components/ui/stepper.js +111 -0
- package/dist/client/components/ui/switch-v01.js +39 -0
- package/dist/client/components/ui/switch.js +17 -0
- package/dist/client/components/ui/system-bar.js +76 -0
- package/dist/client/components/ui/table.js +107 -0
- package/dist/client/components/ui/tabs-v01.js +74 -0
- package/dist/client/components/ui/tabs.js +253 -0
- package/dist/client/components/ui/tag-v02.js +85 -0
- package/dist/client/components/ui/tag.js +73 -0
- package/dist/client/components/ui/text-area-v01.js +26 -0
- package/dist/client/components/ui/text-field-v01.js +78 -0
- package/dist/client/components/ui/text-link.js +23 -0
- package/dist/client/components/ui/textarea.js +19 -0
- package/dist/client/components/ui/timeline.js +87 -0
- package/dist/client/components/ui/toast-v01.js +155 -0
- package/dist/client/components/ui/toast.js +88 -0
- package/dist/client/components/ui/toaster.js +22 -0
- package/dist/client/components/ui/toggle.js +56 -0
- package/dist/client/components/ui/tooltip.js +328 -0
- package/dist/client/components/ui/typography.js +119 -0
- package/dist/client/hooks/use-mobile.js +20 -0
- package/dist/client/hooks/use-segmented-control.js +32 -0
- package/dist/client/hooks/use-tabs.js +22 -0
- package/dist/client/hooks/use-toast.js +122 -0
- package/dist/client/lib/concept-colors.js +74 -0
- package/dist/client/lib/concept-icons.js +32 -0
- package/dist/client/lib/utility-icons.js +73 -0
- package/dist/client/lib/utils.js +13 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +159 -0
- package/dist/ui/index.js +774 -0
- package/package.json +9 -6
- package/dist/index.cjs.js +0 -1
- package/dist/index.es.js +0 -18973
- /package/{dist → client}/fonts/FT-Made/FTMade-Regular.otf +0 -0
- /package/{dist → client}/fonts/FT-Made/FTMade-Regular.ttf +0 -0
- /package/{dist → client}/fonts/FT-Made/FTMade-Regular.woff +0 -0
- /package/{dist → client}/fonts/FT-Made/FTMade-Regular.woff2 +0 -0
- /package/{dist → client}/fonts/Mazzard-M/mazzardsoftm-black.otf +0 -0
- /package/{dist → client}/fonts/Mazzard-M/mazzardsoftm-blackitalic.otf +0 -0
- /package/{dist → client}/fonts/Mazzard-M/mazzardsoftm-bold.otf +0 -0
- /package/{dist → client}/fonts/Mazzard-M/mazzardsoftm-bolditalic.otf +0 -0
- /package/{dist → client}/fonts/Mazzard-M/mazzardsoftm-extrabold.otf +0 -0
- /package/{dist → client}/fonts/Mazzard-M/mazzardsoftm-extrabolditalic.otf +0 -0
- /package/{dist → client}/fonts/Mazzard-M/mazzardsoftm-extralight.otf +0 -0
- /package/{dist → client}/fonts/Mazzard-M/mazzardsoftm-extralightitalic.otf +0 -0
- /package/{dist → client}/fonts/Mazzard-M/mazzardsoftm-italic.otf +0 -0
- /package/{dist → client}/fonts/Mazzard-M/mazzardsoftm-light.otf +0 -0
- /package/{dist → client}/fonts/Mazzard-M/mazzardsoftm-lightitalic.otf +0 -0
- /package/{dist → client}/fonts/Mazzard-M/mazzardsoftm-medium.otf +0 -0
- /package/{dist → client}/fonts/Mazzard-M/mazzardsoftm-mediumitalic.otf +0 -0
- /package/{dist → client}/fonts/Mazzard-M/mazzardsoftm-regular.otf +0 -0
- /package/{dist → client}/fonts/Mazzard-M/mazzardsoftm-semibold.otf +0 -0
- /package/{dist → client}/fonts/Mazzard-M/mazzardsoftm-semibolditalic.otf +0 -0
- /package/{dist → client}/fonts/Mazzard-M/mazzardsoftm-thin.otf +0 -0
- /package/{dist → client}/fonts/Mazzard-M/mazzardsoftm-thinitalic.otf +0 -0
|
@@ -17,6 +17,7 @@ interface NavigationContextValue {
|
|
|
17
17
|
setActiveIndex: (index: number | null) => void;
|
|
18
18
|
setIsOpen: (open: boolean) => void;
|
|
19
19
|
registerTrays: (trays: React.ReactNode[]) => void;
|
|
20
|
+
cancelClose: () => void;
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
const NavigationContext = React.createContext<NavigationContextValue | null>(
|
|
@@ -39,12 +40,29 @@ const Navigation = React.forwardRef<HTMLElement, NavigationProps>(
|
|
|
39
40
|
const [isOpen, setIsOpen] = React.useState(false);
|
|
40
41
|
const [activeIndex, setActiveIndex] = React.useState<number | null>(null);
|
|
41
42
|
const [trays, setTrays] = React.useState<React.ReactNode[]>([]);
|
|
43
|
+
const closeTimeoutRef = React.useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
44
|
+
|
|
45
|
+
// Delay nav close so pointer can reach the tray during the height animation.
|
|
46
|
+
const CLOSE_DELAY_MS = 150;
|
|
47
|
+
|
|
48
|
+
const cancelClose = React.useCallback(() => {
|
|
49
|
+
if (closeTimeoutRef.current !== null) {
|
|
50
|
+
clearTimeout(closeTimeoutRef.current);
|
|
51
|
+
closeTimeoutRef.current = null;
|
|
52
|
+
}
|
|
53
|
+
}, []);
|
|
42
54
|
|
|
43
55
|
const handleMouseLeave = () => {
|
|
44
|
-
|
|
45
|
-
|
|
56
|
+
cancelClose();
|
|
57
|
+
closeTimeoutRef.current = setTimeout(() => {
|
|
58
|
+
setIsOpen(false);
|
|
59
|
+
setActiveIndex(null);
|
|
60
|
+
closeTimeoutRef.current = null;
|
|
61
|
+
}, CLOSE_DELAY_MS);
|
|
46
62
|
};
|
|
47
63
|
|
|
64
|
+
React.useEffect(() => () => cancelClose(), [cancelClose]);
|
|
65
|
+
|
|
48
66
|
const registerTrays = React.useCallback((newTrays: React.ReactNode[]) => {
|
|
49
67
|
setTrays(newTrays);
|
|
50
68
|
}, []);
|
|
@@ -57,8 +75,9 @@ const Navigation = React.forwardRef<HTMLElement, NavigationProps>(
|
|
|
57
75
|
setActiveIndex,
|
|
58
76
|
setIsOpen,
|
|
59
77
|
registerTrays,
|
|
78
|
+
cancelClose,
|
|
60
79
|
}),
|
|
61
|
-
[light, isOpen, activeIndex, registerTrays],
|
|
80
|
+
[light, isOpen, activeIndex, registerTrays, cancelClose],
|
|
62
81
|
);
|
|
63
82
|
|
|
64
83
|
return (
|
|
@@ -66,6 +85,7 @@ const Navigation = React.forwardRef<HTMLElement, NavigationProps>(
|
|
|
66
85
|
<nav
|
|
67
86
|
ref={ref}
|
|
68
87
|
className={cn("navigation", light && "navigation--light", className)}
|
|
88
|
+
onMouseEnter={cancelClose}
|
|
69
89
|
onMouseLeave={handleMouseLeave}
|
|
70
90
|
{...props}
|
|
71
91
|
>
|
|
@@ -344,11 +364,12 @@ const NavigationTray = React.forwardRef<HTMLDivElement, NavigationTrayProps>(
|
|
|
344
364
|
},
|
|
345
365
|
ref,
|
|
346
366
|
) => {
|
|
347
|
-
const { light, activeIndex, setActiveIndex, setIsOpen, isOpen } =
|
|
367
|
+
const { light, activeIndex, setActiveIndex, setIsOpen, isOpen, cancelClose } =
|
|
348
368
|
useNavigation();
|
|
349
369
|
const isActive = activeIndex === _index;
|
|
350
370
|
|
|
351
371
|
const handleMouseEnter = () => {
|
|
372
|
+
cancelClose();
|
|
352
373
|
setIsOpen(true);
|
|
353
374
|
setActiveIndex(_index ?? null);
|
|
354
375
|
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
import { cn } from "@/lib/utils";
|
|
4
|
+
|
|
5
|
+
/** Radio v0.1 (native input + styled control). */
|
|
6
|
+
type RadioV01State = "default" | "focus" | "error" | "error-focus" | "disabled";
|
|
7
|
+
|
|
8
|
+
interface RadioV01Props
|
|
9
|
+
extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "type" | "size"> {
|
|
10
|
+
state?: RadioV01State;
|
|
11
|
+
error?: boolean;
|
|
12
|
+
label?: React.ReactNode;
|
|
13
|
+
containerClassName?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const RadioV01 = React.forwardRef<HTMLInputElement, RadioV01Props>(
|
|
17
|
+
(
|
|
18
|
+
{
|
|
19
|
+
className,
|
|
20
|
+
containerClassName,
|
|
21
|
+
state,
|
|
22
|
+
error = false,
|
|
23
|
+
label,
|
|
24
|
+
disabled,
|
|
25
|
+
onFocus,
|
|
26
|
+
onBlur,
|
|
27
|
+
id,
|
|
28
|
+
...props
|
|
29
|
+
},
|
|
30
|
+
ref,
|
|
31
|
+
) => {
|
|
32
|
+
const [focused, setFocused] = React.useState(false);
|
|
33
|
+
const generated = React.useId();
|
|
34
|
+
const inputId = id ?? generated;
|
|
35
|
+
|
|
36
|
+
const resolved: RadioV01State =
|
|
37
|
+
state ??
|
|
38
|
+
(disabled
|
|
39
|
+
? "disabled"
|
|
40
|
+
: error
|
|
41
|
+
? focused
|
|
42
|
+
? "error-focus"
|
|
43
|
+
: "error"
|
|
44
|
+
: focused
|
|
45
|
+
? "focus"
|
|
46
|
+
: "default");
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<label
|
|
50
|
+
htmlFor={inputId}
|
|
51
|
+
data-state={resolved}
|
|
52
|
+
className={cn("radio-v01 font-mazzardSoft", containerClassName)}
|
|
53
|
+
>
|
|
54
|
+
<input
|
|
55
|
+
ref={ref}
|
|
56
|
+
id={inputId}
|
|
57
|
+
type="radio"
|
|
58
|
+
className={cn("radio-v01-input", className)}
|
|
59
|
+
disabled={disabled || resolved === "disabled"}
|
|
60
|
+
aria-invalid={error || undefined}
|
|
61
|
+
onFocus={(event) => {
|
|
62
|
+
setFocused(true);
|
|
63
|
+
onFocus?.(event);
|
|
64
|
+
}}
|
|
65
|
+
onBlur={(event) => {
|
|
66
|
+
setFocused(false);
|
|
67
|
+
onBlur?.(event);
|
|
68
|
+
}}
|
|
69
|
+
{...props}
|
|
70
|
+
/>
|
|
71
|
+
<span className="radio-v01-control" aria-hidden="true">
|
|
72
|
+
<span className="radio-v01-dot" />
|
|
73
|
+
</span>
|
|
74
|
+
{label != null && label !== "" ? (
|
|
75
|
+
<span className="radio-v01-label">{label}</span>
|
|
76
|
+
) : null}
|
|
77
|
+
</label>
|
|
78
|
+
);
|
|
79
|
+
},
|
|
80
|
+
);
|
|
81
|
+
RadioV01.displayName = "RadioV01";
|
|
82
|
+
|
|
83
|
+
export { RadioV01 };
|
|
84
|
+
export type { RadioV01Props, RadioV01State };
|
|
@@ -2,17 +2,7 @@ import * as React from "react";
|
|
|
2
2
|
|
|
3
3
|
import { cn } from "@/lib/utils";
|
|
4
4
|
|
|
5
|
-
/**
|
|
6
|
-
* Search field — built from the Figma component set `Search field`
|
|
7
|
-
* (node 12008:2262, "Search Field -v0.1").
|
|
8
|
-
*
|
|
9
|
-
* Figma models it as a single `State` property: Default, Focus, Active, Filled,
|
|
10
|
-
* Disable. Those map onto real interaction here — focus and value derive the
|
|
11
|
-
* state — and `state` can also be passed to pin one for specs and stories.
|
|
12
|
-
*
|
|
13
|
-
* Spacing and radius come from `--space-*` / `--radius-*`. The sizes Figma
|
|
14
|
-
* specifies that are not on a scale live as `--search-field-*` variables.
|
|
15
|
-
*/
|
|
5
|
+
/** Search field v0.1 (Figma Search field). */
|
|
16
6
|
type SearchFieldV01State =
|
|
17
7
|
| "default"
|
|
18
8
|
| "focus"
|
|
@@ -20,11 +10,6 @@ type SearchFieldV01State =
|
|
|
20
10
|
| "filled"
|
|
21
11
|
| "disabled";
|
|
22
12
|
|
|
23
|
-
/**
|
|
24
|
-
* Figma's icons are stroked at 1.5 on a 16 viewBox — lucide's own 24 viewBox
|
|
25
|
-
* renders a different weight at this size, so the paths are inlined verbatim.
|
|
26
|
-
* All three take `currentColor`.
|
|
27
|
-
*/
|
|
28
13
|
const iconProps = {
|
|
29
14
|
fill: "none",
|
|
30
15
|
strokeWidth: 1.5,
|
|
@@ -57,20 +42,9 @@ const ClearIcon = (props: React.SVGProps<SVGSVGElement>) => (
|
|
|
57
42
|
|
|
58
43
|
interface SearchFieldV01Props
|
|
59
44
|
extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "size"> {
|
|
60
|
-
/**
|
|
61
|
-
* Figma `State`. Omit to let focus and value drive it:
|
|
62
|
-
* empty + blurred = `default`, empty + focused = `focus`,
|
|
63
|
-
* has value + focused = `active`, has value + blurred = `filled`.
|
|
64
|
-
*/
|
|
65
45
|
state?: SearchFieldV01State;
|
|
66
|
-
/**
|
|
67
|
-
* Inline typeahead remainder rendered after the value — Figma's `Active`
|
|
68
|
-
* state ("Entry" + "typeahead"). Also shows the Enter affordance.
|
|
69
|
-
*/
|
|
70
46
|
suggestion?: string;
|
|
71
|
-
/** Renders the clear button once there is a value (Figma `Filled`). */
|
|
72
47
|
onClear?: () => void;
|
|
73
|
-
/** Class for the outer box; `className` goes to the input. */
|
|
74
48
|
containerClassName?: string;
|
|
75
49
|
}
|
|
76
50
|
|
|
@@ -113,8 +87,9 @@ const SearchFieldV01 = React.forwardRef<HTMLInputElement, SearchFieldV01Props>(
|
|
|
113
87
|
? "filled"
|
|
114
88
|
: "default");
|
|
115
89
|
|
|
116
|
-
// Figma drops the search icon as soon as the field is in use.
|
|
117
90
|
const showSearchIcon = resolved === "default" || resolved === "disabled";
|
|
91
|
+
const showCaret =
|
|
92
|
+
state != null && (resolved === "focus" || resolved === "active");
|
|
118
93
|
const showTypeahead = resolved === "active" && Boolean(suggestion);
|
|
119
94
|
const showEnter = resolved === "active";
|
|
120
95
|
const showClear = resolved === "filled" && hasValue && Boolean(onClear);
|
|
@@ -122,6 +97,7 @@ const SearchFieldV01 = React.forwardRef<HTMLInputElement, SearchFieldV01Props>(
|
|
|
122
97
|
return (
|
|
123
98
|
<div
|
|
124
99
|
data-state={resolved}
|
|
100
|
+
data-caret={showCaret ? (hasValue ? "trailing" : "leading") : undefined}
|
|
125
101
|
className={cn(
|
|
126
102
|
"search-field-v01",
|
|
127
103
|
showTypeahead && "search-field-v01--typeahead",
|
|
@@ -135,6 +111,9 @@ const SearchFieldV01 = React.forwardRef<HTMLInputElement, SearchFieldV01Props>(
|
|
|
135
111
|
)}
|
|
136
112
|
|
|
137
113
|
<span className="search-field-v01-field">
|
|
114
|
+
{showCaret && !hasValue && (
|
|
115
|
+
<span className="search-field-v01-caret" aria-hidden />
|
|
116
|
+
)}
|
|
138
117
|
<input
|
|
139
118
|
ref={ref}
|
|
140
119
|
type="search"
|
|
@@ -157,6 +136,9 @@ const SearchFieldV01 = React.forwardRef<HTMLInputElement, SearchFieldV01Props>(
|
|
|
157
136
|
}}
|
|
158
137
|
{...props}
|
|
159
138
|
/>
|
|
139
|
+
{showCaret && hasValue && (
|
|
140
|
+
<span className="search-field-v01-caret" aria-hidden />
|
|
141
|
+
)}
|
|
160
142
|
{showTypeahead && (
|
|
161
143
|
<span className="search-field-v01-suggestion" aria-hidden="true">
|
|
162
144
|
{suggestion}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
import { cn } from "@/lib/utils";
|
|
4
|
+
import {
|
|
5
|
+
IconUtilityHidden,
|
|
6
|
+
IconUtilityPreview,
|
|
7
|
+
IconUtilityQuestion,
|
|
8
|
+
} from "@/components/icons/IconUtility";
|
|
9
|
+
|
|
10
|
+
/** Sign-in field v0.1 — stacked email/password (Figma Sign in). */
|
|
11
|
+
type SignInFieldV01Type = "email" | "password";
|
|
12
|
+
type SignInFieldV01State = "default" | "focus" | "active" | "filled" | "error";
|
|
13
|
+
|
|
14
|
+
interface SignInFieldV01Props
|
|
15
|
+
extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "type" | "size"> {
|
|
16
|
+
type?: SignInFieldV01Type;
|
|
17
|
+
state?: SignInFieldV01State;
|
|
18
|
+
hide?: boolean;
|
|
19
|
+
onHideChange?: (hide: boolean) => void;
|
|
20
|
+
onHelp?: () => void;
|
|
21
|
+
containerClassName?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const SignInFieldV01 = React.forwardRef<HTMLInputElement, SignInFieldV01Props>(
|
|
25
|
+
(
|
|
26
|
+
{
|
|
27
|
+
className,
|
|
28
|
+
containerClassName,
|
|
29
|
+
type = "email",
|
|
30
|
+
state,
|
|
31
|
+
hide,
|
|
32
|
+
onHideChange,
|
|
33
|
+
onHelp,
|
|
34
|
+
placeholder,
|
|
35
|
+
value,
|
|
36
|
+
defaultValue,
|
|
37
|
+
onFocus,
|
|
38
|
+
onBlur,
|
|
39
|
+
onChange,
|
|
40
|
+
disabled,
|
|
41
|
+
...props
|
|
42
|
+
},
|
|
43
|
+
ref,
|
|
44
|
+
) => {
|
|
45
|
+
const isPassword = type === "password";
|
|
46
|
+
const [focused, setFocused] = React.useState(false);
|
|
47
|
+
const [internalValue, setInternalValue] = React.useState(
|
|
48
|
+
defaultValue != null ? String(defaultValue) : "",
|
|
49
|
+
);
|
|
50
|
+
const [internalHide, setInternalHide] = React.useState(true);
|
|
51
|
+
|
|
52
|
+
const currentValue = value != null ? String(value) : internalValue;
|
|
53
|
+
const hasValue = currentValue.length > 0;
|
|
54
|
+
const masked = hide !== undefined ? hide : internalHide;
|
|
55
|
+
|
|
56
|
+
const pinned = state === "error" && !isPassword ? undefined : state;
|
|
57
|
+
|
|
58
|
+
const resolved: SignInFieldV01State =
|
|
59
|
+
pinned ??
|
|
60
|
+
(focused ? (hasValue ? "active" : "focus") : hasValue ? "filled" : "default");
|
|
61
|
+
|
|
62
|
+
const isError = resolved === "error";
|
|
63
|
+
|
|
64
|
+
const showCaret =
|
|
65
|
+
pinned != null && (resolved === "focus" || resolved === "active");
|
|
66
|
+
|
|
67
|
+
const toggleHide = () => {
|
|
68
|
+
if (hide === undefined) setInternalHide(!masked);
|
|
69
|
+
onHideChange?.(!masked);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<div
|
|
74
|
+
data-type={type}
|
|
75
|
+
data-state={resolved}
|
|
76
|
+
data-caret={showCaret ? (hasValue ? "trailing" : "leading") : undefined}
|
|
77
|
+
className={cn("sign-in-field-v01 font-mazzardSoft", containerClassName)}
|
|
78
|
+
>
|
|
79
|
+
<div className="sign-in-field-v01-field">
|
|
80
|
+
{showCaret && !hasValue ? (
|
|
81
|
+
<span className="sign-in-field-v01-caret" aria-hidden />
|
|
82
|
+
) : null}
|
|
83
|
+
<input
|
|
84
|
+
ref={ref}
|
|
85
|
+
type={
|
|
86
|
+
isPassword && masked && !isError
|
|
87
|
+
? "password"
|
|
88
|
+
: isPassword
|
|
89
|
+
? "text"
|
|
90
|
+
: "email"
|
|
91
|
+
}
|
|
92
|
+
className={cn("sign-in-field-v01-input", className)}
|
|
93
|
+
placeholder={
|
|
94
|
+
placeholder ??
|
|
95
|
+
(isPassword ? "Enter your password" : "Enter your email")
|
|
96
|
+
}
|
|
97
|
+
disabled={disabled}
|
|
98
|
+
value={value != null ? value : internalValue}
|
|
99
|
+
onFocus={(event) => {
|
|
100
|
+
setFocused(true);
|
|
101
|
+
onFocus?.(event);
|
|
102
|
+
}}
|
|
103
|
+
onBlur={(event) => {
|
|
104
|
+
setFocused(false);
|
|
105
|
+
onBlur?.(event);
|
|
106
|
+
}}
|
|
107
|
+
onChange={(event) => {
|
|
108
|
+
if (value == null) setInternalValue(event.target.value);
|
|
109
|
+
onChange?.(event);
|
|
110
|
+
}}
|
|
111
|
+
{...props}
|
|
112
|
+
/>
|
|
113
|
+
{showCaret && hasValue ? (
|
|
114
|
+
<span className="sign-in-field-v01-caret" aria-hidden />
|
|
115
|
+
) : null}
|
|
116
|
+
|
|
117
|
+
{isPassword ? (
|
|
118
|
+
<span className="sign-in-field-v01-actions">
|
|
119
|
+
{hasValue && !isError ? (
|
|
120
|
+
<button
|
|
121
|
+
type="button"
|
|
122
|
+
className="sign-in-field-v01-action"
|
|
123
|
+
onClick={toggleHide}
|
|
124
|
+
disabled={disabled}
|
|
125
|
+
aria-label={masked ? "Show password" : "Hide password"}
|
|
126
|
+
aria-pressed={!masked}
|
|
127
|
+
>
|
|
128
|
+
{masked ? <IconUtilityPreview /> : <IconUtilityHidden />}
|
|
129
|
+
</button>
|
|
130
|
+
) : null}
|
|
131
|
+
<button
|
|
132
|
+
type="button"
|
|
133
|
+
className="sign-in-field-v01-action"
|
|
134
|
+
onClick={onHelp}
|
|
135
|
+
disabled={disabled}
|
|
136
|
+
aria-label="Password help"
|
|
137
|
+
>
|
|
138
|
+
<IconUtilityQuestion />
|
|
139
|
+
</button>
|
|
140
|
+
</span>
|
|
141
|
+
) : null}
|
|
142
|
+
</div>
|
|
143
|
+
</div>
|
|
144
|
+
);
|
|
145
|
+
},
|
|
146
|
+
);
|
|
147
|
+
SignInFieldV01.displayName = "SignInFieldV01";
|
|
148
|
+
|
|
149
|
+
export { SignInFieldV01 };
|
|
150
|
+
export type { SignInFieldV01Props, SignInFieldV01State, SignInFieldV01Type };
|