@webiny/ui 0.0.0-mt-2 → 0.0.0-unstable.085ff6572f
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/Accordion/Accordion.d.ts +5 -5
- package/Accordion/Accordion.js +22 -22
- package/Accordion/Accordion.js.map +1 -0
- package/Accordion/Accordion.stories.js +26 -23
- package/Accordion/Accordion.stories.js.map +1 -0
- package/Accordion/AccordionItem.d.ts +27 -8
- package/Accordion/AccordionItem.js +91 -84
- package/Accordion/AccordionItem.js.map +1 -0
- package/Accordion/AccordionItemActions.d.ts +8 -0
- package/Accordion/AccordionItemActions.js +28 -0
- package/Accordion/AccordionItemActions.js.map +1 -0
- package/Accordion/index.js +27 -2
- package/Accordion/index.js.map +1 -0
- package/Alert/Alert.d.ts +4 -4
- package/Alert/Alert.js +19 -15
- package/Alert/Alert.js.map +1 -0
- package/Alert/Alert.stories.js +16 -13
- package/Alert/Alert.stories.js.map +1 -0
- package/Alert/index.js +16 -1
- package/Alert/index.js.map +1 -0
- package/AutoComplete/AutoComplete.d.ts +13 -19
- package/AutoComplete/AutoComplete.js +150 -149
- package/AutoComplete/AutoComplete.js.map +1 -0
- package/AutoComplete/AutoComplete.stories.js +20 -17
- package/AutoComplete/AutoComplete.stories.js.map +1 -0
- package/AutoComplete/MultiAutoComplete.d.ts +44 -40
- package/AutoComplete/MultiAutoComplete.js +304 -311
- package/AutoComplete/MultiAutoComplete.js.map +1 -0
- package/AutoComplete/MultiAutoComplete.stories.js +31 -28
- package/AutoComplete/MultiAutoComplete.stories.js.map +1 -0
- package/AutoComplete/index.js +27 -2
- package/AutoComplete/index.js.map +1 -0
- package/AutoComplete/styles.js +33 -4
- package/AutoComplete/styles.js.map +1 -0
- package/AutoComplete/types.d.ts +4 -3
- package/AutoComplete/types.js +5 -1
- package/AutoComplete/types.js.map +1 -0
- package/AutoComplete/utils.d.ts +11 -5
- package/AutoComplete/utils.js +15 -8
- package/AutoComplete/utils.js.map +1 -0
- package/Avatar/Avatar.d.ts +5 -11
- package/Avatar/Avatar.js +37 -28
- package/Avatar/Avatar.js.map +1 -0
- package/Avatar/Avatar.stories.js +13 -10
- package/Avatar/Avatar.stories.js.map +1 -0
- package/Avatar/index.js +16 -1
- package/Avatar/index.js.map +1 -0
- package/Button/Button.d.ts +39 -24
- package/Button/Button.js +74 -83
- package/Button/Button.js.map +1 -0
- package/Button/Button.stories.js +32 -29
- package/Button/Button.stories.js.map +1 -0
- package/Button/Button.styles.d.ts +6 -0
- package/Button/Button.styles.js +13 -0
- package/Button/Button.styles.js.map +1 -0
- package/Button/CopyButton/CopyButton.d.ts +4 -7
- package/Button/CopyButton/CopyButton.js +18 -18
- package/Button/CopyButton/CopyButton.js.map +1 -0
- package/Button/CopyButton/CopyButton.stories.js +13 -10
- package/Button/CopyButton/CopyButton.stories.js.map +1 -0
- package/Button/IconButton/IconButton.d.ts +4 -7
- package/Button/IconButton/IconButton.js +16 -15
- package/Button/IconButton/IconButton.js.map +1 -0
- package/Button/IconButton/IconButton.stories.js +22 -19
- package/Button/IconButton/IconButton.stories.js.map +1 -0
- package/Button/index.js +38 -3
- package/Button/index.js.map +1 -0
- package/Carousel/Carousel.d.ts +3 -3
- package/Carousel/Carousel.js +24 -25
- package/Carousel/Carousel.js.map +1 -0
- package/Carousel/Carouser.stories.js +20 -17
- package/Carousel/Carouser.stories.js.map +1 -0
- package/Carousel/index.js +13 -1
- package/Carousel/index.js.map +1 -0
- package/Checkbox/Checkbox.d.ts +6 -9
- package/Checkbox/Checkbox.js +40 -44
- package/Checkbox/Checkbox.js.map +1 -0
- package/Checkbox/Checkbox.stories.js +19 -16
- package/Checkbox/Checkbox.stories.js.map +1 -0
- package/Checkbox/Checkbox.styles.js +9 -4
- package/Checkbox/Checkbox.styles.js.map +1 -0
- package/Checkbox/CheckboxGroup.d.ts +2 -2
- package/Checkbox/CheckboxGroup.js +34 -35
- package/Checkbox/CheckboxGroup.js.map +1 -0
- package/Checkbox/CheckboxGroup.stories.js +23 -20
- package/Checkbox/CheckboxGroup.stories.js.map +1 -0
- package/Checkbox/index.js +20 -2
- package/Checkbox/index.js.map +1 -0
- package/Chips/Chip.d.ts +3 -8
- package/Chips/Chip.js +15 -8
- package/Chips/Chip.js.map +1 -0
- package/Chips/Chips.d.ts +4 -4
- package/Chips/Chips.js +21 -14
- package/Chips/Chips.js.map +1 -0
- package/Chips/Chips.stories.js +25 -18
- package/Chips/Chips.stories.js.map +1 -0
- package/Chips/index.d.ts +0 -1
- package/Chips/index.js +27 -3
- package/Chips/index.js.map +1 -0
- package/Chips/styles.js +19 -9
- package/Chips/styles.js.map +1 -0
- package/CodeEditor/CodeEditor.d.ts +5 -8
- package/CodeEditor/CodeEditor.js +42 -49
- package/CodeEditor/CodeEditor.js.map +1 -0
- package/CodeEditor/CodeEditor.stories.js +20 -17
- package/CodeEditor/CodeEditor.stories.js.map +1 -0
- package/CodeEditor/index.js +16 -1
- package/CodeEditor/index.js.map +1 -0
- package/ColorPicker/ColorPicker.d.ts +9 -10
- package/ColorPicker/ColorPicker.js +54 -66
- package/ColorPicker/ColorPicker.js.map +1 -0
- package/ColorPicker/ColorPicker.stories.js +18 -15
- package/ColorPicker/ColorPicker.stories.js.map +1 -0
- package/ColorPicker/index.js +16 -1
- package/ColorPicker/index.js.map +1 -0
- package/ConfirmationDialog/ConfirmationDialog.d.ts +13 -13
- package/ConfirmationDialog/ConfirmationDialog.js +76 -96
- package/ConfirmationDialog/ConfirmationDialog.js.map +1 -0
- package/ConfirmationDialog/ConfirmationDialog.stories.js +15 -12
- package/ConfirmationDialog/ConfirmationDialog.stories.js.map +1 -0
- package/ConfirmationDialog/index.js +27 -2
- package/ConfirmationDialog/index.js.map +1 -0
- package/ConfirmationDialog/withConfirmation.d.ts +2 -2
- package/ConfirmationDialog/withConfirmation.js +14 -6
- package/ConfirmationDialog/withConfirmation.js.map +1 -0
- package/DataTable/DataTable.d.ts +75 -0
- package/DataTable/DataTable.js +198 -0
- package/DataTable/DataTable.js.map +1 -0
- package/DataTable/DataTable.stories.d.ts +1 -0
- package/DataTable/DataTable.stories.js +74 -0
- package/DataTable/DataTable.stories.js.map +1 -0
- package/DataTable/README.md +72 -0
- package/DataTable/index.d.ts +1 -0
- package/DataTable/index.js +16 -0
- package/DataTable/index.js.map +1 -0
- package/DataTable/styled.d.ts +30 -0
- package/DataTable/styled.js +36 -0
- package/DataTable/styled.js.map +1 -0
- package/DelayedOnChange/DelayedOnChange.d.ts +40 -0
- package/DelayedOnChange/DelayedOnChange.js +113 -0
- package/DelayedOnChange/DelayedOnChange.js.map +1 -0
- package/DelayedOnChange/index.d.ts +2 -0
- package/DelayedOnChange/index.js +20 -0
- package/DelayedOnChange/index.js.map +1 -0
- package/DelayedOnChange/withDelayedOnChange.d.ts +3 -0
- package/DelayedOnChange/withDelayedOnChange.js +31 -0
- package/DelayedOnChange/withDelayedOnChange.js.map +1 -0
- package/Dialog/Dialog.d.ts +22 -30
- package/Dialog/Dialog.js +59 -55
- package/Dialog/Dialog.js.map +1 -0
- package/Dialog/Dialog.stories.js +19 -16
- package/Dialog/Dialog.stories.js.map +1 -0
- package/Dialog/index.js +16 -1
- package/Dialog/index.js.map +1 -0
- package/Drawer/Drawer.d.ts +1 -1
- package/Drawer/Drawer.js +14 -9
- package/Drawer/Drawer.js.map +1 -0
- package/Drawer/Drawer.stories.js +18 -15
- package/Drawer/Drawer.stories.js.map +1 -0
- package/Drawer/index.js +16 -1
- package/Drawer/index.js.map +1 -0
- package/DynamicFieldset/Fieldset.d.ts +26 -16
- package/DynamicFieldset/Fieldset.js +69 -74
- package/DynamicFieldset/Fieldset.js.map +1 -0
- package/DynamicFieldset/index.js +13 -1
- package/DynamicFieldset/index.js.map +1 -0
- package/Elevation/Elevation.d.ts +1 -1
- package/Elevation/Elevation.js +12 -6
- package/Elevation/Elevation.js.map +1 -0
- package/Elevation/Elevation.stories.js +19 -16
- package/Elevation/Elevation.stories.js.map +1 -0
- package/Elevation/index.js +16 -1
- package/Elevation/index.js.map +1 -0
- package/FormElementMessage/FormElementMessage.d.ts +1 -1
- package/FormElementMessage/FormElementMessage.js +11 -6
- package/FormElementMessage/FormElementMessage.js.map +1 -0
- package/FormElementMessage/index.js +12 -1
- package/FormElementMessage/index.js.map +1 -0
- package/FullName/FullName.js +7 -7
- package/FullName/FullName.js.map +1 -0
- package/FullName/index.js +16 -1
- package/FullName/index.js.map +1 -0
- package/Grid/Grid.d.ts +1 -1
- package/Grid/Grid.js +19 -10
- package/Grid/Grid.js.map +1 -0
- package/Grid/Grid.stories.js +15 -12
- package/Grid/Grid.stories.js.map +1 -0
- package/Grid/index.js +16 -1
- package/Grid/index.js.map +1 -0
- package/Helpers/ClassNames.d.ts +4 -3
- package/Helpers/ClassNames.js +16 -14
- package/Helpers/ClassNames.js.map +1 -0
- package/Helpers/index.js +12 -2
- package/Helpers/index.js.map +1 -0
- package/Icon/Icon.d.ts +3 -6
- package/Icon/Icon.js +15 -12
- package/Icon/Icon.js.map +1 -0
- package/Icon/Icon.stories.js +23 -20
- package/Icon/Icon.stories.js.map +1 -0
- package/Icon/index.js +16 -1
- package/Icon/index.js.map +1 -0
- package/Image/Image.d.ts +5 -4
- package/Image/Image.js +17 -13
- package/Image/Image.js.map +1 -0
- package/Image/Image.stories.js +14 -11
- package/Image/Image.stories.js.map +1 -0
- package/Image/index.js +16 -1
- package/Image/index.js.map +1 -0
- package/ImageEditor/ImageEditor.d.ts +33 -34
- package/ImageEditor/ImageEditor.js +129 -163
- package/ImageEditor/ImageEditor.js.map +1 -0
- package/ImageEditor/index.js +16 -1
- package/ImageEditor/index.js.map +1 -0
- package/ImageEditor/toolbar/crop.js +26 -22
- package/ImageEditor/toolbar/crop.js.map +1 -0
- package/ImageEditor/toolbar/filter.js +63 -59
- package/ImageEditor/toolbar/filter.js.map +1 -0
- package/ImageEditor/toolbar/flip.js +27 -25
- package/ImageEditor/toolbar/flip.js.map +1 -0
- package/ImageEditor/toolbar/icons/index.js +61 -8
- package/ImageEditor/toolbar/icons/index.js.map +1 -0
- package/ImageEditor/toolbar/index.js +34 -4
- package/ImageEditor/toolbar/index.js.map +1 -0
- package/ImageEditor/toolbar/rotate.js +55 -61
- package/ImageEditor/toolbar/rotate.js.map +1 -0
- package/ImageEditor/toolbar/types.d.ts +23 -12
- package/ImageEditor/toolbar/types.js +5 -1
- package/ImageEditor/toolbar/types.js.map +1 -0
- package/ImageUpload/Image.d.ts +6 -6
- package/ImageUpload/Image.js +52 -54
- package/ImageUpload/Image.js.map +1 -0
- package/ImageUpload/ImageEditorDialog.d.ts +11 -6
- package/ImageUpload/ImageEditorDialog.js +47 -46
- package/ImageUpload/ImageEditorDialog.js.map +1 -0
- package/ImageUpload/MultiImageUpload.d.ts +10 -31
- package/ImageUpload/MultiImageUpload.js +194 -222
- package/ImageUpload/MultiImageUpload.js.map +1 -0
- package/ImageUpload/MultiImageUpload.stories.js +18 -15
- package/ImageUpload/MultiImageUpload.stories.js.map +1 -0
- package/ImageUpload/SingleImageUpload.d.ts +16 -37
- package/ImageUpload/SingleImageUpload.js +96 -106
- package/ImageUpload/SingleImageUpload.js.map +1 -0
- package/ImageUpload/SingleImageUpload.stories.js +19 -16
- package/ImageUpload/SingleImageUpload.stories.js.map +1 -0
- package/ImageUpload/index.js +34 -4
- package/ImageUpload/index.js.map +1 -0
- package/ImageUpload/styled.d.ts +30 -14
- package/ImageUpload/styled.js +25 -16
- package/ImageUpload/styled.js.map +1 -0
- package/Input/Input.d.ts +6 -19
- package/Input/Input.js +102 -141
- package/Input/Input.js.map +1 -0
- package/Input/Input.stories.js +49 -46
- package/Input/Input.stories.js.map +1 -0
- package/Input/__tests__/Input.test.js +54 -63
- package/Input/__tests__/Input.test.js.map +1 -0
- package/Input/index.js +16 -1
- package/Input/index.js.map +1 -0
- package/Input/styled.d.ts +4 -0
- package/Input/styled.js +12 -0
- package/Input/styled.js.map +1 -0
- package/List/CollapsibleList/CollapsibleList.stories.js +19 -16
- package/List/CollapsibleList/CollapsibleList.stories.js.map +1 -0
- package/List/CollapsibleList/index.d.ts +2 -2
- package/List/CollapsibleList/index.js +15 -6
- package/List/CollapsibleList/index.js.map +1 -0
- package/List/DataList/DataList.d.ts +24 -43
- package/List/DataList/DataList.js +87 -122
- package/List/DataList/DataList.js.map +1 -0
- package/List/DataList/DataList.stories.js +30 -26
- package/List/DataList/DataList.stories.js.map +1 -0
- package/List/DataList/DataListModalOverlay/DataListModalOverlay.d.ts +14 -12
- package/List/DataList/DataListModalOverlay/DataListModalOverlay.js +29 -20
- package/List/DataList/DataListModalOverlay/DataListModalOverlay.js.map +1 -0
- package/List/DataList/DataListModalOverlay/DataListModalOverlayAction.d.ts +3 -3
- package/List/DataList/DataListModalOverlay/DataListModalOverlayAction.js +20 -13
- package/List/DataList/DataListModalOverlay/DataListModalOverlayAction.js.map +1 -0
- package/List/DataList/DataListModalOverlay/DataListModalOverlayContext.d.ts +9 -4
- package/List/DataList/DataListModalOverlay/DataListModalOverlayContext.js +24 -12
- package/List/DataList/DataListModalOverlay/DataListModalOverlayContext.js.map +1 -0
- package/List/DataList/DataListModalOverlay/index.js +32 -3
- package/List/DataList/DataListModalOverlay/index.js.map +1 -0
- package/List/DataList/DataListWithSections.d.ts +45 -0
- package/List/DataList/DataListWithSections.js +312 -0
- package/List/DataList/DataListWithSections.js.map +1 -0
- package/List/DataList/Loader.d.ts +2 -2
- package/List/DataList/Loader.js +48 -52
- package/List/DataList/Loader.js.map +1 -0
- package/List/DataList/NoData.d.ts +2 -2
- package/List/DataList/NoData.js +14 -8
- package/List/DataList/NoData.js.map +1 -0
- package/List/DataList/icons/index.d.ts +1 -1
- package/List/DataList/icons/index.js +54 -38
- package/List/DataList/icons/index.js.map +1 -0
- package/List/DataList/index.d.ts +1 -0
- package/List/DataList/index.js +58 -3
- package/List/DataList/index.js.map +1 -0
- package/List/DataList/types.d.ts +1 -1
- package/List/DataList/types.js +5 -1
- package/List/DataList/types.js.map +1 -0
- package/List/List.d.ts +3 -2
- package/List/List.js +66 -62
- package/List/List.js.map +1 -0
- package/List/List.stories.js +40 -37
- package/List/List.stories.js.map +1 -0
- package/List/icons/index.js +20 -3
- package/List/icons/index.js.map +1 -0
- package/List/index.d.ts +1 -1
- package/List/index.js +70 -3
- package/List/index.js.map +1 -0
- package/Menu/Menu.d.ts +14 -21
- package/Menu/Menu.js +49 -62
- package/Menu/Menu.js.map +1 -0
- package/Menu/Menu.stories.js +17 -14
- package/Menu/Menu.stories.js.map +1 -0
- package/Menu/index.js +16 -1
- package/Menu/index.js.map +1 -0
- package/Mosaic/Mosaic.d.ts +4 -14
- package/Mosaic/Mosaic.js +20 -7
- package/Mosaic/Mosaic.js.map +1 -0
- package/Mosaic/Mosaic.stories.js +31 -28
- package/Mosaic/Mosaic.stories.js.map +1 -0
- package/Mosaic/index.js +16 -1
- package/Mosaic/index.js.map +1 -0
- package/Progress/CircularProgress.d.ts +8 -16
- package/Progress/CircularProgress.js +32 -22
- package/Progress/CircularProgress.js.map +1 -0
- package/Progress/index.js +13 -1
- package/Progress/index.js.map +1 -0
- package/Radio/Radio.d.ts +2 -6
- package/Radio/Radio.js +36 -41
- package/Radio/Radio.js.map +1 -0
- package/Radio/Radio.styles.js +9 -4
- package/Radio/Radio.styles.js.map +1 -0
- package/Radio/RadioGroup.d.ts +1 -6
- package/Radio/RadioGroup.js +30 -34
- package/Radio/RadioGroup.js.map +1 -0
- package/Radio/RadioGroup.stories.js +23 -20
- package/Radio/RadioGroup.stories.js.map +1 -0
- package/Radio/index.js +20 -2
- package/Radio/index.js.map +1 -0
- package/RichTextEditor/RichTextEditor.d.ts +13 -9
- package/RichTextEditor/RichTextEditor.js +79 -78
- package/RichTextEditor/RichTextEditor.js.map +1 -0
- package/RichTextEditor/RichTextEditor.stories.js +15 -11
- package/RichTextEditor/RichTextEditor.stories.js.map +1 -0
- package/RichTextEditor/createPropsFromConfig.d.ts +11 -1
- package/RichTextEditor/createPropsFromConfig.js +16 -5
- package/RichTextEditor/createPropsFromConfig.js.map +1 -0
- package/RichTextEditor/index.d.ts +1 -0
- package/RichTextEditor/index.js +27 -2
- package/RichTextEditor/index.js.map +1 -0
- package/Ripple/Ripple.d.ts +4 -5
- package/Ripple/Ripple.js +11 -6
- package/Ripple/Ripple.js.map +1 -0
- package/Ripple/Ripple.stories.js +45 -42
- package/Ripple/Ripple.stories.js.map +1 -0
- package/Ripple/index.js +16 -1
- package/Ripple/index.js.map +1 -0
- package/Scrollbar/Scrollbar.d.ts +5 -5
- package/Scrollbar/Scrollbar.js +10 -5
- package/Scrollbar/Scrollbar.js.map +1 -0
- package/Scrollbar/Scrollbar.stories.js +12 -9
- package/Scrollbar/Scrollbar.stories.js.map +1 -0
- package/Scrollbar/index.js +16 -1
- package/Scrollbar/index.js.map +1 -0
- package/Section/Section.stories.js +15 -12
- package/Section/Section.stories.js.map +1 -0
- package/Section/index.d.ts +4 -5
- package/Section/index.js +23 -18
- package/Section/index.js.map +1 -0
- package/Select/Select.d.ts +8 -10
- package/Select/Select.js +79 -39
- package/Select/Select.js.map +1 -0
- package/Select/Select.stories.js +28 -25
- package/Select/Select.stories.js.map +1 -0
- package/Select/index.js +16 -1
- package/Select/index.js.map +1 -0
- package/Select/styled.d.ts +8 -0
- package/Select/styled.js +18 -0
- package/Select/styled.js.map +1 -0
- package/Skeleton/README.md +21 -0
- package/Skeleton/Skeleton.d.ts +8 -0
- package/Skeleton/Skeleton.js +22 -0
- package/Skeleton/Skeleton.js.map +1 -0
- package/Skeleton/Skeleton.stories.d.ts +1 -0
- package/Skeleton/Skeleton.stories.js +22 -0
- package/Skeleton/Skeleton.stories.js.map +1 -0
- package/Skeleton/index.d.ts +1 -0
- package/Skeleton/index.js +16 -0
- package/Skeleton/index.js.map +1 -0
- package/Slider/Slider.d.ts +1 -6
- package/Slider/Slider.js +39 -47
- package/Slider/Slider.js.map +1 -0
- package/Slider/Slider.stories.js +20 -17
- package/Slider/Slider.stories.js.map +1 -0
- package/Slider/index.js +13 -1
- package/Slider/index.js.map +1 -0
- package/Snackbar/Snackbar.d.ts +5 -7
- package/Snackbar/Snackbar.js +29 -33
- package/Snackbar/Snackbar.js.map +1 -0
- package/Snackbar/Snackbar.stories.js +29 -38
- package/Snackbar/Snackbar.stories.js.map +1 -0
- package/Snackbar/index.js +18 -1
- package/Snackbar/index.js.map +1 -0
- package/Switch/Switch.d.ts +3 -7
- package/Switch/Switch.js +35 -43
- package/Switch/Switch.js.map +1 -0
- package/Switch/Switch.stories.js +19 -16
- package/Switch/Switch.stories.js.map +1 -0
- package/Switch/index.js +16 -1
- package/Switch/index.js.map +1 -0
- package/Tabs/Tab.d.ts +7 -2
- package/Tabs/Tab.js +30 -9
- package/Tabs/Tab.js.map +1 -0
- package/Tabs/Tabs.d.ts +44 -21
- package/Tabs/Tabs.js +128 -129
- package/Tabs/Tabs.js.map +1 -0
- package/Tabs/Tabs.stories.js +25 -23
- package/Tabs/Tabs.stories.js.map +1 -0
- package/Tabs/index.js +27 -2
- package/Tabs/index.js.map +1 -0
- package/Tags/Tags.d.ts +9 -21
- package/Tags/Tags.js +95 -124
- package/Tags/Tags.js.map +1 -0
- package/Tags/Tags.stories.js +19 -16
- package/Tags/Tags.stories.js.map +1 -0
- package/Tags/index.js +16 -1
- package/Tags/index.js.map +1 -0
- package/Tooltip/Tooltip.d.ts +9 -8
- package/Tooltip/Tooltip.js +33 -33
- package/Tooltip/Tooltip.js.map +1 -0
- package/Tooltip/Tooltip.stories.js +14 -11
- package/Tooltip/Tooltip.stories.js.map +1 -0
- package/Tooltip/index.js +16 -1
- package/Tooltip/index.js.map +1 -0
- package/TopAppBar/TopAppBar.d.ts +1 -1
- package/TopAppBar/TopAppBar.js +13 -9
- package/TopAppBar/TopAppBar.js.map +1 -0
- package/TopAppBar/TopAppBar.stories.js +31 -30
- package/TopAppBar/TopAppBar.stories.js.map +1 -0
- package/TopAppBar/TopAppBarActionItem.d.ts +1 -1
- package/TopAppBar/TopAppBarActionItem.js +10 -5
- package/TopAppBar/TopAppBarActionItem.js.map +1 -0
- package/TopAppBar/TopAppBarNavigationIcon.d.ts +1 -1
- package/TopAppBar/TopAppBarNavigationIcon.js +10 -5
- package/TopAppBar/TopAppBarNavigationIcon.js.map +1 -0
- package/TopAppBar/TopAppBarPrimary.js +13 -9
- package/TopAppBar/TopAppBarPrimary.js.map +1 -0
- package/TopAppBar/TopAppBarSecondary.js +15 -11
- package/TopAppBar/TopAppBarSecondary.js.map +1 -0
- package/TopAppBar/TopAppBarSection.d.ts +1 -1
- package/TopAppBar/TopAppBarSection.js +13 -9
- package/TopAppBar/TopAppBarSection.js.map +1 -0
- package/TopAppBar/TopAppBarTitle.d.ts +1 -1
- package/TopAppBar/TopAppBarTitle.js +13 -9
- package/TopAppBar/TopAppBarTitle.js.map +1 -0
- package/TopAppBar/index.js +82 -7
- package/TopAppBar/index.js.map +1 -0
- package/TopProgressBar/TopProgressBar.d.ts +7 -7
- package/TopProgressBar/TopProgressBar.js +15 -7
- package/TopProgressBar/TopProgressBar.js.map +1 -0
- package/TopProgressBar/TopProgressBar.stories.js +16 -13
- package/TopProgressBar/TopProgressBar.stories.js.map +1 -0
- package/TopProgressBar/hoc/index.js +13 -1
- package/TopProgressBar/hoc/index.js.map +1 -0
- package/TopProgressBar/hoc/withTopProgressBar.d.ts +1 -1
- package/TopProgressBar/hoc/withTopProgressBar.js +14 -9
- package/TopProgressBar/hoc/withTopProgressBar.js.map +1 -0
- package/TopProgressBar/index.js +16 -1
- package/TopProgressBar/index.js.map +1 -0
- package/Typography/Typography.d.ts +5 -5
- package/Typography/Typography.js +10 -5
- package/Typography/Typography.js.map +1 -0
- package/Typography/Typography.stories.js +37 -34
- package/Typography/Typography.stories.js.map +1 -0
- package/Typography/index.js +16 -1
- package/Typography/index.js.map +1 -0
- package/package.json +76 -81
- package/styles.scss +3 -4
- package/types.d.ts +4 -4
- package/types.js +5 -1
- package/types.js.map +1 -0
- package/Chips/ChipIcon.d.ts +0 -4
- package/Chips/ChipIcon.js +0 -8
- package/rmwc/textfield/code/index.d.ts +0 -135
- package/rmwc/textfield/code/index.js +0 -571
- package/rmwc/textfield/next/index.d.ts +0 -135
- package/rmwc/textfield/next/index.js +0 -560
- package/rmwc/textfield/package.json +0 -45
|
@@ -1,18 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.ImageEditor = void 0;
|
|
8
|
+
var _regeneratorRuntime2 = _interopRequireDefault(require("@babel/runtime/helpers/regeneratorRuntime"));
|
|
9
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
12
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
13
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
14
|
+
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
|
|
15
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
16
|
+
var _react = _interopRequireDefault(require("react"));
|
|
17
|
+
var _toolbar = require("./toolbar");
|
|
18
|
+
var _styled = _interopRequireDefault(require("@emotion/styled"));
|
|
19
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
20
|
+
var _Button = require("../Button");
|
|
21
|
+
var _loadScript = _interopRequireDefault(require("load-script"));
|
|
22
|
+
/**
|
|
23
|
+
* Package load-script does not have types.
|
|
24
|
+
*/
|
|
25
|
+
// @ts-ignore
|
|
26
|
+
|
|
27
|
+
var toolbar = {
|
|
28
|
+
flip: _toolbar.flip,
|
|
29
|
+
filter: _toolbar.filter,
|
|
30
|
+
crop: _toolbar.crop,
|
|
31
|
+
rotate: _toolbar.rotate
|
|
32
|
+
};
|
|
33
|
+
var Toolbar = /*#__PURE__*/(0, _styled.default)("div", {
|
|
16
34
|
target: "eq22gs70",
|
|
17
35
|
label: "Toolbar"
|
|
18
36
|
})({
|
|
@@ -31,7 +49,7 @@ var Toolbar = /*#__PURE__*/styled("div", {
|
|
|
31
49
|
pointerEvents: "none"
|
|
32
50
|
}
|
|
33
51
|
});
|
|
34
|
-
var ToolOptions = /*#__PURE__*/
|
|
52
|
+
var ToolOptions = /*#__PURE__*/(0, _styled.default)("div", {
|
|
35
53
|
target: "eq22gs71",
|
|
36
54
|
label: "ToolOptions"
|
|
37
55
|
})({
|
|
@@ -41,54 +59,41 @@ var ToolOptions = /*#__PURE__*/styled("div", {
|
|
|
41
59
|
backgroundColor: "var(--mdc-theme-background)",
|
|
42
60
|
borderTop: "1px solid var(--mdc-theme-on-background)"
|
|
43
61
|
});
|
|
44
|
-
var ApplyCancelActions = /*#__PURE__*/
|
|
62
|
+
var ApplyCancelActions = /*#__PURE__*/(0, _styled.default)("div", {
|
|
45
63
|
target: "eq22gs72",
|
|
46
64
|
label: "ApplyCancelActions"
|
|
47
65
|
})({
|
|
48
66
|
textAlign: "center"
|
|
49
67
|
});
|
|
50
|
-
|
|
51
68
|
var initScripts = function initScripts() {
|
|
52
69
|
return new Promise(function (resolve) {
|
|
53
70
|
// @ts-ignore
|
|
54
71
|
if (window.Caman) {
|
|
55
72
|
return resolve();
|
|
56
73
|
}
|
|
57
|
-
|
|
58
|
-
return loadScript("https://cdnjs.cloudflare.com/ajax/libs/camanjs/4.1.2/caman.full.min.js", resolve);
|
|
74
|
+
return (0, _loadScript.default)("https://cdnjs.cloudflare.com/ajax/libs/camanjs/4.1.2/caman.full.min.js", resolve);
|
|
59
75
|
});
|
|
60
76
|
};
|
|
61
|
-
|
|
62
77
|
var ImageEditor = /*#__PURE__*/function (_React$Component) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
var _super = _createSuper(ImageEditor);
|
|
66
|
-
|
|
78
|
+
(0, _inherits2.default)(ImageEditor, _React$Component);
|
|
79
|
+
var _super = (0, _createSuper2.default)(ImageEditor);
|
|
67
80
|
function ImageEditor() {
|
|
68
81
|
var _this;
|
|
69
|
-
|
|
70
|
-
_classCallCheck(this, ImageEditor);
|
|
71
|
-
|
|
82
|
+
(0, _classCallCheck2.default)(this, ImageEditor);
|
|
72
83
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
73
84
|
args[_key] = arguments[_key];
|
|
74
85
|
}
|
|
75
|
-
|
|
76
86
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
77
|
-
|
|
78
|
-
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
87
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "state", {
|
|
79
88
|
tool: null,
|
|
80
89
|
src: ""
|
|
81
90
|
});
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
_defineProperty(_assertThisInitialized(_this), "image", null);
|
|
86
|
-
|
|
87
|
-
_defineProperty(_assertThisInitialized(_this), "updateCanvas", function () {
|
|
91
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "canvas", /*#__PURE__*/_react.default.createRef());
|
|
92
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "image", void 0);
|
|
93
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "updateCanvas", function () {
|
|
88
94
|
var src = _this.props.src;
|
|
89
95
|
_this.image = new window.Image();
|
|
90
96
|
var canvas = _this.canvas.current;
|
|
91
|
-
|
|
92
97
|
if (canvas) {
|
|
93
98
|
_this.image.onload = function () {
|
|
94
99
|
if (_this.image) {
|
|
@@ -98,16 +103,13 @@ var ImageEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
98
103
|
ctx.drawImage(_this.image, 0, 0);
|
|
99
104
|
}
|
|
100
105
|
};
|
|
101
|
-
|
|
102
106
|
_this.image.src = src;
|
|
103
107
|
}
|
|
104
108
|
});
|
|
105
|
-
|
|
106
|
-
_defineProperty(_assertThisInitialized(_this), "activateTool", function (tool) {
|
|
109
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "activateTool", function (tool) {
|
|
107
110
|
if (typeof tool === "string") {
|
|
108
111
|
tool = toolbar[tool];
|
|
109
112
|
}
|
|
110
|
-
|
|
111
113
|
_this.setState({
|
|
112
114
|
tool: tool
|
|
113
115
|
}, function () {
|
|
@@ -118,138 +120,104 @@ var ImageEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
118
120
|
});
|
|
119
121
|
});
|
|
120
122
|
});
|
|
121
|
-
|
|
122
|
-
_defineProperty(_assertThisInitialized(_this), "deactivateTool", function () {
|
|
123
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "deactivateTool", function () {
|
|
123
124
|
_this.setState({
|
|
124
125
|
tool: null
|
|
125
126
|
});
|
|
126
127
|
});
|
|
127
|
-
|
|
128
|
-
_defineProperty(_assertThisInitialized(_this), "getCanvasDataUrl", function () {
|
|
128
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getCanvasDataUrl", function () {
|
|
129
129
|
var canvas = _this.canvas.current;
|
|
130
|
-
|
|
131
130
|
if (canvas) {
|
|
132
131
|
var src = _this.props.src;
|
|
133
|
-
|
|
134
132
|
if (src.startsWith("data:image/jpeg;")) {
|
|
135
133
|
return canvas.toDataURL("image/jpeg", 1.0);
|
|
136
134
|
}
|
|
137
|
-
|
|
138
135
|
return canvas.toDataURL();
|
|
139
136
|
}
|
|
140
|
-
|
|
141
137
|
return "";
|
|
142
138
|
});
|
|
143
|
-
|
|
144
|
-
_defineProperty(_assertThisInitialized(_this), "applyActiveTool", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
139
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "applyActiveTool", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee() {
|
|
145
140
|
var tool;
|
|
146
|
-
return
|
|
147
|
-
while (1) {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
canvas: _this.canvas
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
case 7:
|
|
173
|
-
_this.deactivateTool();
|
|
174
|
-
|
|
175
|
-
case 8:
|
|
176
|
-
case "end":
|
|
177
|
-
return _context.stop();
|
|
178
|
-
}
|
|
141
|
+
return (0, _regeneratorRuntime2.default)().wrap(function _callee$(_context) {
|
|
142
|
+
while (1) switch (_context.prev = _context.next) {
|
|
143
|
+
case 0:
|
|
144
|
+
tool = _this.state.tool;
|
|
145
|
+
if (tool) {
|
|
146
|
+
_context.next = 3;
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
return _context.abrupt("return");
|
|
150
|
+
case 3:
|
|
151
|
+
if (!tool.apply) {
|
|
152
|
+
_context.next = 6;
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
_context.next = 6;
|
|
156
|
+
return tool.apply({
|
|
157
|
+
canvas: _this.canvas
|
|
158
|
+
});
|
|
159
|
+
case 6:
|
|
160
|
+
_this.deactivateTool();
|
|
161
|
+
case 7:
|
|
162
|
+
case "end":
|
|
163
|
+
return _context.stop();
|
|
179
164
|
}
|
|
180
165
|
}, _callee);
|
|
181
166
|
})));
|
|
182
|
-
|
|
183
|
-
_defineProperty(_assertThisInitialized(_this), "cancelActiveTool", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
167
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "cancelActiveTool", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee2() {
|
|
184
168
|
var tool;
|
|
185
|
-
return
|
|
186
|
-
while (1) {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
canvas: _this.canvas
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
case 7:
|
|
212
|
-
_this.deactivateTool();
|
|
213
|
-
|
|
214
|
-
case 8:
|
|
215
|
-
case "end":
|
|
216
|
-
return _context2.stop();
|
|
217
|
-
}
|
|
169
|
+
return (0, _regeneratorRuntime2.default)().wrap(function _callee2$(_context2) {
|
|
170
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
171
|
+
case 0:
|
|
172
|
+
tool = _this.state.tool;
|
|
173
|
+
if (tool) {
|
|
174
|
+
_context2.next = 3;
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
177
|
+
return _context2.abrupt("return");
|
|
178
|
+
case 3:
|
|
179
|
+
if (!tool.cancel) {
|
|
180
|
+
_context2.next = 6;
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
183
|
+
_context2.next = 6;
|
|
184
|
+
return tool.cancel({
|
|
185
|
+
canvas: _this.canvas
|
|
186
|
+
});
|
|
187
|
+
case 6:
|
|
188
|
+
_this.deactivateTool();
|
|
189
|
+
case 7:
|
|
190
|
+
case "end":
|
|
191
|
+
return _context2.stop();
|
|
218
192
|
}
|
|
219
193
|
}, _callee2);
|
|
220
194
|
})));
|
|
221
|
-
|
|
222
|
-
_defineProperty(_assertThisInitialized(_this), "getToolOptions", function (tool) {
|
|
195
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getToolOptions", function (tool) {
|
|
223
196
|
var options = _this.props.options;
|
|
224
|
-
|
|
225
197
|
if (!options || typeof options !== "object") {
|
|
226
198
|
return {};
|
|
227
199
|
}
|
|
228
|
-
|
|
229
200
|
return options[tool.name] || {};
|
|
230
201
|
});
|
|
231
|
-
|
|
232
202
|
return _this;
|
|
233
203
|
}
|
|
234
|
-
|
|
235
|
-
_createClass(ImageEditor, [{
|
|
204
|
+
(0, _createClass2.default)(ImageEditor, [{
|
|
236
205
|
key: "componentDidMount",
|
|
237
206
|
value: function componentDidMount() {
|
|
238
207
|
var _this2 = this;
|
|
239
|
-
|
|
240
208
|
initScripts().then(function () {
|
|
241
209
|
_this2.updateCanvas();
|
|
242
|
-
|
|
243
210
|
setTimeout(function () {
|
|
244
211
|
var options = _this2.props.options;
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
212
|
+
if (!options || typeof options !== "object") {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
for (var key in options) {
|
|
216
|
+
var option = options[key];
|
|
217
|
+
if (option.autoEnable === true) {
|
|
218
|
+
var tool = toolbar[key];
|
|
219
|
+
tool && _this2.activateTool(tool);
|
|
220
|
+
break;
|
|
253
221
|
}
|
|
254
222
|
}
|
|
255
223
|
}, 250);
|
|
@@ -259,22 +227,19 @@ var ImageEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
259
227
|
key: "render",
|
|
260
228
|
value: function render() {
|
|
261
229
|
var _this3 = this;
|
|
262
|
-
|
|
263
230
|
var _this$props = this.props,
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
231
|
+
src = _this$props.src,
|
|
232
|
+
tools = _this$props.tools,
|
|
233
|
+
children = _this$props.children;
|
|
267
234
|
var tool = this.state.tool;
|
|
268
|
-
var editor = /*#__PURE__*/
|
|
235
|
+
var editor = /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(Toolbar, null, tools.map(function (key) {
|
|
269
236
|
var tool = toolbar[key];
|
|
270
|
-
|
|
271
237
|
if (!tool) {
|
|
272
238
|
return null;
|
|
273
239
|
}
|
|
274
|
-
|
|
275
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
240
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
276
241
|
key: key,
|
|
277
|
-
className:
|
|
242
|
+
className: (0, _classnames.default)({
|
|
278
243
|
disabled: _this3.state.tool
|
|
279
244
|
})
|
|
280
245
|
}, tool.icon({
|
|
@@ -282,24 +247,30 @@ var ImageEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
282
247
|
return _this3.activateTool(tool);
|
|
283
248
|
}
|
|
284
249
|
}));
|
|
285
|
-
})), /*#__PURE__*/
|
|
250
|
+
})), /*#__PURE__*/_react.default.createElement(ToolOptions, null, tool ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, typeof tool.renderForm === "function" && tool.renderForm({
|
|
286
251
|
options: this.getToolOptions(tool),
|
|
287
252
|
image: this.image,
|
|
288
253
|
canvas: this.canvas
|
|
289
|
-
}), /*#__PURE__*/
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
254
|
+
}), /*#__PURE__*/_react.default.createElement(ApplyCancelActions, null, /*#__PURE__*/_react.default.createElement(_Button.ButtonSecondary, {
|
|
255
|
+
"data-testid": "button-cancel",
|
|
256
|
+
onClick: function onClick() {
|
|
257
|
+
_this3.cancelActiveTool();
|
|
258
|
+
}
|
|
259
|
+
}, "Cancel"), "\xA0", /*#__PURE__*/_react.default.createElement(_Button.ButtonPrimary, {
|
|
260
|
+
"data-testid": "button-apply",
|
|
261
|
+
onClick: function onClick() {
|
|
262
|
+
_this3.applyActiveTool();
|
|
263
|
+
}
|
|
264
|
+
}, "Apply"))) : /*#__PURE__*/_react.default.createElement("div", {
|
|
294
265
|
style: {
|
|
295
266
|
textAlign: "center"
|
|
296
267
|
}
|
|
297
|
-
}, "Select a tool to start working on your image.")), /*#__PURE__*/
|
|
268
|
+
}, "Select a tool to start working on your image.")), /*#__PURE__*/_react.default.createElement("div", {
|
|
298
269
|
style: {
|
|
299
270
|
margin: "0 auto",
|
|
300
271
|
textAlign: "center"
|
|
301
272
|
}
|
|
302
|
-
}, /*#__PURE__*/
|
|
273
|
+
}, /*#__PURE__*/_react.default.createElement("canvas", {
|
|
303
274
|
key: src,
|
|
304
275
|
id: "canvas",
|
|
305
276
|
style: {
|
|
@@ -307,7 +278,6 @@ var ImageEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
307
278
|
},
|
|
308
279
|
ref: this.canvas
|
|
309
280
|
})));
|
|
310
|
-
|
|
311
281
|
if (typeof children === "function") {
|
|
312
282
|
return children({
|
|
313
283
|
render: function render() {
|
|
@@ -320,16 +290,12 @@ var ImageEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
320
290
|
cancelActiveTool: this.cancelActiveTool
|
|
321
291
|
});
|
|
322
292
|
}
|
|
323
|
-
|
|
324
293
|
return editor;
|
|
325
294
|
}
|
|
326
295
|
}]);
|
|
327
|
-
|
|
328
296
|
return ImageEditor;
|
|
329
|
-
}(
|
|
330
|
-
|
|
331
|
-
|
|
297
|
+
}(_react.default.Component);
|
|
298
|
+
exports.ImageEditor = ImageEditor;
|
|
299
|
+
(0, _defineProperty2.default)(ImageEditor, "defaultProps", {
|
|
332
300
|
tools: ["crop", "flip", "rotate", "filter"]
|
|
333
|
-
});
|
|
334
|
-
|
|
335
|
-
export { ImageEditor };
|
|
301
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["toolbar","flip","filter","crop","rotate","Toolbar","styled","display","justifyContent","alignItems","backgroundColor","margin","padding","position","width","boxSizing","zIndex","opacity","pointerEvents","ToolOptions","borderTop","ApplyCancelActions","textAlign","initScripts","Promise","resolve","window","Caman","loadScript","ImageEditor","tool","src","React","createRef","props","image","Image","canvas","current","onload","height","ctx","getContext","drawImage","setState","tt","onActivate","options","getToolOptions","startsWith","toDataURL","state","apply","deactivateTool","cancel","name","then","updateCanvas","setTimeout","key","option","autoEnable","activateTool","tools","children","editor","map","classNames","disabled","icon","renderForm","cancelActiveTool","applyActiveTool","maxWidth","render","getCanvasDataUrl","activeTool","Component"],"sources":["ImageEditor.tsx"],"sourcesContent":["import React from \"react\";\nimport { flip, filter, crop, rotate } from \"./toolbar\";\nimport { ImageEditorTool, ToolbarTool } from \"./toolbar/types\";\nimport styled from \"@emotion/styled\";\nimport classNames from \"classnames\";\nimport { ButtonSecondary, ButtonPrimary } from \"../Button\";\n/**\n * Package load-script does not have types.\n */\n// @ts-ignore\nimport loadScript from \"load-script\";\n\nconst toolbar = {\n flip,\n filter,\n crop,\n rotate\n};\n\nconst Toolbar = styled(\"div\")({\n display: \"flex\",\n justifyContent: \"center\",\n alignItems: \"center\",\n backgroundColor: \"var(--mdc-theme-secondary)\",\n margin: \"-24px -24px 0px -24px\",\n padding: 2,\n position: \"absolute\",\n width: \"100%\",\n boxSizing: \"border-box\",\n zIndex: 10,\n \"> div.disabled\": {\n opacity: 0.5,\n pointerEvents: \"none\"\n }\n});\n\nconst ToolOptions = styled(\"div\")({\n margin: \"50px -24px 10px -24px\",\n boxSizing: \"border-box\",\n padding: 10,\n backgroundColor: \"var(--mdc-theme-background)\",\n borderTop: \"1px solid var(--mdc-theme-on-background)\"\n});\n\nconst ApplyCancelActions = styled(\"div\")({\n textAlign: \"center\"\n});\n\nconst initScripts = (): Promise<string> => {\n return new Promise((resolve: any) => {\n // @ts-ignore\n if (window.Caman) {\n return resolve();\n }\n return loadScript(\n \"https://cdnjs.cloudflare.com/ajax/libs/camanjs/4.1.2/caman.full.min.js\",\n resolve\n );\n });\n};\n\ninterface RenderPropArgs {\n render: Function;\n getCanvasDataUrl: () => string;\n activeTool: ImageEditorTool | null;\n applyActiveTool: () => Promise<void>;\n cancelActiveTool: () => Promise<void>;\n}\n\ninterface ImageEditorPropsPropsOptions {\n autoEnable: boolean;\n}\n\ninterface ImageEditorProps {\n src: string;\n tools: ToolbarTool[];\n options?: {\n flip: ImageEditorPropsPropsOptions;\n filter: ImageEditorPropsPropsOptions;\n crop: ImageEditorPropsPropsOptions;\n rotate: ImageEditorPropsPropsOptions;\n };\n onToolActivate?: Function;\n onToolDeactivate?: Function;\n children?: (props: RenderPropArgs) => React.ReactNode;\n}\n\ninterface ImageEditorState {\n tool: ImageEditorTool | null;\n src: string;\n}\n\nclass ImageEditor extends React.Component<ImageEditorProps, ImageEditorState> {\n static defaultProps: Partial<ImageEditorProps> = {\n tools: [\"crop\", \"flip\", \"rotate\", \"filter\"]\n };\n\n public override state: ImageEditorState = {\n tool: null,\n src: \"\"\n };\n\n public canvas = React.createRef<HTMLCanvasElement>();\n public image?: HTMLImageElement;\n\n public override componentDidMount() {\n initScripts().then(() => {\n this.updateCanvas();\n setTimeout(() => {\n const { options } = this.props;\n if (!options || typeof options !== \"object\") {\n return;\n }\n for (const key in options) {\n const option = options[key as ToolbarTool];\n if (option.autoEnable === true) {\n const tool: ImageEditorTool | null = toolbar[key as ToolbarTool];\n tool && this.activateTool(tool);\n break;\n }\n }\n }, 250);\n });\n }\n\n private readonly updateCanvas = (): void => {\n const { src } = this.props;\n this.image = new window.Image();\n const canvas = this.canvas.current;\n if (canvas) {\n this.image.onload = () => {\n if (this.image) {\n canvas.width = this.image.width;\n canvas.height = this.image.height;\n const ctx = canvas.getContext(\"2d\") as CanvasRenderingContext2D;\n ctx.drawImage(this.image, 0, 0);\n }\n };\n\n this.image.src = src;\n }\n };\n\n private readonly activateTool = (tool: ToolbarTool | ImageEditorTool): void => {\n if (typeof tool === \"string\") {\n tool = toolbar[tool];\n }\n\n this.setState({ tool }, () => {\n const tt = tool as ImageEditorTool;\n typeof tt.onActivate === \"function\" &&\n tt.onActivate({ canvas: this.canvas, options: this.getToolOptions(tt) });\n });\n };\n\n private readonly deactivateTool = (): void => {\n this.setState({\n tool: null\n });\n };\n\n public readonly getCanvasDataUrl = (): string => {\n const canvas = this.canvas.current as HTMLCanvasElement;\n if (canvas) {\n const { src } = this.props;\n if (src.startsWith(\"data:image/jpeg;\")) {\n return canvas.toDataURL(\"image/jpeg\", 1.0);\n }\n\n return canvas.toDataURL();\n }\n\n return \"\";\n };\n\n private readonly applyActiveTool = async (): Promise<void> => {\n const { tool } = this.state;\n if (!tool) {\n return;\n }\n\n if (tool.apply) {\n await tool.apply({\n canvas: this.canvas\n });\n }\n this.deactivateTool();\n };\n\n private readonly cancelActiveTool = async (): Promise<void> => {\n const { tool } = this.state;\n if (!tool) {\n return;\n }\n\n if (tool.cancel) {\n await tool.cancel({\n canvas: this.canvas\n });\n }\n this.deactivateTool();\n };\n\n private readonly getToolOptions = (\n tool: ImageEditorTool\n ): Partial<ImageEditorPropsPropsOptions> => {\n const { options } = this.props;\n if (!options || typeof options !== \"object\") {\n return {};\n }\n\n return options[tool.name as ToolbarTool] || {};\n };\n\n public override render(): React.ReactNode {\n const { src, tools, children } = this.props;\n const { tool } = this.state;\n const editor = (\n <React.Fragment>\n <Toolbar>\n {tools.map(key => {\n const tool: ImageEditorTool = toolbar[key];\n if (!tool) {\n return null;\n }\n\n return (\n <div key={key} className={classNames({ disabled: this.state.tool })}>\n {tool.icon({\n activateTool: () => this.activateTool(tool)\n })}\n </div>\n );\n })}\n </Toolbar>\n\n <ToolOptions>\n {tool ? (\n <>\n {typeof tool.renderForm === \"function\" &&\n tool.renderForm({\n options: this.getToolOptions(tool as ImageEditorTool),\n image: this.image as HTMLImageElement,\n canvas: this.canvas\n })}\n\n <ApplyCancelActions>\n <ButtonSecondary\n data-testid=\"button-cancel\"\n onClick={() => {\n this.cancelActiveTool();\n }}\n >\n Cancel\n </ButtonSecondary>\n \n <ButtonPrimary\n data-testid=\"button-apply\"\n onClick={() => {\n this.applyActiveTool();\n }}\n >\n Apply\n </ButtonPrimary>\n </ApplyCancelActions>\n </>\n ) : (\n <div style={{ textAlign: \"center\" }}>\n Select a tool to start working on your image.\n </div>\n )}\n </ToolOptions>\n\n <div style={{ margin: \"0 auto\", textAlign: \"center\" }}>\n <canvas\n key={src}\n id={\"canvas\"}\n style={{ maxWidth: 700 }}\n ref={this.canvas as React.Ref<any>}\n />\n </div>\n </React.Fragment>\n );\n\n if (typeof children === \"function\") {\n return children({\n render: () => editor,\n // canvas: this.canvas,\n getCanvasDataUrl: this.getCanvasDataUrl,\n activeTool: this.state.tool,\n applyActiveTool: this.applyActiveTool,\n cancelActiveTool: this.cancelActiveTool\n });\n }\n\n return editor;\n }\n}\n\nexport { ImageEditor };\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AACA;AAEA;AACA;AACA;AAKA;AAJA;AACA;AACA;AACA;;AAGA,IAAMA,OAAO,GAAG;EACZC,IAAI,EAAJA,aAAI;EACJC,MAAM,EAANA,eAAM;EACNC,IAAI,EAAJA,aAAI;EACJC,MAAM,EAANA;AACJ,CAAC;AAED,IAAMC,OAAO,oBAAGC,eAAM,EAAC,KAAK;EAAA;EAAA;AAAA,GAAE;EAC1BC,OAAO,EAAE,MAAM;EACfC,cAAc,EAAE,QAAQ;EACxBC,UAAU,EAAE,QAAQ;EACpBC,eAAe,EAAE,4BAA4B;EAC7CC,MAAM,EAAE,uBAAuB;EAC/BC,OAAO,EAAE,CAAC;EACVC,QAAQ,EAAE,UAAU;EACpBC,KAAK,EAAE,MAAM;EACbC,SAAS,EAAE,YAAY;EACvBC,MAAM,EAAE,EAAE;EACV,gBAAgB,E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|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _ImageEditor = require("./ImageEditor");
|
|
7
|
+
Object.keys(_ImageEditor).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _ImageEditor[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function get() {
|
|
13
|
+
return _ImageEditor[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./ImageEditor\";\n"],"mappings":";;;;;AAAA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
|
|
@@ -1,36 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
import { ReactComponent as CropIcon } from "@svgr/webpack!./icons/crop.svg";
|
|
3
|
-
import { IconButton } from "../../Button";
|
|
4
|
-
import { Tooltip } from "../../Tooltip";
|
|
5
|
-
import Cropper from "cropperjs";
|
|
6
|
-
import "cropperjs/dist/cropper.css";
|
|
7
|
-
var cropper = null;
|
|
1
|
+
"use strict";
|
|
8
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _crop = require("./icons/crop.svg");
|
|
10
|
+
var _Button = require("../../Button");
|
|
11
|
+
var _Tooltip = require("../../Tooltip");
|
|
12
|
+
var _cropperjs = _interopRequireDefault(require("cropperjs"));
|
|
13
|
+
require("cropperjs/dist/cropper.css");
|
|
14
|
+
var cropper = undefined;
|
|
9
15
|
var renderForm = function renderForm() {
|
|
10
|
-
return /*#__PURE__*/
|
|
16
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
11
17
|
style: {
|
|
12
18
|
textAlign: "center"
|
|
13
19
|
}
|
|
14
20
|
}, "Click and drag to crop a portion of the image. Hold Shift to persist aspect ratio.");
|
|
15
21
|
};
|
|
16
|
-
|
|
17
22
|
var tool = {
|
|
18
23
|
name: "crop",
|
|
19
24
|
icon: function icon(_ref) {
|
|
20
25
|
var activateTool = _ref.activateTool;
|
|
21
|
-
return /*#__PURE__*/
|
|
26
|
+
return /*#__PURE__*/_react.default.createElement(_Tooltip.Tooltip, {
|
|
22
27
|
placement: "bottom",
|
|
23
28
|
content: "Crop"
|
|
24
|
-
}, /*#__PURE__*/
|
|
25
|
-
icon: /*#__PURE__*/
|
|
26
|
-
onClick:
|
|
29
|
+
}, /*#__PURE__*/_react.default.createElement(_Button.IconButton, {
|
|
30
|
+
icon: /*#__PURE__*/_react.default.createElement(_crop.ReactComponent, null),
|
|
31
|
+
onClick: function onClick() {
|
|
32
|
+
return activateTool("crop");
|
|
33
|
+
},
|
|
34
|
+
"data-testid": "crop-item"
|
|
27
35
|
}));
|
|
28
36
|
},
|
|
29
37
|
renderForm: renderForm,
|
|
30
38
|
onActivate: function onActivate(_ref2) {
|
|
31
39
|
var canvas = _ref2.canvas,
|
|
32
|
-
|
|
33
|
-
cropper = new
|
|
40
|
+
options = _ref2.options;
|
|
41
|
+
cropper = new _cropperjs.default(canvas.current, options);
|
|
34
42
|
},
|
|
35
43
|
cancel: function cancel() {
|
|
36
44
|
return cropper && cropper.destroy();
|
|
@@ -42,14 +50,11 @@ var tool = {
|
|
|
42
50
|
resolve();
|
|
43
51
|
return;
|
|
44
52
|
}
|
|
45
|
-
|
|
46
53
|
var current = canvas.current;
|
|
47
54
|
var src = cropper.getCroppedCanvas().toDataURL();
|
|
48
|
-
|
|
49
55
|
if (current) {
|
|
50
56
|
var image = new window.Image();
|
|
51
57
|
var ctx = current.getContext("2d");
|
|
52
|
-
|
|
53
58
|
image.onload = function () {
|
|
54
59
|
ctx.drawImage(image, 0, 0);
|
|
55
60
|
current.width = image.width;
|
|
@@ -57,13 +62,12 @@ var tool = {
|
|
|
57
62
|
ctx.drawImage(image, 0, 0);
|
|
58
63
|
resolve();
|
|
59
64
|
};
|
|
60
|
-
|
|
61
65
|
image.src = src;
|
|
62
66
|
}
|
|
63
|
-
|
|
64
67
|
cropper.destroy();
|
|
65
|
-
cropper =
|
|
68
|
+
cropper = undefined;
|
|
66
69
|
});
|
|
67
70
|
}
|
|
68
71
|
};
|
|
69
|
-
|
|
72
|
+
var _default = tool;
|
|
73
|
+
exports.default = _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["cropper","undefined","renderForm","textAlign","tool","name","icon","activateTool","onActivate","canvas","options","Cropper","current","cancel","destroy","apply","Promise","resolve","src","getCroppedCanvas","toDataURL","image","window","Image","ctx","getContext","onload","drawImage","width","height"],"sources":["crop.tsx"],"sourcesContent":["import React from \"react\";\nimport { ImageEditorTool } from \"./types\";\nimport { ReactComponent as CropIcon } from \"./icons/crop.svg\";\nimport { IconButton } from \"~/Button\";\nimport { Tooltip } from \"~/Tooltip\";\nimport Cropper from \"cropperjs\";\nimport \"cropperjs/dist/cropper.css\";\n\nlet cropper: Cropper | undefined = undefined;\n\nconst renderForm = () => {\n return (\n <div style={{ textAlign: \"center\" }}>\n Click and drag to crop a portion of the image. Hold Shift to persist aspect ratio.\n </div>\n );\n};\n\nconst tool: ImageEditorTool = {\n name: \"crop\",\n icon({ activateTool }) {\n return (\n <Tooltip placement={\"bottom\"} content={\"Crop\"}>\n <IconButton\n icon={<CropIcon />}\n onClick={() => activateTool(\"crop\")}\n data-testid={\"crop-item\"}\n />\n </Tooltip>\n );\n },\n renderForm,\n onActivate: ({ canvas, options }) => {\n cropper = new Cropper(canvas.current as HTMLCanvasElement, options);\n },\n cancel: () => cropper && cropper.destroy(),\n apply: ({ canvas }) => {\n return new Promise((resolve: any) => {\n if (!cropper) {\n resolve();\n return;\n }\n\n const current = canvas.current;\n const src = cropper.getCroppedCanvas().toDataURL();\n if (current) {\n const image = new window.Image();\n const ctx = current.getContext(\"2d\") as CanvasRenderingContext2D;\n image.onload = () => {\n ctx.drawImage(image, 0, 0);\n current.width = image.width;\n current.height = image.height;\n\n ctx.drawImage(image, 0, 0);\n resolve();\n };\n image.src = src;\n }\n\n cropper.destroy();\n cropper = undefined;\n });\n }\n};\n\nexport default tool;\n"],"mappings":";;;;;;;AAAA;AAEA;AACA;AACA;AACA;AACA;AAEA,IAAIA,OAA4B,GAAGC,SAAS;AAE5C,IAAMC,UAAU,GAAG,SAAbA,UAAU,GAAS;EACrB,oBACI;IAAK,KAAK,EAAE;MAAEC,SAAS,EAAE;IAAS;EAAE,GAAC,oFAErC,CAAM;AAEd,CAAC;AAED,IAAMC,IAAqB,GAAG;EAC1BC,IAAI,EAAE,MAAM;EACZC,IAAI,sBAAmB;IAAA,IAAhBC,YAAY,QAAZA,YAAY;IACf,oBACI,6BAAC,gBAAO;MAAC,SAAS,EAAE,QAAS;MAAC,OAAO,EAAE;IAAO,gBAC1C,6BAAC,kBAAU;MACP,IAAI,eAAE,6BAAC,oBAAQ,OAAI;MACnB,OAAO,EAAE;QAAA,OAAMA,YAAY,CAAC,MAAM,CAAC;MAAA,CAAC;MACpC,eAAa;IAAY,EAC3B,CACI;EAElB,CAAC;EACDL,UAAU,EAAVA,UAAU;EACVM,UAAU,EAAE,2BAAyB;IAAA,IAAtBC,MAAM,SAANA,MAAM;MAAEC,OAAO,SAAPA,OAAO;IAC1BV,OAAO,GAAG,IAAIW,kBAAO,CAACF,MAAM,CAACG,OAAO,EAAuBF,OAAO,CAAC;EACvE,CAAC;EACDG,MAAM,EAAE;IAAA,OAAMb,OAAO,IAAIA,OAAO,CAACc,OAAO,EAAE;EAAA;EAC1CC,KAAK,EAAE,sBAAgB;IAAA,IAAbN,MAAM,SAANA,MAAM;IACZ,OAAO,IAAIO,OAAO,CAAC,UAACC,OAAY,EAAK;MACjC,IAAI,CAAC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