@ntbjs/react-components 2.0.14 → 3.0.0-rc.1
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/build/data/Alert/Alert.js +18 -33
- package/build/data/Alert/Alert.js.map +1 -1
- package/build/data/Alert/Alert.styled.js +9 -47
- package/build/data/Alert/Alert.styled.js.map +1 -1
- package/build/data/Badge/Badge.js +36 -61
- package/build/data/Badge/Badge.js.map +1 -1
- package/build/data/Badge/Badge.styled.js +21 -70
- package/build/data/Badge/Badge.styled.js.map +1 -1
- package/build/data/Popover/Popover.js +125 -71
- package/build/data/Popover/Popover.js.map +1 -1
- package/build/data/Popover/Popover.styled.js +10 -140
- package/build/data/Popover/Popover.styled.js.map +1 -1
- package/build/data/SeverityBadge/SeverityBadge.js +13 -22
- package/build/data/SeverityBadge/SeverityBadge.js.map +1 -1
- package/build/data/SeverityBadge/index.js +2 -0
- package/build/data/SeverityBadge/index.js.map +1 -0
- package/build/data/Tab/Tab.js +7 -13
- package/build/data/Tab/Tab.js.map +1 -1
- package/build/data/Tab/Tab.styled.js +4 -7
- package/build/data/Tab/Tab.styled.js.map +1 -1
- package/build/data/Tabs/Tabs.js +30 -32
- package/build/data/Tabs/Tabs.js.map +1 -1
- package/build/data/Tabs/Tabs.styled.js +21 -57
- package/build/data/Tabs/Tabs.styled.js.map +1 -1
- package/build/data/Tooltip/Tooltip.js +102 -33
- package/build/data/Tooltip/Tooltip.js.map +1 -1
- package/build/data/Tooltip/Tooltip.styled.js +9 -22
- package/build/data/Tooltip/Tooltip.styled.js.map +1 -1
- package/build/data/VerificationStatusIcon/VerificationStatusIcon.js +16 -23
- package/build/data/VerificationStatusIcon/VerificationStatusIcon.js.map +1 -1
- package/build/data/VerificationStatusIcon/VerificationStatusIcon.styled.js +13 -31
- package/build/data/VerificationStatusIcon/VerificationStatusIcon.styled.js.map +1 -1
- package/build/data/VerificationStatusIcon/index.js +2 -0
- package/build/data/VerificationStatusIcon/index.js.map +1 -0
- package/build/data/_shared/FloatingArrow.styled.js +30 -0
- package/build/data/_shared/FloatingArrow.styled.js.map +1 -0
- package/build/hooks/useEventListner.js.map +1 -1
- package/build/hooks/useFloatingPopover.js +187 -0
- package/build/hooks/useFloatingPopover.js.map +1 -0
- package/build/hooks/useIsomorphicLayoutEffect.js.map +1 -1
- package/build/hooks/useOnClickOutside.js.map +1 -1
- package/build/hooks/useTooltipAutoShow.js.map +1 -1
- package/build/icons/arrow-back.svg.js +3 -3
- package/build/icons/arrow-back.svg.js.map +1 -1
- package/build/icons/arrow-forward.svg.js +4 -4
- package/build/icons/arrow-forward.svg.js.map +1 -1
- package/build/icons/check-rectangle-filled.svg.js +3 -3
- package/build/icons/check-rectangle-filled.svg.js.map +1 -1
- package/build/icons/close.svg.js +3 -3
- package/build/icons/close.svg.js.map +1 -1
- package/build/icons/edit-note.svg.js +3 -3
- package/build/icons/edit-note.svg.js.map +1 -1
- package/build/icons/expand-more.svg.js +3 -3
- package/build/icons/expand-more.svg.js.map +1 -1
- package/build/icons/headset.svg.js +3 -3
- package/build/icons/headset.svg.js.map +1 -1
- package/build/icons/layers.svg.js +3 -3
- package/build/icons/layers.svg.js.map +1 -1
- package/build/icons/link.svg.js +3 -3
- package/build/icons/link.svg.js.map +1 -1
- package/build/icons/play.svg.js +3 -3
- package/build/icons/play.svg.js.map +1 -1
- package/build/icons/search.svg.js +3 -3
- package/build/icons/search.svg.js.map +1 -1
- package/build/icons/star-filled.svg.js +3 -3
- package/build/icons/star-filled.svg.js.map +1 -1
- package/build/icons/star.svg.js +3 -3
- package/build/icons/star.svg.js.map +1 -1
- package/build/icons/triangle-right.svg.js +3 -3
- package/build/icons/triangle-right.svg.js.map +1 -1
- package/build/icons/verification.svg.js +3 -3
- package/build/icons/verification.svg.js.map +1 -1
- package/build/icons/warning-circle.svg.js +3 -3
- package/build/icons/warning-circle.svg.js.map +1 -1
- package/build/inputs/ActionButton/ActionButton.js +11 -22
- package/build/inputs/ActionButton/ActionButton.js.map +1 -1
- package/build/inputs/ActionButton/ActionButton.styled.js +5 -54
- package/build/inputs/ActionButton/ActionButton.styled.js.map +1 -1
- package/build/inputs/Button/Button.js +125 -121
- package/build/inputs/Button/Button.js.map +1 -1
- package/build/inputs/Button/Button.styled.js +42 -260
- package/build/inputs/Button/Button.styled.js.map +1 -1
- package/build/inputs/Checkbox/Checkbox.js +45 -61
- package/build/inputs/Checkbox/Checkbox.js.map +1 -1
- package/build/inputs/Checkbox/Checkbox.styled.js +24 -153
- package/build/inputs/Checkbox/Checkbox.styled.js.map +1 -1
- package/build/inputs/CompactAutocompleteSelect/CompactAutocompleteSelect.js +106 -111
- package/build/inputs/CompactAutocompleteSelect/CompactAutocompleteSelect.js.map +1 -1
- package/build/inputs/CompactAutocompleteSelect/CompactAutocompleteSelect.styled.js +88 -273
- package/build/inputs/CompactAutocompleteSelect/CompactAutocompleteSelect.styled.js.map +1 -1
- package/build/inputs/CompactStarRating/CompactStarRating.js +56 -77
- package/build/inputs/CompactStarRating/CompactStarRating.js.map +1 -1
- package/build/inputs/CompactStarRating/CompactStarRating.styled.js +32 -211
- package/build/inputs/CompactStarRating/CompactStarRating.styled.js.map +1 -1
- package/build/inputs/CompactTextInput/CompactTextInput.js +86 -105
- package/build/inputs/CompactTextInput/CompactTextInput.js.map +1 -1
- package/build/inputs/CompactTextInput/CompactTextInput.styled.js +55 -258
- package/build/inputs/CompactTextInput/CompactTextInput.styled.js.map +1 -1
- package/build/inputs/MultiLevelCheckbox/MultiLevelCheckbox.js +70 -77
- package/build/inputs/MultiLevelCheckbox/MultiLevelCheckbox.js.map +1 -1
- package/build/inputs/MultiLevelCheckbox/MultiLevelCheckbox.styled.js +28 -60
- package/build/inputs/MultiLevelCheckbox/MultiLevelCheckbox.styled.js.map +1 -1
- package/build/inputs/MultiLevelCheckbox/types.js +12 -12
- package/build/inputs/MultiLevelCheckbox/types.js.map +1 -1
- package/build/inputs/MultiLevelCheckboxSelect/MultiLevelCheckboxSelect.js +69 -73
- package/build/inputs/MultiLevelCheckboxSelect/MultiLevelCheckboxSelect.js.map +1 -1
- package/build/inputs/MultiLevelCheckboxSelect/MultiLevelCheckboxSelect.styled.js +44 -87
- package/build/inputs/MultiLevelCheckboxSelect/MultiLevelCheckboxSelect.styled.js.map +1 -1
- package/build/inputs/MultiSelect/MultiSelect.js +69 -79
- package/build/inputs/MultiSelect/MultiSelect.js.map +1 -1
- package/build/inputs/MultiSelect/MultiSelect.styled.js +70 -76
- package/build/inputs/MultiSelect/MultiSelect.styled.js.map +1 -1
- package/build/inputs/Radio/Radio.js +20 -33
- package/build/inputs/Radio/Radio.js.map +1 -1
- package/build/inputs/Radio/Radio.styled.js +15 -96
- package/build/inputs/Radio/Radio.styled.js.map +1 -1
- package/build/inputs/Switch/Switch.js +28 -40
- package/build/inputs/Switch/Switch.js.map +1 -1
- package/build/inputs/Switch/Switch.styled.js +24 -94
- package/build/inputs/Switch/Switch.styled.js.map +1 -1
- package/build/inputs/TextArea/TextArea.js +98 -123
- package/build/inputs/TextArea/TextArea.js.map +1 -1
- package/build/inputs/TextArea/TextArea.styled.js +64 -379
- package/build/inputs/TextArea/TextArea.styled.js.map +1 -1
- package/build/inputs/TextInput/TextInput.js +59 -79
- package/build/inputs/TextInput/TextInput.js.map +1 -1
- package/build/inputs/TextInput/TextInput.styled.js +33 -224
- package/build/inputs/TextInput/TextInput.styled.js.map +1 -1
- package/build/layout/InputGroup/InputGroup.js +6 -9
- package/build/layout/InputGroup/InputGroup.js.map +1 -1
- package/build/layout/InputGroup/InputGroup.styled.js +4 -3
- package/build/layout/InputGroup/InputGroup.styled.js.map +1 -1
- package/build/layout/InputGroup/index.js +2 -0
- package/build/layout/InputGroup/index.js.map +1 -0
- package/build/layout/SectionSeparator/SectionSeparator.js +5 -9
- package/build/layout/SectionSeparator/SectionSeparator.js.map +1 -1
- package/build/layout/SectionSeparator/SectionSeparator.styled.js +4 -8
- package/build/layout/SectionSeparator/SectionSeparator.styled.js.map +1 -1
- package/build/styles/utils/colors-export.d.ts +73 -0
- package/build/styles/utils/colors-export.js.map +1 -1
- package/build/utils/dateTime.js.map +1 -1
- package/build/utils/defaultTheme.js +14 -28
- package/build/utils/defaultTheme.js.map +1 -1
- package/build/utils/getElementRef.js +14 -0
- package/build/utils/getElementRef.js.map +1 -0
- package/build/utils/parseTrigger.js +16 -0
- package/build/utils/parseTrigger.js.map +1 -0
- package/build/widgets/AssetAction/AssetAction.js +26 -33
- package/build/widgets/AssetAction/AssetAction.js.map +1 -1
- package/build/widgets/AssetAction/AssetAction.styled.js +20 -34
- package/build/widgets/AssetAction/AssetAction.styled.js.map +1 -1
- package/build/widgets/AssetActionsBase/AssetActionsBase.js +8 -13
- package/build/widgets/AssetActionsBase/AssetActionsBase.js.map +1 -1
- package/build/widgets/AssetActionsBase/AssetActionsBase.styled.js +4 -9
- package/build/widgets/AssetActionsBase/AssetActionsBase.styled.js.map +1 -1
- package/build/widgets/AssetGallery/AssetGallery.js +15 -40
- package/build/widgets/AssetGallery/AssetGallery.js.map +1 -1
- package/build/widgets/AssetGallery/AssetGalleryBase/AssetGalleryBase.js +55 -70
- package/build/widgets/AssetGallery/AssetGalleryBase/AssetGalleryBase.js.map +1 -1
- package/build/widgets/AssetGallery/AssetGalleryBase/AssetGalleryBase.styled.js +12 -24
- package/build/widgets/AssetGallery/AssetGalleryBase/AssetGalleryBase.styled.js.map +1 -1
- package/build/widgets/AssetGallery/AssetGalleryBase/AssetGalleryCompactCard/AssetGalleryCompactCard.js +146 -122
- package/build/widgets/AssetGallery/AssetGalleryBase/AssetGalleryCompactCard/AssetGalleryCompactCard.js.map +1 -1
- package/build/widgets/AssetGallery/AssetGalleryBase/AssetGalleryCompactCard/AssetGalleryCompactCard.styled.js +99 -286
- package/build/widgets/AssetGallery/AssetGalleryBase/AssetGalleryCompactCard/AssetGalleryCompactCard.styled.js.map +1 -1
- package/build/widgets/AssetGallery/AssetGalleryBase/AssetGalleryGridCard/AssetGalleryGridCard.js +170 -125
- package/build/widgets/AssetGallery/AssetGalleryBase/AssetGalleryGridCard/AssetGalleryGridCard.js.map +1 -1
- package/build/widgets/AssetGallery/AssetGalleryBase/AssetGalleryGridCard/AssetGalleryGridCard.styled.js +135 -364
- package/build/widgets/AssetGallery/AssetGalleryBase/AssetGalleryGridCard/AssetGalleryGridCard.styled.js.map +1 -1
- package/build/widgets/AssetPreview/AssetPreviewTopBar/AssetPreviewTopBar.js +20 -21
- package/build/widgets/AssetPreview/AssetPreviewTopBar/AssetPreviewTopBar.js.map +1 -1
- package/build/widgets/AssetPreview/AssetPreviewTopBar/AssetPreviewTopBar.styled.js +20 -71
- package/build/widgets/AssetPreview/AssetPreviewTopBar/AssetPreviewTopBar.styled.js.map +1 -1
- package/build/widgets/ContextMenu/ContextMenu.js +12 -11
- package/build/widgets/ContextMenu/ContextMenu.js.map +1 -1
- package/build/widgets/ContextMenu/ContextMenu.styled.js +4 -4
- package/build/widgets/ContextMenu/ContextMenu.styled.js.map +1 -1
- package/build/widgets/ContextMenu/ContextMenuItem/ContextMenuItem.js +17 -25
- package/build/widgets/ContextMenu/ContextMenuItem/ContextMenuItem.js.map +1 -1
- package/build/widgets/ContextMenu/ContextMenuItem/ContextMenuItem.styled.js +16 -71
- package/build/widgets/ContextMenu/ContextMenuItem/ContextMenuItem.styled.js.map +1 -1
- package/build/widgets/ContextMenu/ContextMenuItemsGroup/ContextMenuItemsGroup.js +7 -11
- package/build/widgets/ContextMenu/ContextMenuItemsGroup/ContextMenuItemsGroup.js.map +1 -1
- package/build/widgets/ContextMenu/ContextMenuItemsGroup/ContextMenuItemsGroup.styled.js +4 -11
- package/build/widgets/ContextMenu/ContextMenuItemsGroup/ContextMenuItemsGroup.styled.js.map +1 -1
- package/build/widgets/InfoCard/InfoCard.js +26 -21
- package/build/widgets/InfoCard/InfoCard.js.map +1 -1
- package/build/widgets/InfoCard/InfoCard.styled.js +36 -84
- package/build/widgets/InfoCard/InfoCard.styled.js.map +1 -1
- package/build/widgets/InstructionSeverityDisplay/InstructionSeverityDisplay.js +28 -34
- package/build/widgets/InstructionSeverityDisplay/InstructionSeverityDisplay.js.map +1 -1
- package/build/widgets/InstructionSeverityDisplay/InstructionSeverityDisplay.styled.js +21 -57
- package/build/widgets/InstructionSeverityDisplay/InstructionSeverityDisplay.styled.js.map +1 -1
- package/build/widgets/InstructionSeverityDisplay/index.js +2 -0
- package/build/widgets/InstructionSeverityDisplay/index.js.map +1 -0
- package/build/widgets/Instructions/Instructions.js +53 -95
- package/build/widgets/Instructions/Instructions.js.map +1 -1
- package/build/widgets/Instructions/Instructions.styled.js +27 -26
- package/build/widgets/Instructions/Instructions.styled.js.map +1 -1
- package/build/widgets/ProgressBar/ProgressBar.js +39 -37
- package/build/widgets/ProgressBar/ProgressBar.js.map +1 -1
- package/build/widgets/ProgressBar/ProgressBar.styled.js +56 -125
- package/build/widgets/ProgressBar/ProgressBar.styled.js.map +1 -1
- package/build/widgets/SummaryCard/SummaryCard.js +55 -64
- package/build/widgets/SummaryCard/SummaryCard.js.map +1 -1
- package/build/widgets/SummaryCard/SummaryCard.styled.js +51 -106
- package/build/widgets/SummaryCard/SummaryCard.styled.js.map +1 -1
- package/package.json +77 -36
- package/styles/utils/colors-export.d.ts +73 -0
- package/types/components/data/Alert/Alert.d.ts +76 -0
- package/types/components/data/Alert/Alert.styled.d.ts +83 -0
- package/types/components/data/Alert/index.d.ts +1 -0
- package/types/components/data/Badge/Badge.d.ts +128 -0
- package/types/components/data/Badge/Badge.styled.d.ts +132 -0
- package/types/components/data/Badge/index.d.ts +1 -0
- package/types/components/data/Popover/Popover.d.ts +205 -0
- package/types/components/data/Popover/Popover.styled.d.ts +15 -0
- package/types/components/data/Popover/index.d.ts +1 -0
- package/types/components/data/SeverityBadge/SeverityBadge.d.ts +72 -0
- package/types/components/data/SeverityBadge/index.d.ts +1 -0
- package/types/components/data/Tab/Tab.d.ts +27 -0
- package/types/components/data/Tab/Tab.styled.d.ts +1 -0
- package/types/components/data/Tab/index.d.ts +1 -0
- package/types/components/data/Tabs/Tabs.d.ts +111 -0
- package/types/components/data/Tabs/Tabs.styled.d.ts +42 -0
- package/types/components/data/Tabs/index.d.ts +1 -0
- package/types/components/data/Tooltip/Tooltip.d.ts +134 -0
- package/types/components/data/Tooltip/Tooltip.styled.d.ts +8 -0
- package/types/components/data/Tooltip/index.d.ts +1 -0
- package/types/components/data/VerificationStatusIcon/VerificationStatusIcon.d.ts +35 -0
- package/types/components/data/VerificationStatusIcon/VerificationStatusIcon.styled.d.ts +46 -0
- package/types/components/data/VerificationStatusIcon/index.d.ts +1 -0
- package/types/components/data/_shared/FloatingArrow.styled.d.ts +129 -0
- package/types/components/data/index.d.ts +8 -0
- package/types/components/index.d.ts +3 -0
- package/types/components/inputs/ActionButton/ActionButton.d.ts +55 -0
- package/types/components/inputs/ActionButton/ActionButton.styled.d.ts +34 -0
- package/types/components/inputs/ActionButton/index.d.ts +1 -0
- package/types/components/inputs/Button/Button.d.ts +82 -0
- package/types/components/inputs/Button/Button.styled.d.ts +102 -0
- package/types/components/inputs/Button/index.d.ts +1 -0
- package/types/components/inputs/Checkbox/Checkbox.d.ts +92 -0
- package/types/components/inputs/Checkbox/Checkbox.styled.d.ts +33 -0
- package/types/components/inputs/Checkbox/index.d.ts +1 -0
- package/types/components/inputs/CompactAutocompleteSelect/CompactAutocompleteSelect.d.ts +242 -0
- package/types/components/inputs/CompactAutocompleteSelect/CompactAutocompleteSelect.styled.d.ts +157 -0
- package/types/components/inputs/CompactAutocompleteSelect/index.d.ts +1 -0
- package/types/components/inputs/CompactStarRating/CompactStarRating.d.ts +96 -0
- package/types/components/inputs/CompactStarRating/CompactStarRating.styled.d.ts +86 -0
- package/types/components/inputs/CompactStarRating/index.d.ts +1 -0
- package/types/components/inputs/CompactTextInput/CompactTextInput.d.ts +116 -0
- package/types/components/inputs/CompactTextInput/CompactTextInput.styled.d.ts +70 -0
- package/types/components/inputs/CompactTextInput/index.d.ts +1 -0
- package/types/components/inputs/MultiLevelCheckbox/MultiLevelCheckbox.d.ts +41 -0
- package/types/components/inputs/MultiLevelCheckbox/MultiLevelCheckbox.styled.d.ts +21 -0
- package/types/components/inputs/MultiLevelCheckbox/index.d.ts +2 -0
- package/types/components/inputs/MultiLevelCheckbox/types.d.ts +72 -0
- package/types/components/inputs/MultiLevelCheckboxSelect/MultiLevelCheckboxSelect.d.ts +44 -0
- package/types/components/inputs/MultiLevelCheckboxSelect/MultiLevelCheckboxSelect.styled.d.ts +11 -0
- package/types/components/inputs/MultiLevelCheckboxSelect/index.d.ts +1 -0
- package/types/components/inputs/MultiSelect/MultiSelect.d.ts +172 -0
- package/types/components/inputs/MultiSelect/MultiSelect.styled.d.ts +99 -0
- package/types/components/inputs/MultiSelect/index.d.ts +1 -0
- package/types/components/inputs/Radio/Radio.d.ts +65 -0
- package/types/components/inputs/Radio/Radio.styled.d.ts +11 -0
- package/types/components/inputs/Radio/index.d.ts +1 -0
- package/types/components/inputs/Switch/Switch.d.ts +62 -0
- package/types/components/inputs/Switch/Switch.styled.d.ts +20 -0
- package/types/components/inputs/Switch/index.d.ts +1 -0
- package/types/components/inputs/TextArea/TextArea.d.ts +124 -0
- package/types/components/inputs/TextArea/TextArea.styled.d.ts +95 -0
- package/types/components/inputs/TextArea/index.d.ts +1 -0
- package/types/components/inputs/TextInput/TextInput.d.ts +109 -0
- package/types/components/inputs/TextInput/TextInput.styled.d.ts +43 -0
- package/types/components/inputs/TextInput/index.d.ts +1 -0
- package/types/components/inputs/index.d.ts +13 -0
- package/types/components/layout/InputGroup/InputGroup.d.ts +31 -0
- package/types/components/layout/InputGroup/InputGroup.styled.d.ts +1 -0
- package/types/components/layout/InputGroup/index.d.ts +1 -0
- package/types/components/layout/SectionSeparator/SectionSeparator.d.ts +28 -0
- package/types/components/layout/SectionSeparator/SectionSeparator.styled.d.ts +14 -0
- package/types/components/layout/SectionSeparator/index.d.ts +1 -0
- package/types/components/layout/index.d.ts +2 -0
- package/types/components/widgets/AssetAction/AssetAction.d.ts +16 -0
- package/types/components/widgets/AssetAction/AssetAction.styled.d.ts +20 -0
- package/types/components/widgets/AssetAction/index.d.ts +1 -0
- package/types/components/widgets/AssetActionsBase/AssetActionsBase.d.ts +25 -0
- package/types/components/widgets/AssetActionsBase/AssetActionsBase.styled.d.ts +1 -0
- package/types/components/widgets/AssetActionsBase/index.d.ts +1 -0
- package/types/components/widgets/AssetGallery/AssetGallery.d.ts +170 -0
- package/types/components/widgets/AssetGallery/AssetGalleryBase/AssetGalleryBase.d.ts +88 -0
- package/types/components/widgets/AssetGallery/AssetGalleryBase/AssetGalleryBase.styled.d.ts +3 -0
- package/types/components/widgets/AssetGallery/AssetGalleryBase/AssetGalleryCompactCard/AssetGalleryCompactCard.d.ts +3 -0
- package/types/components/widgets/AssetGallery/AssetGalleryBase/AssetGalleryCompactCard/AssetGalleryCompactCard.styled.d.ts +100 -0
- package/types/components/widgets/AssetGallery/AssetGalleryBase/AssetGalleryGridCard/AssetGalleryGridCard.d.ts +2 -0
- package/types/components/widgets/AssetGallery/AssetGalleryBase/AssetGalleryGridCard/AssetGalleryGridCard.styled.d.ts +85 -0
- package/types/components/widgets/AssetGallery/asset.types.d.ts +446 -0
- package/types/components/widgets/AssetGallery/index.d.ts +1 -0
- package/types/components/widgets/AssetPreview/AssetPreviewTopBar/AssetPreviewTopBar.d.ts +60 -0
- package/types/components/widgets/AssetPreview/AssetPreviewTopBar/AssetPreviewTopBar.styled.d.ts +35 -0
- package/types/components/widgets/AssetPreview/AssetPreviewTopBar/index.d.ts +1 -0
- package/types/components/widgets/ContextMenu/ContextMenu.d.ts +134 -0
- package/types/components/widgets/ContextMenu/ContextMenu.styled.d.ts +1 -0
- package/types/components/widgets/ContextMenu/ContextMenuItem/ContextMenuItem.d.ts +45 -0
- package/types/components/widgets/ContextMenu/ContextMenuItem/ContextMenuItem.styled.d.ts +26 -0
- package/types/components/widgets/ContextMenu/ContextMenuItem/index.d.ts +1 -0
- package/types/components/widgets/ContextMenu/ContextMenuItemsGroup/ContextMenuItemsGroup.d.ts +41 -0
- package/types/components/widgets/ContextMenu/ContextMenuItemsGroup/ContextMenuItemsGroup.styled.d.ts +1 -0
- package/types/components/widgets/ContextMenu/ContextMenuItemsGroup/index.d.ts +1 -0
- package/types/components/widgets/ContextMenu/index.d.ts +1 -0
- package/types/components/widgets/InfoCard/InfoCard.d.ts +33 -0
- package/types/components/widgets/InfoCard/InfoCard.styled.d.ts +45 -0
- package/types/components/widgets/InfoCard/index.d.ts +1 -0
- package/types/components/widgets/InstructionSeverityDisplay/InstructionSeverityDisplay.d.ts +46 -0
- package/types/components/widgets/InstructionSeverityDisplay/InstructionSeverityDisplay.styled.d.ts +40 -0
- package/types/components/widgets/InstructionSeverityDisplay/index.d.ts +1 -0
- package/types/components/widgets/Instructions/Instructions.d.ts +156 -0
- package/types/components/widgets/Instructions/Instructions.styled.d.ts +26 -0
- package/types/components/widgets/Instructions/index.d.ts +1 -0
- package/types/components/widgets/ProgressBar/ProgressBar.d.ts +30 -0
- package/types/components/widgets/ProgressBar/ProgressBar.styled.d.ts +78 -0
- package/types/components/widgets/ProgressBar/index.d.ts +1 -0
- package/types/components/widgets/SummaryCard/SummaryCard.d.ts +83 -0
- package/types/components/widgets/SummaryCard/SummaryCard.styled.d.ts +68 -0
- package/types/components/widgets/SummaryCard/index.d.ts +1 -0
- package/types/components/widgets/index.d.ts +11 -0
- package/types/hooks/useElementSize.d.ts +25 -0
- package/types/hooks/useEventListner.d.ts +46 -0
- package/types/hooks/useFloatingPopover.d.ts +242 -0
- package/types/hooks/useIsomorphicLayoutEffect.d.ts +26 -0
- package/types/hooks/useOnClickOutside.d.ts +31 -0
- package/types/hooks/useTooltipAutoShow.d.ts +80 -0
- package/types/icons/index.d.ts +41 -0
- package/types/ssr/index.d.ts +1 -0
- package/types/styles/utils/colors-export.d.ts +73 -0
- package/types/utils/dateTime.d.ts +13 -0
- package/types/utils/defaultTheme.d.ts +174 -0
- package/types/utils/getElementRef.d.ts +21 -0
- package/types/utils/parseTrigger.d.ts +92 -0
- package/build/_virtual/_rollupPluginBabelHelpers.js +0 -12
- package/build/_virtual/_rollupPluginBabelHelpers.js.map +0 -1
- package/build/widgets/AssetGallery/asset.propType.js +0 -56
- package/build/widgets/AssetGallery/asset.propType.js.map +0 -1
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
1
|
import React__default, { useMemo } from 'react';
|
|
3
2
|
import { nanoid } from 'nanoid';
|
|
4
|
-
import PropTypes from 'prop-types';
|
|
5
3
|
import { Radio as Radio$1, RadioLabel } from './Radio.styled.js';
|
|
4
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
6
5
|
|
|
7
6
|
const Radio = React__default.forwardRef(function Radio({
|
|
8
7
|
name,
|
|
9
8
|
value,
|
|
10
9
|
checked,
|
|
11
10
|
defaultChecked,
|
|
12
|
-
disabled,
|
|
11
|
+
disabled = false,
|
|
13
12
|
readOnly,
|
|
14
13
|
label,
|
|
15
14
|
className,
|
|
@@ -28,42 +27,30 @@ const Radio = React__default.forwardRef(function Radio({
|
|
|
28
27
|
onChange(e);
|
|
29
28
|
}
|
|
30
29
|
};
|
|
31
|
-
return
|
|
30
|
+
return jsxs(Radio$1, {
|
|
32
31
|
htmlFor: uniqueId,
|
|
33
32
|
disabled: disabled,
|
|
34
33
|
readOnly: readOnly,
|
|
35
34
|
$isChecked: checked,
|
|
36
35
|
className: className,
|
|
37
|
-
style: style
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
36
|
+
style: style,
|
|
37
|
+
children: [jsx("input", {
|
|
38
|
+
ref: forwardedRef,
|
|
39
|
+
type: "radio",
|
|
40
|
+
name: name,
|
|
41
|
+
value: value,
|
|
42
|
+
checked: checked,
|
|
43
|
+
defaultChecked: defaultChecked,
|
|
44
|
+
disabled: disabled,
|
|
45
|
+
id: uniqueId,
|
|
46
|
+
onChange: handleChange,
|
|
47
|
+
onBlur: onBlur,
|
|
48
|
+
...rest
|
|
49
|
+
}), jsx(RadioLabel, {
|
|
50
|
+
children: label
|
|
51
|
+
})]
|
|
52
|
+
});
|
|
50
53
|
});
|
|
51
|
-
Radio.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
52
|
-
label: PropTypes.any,
|
|
53
|
-
name: PropTypes.string.isRequired,
|
|
54
|
-
value: PropTypes.any.isRequired,
|
|
55
|
-
checked: PropTypes.bool,
|
|
56
|
-
defaultChecked: PropTypes.bool,
|
|
57
|
-
disabled: PropTypes.bool,
|
|
58
|
-
readOnly: PropTypes.bool,
|
|
59
|
-
className: PropTypes.string,
|
|
60
|
-
style: PropTypes.object,
|
|
61
|
-
onChange: PropTypes.func,
|
|
62
|
-
onBlur: PropTypes.func
|
|
63
|
-
} : {};
|
|
64
|
-
Radio.defaultProps = {
|
|
65
|
-
disabled: false
|
|
66
|
-
};
|
|
67
54
|
|
|
68
55
|
export { Radio as default };
|
|
69
56
|
//# sourceMappingURL=Radio.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Radio.js","sources":["../../../src/components/inputs/Radio/Radio.
|
|
1
|
+
{"version":3,"file":"Radio.js","sources":["../../../src/components/inputs/Radio/Radio.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\n\nimport { nanoid } from 'nanoid';\n\nimport * as S from './Radio.styled';\n\ntype RadioOwnProps = {\n /**\n * Text displayed by the radio button\n */\n label?: any;\n /**\n * Name of the radio button (used when sending form data)\n */\n name: string;\n /**\n * Value to be sent when the given radio button is selected\n */\n value: any;\n /**\n * Whether the radio button is checked\n */\n checked?: boolean;\n /**\n * Whether the radio button is checked by default. The most commonly used option should have this set to `true`.\n */\n defaultChecked?: boolean;\n /**\n * Whether the radio button is disabled\n */\n disabled?: boolean;\n /**\n * Display the radio button as read-only\n */\n readOnly?: boolean;\n /**\n * Custom class names for the HTML element\n */\n className?: string;\n /**\n * Custom inline CSS styling\n */\n style?: any;\n /**\n * Optional callback function for the `onChange` event\n */\n onChange?: (...args: any[]) => any;\n /**\n * Optional callback function for the `onBlur` event\n */\n onBlur?: (...args: any[]) => any;\n};\n\n/*\n * NMB-3998 §C.2: `rest` is spread onto `input`, so the published type\n * has to admit that target's props too — a closed type here is worse than `any` for the\n * 125 consumer files. Declared members win over the base (`Omit` by `keyof RadioOwnProps`);\n * a bare `&` would INTERSECT a colliding member instead of overriding it, which narrows\n * it (measured: `rows?: number | string` & `rows?: number`) or empties it to `never`.\n */\ntype Props = Omit<React.ComponentPropsWithoutRef<'input'>, keyof RadioOwnProps> & RadioOwnProps;\n\n/**\n * Radio buttons allow the user to select one option from a set.\n *\n * Use radio buttons when the user needs to see all available options. If available options can be\n * collapsed, consider using a dropdown menu because it uses less space.\n *\n * Radio buttons should have the most commonly used option selected by default.\n *\n * ### Import\n *\n * ``` js\n * import { Radio } from '@ntbjs/react-components/inputs'\n * // or\n * import Radio from '@ntbjs/react-components/inputs/Radio'\n * ```\n */\nconst Radio = React.forwardRef<any, Props>(function Radio(\n {\n name,\n value,\n checked,\n defaultChecked,\n disabled = false,\n readOnly,\n label,\n className,\n style,\n onChange,\n onBlur,\n ...rest\n },\n forwardedRef\n) {\n const uniqueId = useMemo(() => nanoid(), []);\n\n const handleChange = e => {\n // Prevent onChange when readOnly\n if (readOnly) {\n e.preventDefault();\n return;\n }\n if (onChange) {\n onChange(e);\n }\n };\n\n return (\n <S.Radio\n htmlFor={uniqueId}\n disabled={disabled}\n readOnly={readOnly}\n $isChecked={checked}\n className={className}\n style={style}\n >\n <input\n ref={forwardedRef}\n type=\"radio\"\n name={name}\n value={value}\n checked={checked}\n defaultChecked={defaultChecked}\n disabled={disabled}\n id={uniqueId}\n onChange={handleChange}\n onBlur={onBlur}\n {...rest}\n />\n <S.RadioLabel>{label}</S.RadioLabel>\n </S.Radio>\n );\n});\n\nexport default Radio;\n"],"names":["Radio","React","forwardRef","name","value","checked","defaultChecked","disabled","readOnly","label","className","style","onChange","onBlur","rest","forwardedRef","uniqueId","useMemo","nanoid","handleChange","e","preventDefault","_jsxs","S","htmlFor","$isChecked","children","_jsx","ref","type","id"],"mappings":";;;;;AA8EA,MAAMA,KAAK,GAAGC,cAAK,CAACC,UAAU,CAAa,SAASF,KAAKA,CACvD;EACEG,IAAI;EACJC,KAAK;EACLC,OAAO;EACPC,cAAc;AACdC,EAAAA,QAAQ,GAAG,KAAK;EAChBC,QAAQ;EACRC,KAAK;EACLC,SAAS;EACTC,KAAK;EACLC,QAAQ;EACRC,MAAM;EACN,GAAGC;AACL,CAAC,EACDC,YAAY,EACZ;EACA,MAAMC,QAAQ,GAAGC,OAAO,CAAC,MAAMC,MAAM,EAAE,EAAE,EAAE,CAAC;EAE5C,MAAMC,YAAY,GAAGC,CAAC,IAAI;AAExB,IAAA,IAAIZ,QAAQ,EAAE;MACZY,CAAC,CAACC,cAAc,EAAE;AAClB,MAAA;AACF,IAAA;AACA,IAAA,IAAIT,QAAQ,EAAE;MACZA,QAAQ,CAACQ,CAAC,CAAC;AACb,IAAA;EACF,CAAC;AAED,EAAA,OACEE,IAAA,CAACC,OAAO,EAAA;AACNC,IAAAA,OAAO,EAAER,QAAS;AAClBT,IAAAA,QAAQ,EAAEA,QAAS;AACnBC,IAAAA,QAAQ,EAAEA,QAAS;AACnBiB,IAAAA,UAAU,EAAEpB,OAAQ;AACpBK,IAAAA,SAAS,EAAEA,SAAU;AACrBC,IAAAA,KAAK,EAAEA,KAAM;AAAAe,IAAAA,QAAA,GAEbC,GAAA,CAAA,OAAA,EAAA;AACEC,MAAAA,GAAG,EAAEb,YAAa;AAClBc,MAAAA,IAAI,EAAC,OAAO;AACZ1B,MAAAA,IAAI,EAAEA,IAAK;AACXC,MAAAA,KAAK,EAAEA,KAAM;AACbC,MAAAA,OAAO,EAAEA,OAAQ;AACjBC,MAAAA,cAAc,EAAEA,cAAe;AAC/BC,MAAAA,QAAQ,EAAEA,QAAS;AACnBuB,MAAAA,EAAE,EAAEd,QAAS;AACbJ,MAAAA,QAAQ,EAAEO,YAAa;AACvBN,MAAAA,MAAM,EAAEA,MAAO;MAAA,GACXC;AAAI,KACT,CAAC,EACFa,GAAA,CAACJ,UAAY,EAAA;AAAAG,MAAAA,QAAA,EAAEjB;AAAK,KAAe,CAAC;AAAA,GAC7B,CAAC;AAEd,CAAC;;;;"}
|
|
@@ -2,103 +2,22 @@ import { math } from 'polished';
|
|
|
2
2
|
import styled, { css } from 'styled-components';
|
|
3
3
|
import { applyDefaultTheme } from '../../utils/defaultTheme.js';
|
|
4
4
|
|
|
5
|
+
const shouldForwardProp = prop => {
|
|
6
|
+
return prop !== 'theme' && !prop.startsWith('$');
|
|
7
|
+
};
|
|
5
8
|
const radioSize = '18px';
|
|
6
|
-
const RadioLabel = styled.div.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
line-height: ${radioSize};
|
|
19
|
-
user-select: none;
|
|
20
|
-
|
|
21
|
-
input[type='radio'] {
|
|
22
|
-
position: absolute;
|
|
23
|
-
opacity: 0;
|
|
24
|
-
width: ${radioSize};
|
|
25
|
-
height: ${radioSize};
|
|
26
|
-
margin: 0;
|
|
27
|
-
cursor: ${props => props.disabled ? 'not-allowed' : 'pointer'};
|
|
28
|
-
z-index: 1;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
&::before {
|
|
32
|
-
content: '';
|
|
33
|
-
position: absolute;
|
|
34
|
-
border: 2px solid ${props => props.theme.getColor('gray-300')};
|
|
35
|
-
width: ${radioSize};
|
|
36
|
-
height: ${radioSize};
|
|
37
|
-
top: 0;
|
|
38
|
-
left: 0;
|
|
39
|
-
border-radius: 50%;
|
|
40
|
-
transition: all 200ms;
|
|
41
|
-
box-sizing: border-box;
|
|
42
|
-
pointer-events: none;
|
|
43
|
-
|
|
44
|
-
/* Apply checked styling based on $isChecked prop */
|
|
45
|
-
${props => props.$isChecked && css`
|
|
46
|
-
border-color: ${props.theme.getColor('emerald-500')};
|
|
47
|
-
`}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
&::after {
|
|
51
|
-
content: '';
|
|
52
|
-
position: absolute;
|
|
53
|
-
width: 8px;
|
|
54
|
-
height: 8px;
|
|
55
|
-
top: 5px;
|
|
56
|
-
left: 5px;
|
|
57
|
-
border-radius: 50%;
|
|
58
|
-
background: transparent;
|
|
59
|
-
transform: scale(0);
|
|
60
|
-
transition: all 200ms;
|
|
61
|
-
pointer-events: none;
|
|
62
|
-
|
|
63
|
-
/* Apply checked styling based on $isChecked prop */
|
|
64
|
-
${props => props.$isChecked && css`
|
|
65
|
-
background: ${props.theme.getColor('emerald-500')};
|
|
66
|
-
transform: scale(1);
|
|
67
|
-
`}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/* Fallback: :has() selector for browsers that support it */
|
|
71
|
-
&:has(input[type='radio']:checked) {
|
|
72
|
-
&::before {
|
|
73
|
-
border-color: ${props => props.theme.getColor('emerald-500')};
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
&::after {
|
|
77
|
-
background: ${props => props.theme.getColor('emerald-500')};
|
|
78
|
-
transform: scale(1);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
input[type='radio']:checked + ${RadioLabel} {
|
|
83
|
-
opacity: 1;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
${props => props.readOnly && css`
|
|
87
|
-
opacity: 0.5;
|
|
88
|
-
pointer-events: none;
|
|
89
|
-
user-select: text;
|
|
90
|
-
`}
|
|
91
|
-
|
|
92
|
-
${props => props.disabled && css`
|
|
93
|
-
opacity: 0.5;
|
|
94
|
-
cursor: not-allowed;
|
|
95
|
-
user-select: text;
|
|
96
|
-
|
|
97
|
-
input[type='radio'] {
|
|
98
|
-
cursor: not-allowed;
|
|
99
|
-
}
|
|
100
|
-
`}
|
|
101
|
-
`;
|
|
9
|
+
const RadioLabel = styled.div.withConfig({
|
|
10
|
+
shouldForwardProp
|
|
11
|
+
}).attrs(applyDefaultTheme).withConfig({
|
|
12
|
+
displayName: "Radiostyled__RadioLabel",
|
|
13
|
+
componentId: "sc-1ikso9o-0"
|
|
14
|
+
})(["padding-left:", ";font-weight:400;font-size:0.875rem;pointer-events:none;", ";"], math(`${radioSize} + 10px`), props => props.theme.themeProp('color', props.theme.getColor('gray-300'), props.theme.getColor('gray-600')));
|
|
15
|
+
const Radio = styled.label.withConfig({
|
|
16
|
+
shouldForwardProp
|
|
17
|
+
}).attrs(applyDefaultTheme).withConfig({
|
|
18
|
+
displayName: "Radiostyled__Radio",
|
|
19
|
+
componentId: "sc-1ikso9o-1"
|
|
20
|
+
})(["display:block;position:relative;cursor:", ";line-height:", ";user-select:none;input[type='radio']{position:absolute;opacity:0;width:", ";height:", ";margin:0;cursor:", ";z-index:1;}&::before{content:'';position:absolute;border:2px solid ", ";width:", ";height:", ";top:0;left:0;border-radius:50%;transition:all 200ms;box-sizing:border-box;pointer-events:none;", "}&::after{content:'';position:absolute;width:8px;height:8px;top:5px;left:5px;border-radius:50%;background:transparent;transform:scale(0);transition:all 200ms;pointer-events:none;", "}&:has(input[type='radio']:checked){&::before{border-color:", ";}&::after{background:", ";transform:scale(1);}}input[type='radio']:checked + ", "{opacity:1;}", " ", ""], props => props.disabled ? 'not-allowed' : 'pointer', radioSize, radioSize, radioSize, props => props.disabled ? 'not-allowed' : 'pointer', props => props.theme.getColor('gray-300'), radioSize, radioSize, props => props.$isChecked && css(["border-color:", ";"], props.theme.getColor('emerald-500')), props => props.$isChecked && css(["background:", ";transform:scale(1);"], props.theme.getColor('emerald-500')), props => props.theme.getColor('emerald-500'), props => props.theme.getColor('emerald-500'), RadioLabel, props => props.readOnly && css(["opacity:0.5;pointer-events:none;user-select:text;"]), props => props.disabled && css(["opacity:0.5;cursor:not-allowed;user-select:text;input[type='radio']{cursor:not-allowed;}"]));
|
|
102
21
|
|
|
103
22
|
export { Radio, RadioLabel };
|
|
104
23
|
//# sourceMappingURL=Radio.styled.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Radio.styled.js","sources":["../../../src/components/inputs/Radio/Radio.styled.
|
|
1
|
+
{"version":3,"file":"Radio.styled.js","sources":["../../../src/components/inputs/Radio/Radio.styled.ts"],"sourcesContent":["import { math } from 'polished';\nimport styled, { css } from 'styled-components';\nimport { applyDefaultTheme } from '../../../utils/defaultTheme';\n\n/*\n * Single-argument, and it stays that way — peer floor `styled-components: >=5.1.0`\n * and the two majors disagree on the second parameter. Rules in\n * `layout/SectionSeparator/SectionSeparator.styled.ts`, derivation in\n * `scripts/TS-MIGRATION-PLAYBOOK.md` §J.4. `prop` needs the annotation because\n * `withConfig` takes this by reference, so it gets no contextual typing.\n */\nconst shouldForwardProp = (prop: string): boolean => {\n return prop !== 'theme' && !prop.startsWith('$');\n};\n\nconst radioSize = '18px';\n\nexport const RadioLabel = styled.div\n .withConfig({\n shouldForwardProp\n })\n .attrs(applyDefaultTheme)`\n padding-left: ${math(`${radioSize} + 10px`)};\n font-weight: 400;\n font-size: 0.875rem;\n pointer-events: none;\n\n ${props =>\n props.theme.themeProp(\n 'color',\n props.theme.getColor('gray-300'),\n props.theme.getColor('gray-600')\n )};\n`;\n\n/*\n * `disabled` AND `readOnly` HAVE NO `$`, AND THAT IS A DEFECT — declared here, not\n * fixed here.\n *\n * `Radio.tsx` renders `<S.Radio htmlFor=… disabled={disabled} readOnly={readOnly}\n * $isChecked={checked} …>` on a `styled.label`, and neither `disabled` nor `readOnly`\n * is a member of `LabelHTMLAttributes` (they are input attributes), which is why both\n * reads below were TS2339. `shouldForwardProp` forwards every non-`$` prop, so\n * `disabled=\"\"` / `readonly=\"\"` are on the rendered `<label>` today and are in the\n * recorded render baseline. The fix is to rename both `$disabled` / `$readOnly` at\n * both ends; that removes two DOM attributes, so it belongs to C10 with its baseline\n * re-record and must not ride along in a type-only commit. §E.4 third case, §J.9.\n *\n * The `$isChecked` reads live inside `&::before` / `&::after` blocks, but those are\n * blocks of THIS template — not `css`…`` arguments to an interpolation — so the outer\n * `.attrs<P>()` does reach their `${props => …}` and they need no separate `css<P>`.\n * Contrast `CompactTextInput`'s `themeProp()` arguments, which do (§J.7).\n */\ninterface RadioStyleProps {\n /** `checked` — `PropTypes.bool`, passed through as the checked-state affordance. */\n $isChecked?: boolean;\n /** `disabled` — `PropTypes.bool`. Leaks to the DOM; see above. */\n disabled?: boolean;\n /** `readOnly` — `PropTypes.bool`. Leaks to the DOM; see above. */\n readOnly?: boolean;\n}\n\nexport const Radio = styled.label\n .withConfig({\n shouldForwardProp\n })\n .attrs<RadioStyleProps>(applyDefaultTheme)`\n display: block;\n position: relative;\n cursor: ${props => (props.disabled ? 'not-allowed' : 'pointer')};\n line-height: ${radioSize};\n user-select: none;\n\n input[type='radio'] {\n position: absolute;\n opacity: 0;\n width: ${radioSize};\n height: ${radioSize};\n margin: 0;\n cursor: ${props => (props.disabled ? 'not-allowed' : 'pointer')};\n z-index: 1;\n }\n\n &::before {\n content: '';\n position: absolute;\n border: 2px solid ${props => props.theme.getColor('gray-300')};\n width: ${radioSize};\n height: ${radioSize};\n top: 0;\n left: 0;\n border-radius: 50%;\n transition: all 200ms;\n box-sizing: border-box;\n pointer-events: none;\n\n /* Apply checked styling based on $isChecked prop */\n ${props =>\n props.$isChecked &&\n css`\n border-color: ${props.theme.getColor('emerald-500')};\n `}\n }\n\n &::after {\n content: '';\n position: absolute;\n width: 8px;\n height: 8px;\n top: 5px;\n left: 5px;\n border-radius: 50%;\n background: transparent;\n transform: scale(0);\n transition: all 200ms;\n pointer-events: none;\n\n /* Apply checked styling based on $isChecked prop */\n ${props =>\n props.$isChecked &&\n css`\n background: ${props.theme.getColor('emerald-500')};\n transform: scale(1);\n `}\n }\n\n /* Fallback: :has() selector for browsers that support it */\n &:has(input[type='radio']:checked) {\n &::before {\n border-color: ${props => props.theme.getColor('emerald-500')};\n }\n\n &::after {\n background: ${props => props.theme.getColor('emerald-500')};\n transform: scale(1);\n }\n }\n\n input[type='radio']:checked + ${RadioLabel} {\n opacity: 1;\n }\n\n ${props =>\n props.readOnly &&\n css`\n opacity: 0.5;\n pointer-events: none;\n user-select: text;\n `}\n\n ${props =>\n props.disabled &&\n css`\n opacity: 0.5;\n cursor: not-allowed;\n user-select: text;\n\n input[type='radio'] {\n cursor: not-allowed;\n }\n `}\n`;\n"],"names":["shouldForwardProp","prop","startsWith","radioSize","RadioLabel","styled","div","withConfig","attrs","applyDefaultTheme","displayName","componentId","math","props","theme","themeProp","getColor","Radio","label","disabled","$isChecked","css","readOnly"],"mappings":";;;;AAWA,MAAMA,iBAAiB,GAAIC,IAAY,IAAc;EACnD,OAAOA,IAAI,KAAK,OAAO,IAAI,CAACA,IAAI,CAACC,UAAU,CAAC,GAAG,CAAC;AAClD,CAAC;AAED,MAAMC,SAAS,GAAG,MAAM;AAEjB,MAAMC,UAAU,GAAGC,MAAM,CAACC,GAAG,CACjCC,UAAU,CAAC;AACVP,EAAAA;AACF,CAAC,CAAC,CACDQ,KAAK,CAACC,iBAAiB,CAAC,CAAAF,UAAA,CAAA;EAAAG,WAAA,EAAA,yBAAA;EAAAC,WAAA,EAAA;AAAA,CAAA,CAAA,CAAA,CAAA,eAAA,EAAA,0DAAA,EAAA,GAAA,CAAA,EACTC,IAAI,CAAC,CAAA,EAAGT,SAAS,SAAS,CAAC,EAKzCU,KAAK,IACLA,KAAK,CAACC,KAAK,CAACC,SAAS,CACnB,OAAO,EACPF,KAAK,CAACC,KAAK,CAACE,QAAQ,CAAC,UAAU,CAAC,EAChCH,KAAK,CAACC,KAAK,CAACE,QAAQ,CAAC,UAAU,CACjC,CAAC;AA8BE,MAAMC,KAAK,GAAGZ,MAAM,CAACa,KAAK,CAC9BX,UAAU,CAAC;AACVP,EAA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CAQF;;;;"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import React__default, { useState } from 'react';
|
|
2
2
|
import { nanoid } from 'nanoid';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
3
|
import { Switch as Switch$1, SwitchLabel, SwitchIndicator, SwitchIndicatorButton, SwitchIndicatorLabelText, Description } from './Switch.styled.js';
|
|
4
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
5
5
|
|
|
6
6
|
const Switch = React__default.forwardRef(function Switch({
|
|
7
7
|
name,
|
|
8
8
|
checked,
|
|
9
9
|
defaultChecked,
|
|
10
10
|
label,
|
|
11
|
-
disabled,
|
|
12
|
-
readOnly,
|
|
11
|
+
disabled = false,
|
|
12
|
+
readOnly = false,
|
|
13
13
|
description,
|
|
14
14
|
spaciousDescription,
|
|
15
15
|
className,
|
|
@@ -18,47 +18,35 @@ const Switch = React__default.forwardRef(function Switch({
|
|
|
18
18
|
onBlur
|
|
19
19
|
}, forwardedRef) {
|
|
20
20
|
const [uniqueId] = useState(nanoid());
|
|
21
|
-
return
|
|
21
|
+
return jsxs(Switch$1, {
|
|
22
22
|
disabled: disabled,
|
|
23
23
|
readOnly: readOnly,
|
|
24
24
|
className: className,
|
|
25
|
-
style: style
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
25
|
+
style: style,
|
|
26
|
+
children: [jsxs(SwitchLabel, {
|
|
27
|
+
htmlFor: uniqueId,
|
|
28
|
+
children: [jsx("input", {
|
|
29
|
+
ref: forwardedRef,
|
|
30
|
+
checked: checked,
|
|
31
|
+
defaultChecked: defaultChecked,
|
|
32
|
+
disabled: disabled,
|
|
33
|
+
readOnly: readOnly,
|
|
34
|
+
id: uniqueId,
|
|
35
|
+
name: name,
|
|
36
|
+
type: "checkbox",
|
|
37
|
+
onBlur: onBlur,
|
|
38
|
+
onChange: onChange
|
|
39
|
+
}), jsx(SwitchIndicator, {
|
|
40
|
+
children: jsx(SwitchIndicatorButton, {})
|
|
41
|
+
}), typeof label === 'string' && label.length > 0 && jsx(SwitchIndicatorLabelText, {
|
|
42
|
+
children: label
|
|
43
|
+
})]
|
|
44
|
+
}), typeof description === 'string' && description.length > 0 && jsx(Description, {
|
|
45
|
+
$spaciousdescription: spaciousDescription,
|
|
46
|
+
children: description
|
|
47
|
+
})]
|
|
48
|
+
});
|
|
42
49
|
});
|
|
43
|
-
Switch.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
44
|
-
children: PropTypes.any,
|
|
45
|
-
name: PropTypes.string.isRequired,
|
|
46
|
-
checked: PropTypes.bool,
|
|
47
|
-
defaultChecked: PropTypes.bool,
|
|
48
|
-
label: PropTypes.string,
|
|
49
|
-
disabled: PropTypes.bool,
|
|
50
|
-
readOnly: PropTypes.bool,
|
|
51
|
-
description: PropTypes.string,
|
|
52
|
-
spaciousDescription: PropTypes.bool,
|
|
53
|
-
className: PropTypes.string,
|
|
54
|
-
style: PropTypes.object,
|
|
55
|
-
onChange: PropTypes.func,
|
|
56
|
-
onBlur: PropTypes.func
|
|
57
|
-
} : {};
|
|
58
|
-
Switch.defaultProps = {
|
|
59
|
-
disabled: false,
|
|
60
|
-
readOnly: false
|
|
61
|
-
};
|
|
62
50
|
|
|
63
51
|
export { Switch as default };
|
|
64
52
|
//# sourceMappingURL=Switch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Switch.js","sources":["../../../src/components/inputs/Switch/Switch.
|
|
1
|
+
{"version":3,"file":"Switch.js","sources":["../../../src/components/inputs/Switch/Switch.tsx"],"sourcesContent":["import React, { useState } from 'react';\n\nimport { nanoid } from 'nanoid';\n\nimport * as S from './Switch.styled';\n\ntype Props = {\n children?: any;\n name: string;\n /**\n * Whether the switch is toggled on or off\n */\n checked?: boolean;\n /**\n * Whether the switch is toggled on by default\n */\n defaultChecked?: boolean;\n /**\n * Text displayed next to the switch\n */\n label?: string;\n /**\n * Whether the switch is toggled on\n */\n disabled?: boolean;\n /**\n * Whether the switch is displayed as read-only\n */\n readOnly?: boolean;\n /**\n * Text displayed underneath the switch\n */\n description?: string;\n /**\n * Whether there should be extra `margin` added between the switch and the description\n */\n spaciousDescription?: boolean;\n /**\n * Add extra classes to the HTML element\n */\n className?: string;\n /**\n * Custom CSS styling\n */\n style?: any;\n /**\n * Optional callback function for the `onChange` event\n */\n onChange?: (...args: any[]) => any;\n /**\n * Optional callback function for the `onBlur` event\n */\n onBlur?: (...args: any[]) => any;\n};\n\n/**\n * The Switch allows the user to toggle an option.\n *\n * ### Import\n *\n * ``` js\n * import { Switch } from '@ntbjs/react-components/inputs'\n * // or\n * import Switch from '@ntbjs/react-components/inputs/Switch'\n * ```\n */\nconst Switch = React.forwardRef<any, Props>(function Switch(\n {\n name,\n checked,\n defaultChecked,\n label,\n disabled = false,\n readOnly = false,\n description,\n spaciousDescription,\n className,\n style,\n onChange,\n onBlur\n },\n forwardedRef\n) {\n const [uniqueId] = useState(nanoid());\n\n return (\n <S.Switch disabled={disabled} readOnly={readOnly} className={className} style={style}>\n <S.SwitchLabel htmlFor={uniqueId}>\n <input\n ref={forwardedRef}\n checked={checked}\n defaultChecked={defaultChecked}\n disabled={disabled}\n readOnly={readOnly}\n id={uniqueId}\n name={name}\n type=\"checkbox\"\n onBlur={onBlur}\n onChange={onChange}\n />\n <S.SwitchIndicator>\n <S.SwitchIndicatorButton />\n </S.SwitchIndicator>\n {typeof label === 'string' && label.length > 0 && (\n <S.SwitchIndicatorLabelText>{label}</S.SwitchIndicatorLabelText>\n )}\n </S.SwitchLabel>\n {typeof description === 'string' && description.length > 0 && (\n <S.Description $spaciousdescription={spaciousDescription}>{description}</S.Description>\n )}\n </S.Switch>\n );\n});\n\nexport default Switch;\n"],"names":["Switch","React","forwardRef","name","checked","defaultChecked","label","disabled","readOnly","description","spaciousDescription","className","style","onChange","onBlur","forwardedRef","uniqueId","useState","nanoid","_jsxs","S","children","htmlFor","_jsx","ref","id","type","length","$spaciousdescription"],"mappings":";;;;;AAkEA,MAAMA,MAAM,GAAGC,cAAK,CAACC,UAAU,CAAa,SAASF,MAAMA,CACzD;EACEG,IAAI;EACJC,OAAO;EACPC,cAAc;EACdC,KAAK;AACLC,EAAAA,QAAQ,GAAG,KAAK;AAChBC,EAAAA,QAAQ,GAAG,KAAK;EAChBC,WAAW;EACXC,mBAAmB;EACnBC,SAAS;EACTC,KAAK;EACLC,QAAQ;AACRC,EAAAA;AACF,CAAC,EACDC,YAAY,EACZ;EACA,MAAM,CAACC,QAAQ,CAAC,GAAGC,QAAQ,CAACC,MAAM,EAAE,CAAC;AAErC,EAAA,OACEC,IAAA,CAACC,QAAQ,EAAA;AAACb,IAAAA,QAAQ,EAAEA,QAAS;AAACC,IAAAA,QAAQ,EAAEA,QAAS;AAACG,IAAAA,SAAS,EAAEA,SAAU;AAACC,IAAAA,KAAK,EAAEA,KAAM;AAAAS,IAAAA,QAAA,EAAA,CACnFF,IAAA,CAACC,WAAa,EAAA;AAACE,MAAAA,OAAO,EAAEN,QAAS;AAAAK,MAAAA,QAAA,GAC/BE,GAAA,CAAA,OAAA,EAAA;AACEC,QAAAA,GAAG,EAAET,YAAa;AAClBX,QAAAA,OAAO,EAAEA,OAAQ;AACjBC,QAAAA,cAAc,EAAEA,cAAe;AAC/BE,QAAAA,QAAQ,EAAEA,QAAS;AACnBC,QAAAA,QAAQ,EAAEA,QAAS;AACnBiB,QAAAA,EAAE,EAAET,QAAS;AACbb,QAAAA,IAAI,EAAEA,IAAK;AACXuB,QAAAA,IAAI,EAAC,UAAU;AACfZ,QAAAA,MAAM,EAAEA,MAAO;AACfD,QAAAA,QAAQ,EAAEA;AAAS,OACpB,CAAC,EACFU,GAAA,CAACH,eAAiB,EAAA;AAAAC,QAAAA,QAAA,EAChBE,GAAA,CAACH,qBAAuB,EAAA,EAAE;AAAC,OACV,CAAC,EACnB,OAAOd,KAAK,KAAK,QAAQ,IAAIA,KAAK,CAACqB,MAAM,GAAG,CAAC,IAC5CJ,GAAA,CAACH,wBAA0B,EAAA;AAAAC,QAAAA,QAAA,EAAEf;AAAK,OAA6B,CAChE;AAAA,KACY,CAAC,EACf,OAAOG,WAAW,KAAK,QAAQ,IAAIA,WAAW,CAACkB,MAAM,GAAG,CAAC,IACxDJ,GAAA,CAACH,WAAa,EAAA;AAACQ,MAAAA,oBAAoB,EAAElB,mBAAoB;AAAAW,MAAAA,QAAA,EAAEZ;AAAW,KAAgB,CACvF;AAAA,GACO,CAAC;AAEf,CAAC;;;;"}
|
|
@@ -8,110 +8,40 @@ const shouldForwardProp = prop => {
|
|
|
8
8
|
};
|
|
9
9
|
const Switch = styled.div.withConfig({
|
|
10
10
|
shouldForwardProp
|
|
11
|
-
}).attrs(applyDefaultTheme)
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
display: flex;
|
|
17
|
-
flex-direction: column;
|
|
18
|
-
|
|
19
|
-
${props => props.readOnly && css`
|
|
20
|
-
opacity: 0.5;
|
|
21
|
-
> * {
|
|
22
|
-
pointer-events: none;
|
|
23
|
-
user-select: text;
|
|
24
|
-
}
|
|
25
|
-
`}
|
|
26
|
-
|
|
27
|
-
${props => props.disabled && css`
|
|
28
|
-
opacity: 0.5;
|
|
29
|
-
cursor: not-allowed;
|
|
30
|
-
* {
|
|
31
|
-
pointer-events: none;
|
|
32
|
-
user-select: text;
|
|
33
|
-
}
|
|
34
|
-
`}
|
|
35
|
-
`;
|
|
11
|
+
}).attrs(applyDefaultTheme).withConfig({
|
|
12
|
+
displayName: "Switchstyled__Switch",
|
|
13
|
+
componentId: "sc-1aq2wh1-0"
|
|
14
|
+
})(["*{box-sizing:border-box;}display:flex;flex-direction:column;", " ", ""], props => props.readOnly && css(["opacity:0.5;> *{pointer-events:none;user-select:text;}"]), props => props.disabled && css(["opacity:0.5;cursor:not-allowed;*{pointer-events:none;user-select:text;}"]));
|
|
36
15
|
const SwitchIndicator = styled.div.withConfig({
|
|
37
16
|
shouldForwardProp
|
|
38
|
-
}).attrs(applyDefaultTheme)
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
height: ${math(`${switchButtonSize} + 2px`)};
|
|
43
|
-
width: 32px;
|
|
44
|
-
border-radius: 20px;
|
|
45
|
-
border: 1px solid;
|
|
46
|
-
${props => props.theme.themeProp('border-color', props.theme.getColor('gray-500'), props.theme.getColor('gray-300'))}
|
|
47
|
-
transition: background 200ms;
|
|
48
|
-
`;
|
|
17
|
+
}).attrs(applyDefaultTheme).withConfig({
|
|
18
|
+
displayName: "Switchstyled__SwitchIndicator",
|
|
19
|
+
componentId: "sc-1aq2wh1-1"
|
|
20
|
+
})(["display:inline-block;position:relative;", " height:", ";width:32px;border-radius:20px;border:1px solid;", " transition:background 200ms;"], props => props.theme.themeProp('background', props.theme.getColor('gray-900'), props.theme.getColor('gray-200')), math(`${switchButtonSize} + 2px`), props => props.theme.themeProp('border-color', props.theme.getColor('gray-500'), props.theme.getColor('gray-300')));
|
|
49
21
|
const SwitchIndicatorButton = styled.div.withConfig({
|
|
50
22
|
shouldForwardProp
|
|
51
|
-
}).attrs(applyDefaultTheme)
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
width: ${switchButtonSize};
|
|
56
|
-
border-radius: 50%;
|
|
57
|
-
box-shadow: ${props => props.theme.getColor('gray-500')} 0 0px 2px 0px;
|
|
58
|
-
transition: left 200ms;
|
|
59
|
-
`;
|
|
23
|
+
}).attrs(applyDefaultTheme).withConfig({
|
|
24
|
+
displayName: "Switchstyled__SwitchIndicatorButton",
|
|
25
|
+
componentId: "sc-1aq2wh1-2"
|
|
26
|
+
})(["position:absolute;", " height:", ";width:", ";border-radius:50%;box-shadow:", " 0 0px 2px 0px;transition:left 200ms;"], props => props.theme.themeProp('background', props.theme.getColor('gray-200'), props.theme.getColor('white')), switchButtonSize, switchButtonSize, props => props.theme.getColor('gray-500'));
|
|
60
27
|
const SwitchIndicatorLabelText = styled.div.withConfig({
|
|
61
28
|
shouldForwardProp
|
|
62
|
-
}).attrs(applyDefaultTheme)
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
line-height: 18px;
|
|
67
|
-
|
|
68
|
-
${props => props.theme.themeProp('color', props.theme.getColor('gray-300'), props.theme.getColor('gray-600'))};
|
|
69
|
-
`;
|
|
29
|
+
}).attrs(applyDefaultTheme).withConfig({
|
|
30
|
+
displayName: "Switchstyled__SwitchIndicatorLabelText",
|
|
31
|
+
componentId: "sc-1aq2wh1-3"
|
|
32
|
+
})(["padding-left:10px;font-weight:400;font-size:0.875rem;line-height:18px;", ";"], props => props.theme.themeProp('color', props.theme.getColor('gray-300'), props.theme.getColor('gray-600')));
|
|
70
33
|
const SwitchLabel = styled.label.withConfig({
|
|
71
34
|
shouldForwardProp
|
|
72
|
-
}).attrs(applyDefaultTheme)
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
input[type='checkbox'] {
|
|
78
|
-
position: absolute;
|
|
79
|
-
opacity: 0;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
&:has(input[type='checkbox']:not(:checked)) {
|
|
83
|
-
${SwitchIndicatorButton} {
|
|
84
|
-
left: 0;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
&:has(input[type='checkbox']:checked) {
|
|
89
|
-
${SwitchIndicatorButton} {
|
|
90
|
-
left: calc(100% - ${switchButtonSize});
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
${SwitchIndicator} {
|
|
94
|
-
background: ${props => props.theme.getColor('emerald-500')};
|
|
95
|
-
|
|
96
|
-
${props => props.theme.themeProp('border-color', props.theme.getColor('gray-400'), props.theme.getColor('gray-300'), 1)}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
&:has(input[type='checkbox']:focus-visible) {
|
|
101
|
-
${SwitchIndicatorButton} {
|
|
102
|
-
${props => props.theme.themeProp('outline', `8px solid ${rgba(props.theme.getColor('emerald-500'), 0.5)}`, `8px solid ${rgba(props.theme.getColor('emerald-500'), 0.3)}`, 1)}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
`;
|
|
35
|
+
}).attrs(applyDefaultTheme).withConfig({
|
|
36
|
+
displayName: "Switchstyled__SwitchLabel",
|
|
37
|
+
componentId: "sc-1aq2wh1-4"
|
|
38
|
+
})(["display:inline-flex;margin-right:auto;cursor:pointer;input[type='checkbox']{position:absolute;opacity:0;}&:has(input[type='checkbox']:not(:checked)){", "{left:0;}}&:has(input[type='checkbox']:checked){", "{left:calc(100% - ", ");}", "{background:", ";", "}}&:has(input[type='checkbox']:focus-visible){", "{", "}}"], SwitchIndicatorButton, SwitchIndicatorButton, switchButtonSize, SwitchIndicator, props => props.theme.getColor('emerald-500'), props => props.theme.themeProp('border-color', props.theme.getColor('gray-400'), props.theme.getColor('gray-300'), 1), SwitchIndicatorButton, props => props.theme.themeProp('outline', `8px solid ${rgba(props.theme.getColor('emerald-500'), 0.5)}`, `8px solid ${rgba(props.theme.getColor('emerald-500'), 0.3)}`, 1));
|
|
106
39
|
const Description = styled.div.withConfig({
|
|
107
40
|
shouldForwardProp
|
|
108
|
-
}).attrs(applyDefaultTheme)
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
${props => props.theme.themeProp('color', props.theme.getColor('gray-400'), props.theme.getColor('gray-500'))};
|
|
114
|
-
`;
|
|
41
|
+
}).attrs(applyDefaultTheme).withConfig({
|
|
42
|
+
displayName: "Switchstyled__Description",
|
|
43
|
+
componentId: "sc-1aq2wh1-5"
|
|
44
|
+
})(["margin:", " 0 0 0;font-size:0.75rem;line-height:1.333;", ";"], props => props.$spaciousdescription ? '16px' : '6px', props => props.theme.themeProp('color', props.theme.getColor('gray-400'), props.theme.getColor('gray-500')));
|
|
115
45
|
|
|
116
46
|
export { Description, Switch, SwitchIndicator, SwitchIndicatorButton, SwitchIndicatorLabelText, SwitchLabel };
|
|
117
47
|
//# sourceMappingURL=Switch.styled.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Switch.styled.js","sources":["../../../src/components/inputs/Switch/Switch.styled.
|
|
1
|
+
{"version":3,"file":"Switch.styled.js","sources":["../../../src/components/inputs/Switch/Switch.styled.ts"],"sourcesContent":["import { math, rgba } from 'polished';\nimport styled, { css } from 'styled-components';\nimport { applyDefaultTheme } from '../../../utils/defaultTheme';\n\nconst switchButtonSize = '16px';\n\n/*\n * Single-argument, and it stays that way — peer floor `styled-components: >=5.1.0`\n * and the two majors disagree on the second parameter. See\n * `layout/SectionSeparator/SectionSeparator.styled.ts` for the rules and\n * `scripts/TS-MIGRATION-PLAYBOOK.md` §J.4. `prop` needs the annotation because\n * `withConfig` takes this by reference, so it gets no contextual typing.\n */\nconst shouldForwardProp = (prop: string): boolean => {\n return prop !== 'theme' && !prop.startsWith('$');\n};\n\n/*\n * `disabled` AND `readOnly` HAVE NO `$`, AND THAT IS A DEFECT — declared here, not\n * fixed here.\n *\n * `Switch.tsx` renders `<S.Switch disabled={disabled} readOnly={readOnly} …>` on a\n * `styled.div`, and neither is a member of `HTMLAttributes<HTMLDivElement>` (they are\n * input/label attributes), which is why both reads below are TS2339. `shouldForwardProp`\n * forwards every non-`$` prop, so `disabled=\"\"` / `readonly=\"\"` are on the rendered\n * `<div>` today — non-standard attributes on a `<div>` — and they are in the recorded\n * render baseline.\n *\n * The fix is to rename both `$disabled` / `$readOnly` at both ends. That REMOVES two\n * attributes from the rendered HTML, so it belongs to C10 with its baseline re-record\n * and must not ride along in a type-only commit. §E.4, third case.\n */\ninterface SwitchStyleProps {\n /** `disabled` — dims and blocks pointer events. Leaks to the DOM; see above. */\n disabled?: boolean;\n /** `readOnly` — dims and blocks pointer events. Leaks to the DOM; see above. */\n readOnly?: boolean;\n}\n\nexport const Switch = styled.div\n .withConfig({\n shouldForwardProp\n })\n .attrs<SwitchStyleProps>(applyDefaultTheme)`\n * {\n box-sizing: border-box;\n }\n\n display: flex;\n flex-direction: column;\n\n ${props =>\n props.readOnly &&\n css`\n opacity: 0.5;\n > * {\n pointer-events: none;\n user-select: text;\n }\n `}\n\n ${props =>\n props.disabled &&\n css`\n opacity: 0.5;\n cursor: not-allowed;\n * {\n pointer-events: none;\n user-select: text;\n }\n `}\n`;\n\nexport const SwitchIndicator = styled.div\n .withConfig({\n shouldForwardProp\n })\n .attrs(applyDefaultTheme)`\n display: inline-block;\n position: relative;\n ${props =>\n props.theme.themeProp(\n 'background',\n props.theme.getColor('gray-900'),\n props.theme.getColor('gray-200')\n )}\n height: ${math(`${switchButtonSize} + 2px`)};\n width: 32px;\n border-radius: 20px;\n border: 1px solid;\n ${props =>\n props.theme.themeProp(\n 'border-color',\n props.theme.getColor('gray-500'),\n props.theme.getColor('gray-300')\n )}\n transition: background 200ms;\n`;\n\nexport const SwitchIndicatorButton = styled.div\n .withConfig({\n shouldForwardProp\n })\n .attrs(applyDefaultTheme)`\n position: absolute;\n ${props =>\n props.theme.themeProp(\n 'background',\n props.theme.getColor('gray-200'),\n props.theme.getColor('white')\n )}\n height: ${switchButtonSize};\n width: ${switchButtonSize};\n border-radius: 50%;\n box-shadow: ${props => props.theme.getColor('gray-500')} 0 0px 2px 0px;\n transition: left 200ms;\n`;\n\nexport const SwitchIndicatorLabelText = styled.div\n .withConfig({\n shouldForwardProp\n })\n .attrs(applyDefaultTheme)`\n padding-left: 10px;\n font-weight: 400;\n font-size: 0.875rem;\n line-height: 18px;\n\n ${props =>\n props.theme.themeProp(\n 'color',\n props.theme.getColor('gray-300'),\n props.theme.getColor('gray-600')\n )};\n`;\n\nexport const SwitchLabel = styled.label\n .withConfig({\n shouldForwardProp\n })\n .attrs(applyDefaultTheme)`\n display: inline-flex;\n margin-right: auto;\n cursor: pointer;\n\n input[type='checkbox'] {\n position: absolute;\n opacity: 0;\n }\n\n &:has(input[type='checkbox']:not(:checked)) {\n ${SwitchIndicatorButton} {\n left: 0;\n }\n }\n\n &:has(input[type='checkbox']:checked) {\n ${SwitchIndicatorButton} {\n left: calc(100% - ${switchButtonSize});\n }\n\n ${SwitchIndicator} {\n background: ${props => props.theme.getColor('emerald-500')};\n\n ${props =>\n props.theme.themeProp(\n 'border-color',\n props.theme.getColor('gray-400'),\n props.theme.getColor('gray-300'),\n 1\n )}\n }\n }\n\n &:has(input[type='checkbox']:focus-visible) {\n ${SwitchIndicatorButton} {\n ${props =>\n props.theme.themeProp(\n 'outline',\n `8px solid ${rgba(props.theme.getColor('emerald-500'), 0.5)}`,\n `8px solid ${rgba(props.theme.getColor('emerald-500'), 0.3)}`,\n 1\n )}\n }\n }\n`;\n\nexport const Description = styled.div\n .withConfig({\n shouldForwardProp\n })\n .attrs<{\n /**\n * `spaciousDescription` — `PropTypes.bool`. Lower-case `$spaciousdescription` by\n * existing convention at both ends; renaming it would be a two-file change for no\n * type benefit.\n */\n $spaciousdescription?: boolean;\n }>(applyDefaultTheme)`\n margin: ${props => (props.$spaciousdescription ? '16px' : '6px')} 0 0 0;\n font-size: 0.75rem;\n line-height: 1.333;\n\n ${props =>\n props.theme.themeProp(\n 'color',\n props.theme.getColor('gray-400'),\n props.theme.getColor('gray-500')\n )};\n`;\n"],"names":["switchButtonSize","shouldForwardProp","prop","startsWith","Switch","styled","div","withConfig","attrs","applyDefaultTheme","displayName","componentId","props","readOnly","css","disabled","SwitchIndicator","theme","themeProp","getColor","math","SwitchIndicatorButton","SwitchIndicatorLabelText","SwitchLabel","label","rgba","Description","$spaciousdescription"],"mappings":";;;;AAIA,MAAMA,gBAAgB,GAAG,MAAM;AAS/B,MAAMC,iBAAiB,GAAIC,IAAY,IAAc;EACnD,OAAOA,IAAI,KAAK,OAAO,IAAI,CAACA,IAAI,CAACC,UAAU,CAAC,GAAG,CAAC;AAClD,CAAC;AAw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