@webiny/ui 0.0.0-unstable.40876133bb → 0.0.0-unstable.496cf268ac
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 +1 -1
- package/Accordion/Accordion.js +5 -19
- package/Accordion/Accordion.js.map +1 -1
- package/Accordion/Accordion.stories.js +0 -8
- package/Accordion/Accordion.stories.js.map +1 -1
- package/Accordion/AccordionItem.d.ts +21 -2
- package/Accordion/AccordionItem.js +49 -71
- package/Accordion/AccordionItem.js.map +1 -1
- package/Accordion/AccordionItemActions.d.ts +8 -0
- package/Accordion/AccordionItemActions.js +28 -0
- package/Accordion/AccordionItemActions.js.map +1 -0
- package/Accordion/index.js +0 -4
- package/Accordion/index.js.map +1 -1
- package/Alert/Alert.d.ts +1 -1
- package/Alert/Alert.js +4 -11
- package/Alert/Alert.js.map +1 -1
- package/Alert/Alert.stories.js +0 -6
- package/Alert/Alert.stories.js.map +1 -1
- package/Alert/index.js +0 -2
- package/Alert/index.js.map +1 -1
- package/AutoComplete/AutoComplete.js +38 -88
- package/AutoComplete/AutoComplete.js.map +1 -1
- package/AutoComplete/AutoComplete.stories.js +0 -7
- package/AutoComplete/AutoComplete.stories.js.map +1 -1
- package/AutoComplete/MultiAutoComplete.js +52 -128
- package/AutoComplete/MultiAutoComplete.js.map +1 -1
- package/AutoComplete/MultiAutoComplete.stories.js +0 -8
- package/AutoComplete/MultiAutoComplete.stories.js.map +1 -1
- package/AutoComplete/index.js +0 -4
- package/AutoComplete/index.js.map +1 -1
- package/AutoComplete/styles.js +0 -2
- package/AutoComplete/styles.js.map +1 -1
- package/AutoComplete/utils.js +0 -8
- package/AutoComplete/utils.js.map +1 -1
- package/Avatar/Avatar.js +7 -18
- package/Avatar/Avatar.js.map +1 -1
- package/Avatar/Avatar.stories.js +0 -6
- package/Avatar/Avatar.stories.js.map +1 -1
- package/Avatar/index.js +0 -2
- package/Avatar/index.js.map +1 -1
- package/Button/Button.d.ts +30 -1
- package/Button/Button.js +39 -63
- package/Button/Button.js.map +1 -1
- package/Button/Button.stories.js +0 -10
- package/Button/Button.stories.js.map +1 -1
- package/Button/Button.styles.js +0 -2
- package/Button/Button.styles.js.map +1 -1
- package/Button/CopyButton/CopyButton.js +2 -12
- package/Button/CopyButton/CopyButton.js.map +1 -1
- package/Button/CopyButton/CopyButton.stories.js +0 -7
- package/Button/CopyButton/CopyButton.stories.js.map +1 -1
- package/Button/IconButton/IconButton.js +6 -12
- package/Button/IconButton/IconButton.js.map +1 -1
- package/Button/IconButton/IconButton.stories.js +0 -9
- package/Button/IconButton/IconButton.stories.js.map +1 -1
- package/Button/index.js +0 -6
- package/Button/index.js.map +1 -1
- package/Carousel/Carousel.js +0 -14
- package/Carousel/Carousel.js.map +1 -1
- package/Carousel/Carouser.stories.js +0 -7
- package/Carousel/Carouser.stories.js.map +1 -1
- package/Carousel/index.js +0 -2
- package/Carousel/index.js.map +1 -1
- package/Checkbox/Checkbox.d.ts +1 -0
- package/Checkbox/Checkbox.js +13 -31
- package/Checkbox/Checkbox.js.map +1 -1
- package/Checkbox/Checkbox.stories.js +0 -8
- package/Checkbox/Checkbox.stories.js.map +1 -1
- package/Checkbox/Checkbox.styles.js +0 -2
- package/Checkbox/Checkbox.styles.js.map +1 -1
- package/Checkbox/CheckboxGroup.js +7 -24
- package/Checkbox/CheckboxGroup.js.map +1 -1
- package/Checkbox/CheckboxGroup.stories.js +2 -10
- package/Checkbox/CheckboxGroup.stories.js.map +1 -1
- package/Checkbox/index.js +0 -3
- package/Checkbox/index.js.map +1 -1
- package/Chips/Chip.js +1 -8
- package/Chips/Chip.js.map +1 -1
- package/Chips/Chips.js +3 -13
- package/Chips/Chips.js.map +1 -1
- package/Chips/Chips.stories.js +0 -8
- package/Chips/Chips.stories.js.map +1 -1
- package/Chips/index.js +0 -4
- package/Chips/index.js.map +1 -1
- package/Chips/styles.js +0 -2
- package/Chips/styles.js.map +1 -1
- package/CodeEditor/CodeEditor.js +8 -36
- package/CodeEditor/CodeEditor.js.map +1 -1
- package/CodeEditor/CodeEditor.stories.js +0 -10
- package/CodeEditor/CodeEditor.stories.js.map +1 -1
- package/CodeEditor/index.js +0 -2
- package/CodeEditor/index.js.map +1 -1
- package/ColorPicker/ColorPicker.js +7 -31
- package/ColorPicker/ColorPicker.js.map +1 -1
- package/ColorPicker/ColorPicker.stories.js +0 -8
- package/ColorPicker/ColorPicker.stories.js.map +1 -1
- package/ColorPicker/index.js +0 -2
- package/ColorPicker/index.js.map +1 -1
- package/ConfirmationDialog/ConfirmationDialog.js +33 -65
- package/ConfirmationDialog/ConfirmationDialog.js.map +1 -1
- package/ConfirmationDialog/ConfirmationDialog.stories.js +0 -7
- package/ConfirmationDialog/ConfirmationDialog.stories.js.map +1 -1
- package/ConfirmationDialog/index.js +0 -4
- package/ConfirmationDialog/index.js.map +1 -1
- package/ConfirmationDialog/withConfirmation.js +0 -5
- package/ConfirmationDialog/withConfirmation.js.map +1 -1
- package/DataTable/DataTable.d.ts +16 -1
- package/DataTable/DataTable.js +62 -42
- package/DataTable/DataTable.js.map +1 -1
- package/DataTable/DataTable.stories.js +0 -6
- package/DataTable/DataTable.stories.js.map +1 -1
- package/DataTable/index.js +0 -2
- package/DataTable/index.js.map +1 -1
- package/DataTable/styled.d.ts +30 -1
- package/DataTable/styled.js +25 -7
- package/DataTable/styled.js.map +1 -1
- package/DelayedOnChange/DelayedOnChange.js +19 -35
- package/DelayedOnChange/DelayedOnChange.js.map +1 -1
- package/DelayedOnChange/index.js +0 -3
- package/DelayedOnChange/index.js.map +1 -1
- package/DelayedOnChange/withDelayedOnChange.js +3 -9
- package/DelayedOnChange/withDelayedOnChange.js.map +1 -1
- package/Dialog/Dialog.js +7 -39
- package/Dialog/Dialog.js.map +1 -1
- package/Dialog/Dialog.stories.js +0 -7
- package/Dialog/Dialog.stories.js.map +1 -1
- package/Dialog/index.js +0 -2
- package/Dialog/index.js.map +1 -1
- package/Drawer/Drawer.js +0 -9
- package/Drawer/Drawer.js.map +1 -1
- package/Drawer/Drawer.stories.js +0 -8
- package/Drawer/Drawer.stories.js.map +1 -1
- package/Drawer/index.js +0 -2
- package/Drawer/index.js.map +1 -1
- package/DynamicFieldset/Fieldset.js +7 -34
- package/DynamicFieldset/Fieldset.js.map +1 -1
- package/DynamicFieldset/index.js +0 -2
- package/DynamicFieldset/index.js.map +1 -1
- package/Elevation/Elevation.js +0 -5
- package/Elevation/Elevation.js.map +1 -1
- package/Elevation/Elevation.stories.js +0 -8
- package/Elevation/Elevation.stories.js.map +1 -1
- package/Elevation/index.js +0 -2
- package/Elevation/index.js.map +1 -1
- package/FormElementMessage/FormElementMessage.js +0 -5
- package/FormElementMessage/FormElementMessage.js.map +1 -1
- package/FormElementMessage/index.js +0 -1
- package/FormElementMessage/index.js.map +1 -1
- package/FullName/FullName.js +0 -7
- package/FullName/FullName.js.map +1 -1
- package/FullName/index.js +0 -2
- package/FullName/index.js.map +1 -1
- package/Grid/Grid.js +1 -9
- package/Grid/Grid.js.map +1 -1
- package/Grid/Grid.stories.js +0 -6
- package/Grid/Grid.stories.js.map +1 -1
- package/Grid/index.js +0 -2
- package/Grid/index.js.map +1 -1
- package/Helpers/ClassNames.js +0 -9
- package/Helpers/ClassNames.js.map +1 -1
- package/Helpers/index.js +0 -1
- package/Helpers/index.js.map +1 -1
- package/Icon/Icon.js +1 -7
- package/Icon/Icon.js.map +1 -1
- package/Icon/Icon.stories.js +0 -10
- package/Icon/Icon.stories.js.map +1 -1
- package/Icon/index.js +0 -2
- package/Icon/index.js.map +1 -1
- package/Image/Image.js +0 -8
- package/Image/Image.js.map +1 -1
- package/Image/Image.stories.js +0 -7
- package/Image/Image.stories.js.map +1 -1
- package/Image/index.js +0 -2
- package/Image/index.js.map +1 -1
- package/ImageEditor/ImageEditor.js +46 -107
- package/ImageEditor/ImageEditor.js.map +1 -1
- package/ImageEditor/index.js +0 -2
- package/ImageEditor/index.js.map +1 -1
- package/ImageEditor/toolbar/crop.js +1 -16
- package/ImageEditor/toolbar/crop.js.map +1 -1
- package/ImageEditor/toolbar/filter.js +11 -36
- package/ImageEditor/toolbar/filter.js.map +1 -1
- package/ImageEditor/toolbar/flip.js +0 -17
- package/ImageEditor/toolbar/flip.js.map +1 -1
- package/ImageEditor/toolbar/icons/index.js +0 -8
- package/ImageEditor/toolbar/icons/index.js.map +1 -1
- package/ImageEditor/toolbar/index.js +0 -5
- package/ImageEditor/toolbar/index.js.map +1 -1
- package/ImageEditor/toolbar/rotate.js +8 -43
- package/ImageEditor/toolbar/rotate.js.map +1 -1
- package/ImageUpload/Image.js +10 -34
- package/ImageUpload/Image.js.map +1 -1
- package/ImageUpload/ImageEditorDialog.js +11 -33
- package/ImageUpload/ImageEditorDialog.js.map +1 -1
- package/ImageUpload/MultiImageUpload.js +111 -175
- package/ImageUpload/MultiImageUpload.js.map +1 -1
- package/ImageUpload/MultiImageUpload.stories.js +0 -8
- package/ImageUpload/MultiImageUpload.stories.js.map +1 -1
- package/ImageUpload/SingleImageUpload.js +38 -79
- package/ImageUpload/SingleImageUpload.js.map +1 -1
- package/ImageUpload/SingleImageUpload.stories.js +0 -8
- package/ImageUpload/SingleImageUpload.stories.js.map +1 -1
- package/ImageUpload/index.js +0 -5
- package/ImageUpload/index.js.map +1 -1
- package/ImageUpload/styled.d.ts +27 -17
- package/ImageUpload/styled.js +0 -5
- package/ImageUpload/styled.js.map +1 -1
- package/Input/Input.d.ts +2 -12
- package/Input/Input.js +86 -149
- package/Input/Input.js.map +1 -1
- package/Input/Input.stories.js +0 -13
- package/Input/Input.stories.js.map +1 -1
- package/Input/__tests__/Input.test.js +4 -30
- package/Input/__tests__/Input.test.js.map +1 -1
- package/Input/index.js +0 -2
- package/Input/index.js.map +1 -1
- package/List/CollapsibleList/CollapsibleList.stories.js +0 -8
- package/List/CollapsibleList/CollapsibleList.stories.js.map +1 -1
- package/List/CollapsibleList/index.js +0 -6
- package/List/CollapsibleList/index.js.map +1 -1
- package/List/DataList/DataList.js +18 -97
- package/List/DataList/DataList.js.map +1 -1
- package/List/DataList/DataList.stories.js +2 -10
- package/List/DataList/DataList.stories.js.map +1 -1
- package/List/DataList/DataListModalOverlay/DataListModalOverlay.d.ts +8 -6
- package/List/DataList/DataListModalOverlay/DataListModalOverlay.js +5 -16
- package/List/DataList/DataListModalOverlay/DataListModalOverlay.js.map +1 -1
- package/List/DataList/DataListModalOverlay/DataListModalOverlayAction.js +3 -14
- package/List/DataList/DataListModalOverlay/DataListModalOverlayAction.js.map +1 -1
- package/List/DataList/DataListModalOverlay/DataListModalOverlayContext.js +3 -12
- package/List/DataList/DataListModalOverlay/DataListModalOverlayContext.js.map +1 -1
- package/List/DataList/DataListModalOverlay/index.js +0 -3
- package/List/DataList/DataListModalOverlay/index.js.map +1 -1
- package/List/DataList/DataListWithSections.js +4 -48
- package/List/DataList/DataListWithSections.js.map +1 -1
- package/List/DataList/Loader.js +0 -7
- package/List/DataList/Loader.js.map +1 -1
- package/List/DataList/NoData.js +0 -7
- package/List/DataList/NoData.js.map +1 -1
- package/List/DataList/icons/index.js +0 -29
- package/List/DataList/icons/index.js.map +1 -1
- package/List/DataList/index.js +0 -6
- package/List/DataList/index.js.map +1 -1
- package/List/List.js +0 -39
- package/List/List.js.map +1 -1
- package/List/List.stories.js +0 -12
- package/List/List.stories.js.map +1 -1
- package/List/icons/index.js +0 -3
- package/List/icons/index.js.map +1 -1
- package/List/index.js +0 -4
- package/List/index.js.map +1 -1
- package/Menu/Menu.js +2 -28
- package/Menu/Menu.js.map +1 -1
- package/Menu/Menu.stories.js +0 -7
- package/Menu/Menu.stories.js.map +1 -1
- package/Menu/index.js +0 -2
- package/Menu/index.js.map +1 -1
- package/Mosaic/Mosaic.js +3 -7
- package/Mosaic/Mosaic.js.map +1 -1
- package/Mosaic/Mosaic.stories.js +0 -6
- package/Mosaic/Mosaic.stories.js.map +1 -1
- package/Mosaic/index.js +0 -2
- package/Mosaic/index.js.map +1 -1
- package/Progress/CircularProgress.js +6 -14
- package/Progress/CircularProgress.js.map +1 -1
- package/Progress/index.js +0 -2
- package/Progress/index.js.map +1 -1
- package/Radio/Radio.js +9 -28
- package/Radio/Radio.js.map +1 -1
- package/Radio/Radio.styles.js +0 -2
- package/Radio/Radio.styles.js.map +1 -1
- package/Radio/RadioGroup.js +5 -21
- package/Radio/RadioGroup.js.map +1 -1
- package/Radio/RadioGroup.stories.js +2 -10
- package/Radio/RadioGroup.stories.js.map +1 -1
- package/Radio/index.js +0 -3
- package/Radio/index.js.map +1 -1
- package/RichTextEditor/RichTextEditor.js +30 -64
- package/RichTextEditor/RichTextEditor.js.map +1 -1
- package/RichTextEditor/RichTextEditor.stories.js +0 -7
- package/RichTextEditor/RichTextEditor.stories.js.map +1 -1
- package/RichTextEditor/createPropsFromConfig.js +0 -4
- package/RichTextEditor/createPropsFromConfig.js.map +1 -1
- package/RichTextEditor/index.js +0 -3
- package/RichTextEditor/index.js.map +1 -1
- package/Ripple/Ripple.js +0 -6
- package/Ripple/Ripple.js.map +1 -1
- package/Ripple/Ripple.stories.js +0 -12
- package/Ripple/Ripple.stories.js.map +1 -1
- package/Ripple/index.js +0 -2
- package/Ripple/index.js.map +1 -1
- package/Scrollbar/Scrollbar.js +0 -5
- package/Scrollbar/Scrollbar.js.map +1 -1
- package/Scrollbar/Scrollbar.stories.js +0 -6
- package/Scrollbar/Scrollbar.stories.js.map +1 -1
- package/Scrollbar/index.js +0 -2
- package/Scrollbar/index.js.map +1 -1
- package/Section/Section.stories.js +0 -7
- package/Section/Section.stories.js.map +1 -1
- package/Section/index.js +2 -12
- package/Section/index.js.map +1 -1
- package/Select/Select.js +9 -32
- package/Select/Select.js.map +1 -1
- package/Select/Select.stories.js +0 -8
- package/Select/Select.stories.js.map +1 -1
- package/Select/index.js +0 -2
- package/Select/index.js.map +1 -1
- package/Skeleton/Skeleton.d.ts +6 -2
- package/Skeleton/Skeleton.js +8 -11
- package/Skeleton/Skeleton.js.map +1 -1
- package/Skeleton/Skeleton.stories.js +0 -6
- package/Skeleton/Skeleton.stories.js.map +1 -1
- package/Skeleton/index.js +0 -2
- package/Skeleton/index.js.map +1 -1
- package/Slider/Slider.js +7 -29
- package/Slider/Slider.js.map +1 -1
- package/Slider/Slider.stories.js +1 -9
- package/Slider/Slider.stories.js.map +1 -1
- package/Slider/index.js +0 -2
- package/Slider/index.js.map +1 -1
- package/Snackbar/Snackbar.js +0 -19
- package/Snackbar/Snackbar.js.map +1 -1
- package/Snackbar/Snackbar.stories.js +0 -23
- package/Snackbar/Snackbar.stories.js.map +1 -1
- package/Snackbar/index.js +0 -1
- package/Snackbar/index.js.map +1 -1
- package/Switch/Switch.d.ts +1 -1
- package/Switch/Switch.js +5 -28
- package/Switch/Switch.js.map +1 -1
- package/Switch/Switch.stories.js +0 -8
- package/Switch/Switch.stories.js.map +1 -1
- package/Switch/index.js +0 -2
- package/Switch/index.js.map +1 -1
- package/Tabs/Tab.d.ts +1 -0
- package/Tabs/Tab.js +3 -9
- package/Tabs/Tab.js.map +1 -1
- package/Tabs/Tabs.d.ts +1 -0
- package/Tabs/Tabs.js +15 -28
- package/Tabs/Tabs.js.map +1 -1
- package/Tabs/Tabs.stories.js +0 -10
- package/Tabs/Tabs.stories.js.map +1 -1
- package/Tabs/index.js +0 -4
- package/Tabs/index.js.map +1 -1
- package/Tags/Tags.d.ts +8 -15
- package/Tags/Tags.js +77 -130
- package/Tags/Tags.js.map +1 -1
- package/Tags/Tags.stories.js +0 -8
- package/Tags/Tags.stories.js.map +1 -1
- package/Tags/index.js +0 -2
- package/Tags/index.js.map +1 -1
- package/Tooltip/Tooltip.js +0 -19
- package/Tooltip/Tooltip.js.map +1 -1
- package/Tooltip/Tooltip.stories.js +0 -6
- package/Tooltip/Tooltip.stories.js.map +1 -1
- package/Tooltip/index.js +0 -2
- package/Tooltip/index.js.map +1 -1
- package/TopAppBar/TopAppBar.js +1 -8
- package/TopAppBar/TopAppBar.js.map +1 -1
- package/TopAppBar/TopAppBar.stories.js +3 -16
- package/TopAppBar/TopAppBar.stories.js.map +1 -1
- package/TopAppBar/TopAppBarActionItem.js +0 -5
- package/TopAppBar/TopAppBarActionItem.js.map +1 -1
- package/TopAppBar/TopAppBarNavigationIcon.js +0 -5
- package/TopAppBar/TopAppBarNavigationIcon.js.map +1 -1
- package/TopAppBar/TopAppBarPrimary.js +1 -8
- package/TopAppBar/TopAppBarPrimary.js.map +1 -1
- package/TopAppBar/TopAppBarSecondary.js +3 -10
- package/TopAppBar/TopAppBarSecondary.js.map +1 -1
- package/TopAppBar/TopAppBarSection.js +1 -8
- package/TopAppBar/TopAppBarSection.js.map +1 -1
- package/TopAppBar/TopAppBarTitle.js +1 -8
- package/TopAppBar/TopAppBarTitle.js.map +1 -1
- package/TopAppBar/index.js +0 -14
- package/TopAppBar/index.js.map +1 -1
- package/TopProgressBar/TopProgressBar.js +0 -5
- package/TopProgressBar/TopProgressBar.js.map +1 -1
- package/TopProgressBar/TopProgressBar.stories.js +1 -8
- package/TopProgressBar/TopProgressBar.stories.js.map +1 -1
- package/TopProgressBar/hoc/index.js +0 -2
- package/TopProgressBar/hoc/index.js.map +1 -1
- package/TopProgressBar/hoc/withTopProgressBar.js +2 -8
- package/TopProgressBar/hoc/withTopProgressBar.js.map +1 -1
- package/TopProgressBar/index.js +0 -2
- package/TopProgressBar/index.js.map +1 -1
- package/Typography/Typography.d.ts +2 -2
- package/Typography/Typography.js +0 -5
- package/Typography/Typography.js.map +1 -1
- package/Typography/Typography.stories.js +0 -6
- package/Typography/Typography.stories.js.map +1 -1
- package/Typography/index.js +0 -2
- package/Typography/index.js.map +1 -1
- package/package.json +17 -15
- package/types.d.ts +3 -3
- package/types.js.map +1 -1
|
@@ -1 +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,aADY;EAEZC,MAAM,EAANA,eAFY;EAGZC,IAAI,EAAJA,aAHY;EAIZC,MAAM,EAANA;AAJY,CAAhB;AAOA,IAAMC,OAAO,oBAAGC,eAAH,EAAU,KAAV;EAAA;EAAA;AAAA,GAAiB;EAC1BC,OAAO,EAAE,MADiB;EAE1BC,cAAc,EAAE,QAFU;EAG1BC,UAAU,EAAE,QAHc;EAI1BC,eAAe,EAAE,4BAJS;EAK1BC,MAAM,EAAE,uBALkB;EAM1BC,OAAO,EAAE,CANiB;EAO1BC,QAAQ,EAAE,UAPgB;EAQ1BC,KAAK,EAAE,MARmB;EAS1BC,SAAS,EAAE,YATe;EAU1BC,MAAM,EAAE,EAVkB;EAW1B,kBAAkB;IACdC,OAAO,EAAE,GADK;IAEdC,aAAa,EAAE;EAFD;AAXQ,CAAjB,CAAb;AAiBA,IAAMC,WAAW,oBAAGb,eAAH,EAAU,KAAV;EAAA;EAAA;AAAA,GAAiB;EAC9BK,MAAM,EAAE,uBADsB;EAE9BI,SAAS,EAAE,YAFmB;EAG9BH,OAAO,EAAE,EAHqB;EAI9BF,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EAAE;UAAEX,MAAM,EAAE,QAAV;UAAoBW,SAAS,EAAE;QAA/B;MAAZ,gBACI;QACI,GAAG,EAAES,GADT;QAEI,EAAE,EAAE,QAFR;QAGI,KAAK,EAAE;UAAE0C,QAAQ,EAAE;QAAZ,CAHX;QAII,GAAG,EAAE,KAAKpC;MAJd,EADJ,CAvDJ,CADJ;;MAmEA,IAAI,OAAO2B,QAAP,KAAoB,UAAxB,EAAoC;QAChC,OAAOA,QAAQ,CAAC;UACZU,MAAM,EAAE;YAAA,OAAMT,MAAN;UAAA,CADI;UAEZ;UACAU,gBAAgB,EAAE,KAAKA,gBAHX;UAIZC,UAAU,EAAE,KAAKzB,KAAL,CAAWrB,IAJX;UAKZ0C,eAAe,EAAE,KAAKA,eALV;UAMZD,gBAAgB,EAAE,KAAKA;QANX,CAAD,CAAf;MAQH;;MAED,OAAON,MAAP;IACH;;;EA5MqBjC,cAAA,CAAM6C,S;;;8BAA1BhD,W,kBAC+C;EAC7CkC,KAAK,EAAE,CAAC,MAAD,EAAS,MAAT,EAAiB,QAAjB,EAA2B,QAA3B;AADsC,C"}
|
|
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 });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EAAE;QAChC,OAAOA,QAAQ,CAAC;UACZU,MAAM,EAAE;YAAA,OAAMT,MAAM;UAAA;UACpB;UACAU,gBAAgB,EAAE,IAAI,CAACA,gBAAgB;UACvCC,UAAU,EAAE,IAAI,CAACzB,KAAK,CAACrB,IAAI;UAC3B0C,eAAe,EAAE,IAAI,CAACA,eAAe;UACrCD,gBAAgB,EAAE,IAAI,CAACA;QAC3B,CAAC,CAAC;MACN;MAEA,OAAON,MAAM;IACjB;EAAC;EAAA;AAAA,EA5MqBjC,cAAK,CAAC6C,SAAS;AAAA;AAAA,8BAAnChD,WAAW,kBACoC;EAC7CkC,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ;AAC9C,CAAC"}
|
package/ImageEditor/index.js
CHANGED
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
7
6
|
var _ImageEditor = require("./ImageEditor");
|
|
8
|
-
|
|
9
7
|
Object.keys(_ImageEditor).forEach(function (key) {
|
|
10
8
|
if (key === "default" || key === "__esModule") return;
|
|
11
9
|
if (key in exports && exports[key] === _ImageEditor[key]) return;
|
package/ImageEditor/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./ImageEditor\";\n"],"mappings":"
|
|
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,26 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _react = _interopRequireDefault(require("react"));
|
|
11
|
-
|
|
12
9
|
var _crop = require("./icons/crop.svg");
|
|
13
|
-
|
|
14
10
|
var _Button = require("../../Button");
|
|
15
|
-
|
|
16
11
|
var _Tooltip = require("../../Tooltip");
|
|
17
|
-
|
|
18
12
|
var _cropperjs = _interopRequireDefault(require("cropperjs"));
|
|
19
|
-
|
|
20
13
|
require("cropperjs/dist/cropper.css");
|
|
21
|
-
|
|
22
14
|
var cropper = undefined;
|
|
23
|
-
|
|
24
15
|
var renderForm = function renderForm() {
|
|
25
16
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
26
17
|
style: {
|
|
@@ -28,7 +19,6 @@ var renderForm = function renderForm() {
|
|
|
28
19
|
}
|
|
29
20
|
}, "Click and drag to crop a portion of the image. Hold Shift to persist aspect ratio.");
|
|
30
21
|
};
|
|
31
|
-
|
|
32
22
|
var tool = {
|
|
33
23
|
name: "crop",
|
|
34
24
|
icon: function icon(_ref) {
|
|
@@ -47,7 +37,7 @@ var tool = {
|
|
|
47
37
|
renderForm: renderForm,
|
|
48
38
|
onActivate: function onActivate(_ref2) {
|
|
49
39
|
var canvas = _ref2.canvas,
|
|
50
|
-
|
|
40
|
+
options = _ref2.options;
|
|
51
41
|
cropper = new _cropperjs.default(canvas.current, options);
|
|
52
42
|
},
|
|
53
43
|
cancel: function cancel() {
|
|
@@ -60,14 +50,11 @@ var tool = {
|
|
|
60
50
|
resolve();
|
|
61
51
|
return;
|
|
62
52
|
}
|
|
63
|
-
|
|
64
53
|
var current = canvas.current;
|
|
65
54
|
var src = cropper.getCroppedCanvas().toDataURL();
|
|
66
|
-
|
|
67
55
|
if (current) {
|
|
68
56
|
var image = new window.Image();
|
|
69
57
|
var ctx = current.getContext("2d");
|
|
70
|
-
|
|
71
58
|
image.onload = function () {
|
|
72
59
|
ctx.drawImage(image, 0, 0);
|
|
73
60
|
current.width = image.width;
|
|
@@ -75,10 +62,8 @@ var tool = {
|
|
|
75
62
|
ctx.drawImage(image, 0, 0);
|
|
76
63
|
resolve();
|
|
77
64
|
};
|
|
78
|
-
|
|
79
65
|
image.src = src;
|
|
80
66
|
}
|
|
81
|
-
|
|
82
67
|
cropper.destroy();
|
|
83
68
|
cropper = undefined;
|
|
84
69
|
});
|
|
@@ -1 +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":"
|
|
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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,UAAU,CAAC,IAAI,CAA6B;QAChEJ,KAAK,CAACK,MAAM,GAAG,YAAM;UACjBF,GAAG,CAACG,SAAS,CAACN,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;UAC1BT,OAAO,CAACgB,KAAK,GAAGP,KAAK,CAACO,KAAK;UAC3BhB,OAAO,CAACiB,MAAM,GAAGR,KAAK,CAACQ,MAAM;UAE7BL,GAAG,CAACG,SAAS,CAACN,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;UAC1BJ,OAAO,EAAE;QACb,CAAC;QACDI,KAAK,CAACH,GAAG,GAAGA,GAAG;MACnB;MAEAlB,OAAO,CAACc,OAAO,EAAE;MACjBd,OAAO,GAAGC,SAAS;IACvB,CAAC,CAAC;EACN;AACJ,CAAC;AAAC,eAEaG,IAAI;AAAA"}
|
|
@@ -1,44 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
-
|
|
12
9
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
-
|
|
14
10
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
-
|
|
16
11
|
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
17
|
-
|
|
18
12
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
19
|
-
|
|
20
13
|
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
|
|
21
|
-
|
|
22
14
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
23
|
-
|
|
24
15
|
var _debounce2 = _interopRequireDefault(require("lodash/debounce"));
|
|
25
|
-
|
|
26
16
|
var _react = _interopRequireDefault(require("react"));
|
|
27
|
-
|
|
28
17
|
var _filter = require("./icons/filter.svg");
|
|
29
|
-
|
|
30
18
|
var _Slider = require("../../Slider");
|
|
31
|
-
|
|
32
19
|
var _Button = require("../../Button");
|
|
33
|
-
|
|
34
20
|
var _Tooltip = require("../../Tooltip");
|
|
35
|
-
|
|
36
21
|
var _styled = _interopRequireDefault(require("@emotion/styled"));
|
|
37
|
-
|
|
38
22
|
/**
|
|
39
23
|
* When using Caman, we added @ts-ignore because it does not exist in packages, but it is loaded in packages/ui/src/ImageEditor/ImageEditor.tsx:38.
|
|
40
24
|
* TODO: use some other library to edit images
|
|
41
25
|
*/
|
|
26
|
+
|
|
42
27
|
var Wrapper = /*#__PURE__*/(0, _styled.default)("div", {
|
|
43
28
|
target: "e1cnct9n0",
|
|
44
29
|
label: "Wrapper"
|
|
@@ -98,21 +83,15 @@ var sliders = [{
|
|
|
98
83
|
key: "sharpen",
|
|
99
84
|
label: "Sharpen"
|
|
100
85
|
}];
|
|
101
|
-
|
|
102
86
|
var RenderForm = /*#__PURE__*/function (_React$Component) {
|
|
103
87
|
(0, _inherits2.default)(RenderForm, _React$Component);
|
|
104
|
-
|
|
105
88
|
var _super = (0, _createSuper2.default)(RenderForm);
|
|
106
|
-
|
|
107
89
|
function RenderForm() {
|
|
108
90
|
var _this;
|
|
109
|
-
|
|
110
91
|
(0, _classCallCheck2.default)(this, RenderForm);
|
|
111
|
-
|
|
112
92
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
113
93
|
args[_key] = arguments[_key];
|
|
114
94
|
}
|
|
115
|
-
|
|
116
95
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
117
96
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "state", {
|
|
118
97
|
processing: false,
|
|
@@ -120,20 +99,21 @@ var RenderForm = /*#__PURE__*/function (_React$Component) {
|
|
|
120
99
|
});
|
|
121
100
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "applyFilters", (0, _debounce2.default)(function () {
|
|
122
101
|
var canvas = _this.props.canvas;
|
|
123
|
-
var values = _this.state.values;
|
|
124
|
-
|
|
125
|
-
var component = (0, _assertThisInitialized2.default)(_this);
|
|
102
|
+
var values = _this.state.values;
|
|
103
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
104
|
+
var component = (0, _assertThisInitialized2.default)(_this);
|
|
126
105
|
|
|
106
|
+
// @ts-ignore
|
|
127
107
|
Caman(canvas.current, function () {
|
|
128
108
|
var _this2 = this;
|
|
129
|
-
|
|
130
109
|
// @ts-ignore
|
|
131
110
|
this.revert(false);
|
|
132
|
-
Object.keys(values).forEach(
|
|
111
|
+
Object.keys(values).forEach(
|
|
112
|
+
// @ts-ignore
|
|
133
113
|
function (key) {
|
|
134
114
|
return values[key] !== 0 && _this2[key] && _this2[key](values[key]);
|
|
135
|
-
});
|
|
136
|
-
|
|
115
|
+
});
|
|
116
|
+
// @ts-ignore
|
|
137
117
|
this.render();
|
|
138
118
|
component.setState({
|
|
139
119
|
processing: false
|
|
@@ -151,7 +131,6 @@ var RenderForm = /*#__PURE__*/function (_React$Component) {
|
|
|
151
131
|
});
|
|
152
132
|
return _this;
|
|
153
133
|
}
|
|
154
|
-
|
|
155
134
|
(0, _createClass2.default)(RenderForm, [{
|
|
156
135
|
key: "componentDidMount",
|
|
157
136
|
value: function componentDidMount() {
|
|
@@ -161,7 +140,6 @@ var RenderForm = /*#__PURE__*/function (_React$Component) {
|
|
|
161
140
|
key: "render",
|
|
162
141
|
value: function render() {
|
|
163
142
|
var _this3 = this;
|
|
164
|
-
|
|
165
143
|
return /*#__PURE__*/_react.default.createElement(Wrapper, null, /*#__PURE__*/_react.default.createElement("ul", null, sliders.map(function (props) {
|
|
166
144
|
return /*#__PURE__*/_react.default.createElement("li", {
|
|
167
145
|
key: props.key
|
|
@@ -191,9 +169,7 @@ var RenderForm = /*#__PURE__*/function (_React$Component) {
|
|
|
191
169
|
processing: true
|
|
192
170
|
}, function () {
|
|
193
171
|
_this3.resetFiltersValues();
|
|
194
|
-
|
|
195
172
|
_this3.applyFilters();
|
|
196
|
-
|
|
197
173
|
_this3.setState({
|
|
198
174
|
processing: false
|
|
199
175
|
});
|
|
@@ -204,7 +180,6 @@ var RenderForm = /*#__PURE__*/function (_React$Component) {
|
|
|
204
180
|
}]);
|
|
205
181
|
return RenderForm;
|
|
206
182
|
}(_react.default.Component);
|
|
207
|
-
|
|
208
183
|
var tool = {
|
|
209
184
|
name: "filter",
|
|
210
185
|
icon: function icon(_ref) {
|
|
@@ -228,8 +203,8 @@ var tool = {
|
|
|
228
203
|
// @ts-ignore
|
|
229
204
|
Caman(canvas.current, function () {
|
|
230
205
|
// @ts-ignore
|
|
231
|
-
this.revert(false);
|
|
232
|
-
|
|
206
|
+
this.revert(false);
|
|
207
|
+
// @ts-ignore
|
|
233
208
|
this.render();
|
|
234
209
|
});
|
|
235
210
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Wrapper","styled","ul","textAlign","li","display","width","padding","sliders","key","label","min","RenderForm","processing","values","canvas","props","state","component","Caman","current","revert","Object","keys","forEach","render","setState","reduce","output","resetFiltersValues","map","value","applyFilters","React","Component","tool","name","icon","activateTool","renderForm","cancel"],"sources":["filter.tsx"],"sourcesContent":["/**\n * When using Caman, we added @ts-ignore because it does not exist in packages, but it is loaded in packages/ui/src/ImageEditor/ImageEditor.tsx:38.\n * TODO: use some other library to edit images\n */\nimport React from \"react\";\nimport { ReactComponent as FilterIcon } from \"./icons/filter.svg\";\nimport { Slider } from \"~/Slider\";\nimport { ImageEditorTool } from \"./types\";\nimport { IconButton, ButtonDefault } from \"~/Button\";\nimport { Tooltip } from \"~/Tooltip\";\nimport { debounce } from \"lodash\";\nimport styled from \"@emotion/styled\";\n\ninterface RenderFormState {\n values: Record<string, any>;\n processing: boolean;\n}\n\ninterface RenderFormProps {\n canvas: any;\n renderApplyCancel?: Function;\n}\n\nconst Wrapper = styled(\"div\")({\n ul: {\n textAlign: \"center\",\n li: {\n display: \"inline-block\",\n width: 180,\n padding: 10\n }\n },\n \".buttons\": {\n textAlign: \"center\"\n }\n});\n\nconst sliders = [\n {\n key: \"brightness\",\n label: \"Brightness\",\n min: -100\n },\n {\n key: \"vibrance\",\n label: \"Vibrance\",\n min: -100\n },\n {\n key: \"hue\",\n label: \"Hue\",\n min: -100\n },\n {\n key: \"gamma\",\n label: \"Gamma\"\n },\n {\n key: \"clip\",\n label: \"Clip\"\n },\n {\n key: \"stackBlur\",\n label: \"Blur\"\n },\n {\n key: \"contrast\",\n label: \"Contrast\",\n min: -100\n },\n {\n key: \"saturation\",\n label: \"Saturation\",\n min: -100\n },\n {\n key: \"exposure\",\n label: \"Exposure\",\n min: -100\n },\n {\n key: \"sepia\",\n label: \"Sepia\"\n },\n {\n key: \"noise\",\n label: \"Noise\"\n },\n {\n key: \"sharpen\",\n label: \"Sharpen\"\n }\n];\n\nclass RenderForm extends React.Component<RenderFormProps, RenderFormState> {\n public override state: RenderFormState = {\n processing: false,\n values: {}\n };\n\n public override componentDidMount() {\n this.resetFiltersValues();\n }\n\n private readonly applyFilters = debounce(() => {\n const { canvas } = this.props;\n const { values } = this.state;\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const component = this;\n\n // @ts-ignore\n Caman(canvas.current, function () {\n // @ts-ignore\n this.revert(false);\n Object.keys(values).forEach(\n // @ts-ignore\n key => values[key] !== 0 && this[key] && this[key](values[key])\n );\n // @ts-ignore\n this.render();\n component.setState({ processing: false });\n });\n }, 200);\n\n private readonly resetFiltersValues = () => {\n this.setState(state => {\n sliders.reduce((output, current) => {\n state.values[current.key] = 0;\n return output;\n }, {});\n\n return state;\n });\n };\n\n public override render() {\n return (\n <Wrapper>\n <ul>\n {sliders.map(props => (\n <li key={props.key}>\n <Slider\n value={this.state.values[props.key]}\n min={0}\n max={100}\n disabled={this.state.processing}\n onInput={(value: string) => {\n this.setState(state => {\n const values = { ...state.values };\n values[props.key] = value;\n\n return { ...state, processing: true, values };\n }, this.applyFilters);\n }}\n {...props}\n />\n </li>\n ))}\n </ul>\n\n <div style={{ textAlign: \"center\" }}>\n <ButtonDefault\n onClick={() => {\n this.setState({ processing: true }, () => {\n this.resetFiltersValues();\n this.applyFilters();\n this.setState({ processing: false });\n });\n }}\n >\n Reset filters\n </ButtonDefault>\n </div>\n </Wrapper>\n );\n }\n}\n\nconst tool: ImageEditorTool = {\n name: \"filter\",\n icon({ activateTool }) {\n return (\n <Tooltip placement={\"bottom\"} content={\"Filter\"}>\n <IconButton\n icon={<FilterIcon />}\n onClick={() => activateTool(\"filter\")}\n data-testid={\"filter-item\"}\n />\n </Tooltip>\n );\n },\n renderForm(props) {\n return <RenderForm {...props} />;\n },\n cancel: ({ canvas }) => {\n // @ts-ignore\n Caman(canvas.current, function () {\n // @ts-ignore\n this.revert(false);\n // @ts-ignore\n this.render();\n });\n }\n};\n\nexport default tool;\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["Wrapper","styled","ul","textAlign","li","display","width","padding","sliders","key","label","min","RenderForm","processing","values","canvas","props","state","component","Caman","current","revert","Object","keys","forEach","render","setState","reduce","output","resetFiltersValues","map","value","applyFilters","React","Component","tool","name","icon","activateTool","renderForm","cancel"],"sources":["filter.tsx"],"sourcesContent":["/**\n * When using Caman, we added @ts-ignore because it does not exist in packages, but it is loaded in packages/ui/src/ImageEditor/ImageEditor.tsx:38.\n * TODO: use some other library to edit images\n */\nimport React from \"react\";\nimport { ReactComponent as FilterIcon } from \"./icons/filter.svg\";\nimport { Slider } from \"~/Slider\";\nimport { ImageEditorTool } from \"./types\";\nimport { IconButton, ButtonDefault } from \"~/Button\";\nimport { Tooltip } from \"~/Tooltip\";\nimport { debounce } from \"lodash\";\nimport styled from \"@emotion/styled\";\n\ninterface RenderFormState {\n values: Record<string, any>;\n processing: boolean;\n}\n\ninterface RenderFormProps {\n canvas: any;\n renderApplyCancel?: Function;\n}\n\nconst Wrapper = styled(\"div\")({\n ul: {\n textAlign: \"center\",\n li: {\n display: \"inline-block\",\n width: 180,\n padding: 10\n }\n },\n \".buttons\": {\n textAlign: \"center\"\n }\n});\n\nconst sliders = [\n {\n key: \"brightness\",\n label: \"Brightness\",\n min: -100\n },\n {\n key: \"vibrance\",\n label: \"Vibrance\",\n min: -100\n },\n {\n key: \"hue\",\n label: \"Hue\",\n min: -100\n },\n {\n key: \"gamma\",\n label: \"Gamma\"\n },\n {\n key: \"clip\",\n label: \"Clip\"\n },\n {\n key: \"stackBlur\",\n label: \"Blur\"\n },\n {\n key: \"contrast\",\n label: \"Contrast\",\n min: -100\n },\n {\n key: \"saturation\",\n label: \"Saturation\",\n min: -100\n },\n {\n key: \"exposure\",\n label: \"Exposure\",\n min: -100\n },\n {\n key: \"sepia\",\n label: \"Sepia\"\n },\n {\n key: \"noise\",\n label: \"Noise\"\n },\n {\n key: \"sharpen\",\n label: \"Sharpen\"\n }\n];\n\nclass RenderForm extends React.Component<RenderFormProps, RenderFormState> {\n public override state: RenderFormState = {\n processing: false,\n values: {}\n };\n\n public override componentDidMount() {\n this.resetFiltersValues();\n }\n\n private readonly applyFilters = debounce(() => {\n const { canvas } = this.props;\n const { values } = this.state;\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const component = this;\n\n // @ts-ignore\n Caman(canvas.current, function () {\n // @ts-ignore\n this.revert(false);\n Object.keys(values).forEach(\n // @ts-ignore\n key => values[key] !== 0 && this[key] && this[key](values[key])\n );\n // @ts-ignore\n this.render();\n component.setState({ processing: false });\n });\n }, 200);\n\n private readonly resetFiltersValues = () => {\n this.setState(state => {\n sliders.reduce((output, current) => {\n state.values[current.key] = 0;\n return output;\n }, {});\n\n return state;\n });\n };\n\n public override render() {\n return (\n <Wrapper>\n <ul>\n {sliders.map(props => (\n <li key={props.key}>\n <Slider\n value={this.state.values[props.key]}\n min={0}\n max={100}\n disabled={this.state.processing}\n onInput={(value: string) => {\n this.setState(state => {\n const values = { ...state.values };\n values[props.key] = value;\n\n return { ...state, processing: true, values };\n }, this.applyFilters);\n }}\n {...props}\n />\n </li>\n ))}\n </ul>\n\n <div style={{ textAlign: \"center\" }}>\n <ButtonDefault\n onClick={() => {\n this.setState({ processing: true }, () => {\n this.resetFiltersValues();\n this.applyFilters();\n this.setState({ processing: false });\n });\n }}\n >\n Reset filters\n </ButtonDefault>\n </div>\n </Wrapper>\n );\n }\n}\n\nconst tool: ImageEditorTool = {\n name: \"filter\",\n icon({ activateTool }) {\n return (\n <Tooltip placement={\"bottom\"} content={\"Filter\"}>\n <IconButton\n icon={<FilterIcon />}\n onClick={() => activateTool(\"filter\")}\n data-testid={\"filter-item\"}\n />\n </Tooltip>\n );\n },\n renderForm(props) {\n return <RenderForm {...props} />;\n },\n cancel: ({ canvas }) => {\n // @ts-ignore\n Caman(canvas.current, function () {\n // @ts-ignore\n this.revert(false);\n // @ts-ignore\n this.render();\n });\n }\n};\n\nexport default tool;\n"],"mappings":";;;;;;;;;;;;;;;AAIA;AACA;AACA;AAEA;AACA;AAEA;AAXA;AACA;AACA;AACA;;AAoBA,IAAMA,OAAO,oBAAGC,eAAM,EAAC,KAAK;EAAA;EAAA;AAAA,GAAE;EAC1BC,EAAE,EAAE;IACAC,SAAS,EAAE,QAAQ;IACnBC,EAAE,EAAE;MACAC,OAAO,EAAE,cAAc;MACvBC,KAAK,EAAE,GAAG;MACVC,OAAO,EAAE;IACb;EACJ,CAAC;EACD,UAAU,EAAE;IACRJ,SAAS,EAAE;EACf;AACJ,CAAC,CAAC;AAEF,IAAMK,OAAO,GAAG,CACZ;EACIC,GAAG,EAAE,YAAY;EACjBC,KAAK,EAAE,YAAY;EACnBC,GAAG,EAAE,CAAC;AACV,CAAC,EACD;EACIF,GAAG,EAAE,UAAU;EACfC,KAAK,EAAE,UAAU;EACjBC,GAAG,EAAE,CAAC;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I,MAAM,EAAE;IACjB,CAAC,CAAC;EACN;AACJ,CAAC;AAAC,eAEaU,IAAI;AAAA"}
|
|
@@ -1,30 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _react = _interopRequireDefault(require("react"));
|
|
11
|
-
|
|
12
9
|
var _flip = require("./icons/flip.svg");
|
|
13
|
-
|
|
14
10
|
var _cropperjs = _interopRequireDefault(require("cropperjs"));
|
|
15
|
-
|
|
16
11
|
require("cropperjs/dist/cropper.css");
|
|
17
|
-
|
|
18
12
|
var _Button = require("../../Button");
|
|
19
|
-
|
|
20
13
|
var _Tooltip = require("../../Tooltip");
|
|
21
|
-
|
|
22
14
|
var cropper;
|
|
23
15
|
var flipped = {
|
|
24
16
|
x: 1,
|
|
25
17
|
y: 1
|
|
26
18
|
};
|
|
27
|
-
|
|
28
19
|
var renderForm = function renderForm() {
|
|
29
20
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
30
21
|
style: {
|
|
@@ -35,7 +26,6 @@ var renderForm = function renderForm() {
|
|
|
35
26
|
if (!cropper) {
|
|
36
27
|
return;
|
|
37
28
|
}
|
|
38
|
-
|
|
39
29
|
flipped.x = flipped.x === 1 ? -1 : 1;
|
|
40
30
|
cropper.scaleX(flipped.x);
|
|
41
31
|
}
|
|
@@ -44,13 +34,11 @@ var renderForm = function renderForm() {
|
|
|
44
34
|
if (!cropper) {
|
|
45
35
|
return;
|
|
46
36
|
}
|
|
47
|
-
|
|
48
37
|
flipped.y = flipped.y === 1 ? -1 : 1;
|
|
49
38
|
cropper.scaleY(flipped.y);
|
|
50
39
|
}
|
|
51
40
|
}, "FlipY"));
|
|
52
41
|
};
|
|
53
|
-
|
|
54
42
|
var tool = {
|
|
55
43
|
name: "flip",
|
|
56
44
|
icon: function icon(_ref) {
|
|
@@ -88,14 +76,11 @@ var tool = {
|
|
|
88
76
|
resolve();
|
|
89
77
|
return;
|
|
90
78
|
}
|
|
91
|
-
|
|
92
79
|
var current = canvas.current;
|
|
93
80
|
var src = cropper.getCroppedCanvas().toDataURL();
|
|
94
|
-
|
|
95
81
|
if (current) {
|
|
96
82
|
var image = new window.Image();
|
|
97
83
|
var ctx = current.getContext("2d");
|
|
98
|
-
|
|
99
84
|
image.onload = function () {
|
|
100
85
|
ctx.drawImage(image, 0, 0);
|
|
101
86
|
current.width = image.width;
|
|
@@ -103,10 +88,8 @@ var tool = {
|
|
|
103
88
|
ctx.drawImage(image, 0, 0);
|
|
104
89
|
resolve();
|
|
105
90
|
};
|
|
106
|
-
|
|
107
91
|
image.src = src;
|
|
108
92
|
}
|
|
109
|
-
|
|
110
93
|
cropper.destroy();
|
|
111
94
|
});
|
|
112
95
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["cropper","flipped","x","y","renderForm","textAlign","scaleX","scaleY","tool","name","icon","activateTool","cancel","destroy","onActivate","canvas","Cropper","current","background","modal","guides","dragMode","highlight","autoCrop","apply","Promise","resolve","src","getCroppedCanvas","toDataURL","image","window","Image","ctx","getContext","onload","drawImage","width","height"],"sources":["flip.tsx"],"sourcesContent":["import React from \"react\";\nimport { ImageEditorTool } from \"./types\";\nimport { ReactComponent as FlipIcon } from \"./icons/flip.svg\";\nimport Cropper from \"cropperjs\";\nimport \"cropperjs/dist/cropper.css\";\n\nimport { IconButton, ButtonDefault } from \"../../Button\";\nimport { Tooltip } from \"~/Tooltip\";\n\nlet cropper: Cropper;\n\nconst flipped = { x: 1, y: 1 };\n\nconst renderForm = () => {\n return (\n <div style={{ textAlign: \"center\" }}>\n <ButtonDefault\n onClick={() => {\n if (!cropper) {\n return;\n }\n\n flipped.x = flipped.x === 1 ? -1 : 1;\n cropper.scaleX(flipped.x);\n }}\n >\n FlipX\n </ButtonDefault>\n <ButtonDefault\n onClick={() => {\n if (!cropper) {\n return;\n }\n\n flipped.y = flipped.y === 1 ? -1 : 1;\n cropper.scaleY(flipped.y);\n }}\n >\n FlipY\n </ButtonDefault>\n </div>\n );\n};\n\nconst tool: ImageEditorTool = {\n name: \"flip\",\n icon({ activateTool }) {\n return (\n <Tooltip placement={\"bottom\"} content={\"Flip\"}>\n <IconButton\n icon={<FlipIcon />}\n onClick={() => activateTool(\"flip\")}\n data-testid={\"flip-item\"}\n />\n </Tooltip>\n );\n },\n renderForm,\n cancel: () => cropper && cropper.destroy(),\n onActivate: ({ canvas }) => {\n cropper = new Cropper(canvas.current as HTMLCanvasElement, {\n background: false,\n modal: false,\n guides: false,\n dragMode: \"none\",\n highlight: false,\n autoCrop: false\n });\n },\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 });\n }\n};\n\nexport default tool;\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["cropper","flipped","x","y","renderForm","textAlign","scaleX","scaleY","tool","name","icon","activateTool","cancel","destroy","onActivate","canvas","Cropper","current","background","modal","guides","dragMode","highlight","autoCrop","apply","Promise","resolve","src","getCroppedCanvas","toDataURL","image","window","Image","ctx","getContext","onload","drawImage","width","height"],"sources":["flip.tsx"],"sourcesContent":["import React from \"react\";\nimport { ImageEditorTool } from \"./types\";\nimport { ReactComponent as FlipIcon } from \"./icons/flip.svg\";\nimport Cropper from \"cropperjs\";\nimport \"cropperjs/dist/cropper.css\";\n\nimport { IconButton, ButtonDefault } from \"../../Button\";\nimport { Tooltip } from \"~/Tooltip\";\n\nlet cropper: Cropper;\n\nconst flipped = { x: 1, y: 1 };\n\nconst renderForm = () => {\n return (\n <div style={{ textAlign: \"center\" }}>\n <ButtonDefault\n onClick={() => {\n if (!cropper) {\n return;\n }\n\n flipped.x = flipped.x === 1 ? -1 : 1;\n cropper.scaleX(flipped.x);\n }}\n >\n FlipX\n </ButtonDefault>\n <ButtonDefault\n onClick={() => {\n if (!cropper) {\n return;\n }\n\n flipped.y = flipped.y === 1 ? -1 : 1;\n cropper.scaleY(flipped.y);\n }}\n >\n FlipY\n </ButtonDefault>\n </div>\n );\n};\n\nconst tool: ImageEditorTool = {\n name: \"flip\",\n icon({ activateTool }) {\n return (\n <Tooltip placement={\"bottom\"} content={\"Flip\"}>\n <IconButton\n icon={<FlipIcon />}\n onClick={() => activateTool(\"flip\")}\n data-testid={\"flip-item\"}\n />\n </Tooltip>\n );\n },\n renderForm,\n cancel: () => cropper && cropper.destroy(),\n onActivate: ({ canvas }) => {\n cropper = new Cropper(canvas.current as HTMLCanvasElement, {\n background: false,\n modal: false,\n guides: false,\n dragMode: \"none\",\n highlight: false,\n autoCrop: false\n });\n },\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 });\n }\n};\n\nexport default tool;\n"],"mappings":";;;;;;;AAAA;AAEA;AACA;AACA;AAEA;AACA;AAEA,IAAIA,OAAgB;AAEpB,IAAMC,OAAO,GAAG;EAAEC,CAAC,EAAE,CAAC;EAAEC,CAAC,EAAE;AAAE,CAAC;AAE9B,IAAMC,UAAU,GAAG,SAAbA,UAAU,GAAS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K;MACZC,MAAM,EAAE,KAAK;MACbC,QAAQ,EAAE,MAAM;MAChBC,SAAS,EAAE,KAAK;MAChBC,QAAQ,EAAE;IACd,CAAC,CAAC;EACN,CAAC;EACDC,KAAK,EAAE,sBAAgB;IAAA,IAAbT,MAAM,SAANA,MAAM;IACZ,OAAO,IAAIU,OAAO,CAAC,UAACC,OAAY,EAAK;MACjC,IAAI,CAAC1B,OAAO,EAAE;QACV0B,OAAO,EAAE;QACT;MACJ;MAEA,IAAMT,OAAO,GAAGF,MAAM,CAACE,OAAO;MAC9B,IAAMU,GAAG,GAAG3B,OAAO,CAAC4B,gBAAgB,EAAE,CAACC,SAAS,EAAE;MAClD,IAAIZ,OAAO,EAAE;QACT,IAAMa,KAAK,GAAG,IAAIC,MAAM,CAACC,KAAK,EAAE;QAChC,IAAMC,GAAG,GAAGhB,OAAO,CAACiB,UAAU,CAAC,IAAI,CAA6B;QAChEJ,KAAK,CAACK,MAAM,GAAG,YAAM;UACjBF,GAAG,CAACG,SAAS,CAACN,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;UAC1Bb,OAAO,CAACoB,KAAK,GAAGP,KAAK,CAACO,KAAK;UAC3BpB,OAAO,CAACqB,MAAM,GAAGR,KAAK,CAACQ,MAAM;UAE7BL,GAAG,CAACG,SAAS,CAACN,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;UAC1BJ,OAAO,EAAE;QACb,CAAC;QACDI,KAAK,CAACH,GAAG,GAAGA,GAAG;MACnB;MAEA3B,OAAO,CAACa,OAAO,EAAE;IACrB,CAAC,CAAC;EACN;AACJ,CAAC;AAAC,eAEaL,IAAI;AAAA"}
|
|
@@ -51,19 +51,11 @@ Object.defineProperty(exports, "UndoIcon", {
|
|
|
51
51
|
return _undo.ReactComponent;
|
|
52
52
|
}
|
|
53
53
|
});
|
|
54
|
-
|
|
55
54
|
var _crop = require("./crop.svg");
|
|
56
|
-
|
|
57
55
|
var _draw = require("./draw.svg");
|
|
58
|
-
|
|
59
56
|
var _filter = require("./filter.svg");
|
|
60
|
-
|
|
61
57
|
var _flip = require("./flip.svg");
|
|
62
|
-
|
|
63
58
|
var _redo = require("./redo.svg");
|
|
64
|
-
|
|
65
59
|
var _rotateLeft = require("./rotateLeft.svg");
|
|
66
|
-
|
|
67
60
|
var _rotateRight = require("./rotateRight.svg");
|
|
68
|
-
|
|
69
61
|
var _undo = require("./undo.svg");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { ReactComponent as CropIcon } from \"./crop.svg\";\nexport { ReactComponent as DrawIcon } from \"./draw.svg\";\nexport { ReactComponent as FilterIcon } from \"./filter.svg\";\nexport { ReactComponent as FlipIcon } from \"./flip.svg\";\nexport { ReactComponent as RedoIcon } from \"./redo.svg\";\nexport { ReactComponent as RotateLeftIcon } from \"./rotateLeft.svg\";\nexport { ReactComponent as RotateRightIcon } from \"./rotateRight.svg\";\nexport { ReactComponent as UndoIcon } from \"./undo.svg\";\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { ReactComponent as CropIcon } from \"./crop.svg\";\nexport { ReactComponent as DrawIcon } from \"./draw.svg\";\nexport { ReactComponent as FilterIcon } from \"./filter.svg\";\nexport { ReactComponent as FlipIcon } from \"./flip.svg\";\nexport { ReactComponent as RedoIcon } from \"./redo.svg\";\nexport { ReactComponent as RotateLeftIcon } from \"./rotateLeft.svg\";\nexport { ReactComponent as RotateRightIcon } from \"./rotateRight.svg\";\nexport { ReactComponent as UndoIcon } from \"./undo.svg\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
@@ -29,11 +28,7 @@ Object.defineProperty(exports, "rotate", {
|
|
|
29
28
|
return _rotate.default;
|
|
30
29
|
}
|
|
31
30
|
});
|
|
32
|
-
|
|
33
31
|
var _crop = _interopRequireDefault(require("./crop"));
|
|
34
|
-
|
|
35
32
|
var _flip = _interopRequireDefault(require("./flip"));
|
|
36
|
-
|
|
37
33
|
var _filter = _interopRequireDefault(require("./filter"));
|
|
38
|
-
|
|
39
34
|
var _rotate = _interopRequireDefault(require("./rotate"));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { default as crop } from \"./crop\";\nexport { default as flip } from \"./flip\";\nexport { default as filter } from \"./filter\";\nexport { default as rotate } from \"./rotate\";\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { default as crop } from \"./crop\";\nexport { default as flip } from \"./flip\";\nexport { default as filter } from \"./filter\";\nexport { default as rotate } from \"./rotate\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA"}
|