@pega/cosmos-react-core 2.0.0-dev.18.0 → 2.0.0-dev.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/Actions/Actions.js +1 -1
- package/lib/components/Actions/Actions.js.map +1 -1
- package/lib/components/AppShell/AppHeader.js +1 -1
- package/lib/components/AppShell/AppHeader.js.map +1 -1
- package/lib/components/AppShell/AppShell.js +13 -13
- package/lib/components/AppShell/AppShell.js.map +1 -1
- package/lib/components/AppShell/AppShellList.js +6 -6
- package/lib/components/AppShell/AppShellList.js.map +1 -1
- package/lib/components/AppShell/Drawer.js +2 -2
- package/lib/components/AppShell/Drawer.js.map +1 -1
- package/lib/components/AppShell/Operator.js +3 -3
- package/lib/components/AppShell/Operator.js.map +1 -1
- package/lib/components/AppShell/SkipNavigation.js +2 -2
- package/lib/components/AppShell/SkipNavigation.js.map +1 -1
- package/lib/components/Avatar/Avatar.js +1 -1
- package/lib/components/Avatar/Avatar.js.map +1 -1
- package/lib/components/Backdrop/Backdrop.js +1 -1
- package/lib/components/Backdrop/Backdrop.js.map +1 -1
- package/lib/components/Badges/Alert.js +1 -1
- package/lib/components/Badges/Alert.js.map +1 -1
- package/lib/components/Badges/Count.js +1 -1
- package/lib/components/Badges/Count.js.map +1 -1
- package/lib/components/Badges/Selection.js +1 -1
- package/lib/components/Badges/Selection.js.map +1 -1
- package/lib/components/Badges/Status.js +1 -1
- package/lib/components/Badges/Status.js.map +1 -1
- package/lib/components/Badges/Tag.js +1 -1
- package/lib/components/Badges/Tag.js.map +1 -1
- package/lib/components/Banner/Banner.js +3 -3
- package/lib/components/Banner/Banner.js.map +1 -1
- package/lib/components/Boolean/BooleanDisplay.js +1 -1
- package/lib/components/Boolean/BooleanDisplay.js.map +1 -1
- package/lib/components/Breadcrumbs/Breadcrumbs.js +5 -5
- package/lib/components/Breadcrumbs/Breadcrumbs.js.map +1 -1
- package/lib/components/Button/BareButton.js +2 -2
- package/lib/components/Button/BareButton.js.map +1 -1
- package/lib/components/Button/BareRoleButton.d.ts +12 -0
- package/lib/components/Button/BareRoleButton.d.ts.map +1 -0
- package/lib/components/Button/BareRoleButton.js +20 -0
- package/lib/components/Button/BareRoleButton.js.map +1 -0
- package/lib/components/Button/Button.js +2 -2
- package/lib/components/Button/Button.js.map +1 -1
- package/lib/components/Card/Card.js +1 -1
- package/lib/components/Card/Card.js.map +1 -1
- package/lib/components/Card/CardContent.js +1 -1
- package/lib/components/Card/CardContent.js.map +1 -1
- package/lib/components/Card/CardFooter.js +2 -2
- package/lib/components/Card/CardFooter.js.map +1 -1
- package/lib/components/Card/CardHeader.js +1 -1
- package/lib/components/Card/CardHeader.js.map +1 -1
- package/lib/components/Card/CardMedia.js +1 -1
- package/lib/components/Card/CardMedia.js.map +1 -1
- package/lib/components/Card/CollapsibleCard.js +1 -1
- package/lib/components/Card/CollapsibleCard.js.map +1 -1
- package/lib/components/Card/SelectableCard.js +1 -1
- package/lib/components/Card/SelectableCard.js.map +1 -1
- package/lib/components/Checkbox/Checkbox.js +1 -1
- package/lib/components/Checkbox/Checkbox.js.map +1 -1
- package/lib/components/ColorPicker/ColorPicker.js +3 -3
- package/lib/components/ColorPicker/ColorPicker.js.map +1 -1
- package/lib/components/ComboBox/ComboBox.js +12 -12
- package/lib/components/ComboBox/ComboBox.js.map +1 -1
- package/lib/components/ComboBox/ComboBoxInput.js +4 -4
- package/lib/components/ComboBox/ComboBoxInput.js.map +1 -1
- package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.d.ts.map +1 -1
- package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.js +14 -10
- package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.js.map +1 -1
- package/lib/components/ComboBox/SingleSelectInput/SingleSelectInput.d.ts.map +1 -1
- package/lib/components/ComboBox/SingleSelectInput/SingleSelectInput.js +15 -11
- package/lib/components/ComboBox/SingleSelectInput/SingleSelectInput.js.map +1 -1
- package/lib/components/Configuration/Configuration.js +5 -5
- package/lib/components/Configuration/Configuration.js.map +1 -1
- package/lib/components/Currency/CurrencyDisplay.js +1 -1
- package/lib/components/Currency/CurrencyDisplay.js.map +1 -1
- package/lib/components/Currency/CurrencyInput.js +12 -12
- package/lib/components/Currency/CurrencyInput.js.map +1 -1
- package/lib/components/DateTime/DateTimeDisplay.d.ts.map +1 -1
- package/lib/components/DateTime/DateTimeDisplay.js +2 -1
- package/lib/components/DateTime/DateTimeDisplay.js.map +1 -1
- package/lib/components/DateTime/DurationDisplay.d.ts.map +1 -1
- package/lib/components/DateTime/DurationDisplay.js +11 -6
- package/lib/components/DateTime/DurationDisplay.js.map +1 -1
- package/lib/components/DateTime/Input/DateInput.js +6 -6
- package/lib/components/DateTime/Input/DateInput.js.map +1 -1
- package/lib/components/DateTime/Input/DateRangeInput.js +1 -1
- package/lib/components/DateTime/Input/DateRangeInput.js.map +1 -1
- package/lib/components/DateTime/Input/DateTime.styles.d.ts.map +1 -1
- package/lib/components/DateTime/Input/DateTime.styles.js +13 -2
- package/lib/components/DateTime/Input/DateTime.styles.js.map +1 -1
- package/lib/components/DateTime/Input/DateTimeInput.js +9 -9
- package/lib/components/DateTime/Input/DateTimeInput.js.map +1 -1
- package/lib/components/DateTime/Input/DayOfWeekInput.js +2 -2
- package/lib/components/DateTime/Input/DayOfWeekInput.js.map +1 -1
- package/lib/components/DateTime/Input/Duration/DurationInput.js +2 -2
- package/lib/components/DateTime/Input/Duration/DurationInput.js.map +1 -1
- package/lib/components/DateTime/Input/Duration/NumberUnit.js +2 -2
- package/lib/components/DateTime/Input/Duration/NumberUnit.js.map +1 -1
- package/lib/components/DateTime/Input/Duration/Time.js +2 -2
- package/lib/components/DateTime/Input/Duration/Time.js.map +1 -1
- package/lib/components/DateTime/Input/MonthInput.js +6 -6
- package/lib/components/DateTime/Input/MonthInput.js.map +1 -1
- package/lib/components/DateTime/Input/PartInput.js +1 -1
- package/lib/components/DateTime/Input/PartInput.js.map +1 -1
- package/lib/components/DateTime/Input/QuarterInput.js +6 -6
- package/lib/components/DateTime/Input/QuarterInput.js.map +1 -1
- package/lib/components/DateTime/Input/TimeInput.js +9 -9
- package/lib/components/DateTime/Input/TimeInput.js.map +1 -1
- package/lib/components/DateTime/Input/WeekInput.js +6 -6
- package/lib/components/DateTime/Input/WeekInput.js.map +1 -1
- package/lib/components/DateTime/Picker/Calendar.js +11 -11
- package/lib/components/DateTime/Picker/Calendar.js.map +1 -1
- package/lib/components/DateTime/Picker/DatePicker.d.ts.map +1 -1
- package/lib/components/DateTime/Picker/DatePicker.js +7 -9
- package/lib/components/DateTime/Picker/DatePicker.js.map +1 -1
- package/lib/components/DateTime/Picker/DateRangePicker.d.ts.map +1 -1
- package/lib/components/DateTime/Picker/DateRangePicker.js +7 -9
- package/lib/components/DateTime/Picker/DateRangePicker.js.map +1 -1
- package/lib/components/DateTime/Picker/TimePicker.js +4 -4
- package/lib/components/DateTime/Picker/TimePicker.js.map +1 -1
- package/lib/components/DateTime/Picker/Weeks.js +4 -4
- package/lib/components/DateTime/Picker/Weeks.js.map +1 -1
- package/lib/components/DateTime/Picker/utils.d.ts +1 -0
- package/lib/components/DateTime/Picker/utils.d.ts.map +1 -1
- package/lib/components/DateTime/Picker/utils.js +3 -0
- package/lib/components/DateTime/Picker/utils.js.map +1 -1
- package/lib/components/Drawer/Drawer.js +1 -1
- package/lib/components/Drawer/Drawer.js.map +1 -1
- package/lib/components/Email/EmailDisplay.js +2 -2
- package/lib/components/Email/EmailDisplay.js.map +1 -1
- package/lib/components/EmojiPicker/EmojiDisplay.js +1 -1
- package/lib/components/EmojiPicker/EmojiDisplay.js.map +1 -1
- package/lib/components/EmojiPicker/EmojiPicker.js +1 -1
- package/lib/components/EmojiPicker/EmojiPicker.js.map +1 -1
- package/lib/components/EmptyState/EmptyState.js +1 -1
- package/lib/components/EmptyState/EmptyState.js.map +1 -1
- package/lib/components/ErrorState/ErrorState.js +1 -1
- package/lib/components/ErrorState/ErrorState.js.map +1 -1
- package/lib/components/ExpandCollapse/ExpandCollapse.js +1 -1
- package/lib/components/ExpandCollapse/ExpandCollapse.js.map +1 -1
- package/lib/components/FieldGroup/FieldGroup.js +3 -3
- package/lib/components/FieldGroup/FieldGroup.js.map +1 -1
- package/lib/components/FieldGroup/FieldGroupList.js +4 -4
- package/lib/components/FieldGroup/FieldGroupList.js.map +1 -1
- package/lib/components/FieldValueList/FieldValueList.js +5 -5
- package/lib/components/FieldValueList/FieldValueList.js.map +1 -1
- package/lib/components/File/FileDisplay.js +7 -7
- package/lib/components/File/FileDisplay.js.map +1 -1
- package/lib/components/File/FileInput.js +10 -10
- package/lib/components/File/FileInput.js.map +1 -1
- package/lib/components/File/FileItem.js +1 -1
- package/lib/components/File/FileItem.js.map +1 -1
- package/lib/components/File/FileUploadItem.js +4 -4
- package/lib/components/File/FileUploadItem.js.map +1 -1
- package/lib/components/File/FileVisual.js +4 -4
- package/lib/components/File/FileVisual.js.map +1 -1
- package/lib/components/Flex/Flex.js +1 -1
- package/lib/components/Flex/Flex.js.map +1 -1
- package/lib/components/Form/Form.js +1 -1
- package/lib/components/Form/Form.js.map +1 -1
- package/lib/components/FormControl/FormControl.js +1 -1
- package/lib/components/FormControl/FormControl.js.map +1 -1
- package/lib/components/FormField/FormField.js +7 -7
- package/lib/components/FormField/FormField.js.map +1 -1
- package/lib/components/Grid/Grid.js +1 -1
- package/lib/components/Grid/Grid.js.map +1 -1
- package/lib/components/Icon/Icon.js +1 -1
- package/lib/components/Icon/Icon.js.map +1 -1
- package/lib/components/Image/Image.js +1 -1
- package/lib/components/Image/Image.js.map +1 -1
- package/lib/components/Input/Input.js +11 -11
- package/lib/components/Input/Input.js.map +1 -1
- package/lib/components/Label/Label.js +1 -1
- package/lib/components/Label/Label.js.map +1 -1
- package/lib/components/Link/Link.js +1 -1
- package/lib/components/Link/Link.js.map +1 -1
- package/lib/components/List/CommaSeparatedList.js +3 -3
- package/lib/components/List/CommaSeparatedList.js.map +1 -1
- package/lib/components/List/List.js +1 -1
- package/lib/components/List/List.js.map +1 -1
- package/lib/components/List/OrderedList.js +1 -1
- package/lib/components/List/OrderedList.js.map +1 -1
- package/lib/components/List/UnorderedList.js +1 -1
- package/lib/components/List/UnorderedList.js.map +1 -1
- package/lib/components/Location/CurrentLocationButton.js +1 -1
- package/lib/components/Location/CurrentLocationButton.js.map +1 -1
- package/lib/components/Location/LocationDisplay.js +7 -7
- package/lib/components/Location/LocationDisplay.js.map +1 -1
- package/lib/components/Location/LocationInput.js +19 -19
- package/lib/components/Location/LocationInput.js.map +1 -1
- package/lib/components/Location/LocationView.js +1 -1
- package/lib/components/Location/LocationView.js.map +1 -1
- package/lib/components/Menu/FlyoutMenuList.js +3 -3
- package/lib/components/Menu/FlyoutMenuList.js.map +1 -1
- package/lib/components/Menu/Menu.d.ts.map +1 -1
- package/lib/components/Menu/Menu.js +4 -3
- package/lib/components/Menu/Menu.js.map +1 -1
- package/lib/components/Menu/Menu.types.d.ts +3 -1
- package/lib/components/Menu/Menu.types.d.ts.map +1 -1
- package/lib/components/Menu/Menu.types.js.map +1 -1
- package/lib/components/Menu/MenuGroup.js +2 -2
- package/lib/components/Menu/MenuGroup.js.map +1 -1
- package/lib/components/Menu/MenuItem.js +11 -11
- package/lib/components/Menu/MenuItem.js.map +1 -1
- package/lib/components/Menu/MenuList.js +5 -5
- package/lib/components/Menu/MenuList.js.map +1 -1
- package/lib/components/Menu/MenuListHeader.js +2 -2
- package/lib/components/Menu/MenuListHeader.js.map +1 -1
- package/lib/components/MenuButton/MenuButton.js +3 -3
- package/lib/components/MenuButton/MenuButton.js.map +1 -1
- package/lib/components/MetaList/MetaList.js +4 -4
- package/lib/components/MetaList/MetaList.js.map +1 -1
- package/lib/components/Modal/DockedModals.d.ts.map +1 -1
- package/lib/components/Modal/DockedModals.js +4 -6
- package/lib/components/Modal/DockedModals.js.map +1 -1
- package/lib/components/Modal/MinimizedModal.d.ts.map +1 -1
- package/lib/components/Modal/MinimizedModal.js +37 -34
- package/lib/components/Modal/MinimizedModal.js.map +1 -1
- package/lib/components/Modal/Modal.js +8 -8
- package/lib/components/Modal/Modal.js.map +1 -1
- package/lib/components/Modal/ModalManager.js +6 -6
- package/lib/components/Modal/ModalManager.js.map +1 -1
- package/lib/components/MultiStep/MultiStep.js +7 -7
- package/lib/components/MultiStep/MultiStep.js.map +1 -1
- package/lib/components/Number/NumberDisplay.js +1 -1
- package/lib/components/Number/NumberDisplay.js.map +1 -1
- package/lib/components/Number/NumberInput.js +5 -5
- package/lib/components/Number/NumberInput.js.map +1 -1
- package/lib/components/PageTemplates/CategorySubPage.js +7 -7
- package/lib/components/PageTemplates/CategorySubPage.js.map +1 -1
- package/lib/components/PageTemplates/DashboardPage.d.ts +4 -0
- package/lib/components/PageTemplates/DashboardPage.d.ts.map +1 -1
- package/lib/components/PageTemplates/DashboardPage.js +19 -12
- package/lib/components/PageTemplates/DashboardPage.js.map +1 -1
- package/lib/components/PageTemplates/PageTemplates.js +20 -20
- package/lib/components/PageTemplates/PageTemplates.js.map +1 -1
- package/lib/components/PageTemplates/index.d.ts +1 -0
- package/lib/components/PageTemplates/index.d.ts.map +1 -1
- package/lib/components/PageTemplates/index.js +1 -0
- package/lib/components/PageTemplates/index.js.map +1 -1
- package/lib/components/Pagination/Pagination.js +3 -3
- package/lib/components/Pagination/Pagination.js.map +1 -1
- package/lib/components/Phone/PhoneDisplay.js +2 -2
- package/lib/components/Phone/PhoneDisplay.js.map +1 -1
- package/lib/components/Phone/PhoneInput.js +3 -3
- package/lib/components/Phone/PhoneInput.js.map +1 -1
- package/lib/components/Popover/Popover.js +1 -1
- package/lib/components/Popover/Popover.js.map +1 -1
- package/lib/components/Popover/PopoverManager.js +2 -2
- package/lib/components/Popover/PopoverManager.js.map +1 -1
- package/lib/components/Progress/Bar.js +1 -1
- package/lib/components/Progress/Bar.js.map +1 -1
- package/lib/components/Progress/Ellipsis.js +1 -1
- package/lib/components/Progress/Ellipsis.js.map +1 -1
- package/lib/components/Progress/Progress.js +2 -2
- package/lib/components/Progress/Progress.js.map +1 -1
- package/lib/components/Progress/Ring.js +1 -1
- package/lib/components/Progress/Ring.js.map +1 -1
- package/lib/components/RadioButton/RadioButton.js +1 -1
- package/lib/components/RadioButton/RadioButton.js.map +1 -1
- package/lib/components/RadioCheck/RadioCheck.js +2 -2
- package/lib/components/RadioCheck/RadioCheck.js.map +1 -1
- package/lib/components/RadioCheckGroup/RadioCheckGroup.js +10 -10
- package/lib/components/RadioCheckGroup/RadioCheckGroup.js.map +1 -1
- package/lib/components/Rating/Rating.js +2 -2
- package/lib/components/Rating/Rating.js.map +1 -1
- package/lib/components/SearchInput/SearchInput.js +2 -2
- package/lib/components/SearchInput/SearchInput.js.map +1 -1
- package/lib/components/Select/Option.js +1 -1
- package/lib/components/Select/Option.js.map +1 -1
- package/lib/components/Select/Select.js +13 -13
- package/lib/components/Select/Select.js.map +1 -1
- package/lib/components/Sentiment/Sentiment.js +1 -1
- package/lib/components/Sentiment/Sentiment.js.map +1 -1
- package/lib/components/Skeleton/LineSkeleton.js +1 -1
- package/lib/components/Skeleton/LineSkeleton.js.map +1 -1
- package/lib/components/Skeleton/ParagraphSkeleton.js +1 -1
- package/lib/components/Skeleton/ParagraphSkeleton.js.map +1 -1
- package/lib/components/Skeleton/RectangleSkeleton.js +1 -1
- package/lib/components/Skeleton/RectangleSkeleton.js.map +1 -1
- package/lib/components/Slider/Slider.js +5 -5
- package/lib/components/Slider/Slider.js.map +1 -1
- package/lib/components/Slider/SliderTicks.js +4 -4
- package/lib/components/Slider/SliderTicks.js.map +1 -1
- package/lib/components/SummaryItem/SummaryItem.d.ts +1 -1
- package/lib/components/SummaryItem/SummaryItem.d.ts.map +1 -1
- package/lib/components/SummaryItem/SummaryItem.js +2 -2
- package/lib/components/SummaryItem/SummaryItem.js.map +1 -1
- package/lib/components/SummaryList/SummaryList.js +3 -3
- package/lib/components/SummaryList/SummaryList.js.map +1 -1
- package/lib/components/SummaryList/ViewAll.js +1 -1
- package/lib/components/SummaryList/ViewAll.js.map +1 -1
- package/lib/components/Switch/Switch.js +1 -1
- package/lib/components/Switch/Switch.js.map +1 -1
- package/lib/components/Table/Table.d.ts.map +1 -1
- package/lib/components/Table/Table.js +13 -8
- package/lib/components/Table/Table.js.map +1 -1
- package/lib/components/Tabs/Tab.js +1 -1
- package/lib/components/Tabs/Tab.js.map +1 -1
- package/lib/components/Tabs/TabPanel.js +1 -1
- package/lib/components/Tabs/TabPanel.js.map +1 -1
- package/lib/components/Tabs/Tabs.js +4 -4
- package/lib/components/Tabs/Tabs.js.map +1 -1
- package/lib/components/Text/Text.js +1 -1
- package/lib/components/Text/Text.js.map +1 -1
- package/lib/components/TextArea/TextArea.js +23 -23
- package/lib/components/TextArea/TextArea.js.map +1 -1
- package/lib/components/Toaster/Toaster.js +4 -4
- package/lib/components/Toaster/Toaster.js.map +1 -1
- package/lib/components/Tooltip/Tooltip.js +1 -1
- package/lib/components/Tooltip/Tooltip.js.map +1 -1
- package/lib/components/Tree/StandardTree.js +6 -6
- package/lib/components/Tree/StandardTree.js.map +1 -1
- package/lib/components/Tree/Tree.js +3 -3
- package/lib/components/Tree/Tree.js.map +1 -1
- package/lib/components/URL/URLDisplay.js +2 -2
- package/lib/components/URL/URLDisplay.js.map +1 -1
- package/lib/hooks/useFocusWithin.d.ts +1 -1
- package/lib/hooks/useFocusWithin.d.ts.map +1 -1
- package/lib/hooks/useFocusWithin.js +21 -16
- package/lib/hooks/useFocusWithin.js.map +1 -1
- package/lib/hooks/useI18n.d.ts +2 -1
- package/lib/hooks/useI18n.d.ts.map +1 -1
- package/lib/i18n/default.json +2 -1
- package/lib/i18n/i18n.d.ts +4 -2
- package/lib/i18n/i18n.d.ts.map +1 -1
- package/lib/theme/theme.d.ts +30 -30
- package/lib/utils/utils.d.ts +13 -0
- package/lib/utils/utils.d.ts.map +1 -1
- package/lib/utils/utils.js +15 -0
- package/lib/utils/utils.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
export const StyledBareRoleButton = styled.div ``;
|
|
5
|
+
const BareRoleButton = forwardRef(({ children, onClick, onKeyDown, ...restProps }, ref) => {
|
|
6
|
+
return (_jsx(StyledBareRoleButton, { ...restProps, tabIndex: 0, role: 'button', onKeyDown: (e) => {
|
|
7
|
+
if ((e.key === ' ' || e.key === 'Enter') && e.target === e.currentTarget) {
|
|
8
|
+
e.currentTarget.click();
|
|
9
|
+
}
|
|
10
|
+
return onKeyDown?.(e);
|
|
11
|
+
}, onClick: (e) => {
|
|
12
|
+
if (e.target instanceof Element &&
|
|
13
|
+
// Ignore clicks on other interactive elements within this element.
|
|
14
|
+
e.target.closest("button, a, [role='button'], [role='link']") !== e.currentTarget)
|
|
15
|
+
return;
|
|
16
|
+
return onClick?.(e);
|
|
17
|
+
}, ref: ref, children: children }, void 0));
|
|
18
|
+
});
|
|
19
|
+
export default BareRoleButton;
|
|
20
|
+
//# sourceMappingURL=BareRoleButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BareRoleButton.js","sourceRoot":"","sources":["../../../src/components/Button/BareRoleButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAgE,MAAM,OAAO,CAAC;AACjG,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAWvC,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,GAAG,CAAA,EAAE,CAAC;AAEjD,MAAM,cAAc,GAA0D,UAAU,CACtF,CACE,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,SAAS,EAAuB,EACnE,GAA+B,EAC/B,EAAE;IACF,OAAO,CACL,KAAC,oBAAoB,OACf,SAAS,EACb,QAAQ,EAAE,CAAC,EACX,IAAI,EAAC,QAAQ,EACb,SAAS,EAAE,CAAC,CAAgC,EAAE,EAAE;YAC9C,IAAI,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,IAAI,CAAC,CAAC,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,aAAa,EAAE;gBACvE,CAAC,CAAC,aAAgC,CAAC,KAAK,EAAE,CAAC;aAC7C;YAED,OAAO,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC;QACxB,CAAC,EACD,OAAO,EAAE,CAAC,CAA6B,EAAE,EAAE;YACzC,IACE,CAAC,CAAC,MAAM,YAAY,OAAO;gBAC3B,mEAAmE;gBACnE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,2CAA2C,CAAC,KAAK,CAAC,CAAC,aAAa;gBAEjF,OAAO;YAET,OAAO,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;QACtB,CAAC,EACD,GAAG,EAAE,GAAG,YAEP,QAAQ,WACY,CACxB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import { forwardRef, Ref, MouseEvent, KeyboardEvent, ReactNode, FunctionComponent } from 'react';\nimport styled from 'styled-components';\n\nimport { BaseProps, ForwardProps } from '../../types';\n\nexport interface BareRoleButtonProps extends BaseProps {\n children: ReactNode;\n onClick?: (e: MouseEvent<HTMLDivElement>) => void;\n onKeyDown?: (e: KeyboardEvent<HTMLDivElement>) => void;\n ref?: Ref<HTMLDivElement>;\n}\n\nexport const StyledBareRoleButton = styled.div``;\n\nconst BareRoleButton: FunctionComponent<BareRoleButtonProps & ForwardProps> = forwardRef(\n (\n { children, onClick, onKeyDown, ...restProps }: BareRoleButtonProps,\n ref: BareRoleButtonProps['ref']\n ) => {\n return (\n <StyledBareRoleButton\n {...restProps}\n tabIndex={0}\n role='button'\n onKeyDown={(e: KeyboardEvent<HTMLDivElement>) => {\n if ((e.key === ' ' || e.key === 'Enter') && e.target === e.currentTarget) {\n (e.currentTarget as HTMLDivElement).click();\n }\n\n return onKeyDown?.(e);\n }}\n onClick={(e: MouseEvent<HTMLDivElement>) => {\n if (\n e.target instanceof Element &&\n // Ignore clicks on other interactive elements within this element.\n e.target.closest(\"button, a, [role='button'], [role='link']\") !== e.currentTarget\n )\n return;\n\n return onClick?.(e);\n }}\n ref={ref}\n >\n {children}\n </StyledBareRoleButton>\n );\n }\n);\n\nexport default BareRoleButton;\n"]}
|
|
@@ -199,7 +199,7 @@ const Button = forwardRef(({ variant = 'secondary', type = 'button', disabled =
|
|
|
199
199
|
const shouldFocus = useRef(false);
|
|
200
200
|
const buttonRef = useConsolidatedRef(ref, setButtonEl);
|
|
201
201
|
const showProgress = loading && variant !== 'link' && variant !== 'text';
|
|
202
|
-
return (_jsxs(_Fragment, { children: [_jsxs(StyledButton,
|
|
202
|
+
return (_jsxs(_Fragment, { children: [_jsxs(StyledButton, { ...restProps, ref: buttonRef, as: as || (href ? 'a' : 'button'), forwardedAs: forwardedAs || (href ? 'a' : 'button'), variant: variant, icon: icon, compact: compact, type: href ? undefined : type, href: href, disabled: disabled && !href, loading: showProgress, "aria-label": ariaLabel || label, onMouseDown: (e) => {
|
|
203
203
|
if (restProps.onMouseDown) {
|
|
204
204
|
const handlerReturn = restProps.onMouseDown?.(e);
|
|
205
205
|
if (handlerReturn === false || e.defaultPrevented)
|
|
@@ -215,7 +215,7 @@ const Button = forwardRef(({ variant = 'secondary', type = 'button', disabled =
|
|
|
215
215
|
shouldFocus.current = false;
|
|
216
216
|
}
|
|
217
217
|
return restProps.onMouseUp?.(e);
|
|
218
|
-
}
|
|
218
|
+
}, children: [showProgress && _jsx(Progress, { variant: 'ring', placement: 'local' }, void 0), children] }, void 0), buttonEl && label && (_jsx(Tooltip, { target: buttonEl, showDelay: 'none', hideDelay: 'none', describeTarget: false, children: label }, void 0))] }, void 0));
|
|
219
219
|
});
|
|
220
220
|
export default Button;
|
|
221
221
|
//# sourceMappingURL=Button.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","sourceRoot":"","sources":["../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B,KAAC,OAAO,kBAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAC,MAAM,EAAC,SAAS,EAAC,MAAM,EAAC,cAAc,EAAE,KAAK,gBAC/E,KAAK,YACE,CACX,YACA,CACJ,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,MAAM,CAAC","sourcesContent":["import {\n useRef,\n forwardRef,\n FunctionComponent,\n ReactNode,\n PropsWithoutRef,\n Ref,\n MouseEvent,\n MouseEventHandler\n} from 'react';\nimport styled, { css } from 'styled-components';\nimport { mix, readableColor } from 'polished';\n\nimport { BaseProps, ForwardProps, PropsWithDefaults, AsProp } from '../../types';\nimport { defaultThemeProp } from '../../theme';\nimport { tryCatch } from '../../utils';\nimport { getHoverColors, omitProps } from '../../styles';\nimport { useElement, useConsolidatedRef } from '../../hooks';\nimport Tooltip from '../Tooltip';\nimport Progress, { StyledProgressRing } from '../Progress';\nimport { StyledBackdrop } from '../Backdrop';\nimport { StyledIcon } from '../Icon';\nimport { StyledPopover } from '../Popover';\n\nexport interface ButtonProps extends BaseProps, AsProp {\n /** Text or content for the Button. */\n children: ReactNode;\n /**\n * Determines if the Button will be disabled.\n * @default false\n */\n disabled?: boolean;\n /** A location to navigate to. Passing an href will render an anchor styled as a Button. */\n href?: string;\n /**\n * Controls the styling of the Button.\n * @default \"secondary\"\n */\n variant?: 'primary' | 'secondary' | 'simple' | 'link' | 'text';\n /**\n * Controls the behavior of a Button within a Form.\n * @default \"button\"\n */\n type?: 'button' | 'reset' | 'submit';\n /**\n * Set the Icon prop to `true` if you're using just an Icon in your Button. Make sure to pass an Icon as children if `true`.\n * @default false\n */\n icon?: boolean;\n /**\n * Used for a smaller sized button.\n * @default false\n */\n compact?: boolean;\n /**\n * The label text will be used inside a Tooltip.\n */\n label?: string;\n /**\n * The aria label text will be inserted as the aria-label on the Button.\n */\n 'aria-label'?: string;\n /**\n * Optionally renders an indeterminate progress indicator in a button.\n * @default false\n */\n loading?: boolean;\n /** Ref forwarded to the wrapping element. */\n ref?: Ref<HTMLButtonElement>;\n}\n\ntype ButtonPropsWithDefaults = PropsWithDefaults<\n ButtonProps,\n 'variant' | 'type' | 'disabled' | 'icon' | 'loading'\n>;\n\nexport const StyledButton = styled.button.withConfig<ButtonPropsWithDefaults>(omitProps('loading'))(\n ({\n variant,\n icon,\n loading,\n compact,\n theme: {\n base: {\n spacing,\n 'border-radius': baseBorderRadius,\n palette: { 'primary-background': backgroundColor, 'foreground-color': textColor },\n 'hit-area': {\n 'mouse-min': hitAreaMouse,\n 'finger-min': hitAreaFinger,\n 'compact-min': hitAreaCompact\n },\n animation: {\n speed,\n timing: { ease }\n },\n 'disabled-opacity': disabledOpacity\n },\n components: {\n button: {\n color,\n 'secondary-color': secondaryColor,\n padding,\n 'border-radius': borderRadius,\n 'border-width': borderWidth,\n 'focus-shadow': focusShadow,\n touch: { padding: touchPadding }\n },\n link: { color: linkColor }\n }\n }\n }) => {\n const borderColor = variant === 'secondary' ? color : 'transparent';\n const contrastColor = tryCatch(() => readableColor(color));\n\n const hoverColors = getHoverColors(color);\n const hoverPrimaryColor = hoverColors.background;\n const hoverContrastColor = hoverColors.foreground;\n\n const secondaryHoverColor = tryCatch(() => mix(0.85, secondaryColor, color));\n\n let buttonColor = contrastColor;\n let buttonBackgroundColor = color;\n if (variant === 'secondary') {\n buttonColor = color;\n buttonBackgroundColor = secondaryColor;\n } else if (variant === 'simple') {\n if (icon) {\n buttonColor = 'currentColor';\n buttonBackgroundColor = 'transparent';\n } else {\n buttonColor = color;\n buttonBackgroundColor = backgroundColor;\n }\n } else if (variant === 'link') {\n buttonColor = linkColor;\n buttonBackgroundColor = 'transparent';\n } else if (variant === 'text') {\n buttonColor = textColor;\n buttonBackgroundColor = 'transparent';\n }\n\n return css`\n color: ${buttonColor};\n background-color: ${buttonBackgroundColor};\n display: ${variant === 'link' || variant === 'text' ? 'inline' : 'inline-flex'};\n align-items: center;\n outline: none;\n text-decoration: none;\n transition: all calc(0.5 * ${speed}) ${ease};\n cursor: pointer;\n\n ${variant !== 'link' && variant !== 'text'\n ? css`\n justify-content: center;\n line-height: 1;\n border: ${borderWidth} solid ${borderColor};\n position: relative;\n `\n : css`\n text-align: start;\n border: none;\n\n > ${StyledIcon} {\n vertical-align: bottom;\n }\n `}\n\n & + & {\n margin-inline-start: ${spacing};\n }\n\n /* Not able to combine with selector above. Stylis bug? */\n & + ${StyledPopover} + & {\n margin-inline-start: ${spacing};\n }\n\n @media (hover: hover) {\n &:hover {\n ${variant === 'primary' &&\n css`\n background-color: ${hoverPrimaryColor};\n color: ${hoverContrastColor};\n text-decoration: none;\n `}\n\n ${(variant === 'secondary' || (variant === 'simple' && !icon)) &&\n css`\n background-color: ${secondaryHoverColor};\n text-decoration: none;\n `}\n\n ${variant === 'simple' &&\n icon &&\n css`\n ::before {\n content: '';\n position: absolute;\n top: calc(${borderWidth} * -1);\n bottom: calc(${borderWidth} * -1);\n left: calc(${borderWidth} * -1);\n right: calc(${borderWidth} * -1);\n border-radius: inherit;\n background-color: currentColor;\n opacity: 0.15;\n }\n `}\n\n ${(variant === 'link' || variant === 'text') &&\n css`\n text-decoration: underline;\n `}\n }\n }\n\n ${variant !== 'link' &&\n variant !== 'text' &&\n css`\n min-height: ${hitAreaMouse};\n min-width: ${hitAreaMouse};\n border-radius: calc(${baseBorderRadius} * ${borderRadius});\n -webkit-user-select: none;\n user-select: none;\n `}\n\n ${compact &&\n css`\n min-height: ${hitAreaCompact};\n min-width: ${hitAreaCompact};\n `}\n\n ${!icon &&\n variant !== 'link' &&\n variant !== 'text' &&\n css`\n padding: ${padding};\n `}\n\n ${variant !== 'link' &&\n variant !== 'text' &&\n css`\n @media (pointer: coarse) {\n ${!compact &&\n css`\n min-height: ${hitAreaFinger};\n min-width: ${hitAreaFinger};\n `}\n border-radius: calc(${baseBorderRadius} * ${borderRadius});\n ${!icon &&\n css`\n padding: ${touchPadding};\n `}\n }\n `}\n\n &:disabled,\n &[disabled] {\n opacity: ${disabledOpacity};\n cursor: not-allowed;\n pointer-events: none;\n }\n\n &:enabled:focus,\n &:not([disabled]):focus {\n box-shadow: ${focusShadow};\n }\n\n ${icon &&\n variant !== 'link' &&\n variant !== 'text' &&\n css`\n border-radius: calc(${baseBorderRadius} * ${borderRadius});\n > svg {\n display: block;\n }\n `}\n\n ${loading &&\n css`\n ${StyledBackdrop} {\n background-color: ${buttonBackgroundColor};\n border-radius: inherit;\n }\n ${StyledProgressRing} {\n width: 1em;\n height: 1em;\n circle:nth-child(2) {\n animation-duration: calc(${speed} * 2);\n }\n }\n `}\n `;\n }\n);\n\nStyledButton.defaultProps = defaultThemeProp;\n\nconst Button: FunctionComponent<ButtonProps & ForwardProps> = forwardRef(\n (\n {\n variant = 'secondary',\n type = 'button',\n disabled = false,\n icon = false,\n compact = false,\n href,\n as,\n forwardedAs,\n label,\n 'aria-label': ariaLabel,\n loading = false,\n children,\n ...restProps\n }: PropsWithoutRef<ButtonProps> & ForwardProps,\n ref: Ref<HTMLButtonElement>\n ) => {\n const [buttonEl, setButtonEl] = useElement();\n const shouldFocus = useRef(false);\n const buttonRef = useConsolidatedRef<HTMLButtonElement>(ref, setButtonEl);\n const showProgress = loading && variant !== 'link' && variant !== 'text';\n\n return (\n <>\n <StyledButton\n {...restProps}\n ref={buttonRef}\n as={as || (href ? 'a' : 'button')}\n forwardedAs={forwardedAs || (href ? 'a' : 'button')}\n variant={variant}\n icon={icon}\n compact={compact}\n type={href ? undefined : type}\n href={href}\n disabled={disabled && !href}\n loading={showProgress}\n aria-label={ariaLabel || label}\n onMouseDown={(e: MouseEvent<HTMLButtonElement | HTMLAnchorElement>) => {\n if (restProps.onMouseDown) {\n const handlerReturn = (restProps.onMouseDown as MouseEventHandler)?.(e) as\n | false\n | void;\n\n if (handlerReturn === false || e.defaultPrevented) return handlerReturn;\n }\n\n shouldFocus.current = true;\n }}\n onMouseUp={(e: MouseEvent<HTMLButtonElement | HTMLAnchorElement>) => {\n if (buttonRef.current === document.activeElement) {\n shouldFocus.current = false;\n }\n\n if (shouldFocus.current) {\n buttonRef.current?.focus();\n shouldFocus.current = false;\n }\n\n return (restProps.onMouseUp as MouseEventHandler)?.(e);\n }}\n >\n {showProgress && <Progress variant='ring' placement='local' />}\n {children}\n </StyledButton>\n {buttonEl && label && (\n <Tooltip target={buttonEl} showDelay='none' hideDelay='none' describeTarget={false}>\n {label}\n </Tooltip>\n )}\n </>\n );\n }\n);\n\nexport default Button;\n"]}
|
|
1
|
+
{"version":3,"file":"Button.js","sourceRoot":"","sources":["../../../src/components/Button/Button.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,MAAM,EACN,UAAU,EAOX,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,GAAG,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAG9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,QAAQ,EAAE,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAsD3C,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,UAAU,CAA0B,SAAS,CAAC,SAAS,CAAC,CAAC,CACjG,CAAC,EACC,OAAO,EACP,IAAI,EACJ,OAAO,EACP,OAAO,EACP,KAAK,EAAE,EACL,IAAI,EAAE,EACJ,OAAO,EACP,eAAe,EAAE,gBAA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ACvB,SAAS,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC;wBAC3B,WAAW,CAAC,OAAO,GAAG,KAAK,CAAC;qBAC7B;oBAED,OAAQ,SAAS,CAAC,SAA+B,EAAE,CAAC,CAAC,CAAC,CAAC;gBACzD,CAAC,aAEA,YAAY,IAAI,KAAC,QAAQ,IAAC,OAAO,EAAC,MAAM,EAAC,SAAS,EAAC,OAAO,WAAG,EAC7D,QAAQ,YACI,EACd,QAAQ,IAAI,KAAK,IAAI,CACpB,KAAC,OAAO,IAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAC,MAAM,EAAC,SAAS,EAAC,MAAM,EAAC,cAAc,EAAE,KAAK,YAC/E,KAAK,WACE,CACX,YACA,CACJ,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,MAAM,CAAC","sourcesContent":["import {\n useRef,\n forwardRef,\n FunctionComponent,\n ReactNode,\n PropsWithoutRef,\n Ref,\n MouseEvent,\n MouseEventHandler\n} from 'react';\nimport styled, { css } from 'styled-components';\nimport { mix, readableColor } from 'polished';\n\nimport { BaseProps, ForwardProps, PropsWithDefaults, AsProp } from '../../types';\nimport { defaultThemeProp } from '../../theme';\nimport { tryCatch } from '../../utils';\nimport { getHoverColors, omitProps } from '../../styles';\nimport { useElement, useConsolidatedRef } from '../../hooks';\nimport Tooltip from '../Tooltip';\nimport Progress, { StyledProgressRing } from '../Progress';\nimport { StyledBackdrop } from '../Backdrop';\nimport { StyledIcon } from '../Icon';\nimport { StyledPopover } from '../Popover';\n\nexport interface ButtonProps extends BaseProps, AsProp {\n /** Text or content for the Button. */\n children: ReactNode;\n /**\n * Determines if the Button will be disabled.\n * @default false\n */\n disabled?: boolean;\n /** A location to navigate to. Passing an href will render an anchor styled as a Button. */\n href?: string;\n /**\n * Controls the styling of the Button.\n * @default \"secondary\"\n */\n variant?: 'primary' | 'secondary' | 'simple' | 'link' | 'text';\n /**\n * Controls the behavior of a Button within a Form.\n * @default \"button\"\n */\n type?: 'button' | 'reset' | 'submit';\n /**\n * Set the Icon prop to `true` if you're using just an Icon in your Button. Make sure to pass an Icon as children if `true`.\n * @default false\n */\n icon?: boolean;\n /**\n * Used for a smaller sized button.\n * @default false\n */\n compact?: boolean;\n /**\n * The label text will be used inside a Tooltip.\n */\n label?: string;\n /**\n * The aria label text will be inserted as the aria-label on the Button.\n */\n 'aria-label'?: string;\n /**\n * Optionally renders an indeterminate progress indicator in a button.\n * @default false\n */\n loading?: boolean;\n /** Ref forwarded to the wrapping element. */\n ref?: Ref<HTMLButtonElement>;\n}\n\ntype ButtonPropsWithDefaults = PropsWithDefaults<\n ButtonProps,\n 'variant' | 'type' | 'disabled' | 'icon' | 'loading'\n>;\n\nexport const StyledButton = styled.button.withConfig<ButtonPropsWithDefaults>(omitProps('loading'))(\n ({\n variant,\n icon,\n loading,\n compact,\n theme: {\n base: {\n spacing,\n 'border-radius': baseBorderRadius,\n palette: { 'primary-background': backgroundColor, 'foreground-color': textColor },\n 'hit-area': {\n 'mouse-min': hitAreaMouse,\n 'finger-min': hitAreaFinger,\n 'compact-min': hitAreaCompact\n },\n animation: {\n speed,\n timing: { ease }\n },\n 'disabled-opacity': disabledOpacity\n },\n components: {\n button: {\n color,\n 'secondary-color': secondaryColor,\n padding,\n 'border-radius': borderRadius,\n 'border-width': borderWidth,\n 'focus-shadow': focusShadow,\n touch: { padding: touchPadding }\n },\n link: { color: linkColor }\n }\n }\n }) => {\n const borderColor = variant === 'secondary' ? color : 'transparent';\n const contrastColor = tryCatch(() => readableColor(color));\n\n const hoverColors = getHoverColors(color);\n const hoverPrimaryColor = hoverColors.background;\n const hoverContrastColor = hoverColors.foreground;\n\n const secondaryHoverColor = tryCatch(() => mix(0.85, secondaryColor, color));\n\n let buttonColor = contrastColor;\n let buttonBackgroundColor = color;\n if (variant === 'secondary') {\n buttonColor = color;\n buttonBackgroundColor = secondaryColor;\n } else if (variant === 'simple') {\n if (icon) {\n buttonColor = 'currentColor';\n buttonBackgroundColor = 'transparent';\n } else {\n buttonColor = color;\n buttonBackgroundColor = backgroundColor;\n }\n } else if (variant === 'link') {\n buttonColor = linkColor;\n buttonBackgroundColor = 'transparent';\n } else if (variant === 'text') {\n buttonColor = textColor;\n buttonBackgroundColor = 'transparent';\n }\n\n return css`\n color: ${buttonColor};\n background-color: ${buttonBackgroundColor};\n display: ${variant === 'link' || variant === 'text' ? 'inline' : 'inline-flex'};\n align-items: center;\n outline: none;\n text-decoration: none;\n transition: all calc(0.5 * ${speed}) ${ease};\n cursor: pointer;\n\n ${variant !== 'link' && variant !== 'text'\n ? css`\n justify-content: center;\n line-height: 1;\n border: ${borderWidth} solid ${borderColor};\n position: relative;\n `\n : css`\n text-align: start;\n border: none;\n\n > ${StyledIcon} {\n vertical-align: bottom;\n }\n `}\n\n & + & {\n margin-inline-start: ${spacing};\n }\n\n /* Not able to combine with selector above. Stylis bug? */\n & + ${StyledPopover} + & {\n margin-inline-start: ${spacing};\n }\n\n @media (hover: hover) {\n &:hover {\n ${variant === 'primary' &&\n css`\n background-color: ${hoverPrimaryColor};\n color: ${hoverContrastColor};\n text-decoration: none;\n `}\n\n ${(variant === 'secondary' || (variant === 'simple' && !icon)) &&\n css`\n background-color: ${secondaryHoverColor};\n text-decoration: none;\n `}\n\n ${variant === 'simple' &&\n icon &&\n css`\n ::before {\n content: '';\n position: absolute;\n top: calc(${borderWidth} * -1);\n bottom: calc(${borderWidth} * -1);\n left: calc(${borderWidth} * -1);\n right: calc(${borderWidth} * -1);\n border-radius: inherit;\n background-color: currentColor;\n opacity: 0.15;\n }\n `}\n\n ${(variant === 'link' || variant === 'text') &&\n css`\n text-decoration: underline;\n `}\n }\n }\n\n ${variant !== 'link' &&\n variant !== 'text' &&\n css`\n min-height: ${hitAreaMouse};\n min-width: ${hitAreaMouse};\n border-radius: calc(${baseBorderRadius} * ${borderRadius});\n -webkit-user-select: none;\n user-select: none;\n `}\n\n ${compact &&\n css`\n min-height: ${hitAreaCompact};\n min-width: ${hitAreaCompact};\n `}\n\n ${!icon &&\n variant !== 'link' &&\n variant !== 'text' &&\n css`\n padding: ${padding};\n `}\n\n ${variant !== 'link' &&\n variant !== 'text' &&\n css`\n @media (pointer: coarse) {\n ${!compact &&\n css`\n min-height: ${hitAreaFinger};\n min-width: ${hitAreaFinger};\n `}\n border-radius: calc(${baseBorderRadius} * ${borderRadius});\n ${!icon &&\n css`\n padding: ${touchPadding};\n `}\n }\n `}\n\n &:disabled,\n &[disabled] {\n opacity: ${disabledOpacity};\n cursor: not-allowed;\n pointer-events: none;\n }\n\n &:enabled:focus,\n &:not([disabled]):focus {\n box-shadow: ${focusShadow};\n }\n\n ${icon &&\n variant !== 'link' &&\n variant !== 'text' &&\n css`\n border-radius: calc(${baseBorderRadius} * ${borderRadius});\n > svg {\n display: block;\n }\n `}\n\n ${loading &&\n css`\n ${StyledBackdrop} {\n background-color: ${buttonBackgroundColor};\n border-radius: inherit;\n }\n ${StyledProgressRing} {\n width: 1em;\n height: 1em;\n circle:nth-child(2) {\n animation-duration: calc(${speed} * 2);\n }\n }\n `}\n `;\n }\n);\n\nStyledButton.defaultProps = defaultThemeProp;\n\nconst Button: FunctionComponent<ButtonProps & ForwardProps> = forwardRef(\n (\n {\n variant = 'secondary',\n type = 'button',\n disabled = false,\n icon = false,\n compact = false,\n href,\n as,\n forwardedAs,\n label,\n 'aria-label': ariaLabel,\n loading = false,\n children,\n ...restProps\n }: PropsWithoutRef<ButtonProps> & ForwardProps,\n ref: Ref<HTMLButtonElement>\n ) => {\n const [buttonEl, setButtonEl] = useElement();\n const shouldFocus = useRef(false);\n const buttonRef = useConsolidatedRef<HTMLButtonElement>(ref, setButtonEl);\n const showProgress = loading && variant !== 'link' && variant !== 'text';\n\n return (\n <>\n <StyledButton\n {...restProps}\n ref={buttonRef}\n as={as || (href ? 'a' : 'button')}\n forwardedAs={forwardedAs || (href ? 'a' : 'button')}\n variant={variant}\n icon={icon}\n compact={compact}\n type={href ? undefined : type}\n href={href}\n disabled={disabled && !href}\n loading={showProgress}\n aria-label={ariaLabel || label}\n onMouseDown={(e: MouseEvent<HTMLButtonElement | HTMLAnchorElement>) => {\n if (restProps.onMouseDown) {\n const handlerReturn = (restProps.onMouseDown as MouseEventHandler)?.(e) as\n | false\n | void;\n\n if (handlerReturn === false || e.defaultPrevented) return handlerReturn;\n }\n\n shouldFocus.current = true;\n }}\n onMouseUp={(e: MouseEvent<HTMLButtonElement | HTMLAnchorElement>) => {\n if (buttonRef.current === document.activeElement) {\n shouldFocus.current = false;\n }\n\n if (shouldFocus.current) {\n buttonRef.current?.focus();\n shouldFocus.current = false;\n }\n\n return (restProps.onMouseUp as MouseEventHandler)?.(e);\n }}\n >\n {showProgress && <Progress variant='ring' placement='local' />}\n {children}\n </StyledButton>\n {buttonEl && label && (\n <Tooltip target={buttonEl} showDelay='none' hideDelay='none' describeTarget={false}>\n {label}\n </Tooltip>\n )}\n </>\n );\n }\n);\n\nexport default Button;\n"]}
|
|
@@ -57,7 +57,7 @@ const Card = forwardRef((props, ref) => {
|
|
|
57
57
|
...(role && { role }),
|
|
58
58
|
interactive
|
|
59
59
|
};
|
|
60
|
-
return (_jsx(Flex,
|
|
60
|
+
return (_jsx(Flex, { container: { direction: 'column' }, as: StyledCard, forwardedAs: as, ref: ref, ...interactiveProps, ...restProps, children: children }, void 0));
|
|
61
61
|
});
|
|
62
62
|
Card.defaultProps = defaultProps;
|
|
63
63
|
export default Card;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Card.js","sourceRoot":"","sources":["../../../src/components/Card/Card.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAsD,MAAM,OAAO,CAAC;AACvF,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,IAAI,MAAM,SAAS,CAAC;AAE3B,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C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I;YACb,OAAO;YACP,QAAQ,EAAE,CAAC;YACX,IAAI,EAAE,QAAQ;SACf,CAAC;QACF,GAAG,CAAC,WAAW,IAAI;YACjB,QAAQ,EAAE,CAAC;SACZ,CAAC;QACF,GAAG,CAAC,IAAI,IAAI,EAAE,IAAI,EAAE,CAAC;QACrB,WAAW;KACZ,CAAC;IAEF,OAAO,CACL,KAAC,IAAI,IACH,SAAS,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,EAClC,EAAE,EAAE,UAAU,EACd,WAAW,EAAE,EAAE,EACf,GAAG,EAAE,GAAG,KACJ,gBAAgB,KAChB,SAAS,YAEZ,QAAQ,WACJ,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;AAEjC,eAAe,IAAI,CAAC","sourcesContent":["import { forwardRef, FunctionComponent, Ref, PropsWithoutRef, ReactNode } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { defaultThemeProp } from '../../theme';\nimport Flex from '../Flex';\nimport { ForwardProps, BaseProps, AsProp } from '../../types';\nimport { StyledPopover } from '../Popover';\n\nimport { StyledCardMedia } from './CardMedia';\n\nexport interface CardProps extends BaseProps, AsProp {\n /** Components and content for the Card. */\n children?: ReactNode;\n /**\n * Enables the focus, hover, and active styles.\n * @default false\n * @deprecated\n */\n interactive?: boolean;\n /** Callback for onClick event. */\n onClick?: (event: any) => void;\n /**\n * HTML role attribute for accessibility.\n * @default \"region\"\n */\n role?: string;\n}\n\nconst defaultProps: Partial<CardProps> = {\n interactive: false,\n role: 'region'\n};\n\nexport const StyledCard = styled.article<Partial<CardProps>>(props => {\n const {\n 'border-radius': borderRadius,\n 'border-color': borderColor,\n background\n } = props.theme.components.card;\n const interactive = props.interactive\n ? css`\n &:hover {\n border: 0;\n box-shadow: 0 0 0 0.0625rem ${borderColor};\n }\n &:focus {\n border: 0;\n box-shadow: 0 0 0 0.125rem ${borderColor};\n }\n `\n : undefined;\n\n return css`\n ${StyledPopover} &, &:not(& &) {\n background-color: ${background};\n border-radius: ${borderRadius};\n\n &:focus {\n outline: none;\n }\n\n ${interactive}\n\n ${StyledCardMedia} {\n &:first-child img {\n border-radius: ${borderRadius} ${borderRadius} 0 0;\n }\n }\n }\n `;\n});\n\nStyledCard.defaultProps = defaultThemeProp;\n\nconst Card: FunctionComponent<CardProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<CardProps>, ref: Ref<HTMLElement>) => {\n const { children, as, onClick, interactive, role, ...restProps } = props;\n\n const interactiveProps = {\n ...(onClick && {\n onClick,\n tabIndex: 0,\n role: 'button'\n }),\n ...(interactive && {\n tabIndex: 0\n }),\n ...(role && { role }),\n interactive\n };\n\n return (\n <Flex\n container={{ direction: 'column' }}\n as={StyledCard}\n forwardedAs={as}\n ref={ref}\n {...interactiveProps}\n {...restProps}\n >\n {children}\n </Flex>\n );\n }\n);\n\nCard.defaultProps = defaultProps;\n\nexport default Card;\n"]}
|
|
@@ -20,7 +20,7 @@ export const StyledCardContent = styled.div(({ theme }) => {
|
|
|
20
20
|
});
|
|
21
21
|
StyledCardContent.defaultProps = defaultThemeProp;
|
|
22
22
|
const CardContent = ({ children, container, ...restProps }) => {
|
|
23
|
-
return (_jsx(Flex,
|
|
23
|
+
return (_jsx(Flex, { ...restProps, container: { direction: 'column', ...container }, as: StyledCardContent, children: children }, void 0));
|
|
24
24
|
};
|
|
25
25
|
export default CardContent;
|
|
26
26
|
//# sourceMappingURL=CardContent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CardContent.js","sourceRoot":"","sources":["../../../src/components/Card/CardContent.tsx"],"names":[],"mappings":";AACA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,IAAmB,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C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AAC;AACJ,CAAC,CAAC,CAAC;AAEH,iBAAiB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAElD,MAAM,WAAW,GAAuD,CAAC,EACvE,QAAQ,EACR,SAAS,EACT,GAAG,SAAS,EACuC,EAAE,EAAE;IACvD,OAAO,CACL,KAAC,IAAI,OAAK,SAAS,EAAE,SAAS,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,SAAS,EAAE,EAAE,EAAE,EAAE,iBAAiB,YACzF,QAAQ,WACJ,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC","sourcesContent":["import { FunctionComponent, PropsWithChildren, ReactNode } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { defaultThemeProp } from '../../theme';\nimport { BaseProps, ForwardProps } from '../../types';\nimport Flex, { FlexProps } from '../Flex';\nimport { StyledPopover } from '../Popover';\n\nimport { StyledCard } from './Card';\nimport { StyledCardFooter } from './CardFooter';\n\nexport interface CardContentProps extends BaseProps {\n /** The content of the Card. */\n children: ReactNode;\n container?: Exclude<FlexProps['container'], boolean>;\n}\n\nexport const StyledCardContent = styled.div(({ theme }) => {\n return css`\n ${StyledPopover} &, &:not(${StyledCard} ${StyledCard} > &) {\n position: relative;\n padding: calc(1.5 * ${theme.base.spacing}) calc(${theme.components.card.padding} * 2);\n\n & + &,\n & + ${StyledCardFooter} {\n padding-block-start: 0;\n }\n }\n `;\n});\n\nStyledCardContent.defaultProps = defaultThemeProp;\n\nconst CardContent: FunctionComponent<CardContentProps & ForwardProps> = ({\n children,\n container,\n ...restProps\n}: PropsWithChildren<CardContentProps & ForwardProps>) => {\n return (\n <Flex {...restProps} container={{ direction: 'column', ...container }} as={StyledCardContent}>\n {children}\n </Flex>\n );\n};\n\nexport default CardContent;\n"]}
|
|
@@ -14,11 +14,11 @@ export const StyledCardFooter = styled.footer(({ theme }) => {
|
|
|
14
14
|
StyledCardFooter.defaultProps = defaultThemeProp;
|
|
15
15
|
const CardFooter = (props) => {
|
|
16
16
|
const { children, justify, ...restProps } = props;
|
|
17
|
-
return (_jsx(Flex,
|
|
17
|
+
return (_jsx(Flex, { as: StyledCardFooter, container: {
|
|
18
18
|
wrap: 'wrap',
|
|
19
19
|
alignItems: 'center',
|
|
20
20
|
justify
|
|
21
|
-
}
|
|
21
|
+
}, ...restProps, children: children }, void 0));
|
|
22
22
|
};
|
|
23
23
|
export default CardFooter;
|
|
24
24
|
//# sourceMappingURL=CardFooter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CardFooter.js","sourceRoot":"","sources":["../../../src/components/Card/CardFooter.tsx"],"names":[],"mappings":";AACA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,IAA4B,MAAM,SAAS,CAAC;AAEnD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAOpC,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IAC1D,OAAO,GAAG,CAAA;MACN,aAAa,aAAa,UAAU,IAAI,UAAU;4BAC5B,KAAK,CAAC,IAAI,CAAC,OAAO,UAAU,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO;;GAElF,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,gBAAgB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAEjD,MAAM,UAAU,GAAsD,CACpE,KAAyC,EACzC,EAAE;IACF,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK,CAAC;IAElD,OAAO,CACL,KAAC,IAAI,
|
|
1
|
+
{"version":3,"file":"CardFooter.js","sourceRoot":"","sources":["../../../src/components/Card/CardFooter.tsx"],"names":[],"mappings":";AACA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,IAA4B,MAAM,SAAS,CAAC;AAEnD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAOpC,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IAC1D,OAAO,GAAG,CAAA;MACN,aAAa,aAAa,UAAU,IAAI,UAAU;4BAC5B,KAAK,CAAC,IAAI,CAAC,OAAO,UAAU,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO;;GAElF,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,gBAAgB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAEjD,MAAM,UAAU,GAAsD,CACpE,KAAyC,EACzC,EAAE;IACF,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK,CAAC;IAElD,OAAO,CACL,KAAC,IAAI,IACH,EAAE,EAAE,gBAAgB,EACpB,SAAS,EAAE;YACT,IAAI,EAAE,MAAM;YACZ,UAAU,EAAE,QAAQ;YACpB,OAAO;SACR,KACG,SAAS,YAEZ,QAAQ,WACJ,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,UAAU,CAAC","sourcesContent":["import { FunctionComponent, PropsWithChildren } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { defaultThemeProp } from '../../theme';\nimport Flex, { FlexContainerProps } from '../Flex';\nimport { BaseProps, ForwardProps } from '../../types';\nimport { StyledPopover } from '../Popover';\n\nimport { StyledCard } from './Card';\n\nexport interface CardFooterProps extends BaseProps {\n /** [justify-content](https://css-tricks.com/almanac/properties/j/justify-content/) */\n justify?: FlexContainerProps['justify'];\n}\n\nexport const StyledCardFooter = styled.footer(({ theme }) => {\n return css`\n ${StyledPopover} &, &:not(${StyledCard} ${StyledCard} > &) {\n padding: calc(1.5 * ${theme.base.spacing}) calc(${theme.components.card.padding} * 2);\n }\n `;\n});\n\nStyledCardFooter.defaultProps = defaultThemeProp;\n\nconst CardFooter: FunctionComponent<CardFooterProps & ForwardProps> = (\n props: PropsWithChildren<CardFooterProps>\n) => {\n const { children, justify, ...restProps } = props;\n\n return (\n <Flex\n as={StyledCardFooter}\n container={{\n wrap: 'wrap',\n alignItems: 'center',\n justify\n }}\n {...restProps}\n >\n {children}\n </Flex>\n );\n};\n\nexport default CardFooter;\n"]}
|
|
@@ -23,7 +23,7 @@ export const StyledCardHeader = styled.header(({ theme, onClick }) => {
|
|
|
23
23
|
});
|
|
24
24
|
StyledCardHeader.defaultProps = defaultThemeProp;
|
|
25
25
|
const CardHeader = forwardRef(({ children, actions, ...restProps }, ref) => {
|
|
26
|
-
return (_jsx(Flex,
|
|
26
|
+
return (_jsx(Flex, { container: { alignItems: 'center', justify: 'between' }, as: StyledCardHeader, ...restProps, ref: ref, children: actions ? (_jsxs(_Fragment, { children: [_jsx(Flex, { container: { alignItems: 'center' }, item: { grow: 1 }, children: children }, void 0), _jsx("div", { children: actions }, void 0)] }, void 0)) : (children) }, void 0));
|
|
27
27
|
});
|
|
28
28
|
CardHeader.displayName = 'CardHeader';
|
|
29
29
|
export default CardHeader;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CardHeader.js","sourceRoot":"","sources":["../../../src/components/Card/CardHeader.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAwD,MAAM,OAAO,CAAC;AACzF,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,IAAI,MAAM,SAAS,CAAC;AAE3B,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CA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EAAE;IACpF,OAAO,GAAG,CAAA;MACN,aAAa,aAAa,UAAU,IAAI,UAAU;4BAC5B,KAAK,CAAC,IAAI,CAAC,OAAO,UAAU,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO;;UAE3E,iBAAiB;;;;;UAKjB,OAAO,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,SAAS;;;GAG/C,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,gBAAgB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAEjD,MAAM,UAAU,GAAsD,UAAU,CAC9E,CACE,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,SAAS,EAAsC,EACvE,GAA2B,EAC3B,EAAE;IACF,OAAO,CACL,KAAC,IAAI,IACH,SAAS,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,EACvD,EAAE,EAAE,gBAAgB,KAChB,SAAS,EACb,GAAG,EAAE,GAAG,YAEP,OAAO,CAAC,CAAC,CAAC,CACT,8BACE,KAAC,IAAI,IAAC,SAAS,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,YACzD,QAAQ,WACJ,EACP,wBAAM,OAAO,WAAO,YACnB,CACJ,CAAC,CAAC,CAAC,CACF,QAAQ,CACT,WACI,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,UAAU,CAAC,WAAW,GAAG,YAAY,CAAC;AACtC,eAAe,UAAU,CAAC","sourcesContent":["import { forwardRef, FunctionComponent, PropsWithChildren, ReactNode, Ref } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { defaultThemeProp } from '../../theme';\nimport Flex from '../Flex';\nimport { BaseProps, ForwardProps } from '../../types';\nimport { StyledPopover } from '../Popover';\n\nimport { StyledCard } from './Card';\nimport { StyledCardContent } from './CardContent';\n\nexport interface CardHeaderProps extends BaseProps {\n /** The Card header content. */\n children: ReactNode;\n /** Action Buttons that will render within the header. */\n actions?: ReactNode;\n /** Ref for the wrapping element. */\n ref?: Ref<HTMLDivElement>;\n}\n\nexport const StyledCardHeader = styled.header<CardHeaderProps>(({ theme, onClick }) => {\n return css`\n ${StyledPopover} &, &:not(${StyledCard} ${StyledCard} > &) {\n padding: calc(1.5 * ${theme.base.spacing}) calc(${theme.components.card.padding} * 2);\n\n + ${StyledCardContent} {\n padding-block-start: 0;\n }\n\n &:hover {\n ${onClick ? 'cursor: pointer;' : undefined}\n }\n }\n `;\n});\n\nStyledCardHeader.defaultProps = defaultThemeProp;\n\nconst CardHeader: FunctionComponent<CardHeaderProps & ForwardProps> = forwardRef(\n (\n { children, actions, ...restProps }: PropsWithChildren<CardHeaderProps>,\n ref: CardHeaderProps['ref']\n ) => {\n return (\n <Flex\n container={{ alignItems: 'center', justify: 'between' }}\n as={StyledCardHeader}\n {...restProps}\n ref={ref}\n >\n {actions ? (\n <>\n <Flex container={{ alignItems: 'center' }} item={{ grow: 1 }}>\n {children}\n </Flex>\n <div>{actions}</div>\n </>\n ) : (\n children\n )}\n </Flex>\n );\n }\n);\n\nCardHeader.displayName = 'CardHeader';\nexport default CardHeader;\n"]}
|
|
@@ -10,7 +10,7 @@ const StyledCardMedia = styled.div `
|
|
|
10
10
|
}
|
|
11
11
|
`;
|
|
12
12
|
const CardMedia = ({ children, ...restProps }) => {
|
|
13
|
-
return (_jsx(Flex,
|
|
13
|
+
return (_jsx(Flex, { container: true, as: StyledCardMedia, ...restProps, children: children }, void 0));
|
|
14
14
|
};
|
|
15
15
|
export default CardMedia;
|
|
16
16
|
export { StyledCardMedia };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CardMedia.js","sourceRoot":"","sources":["../../../src/components/Card/CardMedia.tsx"],"names":[],"mappings":";AACA,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,IAAI,MAAM,SAAS,CAAC;AAQ3B,MAAM,eAAe,GAAG,MAAM,CAAC,GAAG,CAAyB;;;;;;;CAO1D,CAAC;AAEF,MAAM,SAAS,GAAqD,CAAC,EACnE,QAAQ,EACR,GAAG,SAAS,EACG,EAAE,EAAE;IACnB,OAAO,CACL,KAAC,IAAI,
|
|
1
|
+
{"version":3,"file":"CardMedia.js","sourceRoot":"","sources":["../../../src/components/Card/CardMedia.tsx"],"names":[],"mappings":";AACA,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,IAAI,MAAM,SAAS,CAAC;AAQ3B,MAAM,eAAe,GAAG,MAAM,CAAC,GAAG,CAAyB;;;;;;;CAO1D,CAAC;AAEF,MAAM,SAAS,GAAqD,CAAC,EACnE,QAAQ,EACR,GAAG,SAAS,EACG,EAAE,EAAE;IACnB,OAAO,CACL,KAAC,IAAI,IAAC,SAAS,QAAC,EAAE,EAAE,eAAe,KAAM,SAAS,YAC/C,QAAQ,WACJ,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC;AACzB,OAAO,EAAE,eAAe,EAAE,CAAC","sourcesContent":["import { FunctionComponent, ReactNode } from 'react';\nimport styled from 'styled-components';\n\nimport Flex from '../Flex';\nimport { BaseProps, ForwardProps } from '../../types';\n\nexport interface CardMediaProps extends BaseProps {\n /** The content for the media. */\n children: ReactNode;\n}\n\nconst StyledCardMedia = styled.div<Partial<CardMediaProps>>`\n img,\n video,\n audio {\n object-fit: cover;\n width: 100%;\n }\n`;\n\nconst CardMedia: FunctionComponent<CardMediaProps & ForwardProps> = ({\n children,\n ...restProps\n}: CardMediaProps) => {\n return (\n <Flex container as={StyledCardMedia} {...restProps}>\n {children}\n </Flex>\n );\n};\n\nexport default CardMedia;\nexport { StyledCardMedia };\n"]}
|
|
@@ -30,7 +30,7 @@ const CollapsibleCard = (props) => {
|
|
|
30
30
|
setCollapsed(!collapsed);
|
|
31
31
|
onChange?.({ collapsed: !collapsed });
|
|
32
32
|
};
|
|
33
|
-
return (_jsxs(Card,
|
|
33
|
+
return (_jsxs(Card, { ...restProps, children: [media && _jsx(CardMedia, { children: media }, void 0), _jsxs(CardHeader, { actions: actions, onClick: toggleCollapse, children: [_jsx(StyledToggleButton, { as: Button, variant: 'simple', icon: true, onClick: toggleCollapse, collapsed: collapsed, children: _jsx(Icon, { name: 'caret-down' }, void 0) }, void 0), header] }, void 0), _jsxs(ExpandCollapse, { collapsed: collapsed, children: [children && _jsx(CardContent, { children: children }, void 0), footer && _jsx(CardFooter, { justify: 'center', children: footer }, void 0)] }, void 0)] }, void 0));
|
|
34
34
|
};
|
|
35
35
|
CollapsibleCard.defaultProps = defaultProps;
|
|
36
36
|
export default CollapsibleCard;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CollapsibleCard.js","sourceRoot":"","sources":["../../../src/components/Card/CollapsibleCard.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAiE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAChG,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,IAAI,EAAE,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,aAAa,MAAM,+BAA+B,CAAC;AAC/D,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAE/C,OAAO,IAAmB,MAAM,QAAQ,CAAC;AACzC,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,UAAU,MAAM,cAAc,CAAC;AAEtC,YAAY,CAAC,aAAa,CAAC,CAAC;AAe5B,MAAM,YAAY,GAAkC,EAAE,CAAC;AAEvD,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,CAAyB,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE;IACxF,OAAO,GAAG,CA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AE,OAAO,EAAE,OAAO,EAAE,cAAc,aACnD,KAAC,kBAAkB,IACjB,EAAE,EAAE,MAAM,EACV,OAAO,EAAC,QAAQ,EAChB,IAAI,QACJ,OAAO,EAAE,cAAc,EACvB,SAAS,EAAE,SAAS,YAEpB,KAAC,IAAI,IAAC,IAAI,EAAC,YAAY,WAAG,WACP,EACpB,MAAM,YACI,EACb,MAAC,cAAc,IAAC,SAAS,EAAE,SAAS,aACjC,QAAQ,IAAI,KAAC,WAAW,cAAE,QAAQ,WAAe,EACjD,MAAM,IAAI,KAAC,UAAU,IAAC,OAAO,EAAC,QAAQ,YAAE,MAAM,WAAc,YAC9C,YACZ,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,CAAC,YAAY,GAAG,YAAY,CAAC;AAE5C,eAAe,eAAe,CAAC","sourcesContent":["import { FunctionComponent, ReactElement, ReactNode, PropsWithChildren, useState } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport Button from '../Button';\nimport { defaultThemeProp } from '../../theme';\nimport Icon, { registerIcon } from '../Icon';\nimport * as caretDownIcon from '../Icon/icons/caret-down.icon';\nimport ExpandCollapse from '../ExpandCollapse';\n\nimport Card, { CardProps } from './Card';\nimport CardHeader from './CardHeader';\nimport CardMedia from './CardMedia';\nimport CardContent from './CardContent';\nimport CardFooter from './CardFooter';\n\nregisterIcon(caretDownIcon);\n\nexport interface CollapsibleCardProps extends CardProps {\n /** The header content. */\n header?: ReactElement;\n /** Action Buttons that will render in the header. */\n actions?: ReactElement | ReactElement[];\n /** The footer content. */\n footer?: ReactNode;\n /** CardMedia content that will render above the header. */\n media?: ReactElement;\n /** Callback when the Card toggles from collapsed to expanded. */\n onChange?: (event: { collapsed: boolean }) => void;\n}\n\nconst defaultProps: Partial<CollapsibleCardProps> = {};\n\nconst StyledToggleButton = styled.button<{ collapsed: boolean }>(({ theme, collapsed }) => {\n return css`\n transition: transform calc(2 * ${theme.base.animation.speed})\n ${theme.base.animation.timing.ease};\n transform: ${collapsed ? 'rotate(-90deg)' : 'rotate(0)'};\n margin-inline-end: calc(0.5 * ${theme.base.spacing});\n `;\n});\n\nStyledToggleButton.defaultProps = defaultThemeProp;\n\n/** @deprecated */\nconst CollapsibleCard: FunctionComponent<CollapsibleCardProps> = (\n props: PropsWithChildren<CollapsibleCardProps>\n) => {\n const { header, actions, footer, media, onChange, children, ...restProps } = props;\n const [collapsed, setCollapsed] = useState(false);\n\n const toggleCollapse = () => {\n setCollapsed(!collapsed);\n onChange?.({ collapsed: !collapsed });\n };\n\n return (\n <Card {...restProps}>\n {media && <CardMedia>{media}</CardMedia>}\n <CardHeader actions={actions} onClick={toggleCollapse}>\n <StyledToggleButton\n as={Button}\n variant='simple'\n icon\n onClick={toggleCollapse}\n collapsed={collapsed}\n >\n <Icon name='caret-down' />\n </StyledToggleButton>\n {header}\n </CardHeader>\n <ExpandCollapse collapsed={collapsed}>\n {children && <CardContent>{children}</CardContent>}\n {footer && <CardFooter justify='center'>{footer}</CardFooter>}\n </ExpandCollapse>\n </Card>\n );\n};\n\nCollapsibleCard.defaultProps = defaultProps;\n\nexport default CollapsibleCard;\n"]}
|
|
@@ -38,7 +38,7 @@ const SelectableCard = (props) => {
|
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
40
|
const debouncedClickListener = () => debounce(onCardClick, 100)();
|
|
41
|
-
return (_jsx(StyledSelectableCard,
|
|
41
|
+
return (_jsx(StyledSelectableCard, { type: type, interactive: true, checked: checked, onClick: () => debouncedClickListener(), children: _jsx(CardContent, { children: _jsx(Flex, { container: { alignItems: 'start' }, children: _jsx("div", { children: _jsx(RadioCheck, { checked: checked, type: type, label: children, onChange: () => debouncedClickListener() }, void 0) }, void 0) }, void 0) }, void 0) }, void 0));
|
|
42
42
|
};
|
|
43
43
|
SelectableCard.defaultProps = defaultProps;
|
|
44
44
|
export default SelectableCard;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectableCard.js","sourceRoot":"","sources":["../../../src/components/Card/Sel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AAG,UAAU;;;CAG1B,CAAC;AAEF,oBAAoB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAErD,MAAM,cAAc,GAA0D,CAC5E,KAA0B,EAC1B,EAAE;IACF,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAC3D,MAAM,CAAC,OAAO,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC;IAE5D,MAAM,WAAW,GAAG,GAAG,EAAE;QACvB,aAAa,CAAC,CAAC,OAAO,CAAC,CAAC;QACxB,IAAI,QAAQ,EAAE;YACZ,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;SACjC;IACH,CAAC,CAAC;IAEF,MAAM,sBAAsB,GAAG,GAAG,EAAE,CAAC,QAAQ,CAAC,WAAW,EAAE,GAAG,CAAC,EAAE,CAAC;IAElE,OAAO,CACL,KAAC,oBAAoB,IACnB,IAAI,EAAE,IAAI,EACV,WAAW,QACX,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,GAAG,EAAE,CAAC,sBAAsB,EAAE,YAEvC,KAAC,WAAW,cACV,KAAC,IAAI,IAAC,SAAS,EAAE,EAAE,UAAU,EAAE,OAAO,EAAE,YACtC,wBACE,KAAC,UAAU,IACT,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,QAAQ,EACf,QAAQ,EAAE,GAAG,EAAE,CAAC,sBAAsB,EAAE,WACxC,WACE,WACD,WACK,WACO,CACxB,CAAC;AACJ,CAAC,CAAC;AAEF,cAAc,CAAC,YAAY,GAAG,YAAY,CAAC;AAE3C,eAAe,cAAc,CAAC","sourcesContent":["import { FunctionComponent, ReactElement, useState } from 'react';\nimport styled from 'styled-components';\n\nimport { BaseProps, ForwardProps } from '../../types';\nimport { defaultThemeProp } from '../../theme';\nimport { debounce } from '../../utils';\nimport Flex, { StyledFlex } from '../Flex/Flex';\nimport RadioCheck from '../RadioCheck';\nimport { RadioCheckProps } from '../RadioCheck/RadioCheck';\n\nimport CardContent from './CardContent';\nimport { StyledCard } from './Card';\n\nexport interface SelectableCardProps extends BaseProps {\n /** The type of Card selection. Either 'checkbox' or 'radio'. */\n type: RadioCheckProps['type'];\n /** The content of the Card. */\n children: ReactElement<any>;\n /**\n * Determines whether the Card is selected by default.\n * @default false\n */\n defaultChecked?: RadioCheckProps['defaultChecked'];\n /** Callback when the Card is selected or de-selected. */\n onChange?: (event: { checked: boolean }) => void;\n}\n\nconst defaultProps: Partial<SelectableCardProps> = {\n defaultChecked: false\n};\n\ninterface StyledSelectableCardProps extends SelectableCardProps {\n checked: boolean;\n}\n\nconst StyledSelectableCard = styled(StyledCard)<StyledSelectableCardProps>`\n border: 0.0625rem solid\n ${props => (props.checked ? props.theme.base.palette.interactive : '#f4f4f4')};\n\n &:hover {\n border: 0.0625rem solid\n ${props => (props.checked ? props.theme.base.palette.interactive : 'gray')};\n }\n\n ${StyledFlex}${StyledFlex}:nth-child(1) {\n margin-right: 0.625rem;\n }\n\n ${StyledFlex}${StyledFlex}:nth-child(2) {\n margin-top: -0.1875rem;\n }\n`;\n\nStyledSelectableCard.defaultProps = defaultThemeProp;\n\nconst SelectableCard: FunctionComponent<SelectableCardProps & ForwardProps> = (\n props: SelectableCardProps\n) => {\n const { type, defaultChecked, onChange, children } = props;\n const [checked, changeChecked] = useState(!!defaultChecked);\n\n const onCardClick = () => {\n changeChecked(!checked);\n if (onChange) {\n onChange({ checked: !checked });\n }\n };\n\n const debouncedClickListener = () => debounce(onCardClick, 100)();\n\n return (\n <StyledSelectableCard\n type={type}\n interactive\n checked={checked}\n onClick={() => debouncedClickListener()}\n >\n <CardContent>\n <Flex container={{ alignItems: 'start' }}>\n <div>\n <RadioCheck\n checked={checked}\n type={type}\n label={children}\n onChange={() => debouncedClickListener()}\n />\n </div>\n </Flex>\n </CardContent>\n </StyledSelectableCard>\n );\n};\n\nSelectableCard.defaultProps = defaultProps;\n\nexport default SelectableCard;\n"]}
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { forwardRef } from 'react';
|
|
3
3
|
import RadioCheck from '../RadioCheck';
|
|
4
4
|
// Odd issue with SB doc prop table not being generated when called Checkbox...so using CB
|
|
5
|
-
const CB = forwardRef((props, ref) => (_jsx(RadioCheck,
|
|
5
|
+
const CB = forwardRef((props, ref) => (_jsx(RadioCheck, { ...props, type: 'checkbox', ref: ref }, void 0)));
|
|
6
6
|
// Adding here for doc purposes only
|
|
7
7
|
CB.defaultProps = RadioCheck.defaultProps;
|
|
8
8
|
export default CB;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.js","sourceRoot":"","sources":["../../../src/components/Checkbox/Checkbox.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,UAAU,EAAO,MAAM,OAAO,CAAC;AAG5C,OAAO,UAA+B,MAAM,eAAe,CAAC;AA8B5D,0FAA0F;AAC1F,MAAM,EAAE,GAAqC,UAAU,CACrD,CAAC,KAAoB,EAAE,GAA0B,EAAE,EAAE,CAAC,CACpD,KAAC,UAAU,
|
|
1
|
+
{"version":3,"file":"Checkbox.js","sourceRoot":"","sources":["../../../src/components/Checkbox/Checkbox.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,UAAU,EAAO,MAAM,OAAO,CAAC;AAG5C,OAAO,UAA+B,MAAM,eAAe,CAAC;AA8B5D,0FAA0F;AAC1F,MAAM,EAAE,GAAqC,UAAU,CACrD,CAAC,KAAoB,EAAE,GAA0B,EAAE,EAAE,CAAC,CACpD,KAAC,UAAU,OAAK,KAAK,EAAE,IAAI,EAAC,UAAU,EAAC,GAAG,EAAE,GAAG,WAAI,CACpD,CACF,CAAC;AAEF,oCAAoC;AACpC,EAAE,CAAC,YAAY,GAAG,UAAU,CAAC,YAAY,CAAC;AAE1C,eAAe,EAAE,CAAC","sourcesContent":["import { FC, forwardRef, Ref } from 'react';\n\nimport { FormControlProps } from '../FormControl';\nimport RadioCheck, { RadioCheckProps } from '../RadioCheck';\nimport { ForwardProps } from '../../types';\n\nexport interface CheckboxProps {\n /**\n * Sets DOM id for the control and associates label element via 'for' attribute.\n * If an id is not pass, a random id will be generated for any render.\n */\n id?: FormControlProps['id'];\n /** Pass a string or a fragment with an Icon and string. */\n label?: FormControlProps['label'];\n /** Indicate if the field is required. The browser defaults to false. */\n required?: FormControlProps['required'];\n /** Disable the control. The browser defaults to false. */\n disabled?: FormControlProps['disabled'];\n /** Sets html name attribute for the underlying control. Useful for mapping to a data field. */\n name?: FormControlProps['name'];\n /** Sets checked prop via onChange when using as controlled component. */\n checked?: RadioCheckProps['checked'];\n /** Initialize checked prop when using as uncontrolled component. */\n defaultChecked?: RadioCheckProps['defaultChecked'];\n /**\n * Sets Checkbox to an an [indeterminate state](https://css-tricks.com/almanac/selectors/i/indeterminate/#indeterminate-checkboxes).\n * @default false\n */\n indeterminate?: RadioCheckProps['indeterminate'];\n /** Set visual state based on a validation state. */\n status?: FormControlProps['status'];\n}\n\n// Odd issue with SB doc prop table not being generated when called Checkbox...so using CB\nconst CB: FC<CheckboxProps & ForwardProps> = forwardRef(\n (props: CheckboxProps, ref: Ref<HTMLInputElement>) => (\n <RadioCheck {...props} type='checkbox' ref={ref} />\n )\n);\n\n// Adding here for doc purposes only\nCB.defaultProps = RadioCheck.defaultProps;\n\nexport default CB;\n"]}
|
|
@@ -107,13 +107,13 @@ const ColorPicker = forwardRef((props, ref) => {
|
|
|
107
107
|
popoverEl?.focus();
|
|
108
108
|
}
|
|
109
109
|
}, [showPopOver]);
|
|
110
|
-
return (_jsx(FormField,
|
|
110
|
+
return (_jsx(FormField, { inline: inline, container: inline ? { justify: 'between' } : undefined, as: StyledColorPicker, id: id, label: label, labelHidden: labelHidden, swatchOnly: swatchOnly, info: info, disabled: disabled, status: status, required: required, children: _jsxs(Flex, { container: { alignItems: 'center' }, item: swatchOnly ? { alignSelf: 'start' } : undefined, as: StyledFormControl, disabled: disabled, status: status, required: required, readOnly: readOnly, onClick: readOnly ? undefined : () => setShowPopOver(true), children: [_jsx("input", { ...restProps, id: id, type: readOnly ? undefined : 'color', ref: inputRef, defaultValue: value, disabled: disabled, required: required, readOnly: readOnly, onClick: e => {
|
|
111
111
|
e.preventDefault();
|
|
112
112
|
if (readOnly)
|
|
113
113
|
e.preventDefault();
|
|
114
|
-
} }
|
|
114
|
+
} }, void 0), _jsx("div", { style: { backgroundColor: value }, ref: maskedSwatchRef }, void 0), !swatchOnly && value, _jsx(Popover, { placement: 'bottom-start', style: { zIndex: '3000' }, show: showPopOver, ref: setPopoverEl, groupId: 'popover', target: maskedSwatchRef.current, children: _jsx(ChromePicker, { disableAlpha: !alpha, color: value, onChange: (color, e) => {
|
|
115
115
|
onChange?.(color, e);
|
|
116
|
-
} }, void 0) }
|
|
116
|
+
} }, void 0) }, void 0)] }, void 0) }, void 0));
|
|
117
117
|
});
|
|
118
118
|
export default ColorPicker;
|
|
119
119
|
//# sourceMappingURL=ColorPicker.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorPicker.js","sourceRoot":"","sources":["../../../src/components/ColorPicker/ColorPicker.tsx"],"names":[],"mappings":";AAAA,OAAO,EAEL,UAAU,EAEV,QAAQ,EAGR,SAAS,EACV,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,YAAY,EAAsB,MAAM,aAAa,CAAC;AAG/D,OAAO,SAA6B,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAoB,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,kBAAkB,EA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;wBACX,CAAC,CAAC,cAAc,EAAE,CAAC;wBACnB,IAAI,QAAQ;4BAAE,CAAC,CAAC,cAAc,EAAE,CAAC;oBACnC,CAAC,YACD,EACF,cAAK,KAAK,EAAE,EAAE,eAAe,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,eAAe,WAAI,EAC/D,CAAC,UAAU,IAAI,KAAK,EACrB,KAAC,OAAO,kBACN,SAAS,EAAC,cAAc,EACxB,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,EACzB,IAAI,EAAE,WAAW,EACjB,GAAG,EAAE,YAAY,EACjB,OAAO,EAAC,SAAS,EACjB,MAAM,EAAE,eAAe,CAAC,OAAO,gBAE/B,KAAC,YAAY,IACX,YAAY,EAAE,CAAC,KAAK,EACpB,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE;4BACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;wBACvB,CAAC,WACD,YACM,aACL,YACG,CACb,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,WAAW,CAAC","sourcesContent":["import {\n FC,\n forwardRef,\n Ref,\n useState,\n PropsWithoutRef,\n MouseEventHandler,\n useEffect\n} from 'react';\nimport styled, { css } from 'styled-components';\nimport { hideVisually } from 'polished';\nimport { ChromePicker, ColorChangeHandler } from 'react-color';\n\nimport { BaseProps, ForwardProps, PropsWithDefaults } from '../../types';\nimport FormField, { FormFieldProps } from '../FormField';\nimport { defaultThemeProp } from '../../theme';\nimport { FormControlProps, StyledFormControl } from '../FormControl';\nimport Flex from '../Flex';\nimport { useConsolidatedRef, useUID, useElement, useOuterEvent } from '../../hooks';\nimport Popover from '../Popover';\n\nexport interface ColorPickerProps extends BaseProps {\n /** label for the color picker control */\n label: FormControlProps['label'];\n /**\n * Sets DOM id for the control and associates label element via 'for' attribute.\n * If an id is not passed, a random id will be generated for any render.\n */\n id?: FormControlProps['id'];\n /**\n * Color picker value in hex\n * @default \"#000000\"\n */\n value?: FormControlProps['value'];\n /**\n * Show color swatch without hex value display.\n * @default false\n */\n swatchOnly?: boolean;\n /**\n * Enables alpha slider.\n * @default false\n */\n alpha?: boolean;\n /** Indicate if the field is required. The browser defaults to false. */\n required?: FormControlProps['required'];\n /** Disable the control. */\n disabled?: FormControlProps['disabled'];\n /** Visually hides the label region. */\n labelHidden?: FormControlProps['labelHidden'];\n /** It is recommended to pass a simple string to offer guidance. Text will be styled based on status prop. */\n info?: FormControlProps['info'];\n /** Set visual state based on a validation state. */\n status?: FormControlProps['status'];\n /** Makes the input non editable and non clickable. The browser defaults to false. */\n readOnly?: FormControlProps['readOnly'];\n /** Sets html name attribute for the underlying control. Useful for mapping to a data field. */\n name?: FormControlProps['name'];\n /** Layout field elements inline in a row. */\n inline?: FormFieldProps['inline'];\n /** onChange event handler that gets called on change of value. */\n onChange?: ColorChangeHandler;\n /** onBeforeClose of the color picker */\n onBeforeClose?: () => void;\n /** Called when the underlying input element is clicked. This should be rarely if ever used. */\n onClick?: MouseEventHandler<HTMLInputElement>;\n /** Ref placed on the input element. */\n ref?: Ref<HTMLInputElement>;\n}\n\ntype ColorPickerPropsWithDefaults = PropsWithDefaults<ColorPickerProps, 'value' | 'swatchOnly'>;\n\nconst StyledColorPicker = styled.div<Pick<ColorPickerPropsWithDefaults, 'swatchOnly'>>(\n ({ theme, swatchOnly }) => {\n const size = theme.components.input.height;\n const borderWidth = theme.components['form-control']['border-width'];\n\n return css`\n ${StyledFormControl} {\n overflow: hidden;\n text-transform: uppercase;\n ${!swatchOnly &&\n css`\n min-width: 8rem;\n `}\n\n ${!swatchOnly &&\n css`\n padding-inline-end: ${theme.base.spacing};\n `}\n\n &:focus-within {\n box-shadow: ${theme.base.shadow.focus};\n border: none;\n }\n\n & > input {\n ${hideVisually}\n\n & + div {\n height: calc(${size} - (2 * ${borderWidth}));\n\n ${swatchOnly\n ? css`\n width: calc(${size} - (2 * ${borderWidth}));\n `\n : css`\n min-width: calc(${size} - ${borderWidth});\n margin-inline-end: ${theme.base.spacing};\n border-inline-end: ${borderWidth} solid\n ${theme.components['form-control']['border-color']};\n `}\n }\n\n &:focus + div {\n width: ${size};\n height: ${size};\n }\n }\n\n & input {\n height: 2rem !important;\n min-height: 2rem;\n color: #000000 !important;\n background-color: #ffffff !important;\n font-size: 0.8125rem !important;\n font-family: ${theme.base['font-family']};\n\n & + label {\n font-weight: 600;\n color: rgba(0, 0, 0, 0.6) !important;\n font-size: 0.8125rem !important;\n font-family: ${theme.base['font-family']};\n }\n }\n }\n `;\n }\n);\n\nStyledColorPicker.defaultProps = defaultThemeProp;\n\nconst ColorPicker: FC<ColorPickerProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<ColorPickerProps>, ref: ColorPickerProps['ref']) => {\n const uid = useUID();\n const {\n id = uid,\n value = '#000000',\n label,\n info,\n disabled,\n status,\n required,\n readOnly,\n labelHidden,\n swatchOnly = false,\n alpha = false,\n inline,\n onClick,\n onChange,\n onBeforeClose,\n ...restProps\n } = props;\n\n const inputRef = useConsolidatedRef(ref);\n const maskedSwatchRef = useConsolidatedRef<HTMLDivElement>();\n const [popoverEl, setPopoverEl] = useElement<HTMLElement>(null);\n const [showPopOver, setShowPopOver] = useState(false);\n\n const hidePopover = () => {\n if (showPopOver) {\n onBeforeClose?.();\n }\n\n setShowPopOver(false);\n };\n\n const closePopover = (e: KeyboardEvent) => {\n if (e.key === 'Escape') {\n e.preventDefault();\n hidePopover();\n }\n };\n\n useOuterEvent('mousedown', [popoverEl], hidePopover);\n\n useEffect(() => {\n document.addEventListener('keydown', closePopover);\n popoverEl?.addEventListener('keydown', closePopover);\n return () => {\n document.removeEventListener('keydown', closePopover);\n popoverEl?.removeEventListener('keydown', closePopover);\n };\n }, [popoverEl]);\n\n useEffect(() => {\n if (showPopOver) {\n popoverEl?.focus();\n }\n }, [showPopOver]);\n\n return (\n <FormField\n inline={inline}\n container={inline ? { justify: 'between' } : undefined}\n as={StyledColorPicker}\n id={id}\n label={label}\n labelHidden={labelHidden}\n swatchOnly={swatchOnly}\n info={info}\n disabled={disabled}\n status={status}\n required={required}\n >\n <Flex\n container={{ alignItems: 'center' }}\n item={swatchOnly ? { alignSelf: 'start' } : undefined}\n as={StyledFormControl}\n disabled={disabled}\n status={status}\n required={required}\n readOnly={readOnly}\n onClick={readOnly ? undefined : () => setShowPopOver(true)}\n >\n <input\n {...restProps}\n id={id}\n type={readOnly ? undefined : 'color'}\n ref={inputRef}\n defaultValue={value}\n disabled={disabled}\n required={required}\n readOnly={readOnly}\n onClick={e => {\n e.preventDefault();\n if (readOnly) e.preventDefault();\n }}\n />\n <div style={{ backgroundColor: value }} ref={maskedSwatchRef} />\n {!swatchOnly && value}\n <Popover\n placement='bottom-start'\n style={{ zIndex: '3000' }}\n show={showPopOver}\n ref={setPopoverEl}\n groupId='popover'\n target={maskedSwatchRef.current}\n >\n <ChromePicker\n disableAlpha={!alpha}\n color={value}\n onChange={(color, e) => {\n onChange?.(color, e);\n }}\n />\n </Popover>\n </Flex>\n </FormField>\n );\n }\n);\n\nexport default ColorPicker;\n"]}
|
|
1
|
+
{"version":3,"file":"ColorPicker.js","sourceRoot":"","sources":["../../../src/components/ColorPicker/ColorPicker.tsx"],"names":[],"mappings":";AAAA,OAAO,EAEL,UAAU,EAEV,QAAQ,EAGR,SAAS,EACV,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,YAAY,EAAsB,MAAM,aAAa,CAAC;AAG/D,OAAO,SAA6B,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAoB,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,kBAAkB,EAAE,M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AC,CAAC,cAAc,EAAE,CAAC;wBACnB,IAAI,QAAQ;4BAAE,CAAC,CAAC,cAAc,EAAE,CAAC;oBACnC,CAAC,WACD,EACF,cAAK,KAAK,EAAE,EAAE,eAAe,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,eAAe,WAAI,EAC/D,CAAC,UAAU,IAAI,KAAK,EACrB,KAAC,OAAO,IACN,SAAS,EAAC,cAAc,EACxB,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,EACzB,IAAI,EAAE,WAAW,EACjB,GAAG,EAAE,YAAY,EACjB,OAAO,EAAC,SAAS,EACjB,MAAM,EAAE,eAAe,CAAC,OAAO,YAE/B,KAAC,YAAY,IACX,YAAY,EAAE,CAAC,KAAK,EACpB,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE;4BACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;wBACvB,CAAC,WACD,WACM,YACL,WACG,CACb,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,WAAW,CAAC","sourcesContent":["import {\n FC,\n forwardRef,\n Ref,\n useState,\n PropsWithoutRef,\n MouseEventHandler,\n useEffect\n} from 'react';\nimport styled, { css } from 'styled-components';\nimport { hideVisually } from 'polished';\nimport { ChromePicker, ColorChangeHandler } from 'react-color';\n\nimport { BaseProps, ForwardProps, PropsWithDefaults } from '../../types';\nimport FormField, { FormFieldProps } from '../FormField';\nimport { defaultThemeProp } from '../../theme';\nimport { FormControlProps, StyledFormControl } from '../FormControl';\nimport Flex from '../Flex';\nimport { useConsolidatedRef, useUID, useElement, useOuterEvent } from '../../hooks';\nimport Popover from '../Popover';\n\nexport interface ColorPickerProps extends BaseProps {\n /** label for the color picker control */\n label: FormControlProps['label'];\n /**\n * Sets DOM id for the control and associates label element via 'for' attribute.\n * If an id is not passed, a random id will be generated for any render.\n */\n id?: FormControlProps['id'];\n /**\n * Color picker value in hex\n * @default \"#000000\"\n */\n value?: FormControlProps['value'];\n /**\n * Show color swatch without hex value display.\n * @default false\n */\n swatchOnly?: boolean;\n /**\n * Enables alpha slider.\n * @default false\n */\n alpha?: boolean;\n /** Indicate if the field is required. The browser defaults to false. */\n required?: FormControlProps['required'];\n /** Disable the control. */\n disabled?: FormControlProps['disabled'];\n /** Visually hides the label region. */\n labelHidden?: FormControlProps['labelHidden'];\n /** It is recommended to pass a simple string to offer guidance. Text will be styled based on status prop. */\n info?: FormControlProps['info'];\n /** Set visual state based on a validation state. */\n status?: FormControlProps['status'];\n /** Makes the input non editable and non clickable. The browser defaults to false. */\n readOnly?: FormControlProps['readOnly'];\n /** Sets html name attribute for the underlying control. Useful for mapping to a data field. */\n name?: FormControlProps['name'];\n /** Layout field elements inline in a row. */\n inline?: FormFieldProps['inline'];\n /** onChange event handler that gets called on change of value. */\n onChange?: ColorChangeHandler;\n /** onBeforeClose of the color picker */\n onBeforeClose?: () => void;\n /** Called when the underlying input element is clicked. This should be rarely if ever used. */\n onClick?: MouseEventHandler<HTMLInputElement>;\n /** Ref placed on the input element. */\n ref?: Ref<HTMLInputElement>;\n}\n\ntype ColorPickerPropsWithDefaults = PropsWithDefaults<ColorPickerProps, 'value' | 'swatchOnly'>;\n\nconst StyledColorPicker = styled.div<Pick<ColorPickerPropsWithDefaults, 'swatchOnly'>>(\n ({ theme, swatchOnly }) => {\n const size = theme.components.input.height;\n const borderWidth = theme.components['form-control']['border-width'];\n\n return css`\n ${StyledFormControl} {\n overflow: hidden;\n text-transform: uppercase;\n ${!swatchOnly &&\n css`\n min-width: 8rem;\n `}\n\n ${!swatchOnly &&\n css`\n padding-inline-end: ${theme.base.spacing};\n `}\n\n &:focus-within {\n box-shadow: ${theme.base.shadow.focus};\n border: none;\n }\n\n & > input {\n ${hideVisually}\n\n & + div {\n height: calc(${size} - (2 * ${borderWidth}));\n\n ${swatchOnly\n ? css`\n width: calc(${size} - (2 * ${borderWidth}));\n `\n : css`\n min-width: calc(${size} - ${borderWidth});\n margin-inline-end: ${theme.base.spacing};\n border-inline-end: ${borderWidth} solid\n ${theme.components['form-control']['border-color']};\n `}\n }\n\n &:focus + div {\n width: ${size};\n height: ${size};\n }\n }\n\n & input {\n height: 2rem !important;\n min-height: 2rem;\n color: #000000 !important;\n background-color: #ffffff !important;\n font-size: 0.8125rem !important;\n font-family: ${theme.base['font-family']};\n\n & + label {\n font-weight: 600;\n color: rgba(0, 0, 0, 0.6) !important;\n font-size: 0.8125rem !important;\n font-family: ${theme.base['font-family']};\n }\n }\n }\n `;\n }\n);\n\nStyledColorPicker.defaultProps = defaultThemeProp;\n\nconst ColorPicker: FC<ColorPickerProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<ColorPickerProps>, ref: ColorPickerProps['ref']) => {\n const uid = useUID();\n const {\n id = uid,\n value = '#000000',\n label,\n info,\n disabled,\n status,\n required,\n readOnly,\n labelHidden,\n swatchOnly = false,\n alpha = false,\n inline,\n onClick,\n onChange,\n onBeforeClose,\n ...restProps\n } = props;\n\n const inputRef = useConsolidatedRef(ref);\n const maskedSwatchRef = useConsolidatedRef<HTMLDivElement>();\n const [popoverEl, setPopoverEl] = useElement<HTMLElement>(null);\n const [showPopOver, setShowPopOver] = useState(false);\n\n const hidePopover = () => {\n if (showPopOver) {\n onBeforeClose?.();\n }\n\n setShowPopOver(false);\n };\n\n const closePopover = (e: KeyboardEvent) => {\n if (e.key === 'Escape') {\n e.preventDefault();\n hidePopover();\n }\n };\n\n useOuterEvent('mousedown', [popoverEl], hidePopover);\n\n useEffect(() => {\n document.addEventListener('keydown', closePopover);\n popoverEl?.addEventListener('keydown', closePopover);\n return () => {\n document.removeEventListener('keydown', closePopover);\n popoverEl?.removeEventListener('keydown', closePopover);\n };\n }, [popoverEl]);\n\n useEffect(() => {\n if (showPopOver) {\n popoverEl?.focus();\n }\n }, [showPopOver]);\n\n return (\n <FormField\n inline={inline}\n container={inline ? { justify: 'between' } : undefined}\n as={StyledColorPicker}\n id={id}\n label={label}\n labelHidden={labelHidden}\n swatchOnly={swatchOnly}\n info={info}\n disabled={disabled}\n status={status}\n required={required}\n >\n <Flex\n container={{ alignItems: 'center' }}\n item={swatchOnly ? { alignSelf: 'start' } : undefined}\n as={StyledFormControl}\n disabled={disabled}\n status={status}\n required={required}\n readOnly={readOnly}\n onClick={readOnly ? undefined : () => setShowPopOver(true)}\n >\n <input\n {...restProps}\n id={id}\n type={readOnly ? undefined : 'color'}\n ref={inputRef}\n defaultValue={value}\n disabled={disabled}\n required={required}\n readOnly={readOnly}\n onClick={e => {\n e.preventDefault();\n if (readOnly) e.preventDefault();\n }}\n />\n <div style={{ backgroundColor: value }} ref={maskedSwatchRef} />\n {!swatchOnly && value}\n <Popover\n placement='bottom-start'\n style={{ zIndex: '3000' }}\n show={showPopOver}\n ref={setPopoverEl}\n groupId='popover'\n target={maskedSwatchRef.current}\n >\n <ChromePicker\n disableAlpha={!alpha}\n color={value}\n onChange={(color, e) => {\n onChange?.(color, e);\n }}\n />\n </Popover>\n </Flex>\n </FormField>\n );\n }\n);\n\nexport default ColorPicker;\n"]}
|
|
@@ -101,7 +101,7 @@ const ComboBox = forwardRef((props, ref) => {
|
|
|
101
101
|
setOpen(!open);
|
|
102
102
|
}, [open, onDropdownButtonClickProp]);
|
|
103
103
|
const dropdownButton = useMemo(() => {
|
|
104
|
-
return (menu?.items?.length || onDropdownButtonClickProp || !onChange) && !readOnly ? (_jsx(Button,
|
|
104
|
+
return (menu?.items?.length || onDropdownButtonClickProp || !onChange) && !readOnly ? (_jsx(Button, { "aria-label": t(open ? 'combobox_close_list_button_a11y' : 'combobox_open_list_button_a11y'), icon: true, variant: 'simple', onClick: onDropdownButtonClick, disabled: disabled, tabIndex: '-1', children: _jsx(Icon, { name: open ? 'caret-up' : 'caret-down' }, void 0) }, void 0)) : null;
|
|
105
105
|
}, [onDropdownButtonClick, onChange, readOnly, open, disabled]);
|
|
106
106
|
const onInputClick = useCallback((e) => {
|
|
107
107
|
if (readOnly)
|
|
@@ -117,15 +117,15 @@ const ComboBox = forwardRef((props, ref) => {
|
|
|
117
117
|
// Workaround for the following error from jsx-ast-utils, fixed in version 3.5.0.
|
|
118
118
|
// The prop value with an expression type of JSXFragment could not be resolved. Please file issue to get this fixed immediately.
|
|
119
119
|
const inputActions = (_jsxs(_Fragment, { children: [dropdownButton, actions] }, void 0));
|
|
120
|
-
const Comp = (_jsxs(StyledComboBox,
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
120
|
+
const Comp = (_jsxs(StyledComboBox, { ref: containerRef, as: StyledFormControl, id: `${id}-combobox`, children: [_jsx(ComboBoxInput, { ref: inputRef, role: 'combobox', "aria-haspopup": 'listbox', "aria-expanded": !readOnly && !disabled && open, "aria-autocomplete": 'list', "aria-describedby": `${id}-inputDescription`, selected: selected?.items, spellCheck: false, ...{
|
|
121
|
+
id,
|
|
122
|
+
readOnly,
|
|
123
|
+
disabled,
|
|
124
|
+
onChange,
|
|
125
|
+
value,
|
|
126
|
+
mode,
|
|
127
|
+
status
|
|
128
|
+
}, actions: inputActions, onRemove: selected?.onRemove, onClick: onInputClick, onKeyDown: onInputKeyDown, ...restProps }, void 0), _jsxs(StyledAriaDescription, { id: `${id}-inputDescription`, children: [t('combobox_open_close'), !!onChange && ` ${t('combobox_search_instructions')}`] }, void 0), _jsx(Popover, { show: open && menu !== undefined, target: containerRef.current, placement: 'bottom-start', modifiers: popoverModifiers, strategy: isMobile ? 'absolute' : 'fixed', onMouseDown: (e) => e.preventDefault(), children: menu && (_jsx(Menu, { ref: menuRef, id: menuComponentId, role: 'listbox', mode: mode, ...menu, items: menu.items, focusControlEl: inputRef.current || undefined, onItemClick: (itemId, e) => {
|
|
129
129
|
if (mode === 'single-select') {
|
|
130
130
|
setOpen(false);
|
|
131
131
|
}
|
|
@@ -134,8 +134,8 @@ const ComboBox = forwardRef((props, ref) => {
|
|
|
134
134
|
if (clickedItem?.primary && !clickedItem?.selected) {
|
|
135
135
|
selected?.onNew?.(clickedItem?.primary);
|
|
136
136
|
}
|
|
137
|
-
}, arrowNavigationUnsupported: true }
|
|
138
|
-
return label ? (_jsx(FormField,
|
|
137
|
+
}, arrowNavigationUnsupported: true }, void 0)) }, void 0)] }, void 0));
|
|
138
|
+
return label ? (_jsx(FormField, { ...{ label, labelHidden, id, info, status, required, disabled }, children: Comp }, void 0)) : (Comp);
|
|
139
139
|
});
|
|
140
140
|
export default ComboBox;
|
|
141
141
|
//# sourceMappingURL=ComboBox.js.map
|