@lumx/react 3.0.2 → 3.0.3
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/{esm/_internal/_rollupPluginBabelHelpers.js → _internal/ClickAwayProvider.js} +107 -2
- package/_internal/ClickAwayProvider.js.map +1 -0
- package/_internal/types.d.ts +271 -0
- package/index.d.ts +2686 -0
- package/index.js +12533 -0
- package/index.js.map +1 -0
- package/package.json +7 -6
- package/src/components/alert-dialog/AlertDialog.tsx +2 -1
- package/src/components/autocomplete/Autocomplete.tsx +2 -2
- package/src/components/autocomplete/AutocompleteMultiple.tsx +2 -1
- package/src/components/avatar/Avatar.tsx +2 -1
- package/src/components/badge/Badge.test.tsx +1 -1
- package/src/components/badge/Badge.tsx +2 -1
- package/src/components/button/Button.test.tsx +1 -1
- package/src/components/button/Button.tsx +2 -1
- package/src/components/button/ButtonGroup.tsx +2 -1
- package/src/components/button/ButtonRoot.test.tsx +1 -1
- package/src/components/button/ButtonRoot.tsx +2 -1
- package/src/components/button/IconButton.tsx +2 -1
- package/src/components/checkbox/Checkbox.test.tsx +1 -1
- package/src/components/checkbox/Checkbox.tsx +2 -1
- package/src/components/chip/Chip.test.tsx +1 -1
- package/src/components/chip/Chip.tsx +3 -1
- package/src/components/chip/ChipGroup.tsx +2 -1
- package/src/components/comment-block/CommentBlock.tsx +2 -1
- package/src/components/date-picker/DatePicker.tsx +1 -1
- package/src/components/date-picker/DatePickerControlled.tsx +1 -1
- package/src/components/date-picker/DatePickerField.tsx +1 -1
- package/src/components/date-picker/constants.ts +1 -1
- package/src/components/date-picker/types.ts +1 -1
- package/src/components/dialog/Dialog.tsx +4 -8
- package/src/components/divider/Divider.test.tsx +1 -1
- package/src/components/divider/Divider.tsx +3 -2
- package/src/components/drag-handle/DragHandle.tsx +2 -1
- package/src/components/dropdown/Dropdown.tsx +2 -1
- package/src/components/expansion-panel/ExpansionPanel.test.tsx +1 -1
- package/src/components/expansion-panel/ExpansionPanel.tsx +3 -10
- package/src/components/flag/Flag.test.tsx +1 -1
- package/src/components/flag/Flag.tsx +2 -1
- package/src/components/flex-box/FlexBox.stories.tsx +8 -0
- package/src/components/flex-box/FlexBox.tsx +7 -3
- package/src/components/flex-box/__snapshots__/FlexBox.test.tsx.snap +16 -0
- package/src/components/generic-block/GenericBlock.stories.jsx +23 -1
- package/src/components/generic-block/GenericBlock.tsx +18 -4
- package/src/components/generic-block/constants.ts +9 -0
- package/src/components/generic-block/index.ts +1 -0
- package/src/components/grid/Grid.tsx +2 -1
- package/src/components/grid/GridItem.tsx +2 -1
- package/src/components/heading/Heading.tsx +2 -1
- package/src/components/heading/HeadingLevelProvider.tsx +1 -1
- package/src/components/heading/context.tsx +1 -1
- package/src/components/icon/Icon.test.tsx +1 -1
- package/src/components/icon/Icon.tsx +2 -1
- package/src/components/image-block/ImageBlock.tsx +2 -1
- package/src/components/index.ts +1 -1
- package/src/components/inline-list/InlineList.stories.tsx +40 -0
- package/src/components/inline-list/InlineList.test.tsx +41 -0
- package/src/components/inline-list/InlineList.tsx +80 -0
- package/src/components/inline-list/index.ts +1 -0
- package/src/components/input-helper/InputHelper.tsx +2 -1
- package/src/components/input-label/InputLabel.tsx +2 -1
- package/src/components/lightbox/Lightbox.tsx +2 -1
- package/src/components/link/Link.tsx +2 -1
- package/src/components/link-preview/LinkPreview.test.tsx +1 -1
- package/src/components/link-preview/LinkPreview.tsx +2 -1
- package/src/components/list/List.tsx +2 -1
- package/src/components/list/ListDivider.tsx +2 -1
- package/src/components/list/ListItem.tsx +3 -8
- package/src/components/list/ListSubheader.tsx +2 -1
- package/src/components/list/useInteractiveList.tsx +1 -1
- package/src/components/message/Message.test.tsx +1 -1
- package/src/components/message/Message.tsx +2 -1
- package/src/components/mosaic/Mosaic.tsx +2 -1
- package/src/components/notification/Notification.tsx +2 -1
- package/src/components/popover/Popover.tsx +2 -1
- package/src/components/post-block/PostBlock.tsx +2 -1
- package/src/components/progress/Progress.tsx +2 -1
- package/src/components/progress-tracker/ProgressTracker.tsx +2 -1
- package/src/components/progress-tracker/ProgressTrackerStep.test.tsx +1 -1
- package/src/components/progress-tracker/ProgressTrackerStep.tsx +2 -1
- package/src/components/progress-tracker/ProgressTrackerStepPanel.tsx +2 -1
- package/src/components/radio-button/RadioButton.test.tsx +1 -1
- package/src/components/radio-button/RadioButton.tsx +2 -1
- package/src/components/radio-button/RadioGroup.tsx +2 -1
- package/src/components/select/Select.test.tsx +1 -1
- package/src/components/select/Select.tsx +2 -1
- package/src/components/select/SelectMultiple.test.tsx +1 -1
- package/src/components/select/SelectMultiple.tsx +2 -1
- package/src/components/select/WithSelectContext.tsx +1 -1
- package/src/components/select/constants.ts +1 -1
- package/src/components/side-navigation/SideNavigation.tsx +2 -1
- package/src/components/side-navigation/SideNavigationItem.test.tsx +1 -1
- package/src/components/side-navigation/SideNavigationItem.tsx +3 -9
- package/src/components/skeleton/SkeletonCircle.tsx +2 -1
- package/src/components/skeleton/SkeletonRectangle.tsx +2 -1
- package/src/components/skeleton/SkeletonTypography.tsx +2 -1
- package/src/components/slider/Slider.tsx +2 -1
- package/src/components/slideshow/Slides.tsx +2 -1
- package/src/components/slideshow/Slideshow.tsx +1 -1
- package/src/components/slideshow/SlideshowControls.tsx +2 -1
- package/src/components/slideshow/SlideshowItem.tsx +2 -1
- package/src/components/slideshow/SlideshowItemGroup.tsx +2 -1
- package/src/components/switch/Switch.test.tsx +1 -1
- package/src/components/switch/Switch.tsx +2 -1
- package/src/components/table/Table.tsx +2 -1
- package/src/components/table/TableBody.tsx +2 -1
- package/src/components/table/TableCell.tsx +3 -1
- package/src/components/table/TableHeader.tsx +2 -1
- package/src/components/table/TableRow.tsx +2 -1
- package/src/components/tabs/Tab.test.tsx +1 -1
- package/src/components/tabs/Tab.tsx +2 -1
- package/src/components/tabs/TabList.test.tsx +1 -1
- package/src/components/tabs/TabList.tsx +2 -1
- package/src/components/tabs/TabPanel.tsx +2 -1
- package/src/components/text/{Text.stories.tsx → Text.stories.jsx} +23 -28
- package/src/components/text/Text.test.tsx +15 -1
- package/src/components/text/Text.tsx +38 -12
- package/src/components/text-field/TextField.test.tsx +1 -1
- package/src/components/text-field/TextField.tsx +2 -1
- package/src/components/thumbnail/Thumbnail.tsx +2 -1
- package/src/components/thumbnail/types.ts +1 -1
- package/src/components/toolbar/Toolbar.tsx +2 -1
- package/src/components/tooltip/Tooltip.tsx +2 -1
- package/src/components/tooltip/useTooltipOpen.tsx +1 -1
- package/src/components/uploader/Uploader.test.tsx +1 -1
- package/src/components/uploader/Uploader.tsx +2 -1
- package/src/components/user-block/UserBlock.tsx +2 -1
- package/src/hooks/useCallbackOnEscape.ts +2 -1
- package/src/hooks/useClickAway.tsx +1 -1
- package/src/hooks/useDisableBodyScroll.ts +1 -1
- package/src/hooks/useFocusTrap.ts +1 -1
- package/src/hooks/useInterval.tsx +1 -1
- package/src/hooks/useOnResize.ts +1 -1
- package/src/index.ts +5 -0
- package/src/stories/generated/GenericBlock/Demos.stories.tsx +3 -1
- package/src/stories/generated/Heading/Demos.stories.tsx +6 -0
- package/src/stories/withResizableBox.tsx +18 -0
- package/src/testing/utils/commonTestsSuite.ts +1 -1
- package/src/utils/{getRootClassName.ts → className.ts} +19 -0
- package/src/utils/event.ts +1 -0
- package/src/utils/index.ts +5 -0
- package/src/utils/type.ts +3 -0
- package/src/utils/utils.test.ts +1 -1
- package/types.d.ts +68 -11
- package/utils/index.d.ts +29 -0
- package/utils/index.js +2 -0
- package/utils/index.js.map +1 -0
- package/esm/_internal/AlertDialog.js +0 -141
- package/esm/_internal/AlertDialog.js.map +0 -1
- package/esm/_internal/AutocompleteMultiple.js +0 -257
- package/esm/_internal/AutocompleteMultiple.js.map +0 -1
- package/esm/_internal/Avatar2.js +0 -82
- package/esm/_internal/Avatar2.js.map +0 -1
- package/esm/_internal/Badge2.js +0 -54
- package/esm/_internal/Badge2.js.map +0 -1
- package/esm/_internal/Button2.js +0 -84
- package/esm/_internal/Button2.js.map +0 -1
- package/esm/_internal/ButtonGroup.js +0 -51
- package/esm/_internal/ButtonGroup.js.map +0 -1
- package/esm/_internal/ButtonRoot.js +0 -135
- package/esm/_internal/ButtonRoot.js.map +0 -1
- package/esm/_internal/Checkbox2.js +0 -116
- package/esm/_internal/Checkbox2.js.map +0 -1
- package/esm/_internal/Chip2.js +0 -118
- package/esm/_internal/Chip2.js.map +0 -1
- package/esm/_internal/ChipGroup.js +0 -122
- package/esm/_internal/ChipGroup.js.map +0 -1
- package/esm/_internal/ClickAwayProvider.js +0 -217
- package/esm/_internal/ClickAwayProvider.js.map +0 -1
- package/esm/_internal/CommentBlock.js +0 -124
- package/esm/_internal/CommentBlock.js.map +0 -1
- package/esm/_internal/DatePickerField.js +0 -347
- package/esm/_internal/DatePickerField.js.map +0 -1
- package/esm/_internal/Dialog2.js +0 -274
- package/esm/_internal/Dialog2.js.map +0 -1
- package/esm/_internal/Divider2.js +0 -53
- package/esm/_internal/Divider2.js.map +0 -1
- package/esm/_internal/DragHandle.js +0 -50
- package/esm/_internal/DragHandle.js.map +0 -1
- package/esm/_internal/Dropdown2.js +0 -157
- package/esm/_internal/Dropdown2.js.map +0 -1
- package/esm/_internal/ExpansionPanel.js +0 -156
- package/esm/_internal/ExpansionPanel.js.map +0 -1
- package/esm/_internal/Flag2.js +0 -48
- package/esm/_internal/Flag2.js.map +0 -1
- package/esm/_internal/FlexBox.js +0 -55
- package/esm/_internal/FlexBox.js.map +0 -1
- package/esm/_internal/GenericBlock.js +0 -125
- package/esm/_internal/GenericBlock.js.map +0 -1
- package/esm/_internal/GridItem.js +0 -96
- package/esm/_internal/GridItem.js.map +0 -1
- package/esm/_internal/HeadingLevelProvider.js +0 -112
- package/esm/_internal/HeadingLevelProvider.js.map +0 -1
- package/esm/_internal/Icon2.js +0 -120
- package/esm/_internal/Icon2.js.map +0 -1
- package/esm/_internal/IconButton.js +0 -74
- package/esm/_internal/IconButton.js.map +0 -1
- package/esm/_internal/ImageBlock.js +0 -101
- package/esm/_internal/ImageBlock.js.map +0 -1
- package/esm/_internal/InputHelper.js +0 -72
- package/esm/_internal/InputHelper.js.map +0 -1
- package/esm/_internal/InputLabel.js +0 -58
- package/esm/_internal/InputLabel.js.map +0 -1
- package/esm/_internal/Lightbox2.js +0 -123
- package/esm/_internal/Lightbox2.js.map +0 -1
- package/esm/_internal/Link2.js +0 -122
- package/esm/_internal/Link2.js.map +0 -1
- package/esm/_internal/LinkPreview.js +0 -105
- package/esm/_internal/LinkPreview.js.map +0 -1
- package/esm/_internal/List2.js +0 -799
- package/esm/_internal/List2.js.map +0 -1
- package/esm/_internal/ListSubheader.js +0 -79
- package/esm/_internal/ListSubheader.js.map +0 -1
- package/esm/_internal/Message2.js +0 -78
- package/esm/_internal/Message2.js.map +0 -1
- package/esm/_internal/Mosaic2.js +0 -89
- package/esm/_internal/Mosaic2.js.map +0 -1
- package/esm/_internal/Notification2.js +0 -133
- package/esm/_internal/Notification2.js.map +0 -1
- package/esm/_internal/Popover2.js +0 -2473
- package/esm/_internal/Popover2.js.map +0 -1
- package/esm/_internal/PostBlock.js +0 -96
- package/esm/_internal/PostBlock.js.map +0 -1
- package/esm/_internal/Progress2.js +0 -81
- package/esm/_internal/Progress2.js.map +0 -1
- package/esm/_internal/ProgressTrackerStepPanel.js +0 -313
- package/esm/_internal/ProgressTrackerStepPanel.js.map +0 -1
- package/esm/_internal/RadioGroup.js +0 -147
- package/esm/_internal/RadioGroup.js.map +0 -1
- package/esm/_internal/SelectMultiple.js +0 -424
- package/esm/_internal/SelectMultiple.js.map +0 -1
- package/esm/_internal/SideNavigationItem.js +0 -151
- package/esm/_internal/SideNavigationItem.js.map +0 -1
- package/esm/_internal/SkeletonTypography.js +0 -168
- package/esm/_internal/SkeletonTypography.js.map +0 -1
- package/esm/_internal/Slider2.js +0 -327
- package/esm/_internal/Slider2.js.map +0 -1
- package/esm/_internal/Slides.js +0 -864
- package/esm/_internal/Slides.js.map +0 -1
- package/esm/_internal/Switch2.js +0 -116
- package/esm/_internal/Switch2.js.map +0 -1
- package/esm/_internal/TabPanel.js +0 -280
- package/esm/_internal/TabPanel.js.map +0 -1
- package/esm/_internal/TableRow.js +0 -291
- package/esm/_internal/TableRow.js.map +0 -1
- package/esm/_internal/Text2.js +0 -63
- package/esm/_internal/Text2.js.map +0 -1
- package/esm/_internal/TextField.js +0 -322
- package/esm/_internal/TextField.js.map +0 -1
- package/esm/_internal/Thumbnail2.js +0 -301
- package/esm/_internal/Thumbnail2.js.map +0 -1
- package/esm/_internal/Toolbar2.js +0 -60
- package/esm/_internal/Toolbar2.js.map +0 -1
- package/esm/_internal/Tooltip2.js +0 -282
- package/esm/_internal/Tooltip2.js.map +0 -1
- package/esm/_internal/Uploader2.js +0 -84
- package/esm/_internal/Uploader2.js.map +0 -1
- package/esm/_internal/UserBlock.js +0 -132
- package/esm/_internal/UserBlock.js.map +0 -1
- package/esm/_internal/_rollupPluginBabelHelpers.js.map +0 -1
- package/esm/_internal/alert-dialog.js +0 -34
- package/esm/_internal/alert-dialog.js.map +0 -1
- package/esm/_internal/autocomplete.js +0 -32
- package/esm/_internal/autocomplete.js.map +0 -1
- package/esm/_internal/avatar.js +0 -13
- package/esm/_internal/avatar.js.map +0 -1
- package/esm/_internal/badge.js +0 -10
- package/esm/_internal/badge.js.map +0 -1
- package/esm/_internal/button.js +0 -25
- package/esm/_internal/button.js.map +0 -1
- package/esm/_internal/checkbox.js +0 -14
- package/esm/_internal/checkbox.js.map +0 -1
- package/esm/_internal/chip.js +0 -12
- package/esm/_internal/chip.js.map +0 -1
- package/esm/_internal/comment-block.js +0 -24
- package/esm/_internal/comment-block.js.map +0 -1
- package/esm/_internal/components.js +0 -156
- package/esm/_internal/components.js.map +0 -1
- package/esm/_internal/constants.js +0 -13
- package/esm/_internal/constants.js.map +0 -1
- package/esm/_internal/date-picker.js +0 -32
- package/esm/_internal/date-picker.js.map +0 -1
- package/esm/_internal/dialog.js +0 -27
- package/esm/_internal/dialog.js.map +0 -1
- package/esm/_internal/divider.js +0 -10
- package/esm/_internal/divider.js.map +0 -1
- package/esm/_internal/drag-handle.js +0 -11
- package/esm/_internal/drag-handle.js.map +0 -1
- package/esm/_internal/dropdown.js +0 -21
- package/esm/_internal/dropdown.js.map +0 -1
- package/esm/_internal/expansion-panel.js +0 -32
- package/esm/_internal/expansion-panel.js.map +0 -1
- package/esm/_internal/flag.js +0 -11
- package/esm/_internal/flag.js.map +0 -1
- package/esm/_internal/flex-box.js +0 -11
- package/esm/_internal/flex-box.js.map +0 -1
- package/esm/_internal/generic-block.js +0 -20
- package/esm/_internal/generic-block.js.map +0 -1
- package/esm/_internal/getRootClassName.js +0 -346
- package/esm/_internal/getRootClassName.js.map +0 -1
- package/esm/_internal/grid.js +0 -10
- package/esm/_internal/grid.js.map +0 -1
- package/esm/_internal/heading.js +0 -11
- package/esm/_internal/heading.js.map +0 -1
- package/esm/_internal/icon.js +0 -10
- package/esm/_internal/icon.js.map +0 -1
- package/esm/_internal/image-block.js +0 -14
- package/esm/_internal/image-block.js.map +0 -1
- package/esm/_internal/input-helper.js +0 -10
- package/esm/_internal/input-helper.js.map +0 -1
- package/esm/_internal/input-label.js +0 -10
- package/esm/_internal/input-label.js.map +0 -1
- package/esm/_internal/lightbox.js +0 -27
- package/esm/_internal/lightbox.js.map +0 -1
- package/esm/_internal/link-preview.js +0 -15
- package/esm/_internal/link-preview.js.map +0 -1
- package/esm/_internal/link.js +0 -12
- package/esm/_internal/link.js.map +0 -1
- package/esm/_internal/list.js +0 -15
- package/esm/_internal/list.js.map +0 -1
- package/esm/_internal/mergeRefs.js +0 -25
- package/esm/_internal/mergeRefs.js.map +0 -1
- package/esm/_internal/message.js +0 -11
- package/esm/_internal/message.js.map +0 -1
- package/esm/_internal/mosaic.js +0 -14
- package/esm/_internal/mosaic.js.map +0 -1
- package/esm/_internal/notification.js +0 -18
- package/esm/_internal/notification.js.map +0 -1
- package/esm/_internal/partitionMulti.js +0 -27
- package/esm/_internal/partitionMulti.js.map +0 -1
- package/esm/_internal/popover.js +0 -15
- package/esm/_internal/popover.js.map +0 -1
- package/esm/_internal/post-block.js +0 -15
- package/esm/_internal/post-block.js.map +0 -1
- package/esm/_internal/progress-tracker.js +0 -17
- package/esm/_internal/progress-tracker.js.map +0 -1
- package/esm/_internal/progress.js +0 -10
- package/esm/_internal/progress.js.map +0 -1
- package/esm/_internal/radio-button.js +0 -13
- package/esm/_internal/radio-button.js.map +0 -1
- package/esm/_internal/renderLink.js +0 -25
- package/esm/_internal/renderLink.js.map +0 -1
- package/esm/_internal/select.js +0 -31
- package/esm/_internal/select.js.map +0 -1
- package/esm/_internal/side-navigation.js +0 -25
- package/esm/_internal/side-navigation.js.map +0 -1
- package/esm/_internal/skeleton.js +0 -10
- package/esm/_internal/skeleton.js.map +0 -1
- package/esm/_internal/slider.js +0 -13
- package/esm/_internal/slider.js.map +0 -1
- package/esm/_internal/slideshow.js +0 -29
- package/esm/_internal/slideshow.js.map +0 -1
- package/esm/_internal/state.js +0 -145
- package/esm/_internal/state.js.map +0 -1
- package/esm/_internal/switch.js +0 -13
- package/esm/_internal/switch.js.map +0 -1
- package/esm/_internal/table.js +0 -12
- package/esm/_internal/table.js.map +0 -1
- package/esm/_internal/tabs.js +0 -15
- package/esm/_internal/tabs.js.map +0 -1
- package/esm/_internal/text-field.js +0 -26
- package/esm/_internal/text-field.js.map +0 -1
- package/esm/_internal/text.js +0 -10
- package/esm/_internal/text.js.map +0 -1
- package/esm/_internal/thumbnail.js +0 -13
- package/esm/_internal/thumbnail.js.map +0 -1
- package/esm/_internal/toolbar.js +0 -9
- package/esm/_internal/toolbar.js.map +0 -1
- package/esm/_internal/tooltip.js +0 -18
- package/esm/_internal/tooltip.js.map +0 -1
- package/esm/_internal/type.js +0 -40
- package/esm/_internal/type.js.map +0 -1
- package/esm/_internal/types.js +0 -23
- package/esm/_internal/types.js.map +0 -1
- package/esm/_internal/uploader.js +0 -11
- package/esm/_internal/uploader.js.map +0 -1
- package/esm/_internal/useDelayedVisibility.js +0 -47
- package/esm/_internal/useDelayedVisibility.js.map +0 -1
- package/esm/_internal/useDisableBodyScroll.js +0 -220
- package/esm/_internal/useDisableBodyScroll.js.map +0 -1
- package/esm/_internal/useFocusTrap.js +0 -86
- package/esm/_internal/useFocusTrap.js.map +0 -1
- package/esm/_internal/useRovingTabIndex.js +0 -87
- package/esm/_internal/useRovingTabIndex.js.map +0 -1
- package/esm/_internal/user-block.js +0 -17
- package/esm/_internal/user-block.js.map +0 -1
- package/esm/index.js +0 -95
- package/esm/index.js.map +0 -1
- package/esm/index2.js +0 -16
- package/esm/index2.js.map +0 -1
- package/src/utils/index.tsx +0 -7
|
@@ -1,322 +0,0 @@
|
|
|
1
|
-
import { b as _objectWithoutProperties, d as _slicedToArray, _ as _objectSpread2, c as _extends } from './_rollupPluginBabelHelpers.js';
|
|
2
|
-
import { Size, Theme, Emphasis, Kind } from './components.js';
|
|
3
|
-
import React, { forwardRef, useMemo, useState, useRef, useEffect } from 'react';
|
|
4
|
-
import { g as getRootClassName, c as classnames, h as handleBasicClasses } from './getRootClassName.js';
|
|
5
|
-
import { I as Icon, c as mdiAlertCircle, b as mdiCheckCircle, n as mdiCloseCircle } from './Icon2.js';
|
|
6
|
-
import { u as uid } from '../index2.js';
|
|
7
|
-
import get from 'lodash/get';
|
|
8
|
-
import { m as mergeRefs } from './mergeRefs.js';
|
|
9
|
-
import { I as IconButton } from './IconButton.js';
|
|
10
|
-
import { I as InputHelper } from './InputHelper.js';
|
|
11
|
-
import { I as InputLabel } from './InputLabel.js';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Defines the props of the component.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Component display name.
|
|
19
|
-
*/
|
|
20
|
-
var COMPONENT_NAME = 'TextField';
|
|
21
|
-
/**
|
|
22
|
-
* Component default class name and class prefix.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
var CLASSNAME = getRootClassName(COMPONENT_NAME);
|
|
26
|
-
/**
|
|
27
|
-
* Default minimum number of rows in the multiline mode.
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
var DEFAULT_MIN_ROWS = 2;
|
|
31
|
-
/**
|
|
32
|
-
* Component default props.
|
|
33
|
-
*/
|
|
34
|
-
|
|
35
|
-
var DEFAULT_PROPS = {
|
|
36
|
-
theme: Theme.light,
|
|
37
|
-
type: 'text'
|
|
38
|
-
};
|
|
39
|
-
/**
|
|
40
|
-
* Hook that allows to calculate the number of rows needed for a text area.
|
|
41
|
-
* @param minimumRows Minimum number of rows that we want to display.
|
|
42
|
-
* @return rows to be used and a callback to recalculate
|
|
43
|
-
*/
|
|
44
|
-
|
|
45
|
-
var useComputeNumberOfRows = function useComputeNumberOfRows(minimumRows) {
|
|
46
|
-
var _useState = useState(minimumRows),
|
|
47
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
48
|
-
rows = _useState2[0],
|
|
49
|
-
setRows = _useState2[1];
|
|
50
|
-
|
|
51
|
-
var recompute = function recompute(target) {
|
|
52
|
-
/**
|
|
53
|
-
* HEAD's UP! This part is a little bit tricky. The idea here is to only
|
|
54
|
-
* display the necessary rows on the textarea. In order to dynamically adjust
|
|
55
|
-
* the height on that field, we need to:
|
|
56
|
-
* 1. Set the current amount of rows to the minimum. That will make the scroll appear.
|
|
57
|
-
* 2. With that, we will have the `scrollHeight`, meaning the height of the container adjusted to the current content
|
|
58
|
-
* 3. With the scroll height, we can figure out how many rows we need to use by dividing the scroll height
|
|
59
|
-
* by the line height.
|
|
60
|
-
* 4. With that number, we can readjust the number of rows on the text area. We need to do that here, if we leave that to
|
|
61
|
-
* the state change through React, there are some scenarios (resize, hitting ENTER or BACKSPACE which add or remove lines)
|
|
62
|
-
* when we will not see the update and the rows will be resized to the minimum.
|
|
63
|
-
* 5. In case there is any other update on the component that changes the UI, we need to keep the number of rows
|
|
64
|
-
* on the state in order to allow React to re-render. Therefore, we save them using `useState`
|
|
65
|
-
*/
|
|
66
|
-
// eslint-disable-next-line no-param-reassign
|
|
67
|
-
target.rows = minimumRows;
|
|
68
|
-
var currentRows = target.scrollHeight / (target.clientHeight / minimumRows);
|
|
69
|
-
currentRows = currentRows >= minimumRows ? currentRows : minimumRows; // eslint-disable-next-line no-param-reassign
|
|
70
|
-
|
|
71
|
-
target.rows = currentRows;
|
|
72
|
-
setRows(currentRows);
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
return {
|
|
76
|
-
recomputeNumberOfRows: recompute,
|
|
77
|
-
rows: rows
|
|
78
|
-
};
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
var renderInputNative = function renderInputNative(props) {
|
|
82
|
-
var id = props.id,
|
|
83
|
-
isDisabled = props.isDisabled,
|
|
84
|
-
isRequired = props.isRequired,
|
|
85
|
-
placeholder = props.placeholder,
|
|
86
|
-
multiline = props.multiline,
|
|
87
|
-
value = props.value,
|
|
88
|
-
setFocus = props.setFocus,
|
|
89
|
-
onChange = props.onChange,
|
|
90
|
-
onFocus = props.onFocus,
|
|
91
|
-
onBlur = props.onBlur,
|
|
92
|
-
inputRef = props.inputRef,
|
|
93
|
-
rows = props.rows,
|
|
94
|
-
recomputeNumberOfRows = props.recomputeNumberOfRows,
|
|
95
|
-
type = props.type,
|
|
96
|
-
name = props.name,
|
|
97
|
-
forwardedProps = _objectWithoutProperties(props, ["id", "isDisabled", "isRequired", "placeholder", "multiline", "value", "setFocus", "onChange", "onFocus", "onBlur", "inputRef", "rows", "recomputeNumberOfRows", "type", "name"]); // eslint-disable-next-line react-hooks/rules-of-hooks
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
var ref = useRef(null); // eslint-disable-next-line react-hooks/rules-of-hooks
|
|
101
|
-
|
|
102
|
-
useEffect(function () {
|
|
103
|
-
// Recompute the number of rows for the first rendering
|
|
104
|
-
if (multiline && ref && ref.current) {
|
|
105
|
-
recomputeNumberOfRows(ref.current);
|
|
106
|
-
}
|
|
107
|
-
}, [ref, multiline, recomputeNumberOfRows, value]);
|
|
108
|
-
|
|
109
|
-
var onTextFieldFocus = function onTextFieldFocus(event) {
|
|
110
|
-
onFocus === null || onFocus === void 0 ? void 0 : onFocus(event);
|
|
111
|
-
setFocus(true);
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
var onTextFieldBlur = function onTextFieldBlur(event) {
|
|
115
|
-
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
116
|
-
setFocus(false);
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
var handleChange = function handleChange(event) {
|
|
120
|
-
onChange(get(event, 'target.value'), name, event);
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
var Component = multiline ? 'textarea' : 'input';
|
|
124
|
-
|
|
125
|
-
var inputProps = _objectSpread2({}, forwardedProps, {
|
|
126
|
-
id: id,
|
|
127
|
-
className: multiline ? "".concat(CLASSNAME, "__input-native ").concat(CLASSNAME, "__input-native--textarea") : "".concat(CLASSNAME, "__input-native ").concat(CLASSNAME, "__input-native--text"),
|
|
128
|
-
placeholder: placeholder,
|
|
129
|
-
value: value,
|
|
130
|
-
name: name,
|
|
131
|
-
disabled: isDisabled,
|
|
132
|
-
required: isRequired,
|
|
133
|
-
onFocus: onTextFieldFocus,
|
|
134
|
-
onBlur: onTextFieldBlur,
|
|
135
|
-
onChange: handleChange,
|
|
136
|
-
ref: mergeRefs(inputRef, ref)
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
if (multiline) {
|
|
140
|
-
inputProps.rows = rows;
|
|
141
|
-
} else {
|
|
142
|
-
inputProps.type = type;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
return React.createElement(Component, inputProps);
|
|
146
|
-
};
|
|
147
|
-
/**
|
|
148
|
-
* TextField component.
|
|
149
|
-
*
|
|
150
|
-
* @param props Component props.
|
|
151
|
-
* @param ref Component ref.
|
|
152
|
-
* @return React element.
|
|
153
|
-
*/
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
var TextField = forwardRef(function (props, ref) {
|
|
157
|
-
var chips = props.chips,
|
|
158
|
-
className = props.className,
|
|
159
|
-
clearButtonProps = props.clearButtonProps,
|
|
160
|
-
disabled = props.disabled,
|
|
161
|
-
error = props.error,
|
|
162
|
-
forceFocusStyle = props.forceFocusStyle,
|
|
163
|
-
hasError = props.hasError,
|
|
164
|
-
helper = props.helper,
|
|
165
|
-
icon = props.icon,
|
|
166
|
-
id = props.id,
|
|
167
|
-
inputRef = props.inputRef,
|
|
168
|
-
_props$isDisabled = props.isDisabled,
|
|
169
|
-
isDisabled = _props$isDisabled === void 0 ? disabled : _props$isDisabled,
|
|
170
|
-
isRequired = props.isRequired,
|
|
171
|
-
isValid = props.isValid,
|
|
172
|
-
label = props.label,
|
|
173
|
-
maxLength = props.maxLength,
|
|
174
|
-
minimumRows = props.minimumRows,
|
|
175
|
-
multiline = props.multiline,
|
|
176
|
-
name = props.name,
|
|
177
|
-
onBlur = props.onBlur,
|
|
178
|
-
onChange = props.onChange,
|
|
179
|
-
onFocus = props.onFocus,
|
|
180
|
-
placeholder = props.placeholder,
|
|
181
|
-
textFieldRef = props.textFieldRef,
|
|
182
|
-
theme = props.theme,
|
|
183
|
-
type = props.type,
|
|
184
|
-
value = props.value,
|
|
185
|
-
afterElement = props.afterElement,
|
|
186
|
-
forwardedProps = _objectWithoutProperties(props, ["chips", "className", "clearButtonProps", "disabled", "error", "forceFocusStyle", "hasError", "helper", "icon", "id", "inputRef", "isDisabled", "isRequired", "isValid", "label", "maxLength", "minimumRows", "multiline", "name", "onBlur", "onChange", "onFocus", "placeholder", "textFieldRef", "theme", "type", "value", "afterElement"]);
|
|
187
|
-
|
|
188
|
-
var textFieldId = useMemo(function () {
|
|
189
|
-
return id || "text-field-".concat(uid());
|
|
190
|
-
}, [id]);
|
|
191
|
-
|
|
192
|
-
var _useState3 = useState(false),
|
|
193
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
194
|
-
isFocus = _useState4[0],
|
|
195
|
-
setFocus = _useState4[1];
|
|
196
|
-
|
|
197
|
-
var _useComputeNumberOfRo = useComputeNumberOfRows(multiline ? minimumRows || DEFAULT_MIN_ROWS : 0),
|
|
198
|
-
rows = _useComputeNumberOfRo.rows,
|
|
199
|
-
recomputeNumberOfRows = _useComputeNumberOfRo.recomputeNumberOfRows;
|
|
200
|
-
|
|
201
|
-
var valueLength = (value || '').length;
|
|
202
|
-
var isNotEmpty = valueLength > 0;
|
|
203
|
-
/**
|
|
204
|
-
* Function triggered when the Clear Button is clicked.
|
|
205
|
-
* The idea is to execute the `onChange` callback with an empty string
|
|
206
|
-
* and remove focus from the clear button.
|
|
207
|
-
* @param evt On clear event.
|
|
208
|
-
*/
|
|
209
|
-
|
|
210
|
-
var onClear = function onClear(evt) {
|
|
211
|
-
evt.nativeEvent.preventDefault();
|
|
212
|
-
evt.nativeEvent.stopPropagation();
|
|
213
|
-
evt.currentTarget.blur();
|
|
214
|
-
onChange('');
|
|
215
|
-
};
|
|
216
|
-
|
|
217
|
-
return React.createElement("div", {
|
|
218
|
-
ref: ref,
|
|
219
|
-
className: classnames(className, handleBasicClasses({
|
|
220
|
-
hasChips: Boolean(chips),
|
|
221
|
-
hasError: !isValid && hasError,
|
|
222
|
-
hasIcon: Boolean(icon),
|
|
223
|
-
hasInput: !multiline,
|
|
224
|
-
hasInputClear: clearButtonProps && isNotEmpty,
|
|
225
|
-
hasLabel: Boolean(label),
|
|
226
|
-
hasPlaceholder: Boolean(placeholder),
|
|
227
|
-
hasTextarea: multiline,
|
|
228
|
-
hasValue: Boolean(value),
|
|
229
|
-
isDisabled: isDisabled,
|
|
230
|
-
isFocus: isFocus || forceFocusStyle,
|
|
231
|
-
isValid: isValid,
|
|
232
|
-
prefix: CLASSNAME,
|
|
233
|
-
theme: theme
|
|
234
|
-
}))
|
|
235
|
-
}, (label || maxLength) && React.createElement("div", {
|
|
236
|
-
className: "".concat(CLASSNAME, "__header")
|
|
237
|
-
}, label && React.createElement(InputLabel, {
|
|
238
|
-
htmlFor: textFieldId,
|
|
239
|
-
className: "".concat(CLASSNAME, "__label"),
|
|
240
|
-
isRequired: isRequired,
|
|
241
|
-
theme: theme
|
|
242
|
-
}, label), maxLength && React.createElement("div", {
|
|
243
|
-
className: "".concat(CLASSNAME, "__char-counter")
|
|
244
|
-
}, React.createElement("span", null, maxLength - valueLength), maxLength - valueLength === 0 && React.createElement(Icon, {
|
|
245
|
-
icon: mdiAlertCircle,
|
|
246
|
-
size: Size.xxs
|
|
247
|
-
}))), React.createElement("div", {
|
|
248
|
-
className: "".concat(CLASSNAME, "__wrapper"),
|
|
249
|
-
ref: textFieldRef
|
|
250
|
-
}, icon && React.createElement(Icon, {
|
|
251
|
-
className: "".concat(CLASSNAME, "__input-icon"),
|
|
252
|
-
color: theme === Theme.dark ? 'light' : undefined,
|
|
253
|
-
icon: icon,
|
|
254
|
-
size: Size.xs
|
|
255
|
-
}), chips && React.createElement("div", {
|
|
256
|
-
className: "".concat(CLASSNAME, "__chips")
|
|
257
|
-
}, chips, renderInputNative(_objectSpread2({
|
|
258
|
-
id: textFieldId,
|
|
259
|
-
inputRef: inputRef,
|
|
260
|
-
isDisabled: isDisabled,
|
|
261
|
-
isRequired: isRequired,
|
|
262
|
-
maxLength: maxLength,
|
|
263
|
-
multiline: multiline,
|
|
264
|
-
onBlur: onBlur,
|
|
265
|
-
onChange: onChange,
|
|
266
|
-
onFocus: onFocus,
|
|
267
|
-
placeholder: placeholder,
|
|
268
|
-
recomputeNumberOfRows: recomputeNumberOfRows,
|
|
269
|
-
rows: rows,
|
|
270
|
-
setFocus: setFocus,
|
|
271
|
-
type: type,
|
|
272
|
-
value: value,
|
|
273
|
-
name: name
|
|
274
|
-
}, forwardedProps))), !chips && React.createElement("div", {
|
|
275
|
-
className: "".concat(CLASSNAME, "__input-wrapper")
|
|
276
|
-
}, renderInputNative(_objectSpread2({
|
|
277
|
-
id: textFieldId,
|
|
278
|
-
inputRef: inputRef,
|
|
279
|
-
isDisabled: isDisabled,
|
|
280
|
-
isRequired: isRequired,
|
|
281
|
-
maxLength: maxLength,
|
|
282
|
-
multiline: multiline,
|
|
283
|
-
onBlur: onBlur,
|
|
284
|
-
onChange: onChange,
|
|
285
|
-
onFocus: onFocus,
|
|
286
|
-
placeholder: placeholder,
|
|
287
|
-
recomputeNumberOfRows: recomputeNumberOfRows,
|
|
288
|
-
rows: rows,
|
|
289
|
-
setFocus: setFocus,
|
|
290
|
-
type: type,
|
|
291
|
-
value: value,
|
|
292
|
-
name: name
|
|
293
|
-
}, forwardedProps))), (isValid || hasError) && React.createElement(Icon, {
|
|
294
|
-
className: "".concat(CLASSNAME, "__input-validity"),
|
|
295
|
-
color: theme === Theme.dark ? 'light' : undefined,
|
|
296
|
-
icon: isValid ? mdiCheckCircle : mdiAlertCircle,
|
|
297
|
-
size: Size.xxs
|
|
298
|
-
}), clearButtonProps && isNotEmpty && React.createElement(IconButton, _extends({}, clearButtonProps, {
|
|
299
|
-
className: "".concat(CLASSNAME, "__input-clear"),
|
|
300
|
-
icon: mdiCloseCircle,
|
|
301
|
-
emphasis: Emphasis.low,
|
|
302
|
-
size: Size.s,
|
|
303
|
-
theme: theme,
|
|
304
|
-
onClick: onClear,
|
|
305
|
-
type: "button"
|
|
306
|
-
})), afterElement && React.createElement("div", {
|
|
307
|
-
className: "".concat(CLASSNAME, "__after-element")
|
|
308
|
-
}, afterElement)), hasError && error && React.createElement(InputHelper, {
|
|
309
|
-
className: "".concat(CLASSNAME, "__helper"),
|
|
310
|
-
kind: Kind.error,
|
|
311
|
-
theme: theme
|
|
312
|
-
}, error), helper && React.createElement(InputHelper, {
|
|
313
|
-
className: "".concat(CLASSNAME, "__helper"),
|
|
314
|
-
theme: theme
|
|
315
|
-
}, helper));
|
|
316
|
-
});
|
|
317
|
-
TextField.displayName = COMPONENT_NAME;
|
|
318
|
-
TextField.className = CLASSNAME;
|
|
319
|
-
TextField.defaultProps = DEFAULT_PROPS;
|
|
320
|
-
|
|
321
|
-
export { TextField as T };
|
|
322
|
-
//# sourceMappingURL=TextField.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TextField.js","sources":["../../../src/components/text-field/TextField.tsx"],"sourcesContent":["import React, { forwardRef, ReactNode, Ref, SyntheticEvent, useEffect, useMemo, useRef, useState } from 'react';\n\nimport classNames from 'classnames';\nimport get from 'lodash/get';\nimport { uid } from 'uid';\n\nimport { mdiAlertCircle, mdiCheckCircle, mdiCloseCircle } from '@lumx/icons';\nimport { Emphasis, Icon, IconButton, IconButtonProps, InputHelper, InputLabel, Kind, Size, Theme } from '@lumx/react';\nimport { Comp, GenericProps, getRootClassName, handleBasicClasses, HasTheme } from '@lumx/react/utils';\nimport { mergeRefs } from '@lumx/react/utils/mergeRefs';\n\n/**\n * Defines the props of the component.\n */\nexport interface TextFieldProps extends GenericProps, HasTheme {\n /** Chip Group to be rendered before the main text input. */\n chips?: HTMLElement | ReactNode;\n /** Props to pass to the clear button (minus those already set by the TextField props). If not specified, the button won't be displayed. */\n clearButtonProps?: Pick<IconButtonProps, 'label'> &\n Omit<IconButtonProps, 'label' | 'onClick' | 'icon' | 'emphasis'>;\n /** Error message. */\n error?: string | ReactNode;\n /** Whether we force the focus style or not. */\n forceFocusStyle?: boolean;\n /** Whether the text field is displayed with error style or not. */\n hasError?: boolean;\n /** Additional element to put at the end of the text field. */\n afterElement?: ReactNode;\n /** Helper text. */\n helper?: string | ReactNode;\n /** Icon (SVG path). */\n icon?: string;\n /** Native input id property (generated if not provided to link the label element). */\n id?: string;\n /** Reference to the <input> or <textarea> element. */\n inputRef?: Ref<HTMLInputElement | HTMLTextAreaElement>;\n /** Whether the component is disabled or not. */\n isDisabled?: boolean;\n /** Whether the component is required or not. */\n isRequired?: boolean;\n /** Whether the text field is displayed with valid style or not. */\n isValid?: boolean;\n /** Label text. */\n label?: string;\n /** Max string length the input accepts (constrains the input and displays a character counter). */\n maxLength?: number;\n /** Minimum number of rows displayed in multiline mode (requires `multiline` to be enabled). */\n minimumRows?: number;\n /** Whether the text field is a textarea or an input. */\n multiline?: boolean;\n /** Native input name property. */\n name?: string;\n /** Placeholder text. */\n placeholder?: string;\n /** Reference to the wrapper. */\n textFieldRef?: Ref<HTMLDivElement>;\n /** Value. */\n value?: string;\n /** On blur callback. */\n onBlur?(event: React.FocusEvent): void;\n /** On change callback. */\n onChange(value: string, name?: string, event?: SyntheticEvent): void;\n /** On focus callback. */\n onFocus?(event: React.FocusEvent): void;\n}\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'TextField';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/**\n * Default minimum number of rows in the multiline mode.\n */\nconst DEFAULT_MIN_ROWS = 2;\n\n/**\n * Component default props.\n */\nconst DEFAULT_PROPS: Partial<TextFieldProps> = {\n theme: Theme.light,\n type: 'text',\n};\n\n/**\n * Hook that allows to calculate the number of rows needed for a text area.\n * @param minimumRows Minimum number of rows that we want to display.\n * @return rows to be used and a callback to recalculate\n */\nconst useComputeNumberOfRows = (\n minimumRows: number,\n): {\n /** number of rows to be used on the text area */\n rows: number;\n /**\n * Callback in order to recalculate the number of rows due to a change on the text area\n */\n recomputeNumberOfRows(target: Element): void;\n} => {\n const [rows, setRows] = useState(minimumRows);\n\n const recompute = (target: Element) => {\n /**\n * HEAD's UP! This part is a little bit tricky. The idea here is to only\n * display the necessary rows on the textarea. In order to dynamically adjust\n * the height on that field, we need to:\n * 1. Set the current amount of rows to the minimum. That will make the scroll appear.\n * 2. With that, we will have the `scrollHeight`, meaning the height of the container adjusted to the current content\n * 3. With the scroll height, we can figure out how many rows we need to use by dividing the scroll height\n * by the line height.\n * 4. With that number, we can readjust the number of rows on the text area. We need to do that here, if we leave that to\n * the state change through React, there are some scenarios (resize, hitting ENTER or BACKSPACE which add or remove lines)\n * when we will not see the update and the rows will be resized to the minimum.\n * 5. In case there is any other update on the component that changes the UI, we need to keep the number of rows\n * on the state in order to allow React to re-render. Therefore, we save them using `useState`\n */\n // eslint-disable-next-line no-param-reassign\n (target as HTMLTextAreaElement).rows = minimumRows;\n let currentRows = target.scrollHeight / (target.clientHeight / minimumRows);\n currentRows = currentRows >= minimumRows ? currentRows : minimumRows;\n // eslint-disable-next-line no-param-reassign\n (target as HTMLTextAreaElement).rows = currentRows;\n\n setRows(currentRows);\n };\n\n return {\n recomputeNumberOfRows: recompute,\n rows,\n };\n};\n\ninterface InputNativeProps {\n id?: string;\n inputRef?: TextFieldProps['inputRef'];\n isDisabled?: boolean;\n isRequired?: boolean;\n multiline?: boolean;\n maxLength?: number;\n placeholder?: string;\n rows: number;\n type: string;\n name?: string;\n value?: string;\n setFocus(focus: boolean): void;\n recomputeNumberOfRows(target: Element): void;\n onChange(value: string, name?: string, event?: SyntheticEvent): void;\n onFocus?(value: React.FocusEvent): void;\n onBlur?(value: React.FocusEvent): void;\n}\n\nconst renderInputNative: React.FC<InputNativeProps> = (props) => {\n const {\n id,\n isDisabled,\n isRequired,\n placeholder,\n multiline,\n value,\n setFocus,\n onChange,\n onFocus,\n onBlur,\n inputRef,\n rows,\n recomputeNumberOfRows,\n type,\n name,\n ...forwardedProps\n } = props;\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const ref = useRef<HTMLElement>(null);\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useEffect(() => {\n // Recompute the number of rows for the first rendering\n if (multiline && ref && ref.current) {\n recomputeNumberOfRows(ref.current);\n }\n }, [ref, multiline, recomputeNumberOfRows, value]);\n\n const onTextFieldFocus = (event: React.FocusEvent) => {\n onFocus?.(event);\n setFocus(true);\n };\n\n const onTextFieldBlur = (event: React.FocusEvent) => {\n onBlur?.(event);\n setFocus(false);\n };\n\n const handleChange = (event: React.ChangeEvent) => {\n onChange(get(event, 'target.value'), name, event);\n };\n\n const Component = multiline ? 'textarea' : 'input';\n const inputProps: any = {\n ...forwardedProps,\n id,\n className: multiline\n ? `${CLASSNAME}__input-native ${CLASSNAME}__input-native--textarea`\n : `${CLASSNAME}__input-native ${CLASSNAME}__input-native--text`,\n placeholder,\n value,\n name,\n disabled: isDisabled,\n required: isRequired,\n onFocus: onTextFieldFocus,\n onBlur: onTextFieldBlur,\n onChange: handleChange,\n ref: mergeRefs(inputRef as any, ref) as any,\n };\n if (multiline) {\n inputProps.rows = rows;\n } else {\n inputProps.type = type;\n }\n return <Component {...inputProps} />;\n};\n\n/**\n * TextField component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const TextField: Comp<TextFieldProps, HTMLDivElement> = forwardRef((props, ref) => {\n const {\n chips,\n className,\n clearButtonProps,\n disabled,\n error,\n forceFocusStyle,\n hasError,\n helper,\n icon,\n id,\n inputRef,\n isDisabled = disabled,\n isRequired,\n isValid,\n label,\n maxLength,\n minimumRows,\n multiline,\n name,\n onBlur,\n onChange,\n onFocus,\n placeholder,\n textFieldRef,\n theme,\n type,\n value,\n afterElement,\n ...forwardedProps\n } = props;\n const textFieldId = useMemo(() => id || `text-field-${uid()}`, [id]);\n const [isFocus, setFocus] = useState(false);\n const { rows, recomputeNumberOfRows } = useComputeNumberOfRows(multiline ? minimumRows || DEFAULT_MIN_ROWS : 0);\n const valueLength = (value || '').length;\n const isNotEmpty = valueLength > 0;\n\n /**\n * Function triggered when the Clear Button is clicked.\n * The idea is to execute the `onChange` callback with an empty string\n * and remove focus from the clear button.\n * @param evt On clear event.\n */\n const onClear = (evt: React.ChangeEvent) => {\n evt.nativeEvent.preventDefault();\n evt.nativeEvent.stopPropagation();\n (evt.currentTarget as HTMLElement).blur();\n\n onChange('');\n };\n\n return (\n <div\n ref={ref}\n className={classNames(\n className,\n handleBasicClasses({\n hasChips: Boolean(chips),\n hasError: !isValid && hasError,\n hasIcon: Boolean(icon),\n hasInput: !multiline,\n hasInputClear: clearButtonProps && isNotEmpty,\n hasLabel: Boolean(label),\n hasPlaceholder: Boolean(placeholder),\n hasTextarea: multiline,\n hasValue: Boolean(value),\n isDisabled,\n isFocus: isFocus || forceFocusStyle,\n isValid,\n prefix: CLASSNAME,\n theme,\n }),\n )}\n >\n {(label || maxLength) && (\n <div className={`${CLASSNAME}__header`}>\n {label && (\n <InputLabel\n htmlFor={textFieldId}\n className={`${CLASSNAME}__label`}\n isRequired={isRequired}\n theme={theme}\n >\n {label}\n </InputLabel>\n )}\n\n {maxLength && (\n <div className={`${CLASSNAME}__char-counter`}>\n <span>{maxLength - valueLength}</span>\n {maxLength - valueLength === 0 && <Icon icon={mdiAlertCircle} size={Size.xxs} />}\n </div>\n )}\n </div>\n )}\n\n <div className={`${CLASSNAME}__wrapper`} ref={textFieldRef}>\n {icon && (\n <Icon\n className={`${CLASSNAME}__input-icon`}\n color={theme === Theme.dark ? 'light' : undefined}\n icon={icon}\n size={Size.xs}\n />\n )}\n\n {chips && (\n <div className={`${CLASSNAME}__chips`}>\n {chips}\n\n {renderInputNative({\n id: textFieldId,\n inputRef,\n isDisabled,\n isRequired,\n maxLength,\n multiline,\n onBlur,\n onChange,\n onFocus,\n placeholder,\n recomputeNumberOfRows,\n rows,\n setFocus,\n type,\n value,\n name,\n ...forwardedProps,\n })}\n </div>\n )}\n\n {!chips && (\n <div className={`${CLASSNAME}__input-wrapper`}>\n {renderInputNative({\n id: textFieldId,\n inputRef,\n isDisabled,\n isRequired,\n maxLength,\n multiline,\n onBlur,\n onChange,\n onFocus,\n placeholder,\n recomputeNumberOfRows,\n rows,\n setFocus,\n type,\n value,\n name,\n ...forwardedProps,\n })}\n </div>\n )}\n\n {(isValid || hasError) && (\n <Icon\n className={`${CLASSNAME}__input-validity`}\n color={theme === Theme.dark ? 'light' : undefined}\n icon={isValid ? mdiCheckCircle : mdiAlertCircle}\n size={Size.xxs}\n />\n )}\n\n {clearButtonProps && isNotEmpty && (\n <IconButton\n {...clearButtonProps}\n className={`${CLASSNAME}__input-clear`}\n icon={mdiCloseCircle}\n emphasis={Emphasis.low}\n size={Size.s}\n theme={theme}\n onClick={onClear}\n type=\"button\"\n />\n )}\n\n {afterElement && <div className={`${CLASSNAME}__after-element`}>{afterElement}</div>}\n </div>\n\n {hasError && error && (\n <InputHelper className={`${CLASSNAME}__helper`} kind={Kind.error} theme={theme}>\n {error}\n </InputHelper>\n )}\n\n {helper && (\n <InputHelper className={`${CLASSNAME}__helper`} theme={theme}>\n {helper}\n </InputHelper>\n )}\n </div>\n );\n});\nTextField.displayName = COMPONENT_NAME;\nTextField.className = CLASSNAME;\nTextField.defaultProps = DEFAULT_PROPS;\n"],"names":["COMPONENT_NAME","CLASSNAME","getRootClassName","DEFAULT_MIN_ROWS","DEFAULT_PROPS","theme","Theme","light","type","useComputeNumberOfRows","minimumRows","useState","rows","setRows","recompute","target","currentRows","scrollHeight","clientHeight","recomputeNumberOfRows","renderInputNative","props","id","isDisabled","isRequired","placeholder","multiline","value","setFocus","onChange","onFocus","onBlur","inputRef","name","forwardedProps","ref","useRef","useEffect","current","onTextFieldFocus","event","onTextFieldBlur","handleChange","get","Component","inputProps","className","disabled","required","mergeRefs","TextField","forwardRef","chips","clearButtonProps","error","forceFocusStyle","hasError","helper","icon","isValid","label","maxLength","textFieldRef","afterElement","textFieldId","useMemo","uid","isFocus","valueLength","length","isNotEmpty","onClear","evt","nativeEvent","preventDefault","stopPropagation","currentTarget","blur","classNames","handleBasicClasses","hasChips","Boolean","hasIcon","hasInput","hasInputClear","hasLabel","hasPlaceholder","hasTextarea","hasValue","prefix","mdiAlertCircle","Size","xxs","dark","undefined","xs","mdiCheckCircle","mdiCloseCircle","Emphasis","low","s","Kind","displayName","defaultProps"],"mappings":";;;;;;;;;;;;AAWA;;;;AAuDA;;;AAGA,IAAMA,cAAc,GAAG,WAAvB;AAEA;;;;AAGA,IAAMC,SAAS,GAAGC,gBAAgB,CAACF,cAAD,CAAlC;AAEA;;;;AAGA,IAAMG,gBAAgB,GAAG,CAAzB;AAEA;;;;AAGA,IAAMC,aAAsC,GAAG;AAC3CC,EAAAA,KAAK,EAAEC,KAAK,CAACC,KAD8B;AAE3CC,EAAAA,IAAI,EAAE;AAFqC,CAA/C;AAKA;;;;;;AAKA,IAA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AAS,CAACJ,SAAV,GAAsB7C,SAAtB;AACAiD,SAAS,CAACqD,YAAV,GAAyBnG,aAAzB;;;;"}
|
|
@@ -1,301 +0,0 @@
|
|
|
1
|
-
import { d as _slicedToArray, b as _objectWithoutProperties, _ as _objectSpread2, c as _extends } from './_rollupPluginBabelHelpers.js';
|
|
2
|
-
import { AspectRatio, Size, Theme } from './components.js';
|
|
3
|
-
import React, { useState, useEffect, useMemo, forwardRef } from 'react';
|
|
4
|
-
import { g as getRootClassName, c as classnames, h as handleBasicClasses } from './getRootClassName.js';
|
|
5
|
-
import { I as Icon, t as mdiImageBroken } from './Icon2.js';
|
|
6
|
-
import { m as mergeRefs } from './mergeRefs.js';
|
|
7
|
-
|
|
8
|
-
function getState(img, event) {
|
|
9
|
-
// Error event occurred or image loaded empty.
|
|
10
|
-
if ((event === null || event === void 0 ? void 0 : event.type) === 'error' || (img === null || img === void 0 ? void 0 : img.complete) && ((img === null || img === void 0 ? void 0 : img.naturalWidth) === 0 || (img === null || img === void 0 ? void 0 : img.naturalHeight) === 0)) {
|
|
11
|
-
return 'hasError';
|
|
12
|
-
} // Image is undefined or incomplete.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (!img || !img.complete) {
|
|
16
|
-
return 'isLoading';
|
|
17
|
-
} // Else loaded.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return 'isLoaded';
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function useImageLoad(imageURL, imgRef) {
|
|
24
|
-
var _useState = useState(getState(imgRef)),
|
|
25
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
26
|
-
state = _useState2[0],
|
|
27
|
-
setState = _useState2[1]; // Update state when changing image URL or DOM reference.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
useEffect(function () {
|
|
31
|
-
setState(getState(imgRef));
|
|
32
|
-
}, [imageURL, imgRef]); // Listen to `load` and `error` event on image
|
|
33
|
-
|
|
34
|
-
useEffect(function () {
|
|
35
|
-
var img = imgRef;
|
|
36
|
-
if (!img) return undefined;
|
|
37
|
-
|
|
38
|
-
var update = function update(event) {
|
|
39
|
-
return setState(getState(img, event));
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
img.addEventListener('load', update);
|
|
43
|
-
img.addEventListener('error', update);
|
|
44
|
-
return function () {
|
|
45
|
-
img.removeEventListener('load', update);
|
|
46
|
-
img.removeEventListener('error', update);
|
|
47
|
-
};
|
|
48
|
-
}, [imgRef, imgRef === null || imgRef === void 0 ? void 0 : imgRef.src]);
|
|
49
|
-
return state;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// Calculate shift to center the focus point in the container.
|
|
53
|
-
function shiftPosition(_ref) {
|
|
54
|
-
var scale = _ref.scale,
|
|
55
|
-
focusPoint = _ref.focusPoint,
|
|
56
|
-
imageSize = _ref.imageSize,
|
|
57
|
-
containerSize = _ref.containerSize;
|
|
58
|
-
var scaledSize = imageSize / scale;
|
|
59
|
-
if (scaledSize === containerSize) return 0;
|
|
60
|
-
var scaledFocusHeight = focusPoint * scaledSize;
|
|
61
|
-
var startFocus = scaledFocusHeight - containerSize / 2;
|
|
62
|
-
var shift = startFocus / (scaledSize - containerSize);
|
|
63
|
-
return Math.floor(Math.max(Math.min(shift, 1), 0) * 100);
|
|
64
|
-
}
|
|
65
|
-
// Compute CSS properties to apply the focus point.
|
|
66
|
-
var useFocusPointStyle = function useFocusPointStyle(_ref2, element, isLoaded) {
|
|
67
|
-
var image = _ref2.image,
|
|
68
|
-
aspectRatio = _ref2.aspectRatio,
|
|
69
|
-
focusPoint = _ref2.focusPoint,
|
|
70
|
-
_ref2$imgProps = _ref2.imgProps;
|
|
71
|
-
_ref2$imgProps = _ref2$imgProps === void 0 ? {} : _ref2$imgProps;
|
|
72
|
-
var width = _ref2$imgProps.width,
|
|
73
|
-
height = _ref2$imgProps.height;
|
|
74
|
-
// Get natural image size from imgProps or img element.
|
|
75
|
-
var imageSize = useMemo(function () {
|
|
76
|
-
// Focus point is not applicable => exit early
|
|
77
|
-
if (!image || aspectRatio === AspectRatio.original || !(focusPoint === null || focusPoint === void 0 ? void 0 : focusPoint.x) && !(focusPoint === null || focusPoint === void 0 ? void 0 : focusPoint.y)) return undefined;
|
|
78
|
-
if (typeof width === 'number' && typeof height === 'number') return {
|
|
79
|
-
width: width,
|
|
80
|
-
height: height
|
|
81
|
-
};
|
|
82
|
-
if (element && isLoaded) return {
|
|
83
|
-
width: element.naturalWidth,
|
|
84
|
-
height: element.naturalHeight
|
|
85
|
-
};
|
|
86
|
-
return undefined;
|
|
87
|
-
}, [aspectRatio, element, focusPoint === null || focusPoint === void 0 ? void 0 : focusPoint.x, focusPoint === null || focusPoint === void 0 ? void 0 : focusPoint.y, height, image, isLoaded, width]); // Get container size (dependant on imageSize).
|
|
88
|
-
|
|
89
|
-
var _useState = useState(undefined),
|
|
90
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
91
|
-
containerSize = _useState2[0],
|
|
92
|
-
setContainerSize = _useState2[1];
|
|
93
|
-
|
|
94
|
-
useEffect(function updateContainerSize() {
|
|
95
|
-
var cWidth = element === null || element === void 0 ? void 0 : element.offsetWidth;
|
|
96
|
-
var cHeight = element === null || element === void 0 ? void 0 : element.offsetHeight;
|
|
97
|
-
|
|
98
|
-
if (cWidth && cHeight) {
|
|
99
|
-
// Update only if needed.
|
|
100
|
-
setContainerSize(function (oldContainerSize) {
|
|
101
|
-
return (oldContainerSize === null || oldContainerSize === void 0 ? void 0 : oldContainerSize.width) === cWidth && oldContainerSize.height === cHeight ? oldContainerSize : {
|
|
102
|
-
width: cWidth,
|
|
103
|
-
height: cHeight
|
|
104
|
-
};
|
|
105
|
-
});
|
|
106
|
-
} else if (imageSize) {
|
|
107
|
-
// Wait for a render (in case the container size is dependent on the image size).
|
|
108
|
-
requestAnimationFrame(updateContainerSize);
|
|
109
|
-
}
|
|
110
|
-
}, [element === null || element === void 0 ? void 0 : element.offsetHeight, element === null || element === void 0 ? void 0 : element.offsetWidth, imageSize]); // Compute style.
|
|
111
|
-
|
|
112
|
-
var _useState3 = useState({}),
|
|
113
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
114
|
-
style = _useState4[0],
|
|
115
|
-
setStyle = _useState4[1];
|
|
116
|
-
|
|
117
|
-
useEffect(function () {
|
|
118
|
-
// Focus point is not applicable => exit early
|
|
119
|
-
if (!image || aspectRatio === AspectRatio.original || !(focusPoint === null || focusPoint === void 0 ? void 0 : focusPoint.x) && !(focusPoint === null || focusPoint === void 0 ? void 0 : focusPoint.y)) {
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
if (!element || !imageSize) {
|
|
124
|
-
// Focus point can be computed but now right now (image size unknown).
|
|
125
|
-
setStyle({
|
|
126
|
-
visibility: 'hidden'
|
|
127
|
-
});
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
if (!containerSize) {
|
|
132
|
-
// Missing container size abort focus point compute.
|
|
133
|
-
setStyle({});
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
var heightScale = imageSize.height / containerSize.height;
|
|
138
|
-
var widthScale = imageSize.width / containerSize.width;
|
|
139
|
-
var scale = Math.min(widthScale, heightScale); // Focus Y relative to the top (instead of the center)
|
|
140
|
-
|
|
141
|
-
var focusPointFromTop = Math.abs(((focusPoint === null || focusPoint === void 0 ? void 0 : focusPoint.y) || 0) - 1) / 2;
|
|
142
|
-
var y = shiftPosition({
|
|
143
|
-
scale: scale,
|
|
144
|
-
focusPoint: focusPointFromTop,
|
|
145
|
-
imageSize: imageSize.height,
|
|
146
|
-
containerSize: containerSize.height
|
|
147
|
-
}); // Focus X relative to the left (instead of the center)
|
|
148
|
-
|
|
149
|
-
var focusPointFromLeft = Math.abs(((focusPoint === null || focusPoint === void 0 ? void 0 : focusPoint.x) || 0) + 1) / 2;
|
|
150
|
-
var x = shiftPosition({
|
|
151
|
-
scale: scale,
|
|
152
|
-
focusPoint: focusPointFromLeft,
|
|
153
|
-
imageSize: imageSize.width,
|
|
154
|
-
containerSize: containerSize.width
|
|
155
|
-
});
|
|
156
|
-
var objectPosition = "".concat(x, "% ").concat(y, "%"); // Update only if needed.
|
|
157
|
-
|
|
158
|
-
setStyle(function (oldStyle) {
|
|
159
|
-
return oldStyle.objectPosition === objectPosition ? oldStyle : {
|
|
160
|
-
objectPosition: objectPosition
|
|
161
|
-
};
|
|
162
|
-
});
|
|
163
|
-
}, [aspectRatio, containerSize, element, focusPoint === null || focusPoint === void 0 ? void 0 : focusPoint.x, focusPoint === null || focusPoint === void 0 ? void 0 : focusPoint.y, image, imageSize]);
|
|
164
|
-
return style;
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* Component display name.
|
|
169
|
-
*/
|
|
170
|
-
var COMPONENT_NAME = 'Thumbnail';
|
|
171
|
-
/**
|
|
172
|
-
* Component default class name and class prefix.
|
|
173
|
-
*/
|
|
174
|
-
|
|
175
|
-
var CLASSNAME = getRootClassName(COMPONENT_NAME);
|
|
176
|
-
/**
|
|
177
|
-
* Component default props.
|
|
178
|
-
*/
|
|
179
|
-
|
|
180
|
-
var DEFAULT_PROPS = {
|
|
181
|
-
fallback: mdiImageBroken,
|
|
182
|
-
loading: 'lazy',
|
|
183
|
-
theme: Theme.light
|
|
184
|
-
};
|
|
185
|
-
/**
|
|
186
|
-
* Thumbnail component.
|
|
187
|
-
*
|
|
188
|
-
* @param props Component props.
|
|
189
|
-
* @param ref Component ref.
|
|
190
|
-
* @return React element.
|
|
191
|
-
*/
|
|
192
|
-
|
|
193
|
-
var Thumbnail = forwardRef(function (props, ref) {
|
|
194
|
-
var align = props.align,
|
|
195
|
-
alt = props.alt,
|
|
196
|
-
_props$aspectRatio = props.aspectRatio,
|
|
197
|
-
aspectRatio = _props$aspectRatio === void 0 ? AspectRatio.original : _props$aspectRatio,
|
|
198
|
-
badge = props.badge,
|
|
199
|
-
className = props.className,
|
|
200
|
-
crossOrigin = props.crossOrigin,
|
|
201
|
-
fallback = props.fallback,
|
|
202
|
-
fillHeight = props.fillHeight,
|
|
203
|
-
focusPoint = props.focusPoint,
|
|
204
|
-
image = props.image,
|
|
205
|
-
imgProps = props.imgProps,
|
|
206
|
-
propImgRef = props.imgRef,
|
|
207
|
-
isLoadingProp = props.isLoading,
|
|
208
|
-
loading = props.loading,
|
|
209
|
-
size = props.size,
|
|
210
|
-
theme = props.theme,
|
|
211
|
-
variant = props.variant,
|
|
212
|
-
linkProps = props.linkProps,
|
|
213
|
-
linkAs = props.linkAs,
|
|
214
|
-
forwardedProps = _objectWithoutProperties(props, ["align", "alt", "aspectRatio", "badge", "className", "crossOrigin", "fallback", "fillHeight", "focusPoint", "image", "imgProps", "imgRef", "isLoading", "loading", "size", "theme", "variant", "linkProps", "linkAs"]);
|
|
215
|
-
|
|
216
|
-
var _useState = useState(),
|
|
217
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
218
|
-
imgElement = _useState2[0],
|
|
219
|
-
setImgElement = _useState2[1]; // Image loading state.
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
var loadingState = useImageLoad(image, imgElement);
|
|
223
|
-
var isLoaded = loadingState === 'isLoaded';
|
|
224
|
-
var isLoading = isLoadingProp || loadingState === 'isLoading';
|
|
225
|
-
var hasError = loadingState === 'hasError'; // Focus point.
|
|
226
|
-
|
|
227
|
-
var focusPointStyle = useFocusPointStyle(props, imgElement, isLoaded);
|
|
228
|
-
var hasIconErrorFallback = hasError && typeof fallback === 'string';
|
|
229
|
-
var hasCustomErrorFallback = hasError && !hasIconErrorFallback;
|
|
230
|
-
var imageErrorStyle = {};
|
|
231
|
-
|
|
232
|
-
if (hasIconErrorFallback) {
|
|
233
|
-
// Keep the image layout on icon fallback.
|
|
234
|
-
imageErrorStyle.visibility = 'hidden';
|
|
235
|
-
} else if (hasCustomErrorFallback) {
|
|
236
|
-
// Remove the image on custom fallback.
|
|
237
|
-
imageErrorStyle.display = 'none';
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
var isLink = Boolean((linkProps === null || linkProps === void 0 ? void 0 : linkProps.href) || linkAs);
|
|
241
|
-
var isButton = !!forwardedProps.onClick;
|
|
242
|
-
var isClickable = isButton || isLink;
|
|
243
|
-
var Wrapper = 'div';
|
|
244
|
-
|
|
245
|
-
var wrapperProps = _objectSpread2({}, forwardedProps);
|
|
246
|
-
|
|
247
|
-
if (isLink) {
|
|
248
|
-
Wrapper = linkAs || 'a';
|
|
249
|
-
Object.assign(wrapperProps, linkProps);
|
|
250
|
-
} else if (isButton) {
|
|
251
|
-
Wrapper = 'button';
|
|
252
|
-
wrapperProps.type = forwardedProps.type || 'button';
|
|
253
|
-
wrapperProps['aria-label'] = forwardedProps['aria-label'] || alt;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
return React.createElement(Wrapper, _extends({}, wrapperProps, {
|
|
257
|
-
ref: ref,
|
|
258
|
-
className: classnames(linkProps === null || linkProps === void 0 ? void 0 : linkProps.className, className, handleBasicClasses({
|
|
259
|
-
align: align,
|
|
260
|
-
aspectRatio: aspectRatio,
|
|
261
|
-
prefix: CLASSNAME,
|
|
262
|
-
size: size,
|
|
263
|
-
theme: theme,
|
|
264
|
-
variant: variant,
|
|
265
|
-
isClickable: isClickable,
|
|
266
|
-
hasError: hasError,
|
|
267
|
-
hasIconErrorFallback: hasIconErrorFallback,
|
|
268
|
-
hasCustomErrorFallback: hasCustomErrorFallback,
|
|
269
|
-
isLoading: isLoading,
|
|
270
|
-
hasBadge: !!badge
|
|
271
|
-
}), fillHeight && "".concat(CLASSNAME, "--fill-height"))
|
|
272
|
-
}), React.createElement("div", {
|
|
273
|
-
className: "".concat(CLASSNAME, "__background")
|
|
274
|
-
}, React.createElement("img", _extends({}, imgProps, {
|
|
275
|
-
style: _objectSpread2({}, imgProps === null || imgProps === void 0 ? void 0 : imgProps.style, {}, imageErrorStyle, {}, focusPointStyle),
|
|
276
|
-
ref: mergeRefs(setImgElement, propImgRef),
|
|
277
|
-
className: classnames(handleBasicClasses({
|
|
278
|
-
prefix: "".concat(CLASSNAME, "__image"),
|
|
279
|
-
isLoading: isLoading,
|
|
280
|
-
hasDefinedSize: Boolean((imgProps === null || imgProps === void 0 ? void 0 : imgProps.height) && imgProps.width)
|
|
281
|
-
}), imgProps === null || imgProps === void 0 ? void 0 : imgProps.className),
|
|
282
|
-
crossOrigin: crossOrigin,
|
|
283
|
-
src: image,
|
|
284
|
-
alt: alt,
|
|
285
|
-
loading: loading
|
|
286
|
-
})), !isLoading && hasError && React.createElement("div", {
|
|
287
|
-
className: "".concat(CLASSNAME, "__fallback")
|
|
288
|
-
}, hasIconErrorFallback ? React.createElement(Icon, {
|
|
289
|
-
icon: fallback,
|
|
290
|
-
size: Size.xxs,
|
|
291
|
-
theme: theme
|
|
292
|
-
}) : fallback)), badge && React.cloneElement(badge, {
|
|
293
|
-
className: classnames("".concat(CLASSNAME, "__badge"), badge.props.className)
|
|
294
|
-
}));
|
|
295
|
-
});
|
|
296
|
-
Thumbnail.displayName = COMPONENT_NAME;
|
|
297
|
-
Thumbnail.className = CLASSNAME;
|
|
298
|
-
Thumbnail.defaultProps = DEFAULT_PROPS;
|
|
299
|
-
|
|
300
|
-
export { Thumbnail as T, useFocusPointStyle as u };
|
|
301
|
-
//# sourceMappingURL=Thumbnail2.js.map
|