@codeleap/web 3.24.3 → 3.25.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codeleap/web",
3
- "version": "3.24.3",
3
+ "version": "3.25.2",
4
4
  "main": "src/index.ts",
5
5
  "repository": {
6
6
  "url": "https://github.com/codeleap-uk/internal-libs-monorepo.git",
@@ -7,6 +7,8 @@ import { ModalProps } from '../Modal'
7
7
  import { useCropPicker } from './useCropPicker'
8
8
  import { ButtonProps } from '../Button'
9
9
 
10
+ export type CropImageType = 'png' | 'jpeg' | 'webp'
11
+
10
12
  export type BaseCropProps = Partial<ReactCropProps>
11
13
 
12
14
  export type CropPickerProps = Partial<FileInputProps> &
@@ -7,7 +7,7 @@ import {
7
7
  useRef,
8
8
  useState,
9
9
  } from '@codeleap/common'
10
- import { ImageReading, UseCropPickerProps } from './types'
10
+ import { CropImageType, ImageReading, UseCropPickerProps } from './types'
11
11
  import { Crop } from 'react-image-crop'
12
12
  import { cropImage, readImage } from './utils'
13
13
  import { FileInputRef } from '../FileInput'
@@ -40,9 +40,9 @@ export function useCropPicker({
40
40
  setTimeout(() => setImage(null), 500)
41
41
  }
42
42
 
43
- const onConfirmCrop = async () => {
43
+ const onConfirmCrop = async (imageType: CropImageType = 'jpeg') => {
44
44
  setIsLoading(true)
45
- const [preview, croppedFile] = await cropImage(image, relativeCrop)
45
+ const [preview, croppedFile] = await cropImage(image, relativeCrop, imageType)
46
46
  onResolved([
47
47
  {
48
48
  file: new File([croppedFile], 'cropped.jpg'),
@@ -1,5 +1,5 @@
1
1
  import { Crop } from 'react-image-crop'
2
- import { ImageReading } from './types'
2
+ import { CropImageType, ImageReading } from './types'
3
3
 
4
4
  export function readImage(file: File | Blob): Promise<ImageReading> {
5
5
  const reader = new FileReader()
@@ -13,7 +13,7 @@ export function readImage(file: File | Blob): Promise<ImageReading> {
13
13
  })
14
14
  }
15
15
 
16
- export function cropImage(image: ImageReading, crop: Crop): Promise<[string, Blob]> {
16
+ export function cropImage(image: ImageReading, crop: Crop, type: CropImageType): Promise<[string, Blob]> {
17
17
  const canvas = document.createElement('canvas')
18
18
  const ctx = canvas.getContext('2d', { alpha: true })
19
19
 
@@ -46,6 +46,6 @@ export function cropImage(image: ImageReading, crop: Crop): Promise<[string, Blo
46
46
  readImage(blob).then(cropped => {
47
47
  resolve([cropped.src, blob])
48
48
  }).catch(reject)
49
- }, 'image/png')
49
+ }, `image/${type}`)
50
50
  })
51
51
  }
@@ -20,7 +20,8 @@ export * from './types'
20
20
  const DefaultOption = (props: TCustomOption & { component: (props: TCustomOption) => JSX.Element }) => {
21
21
  const { isSelected, optionsStyles, label, selectedIcon, component = null, itemProps = {} as TCustomOption['itemProps'], isFocused, debugName } = props
22
22
 
23
- const styles = optionsStyles({ isSelected, isFocused, baseStyles: (itemProps?.styles ?? {}) })
23
+ // @ts-ignore
24
+ const styles = optionsStyles({ isSelected, isFocused, baseStyles: (props?.data?.itemProps?.style ?? itemProps?.style ?? {}) })
24
25
 
25
26
  let _Component = null
26
27
 
@@ -33,6 +34,7 @@ const DefaultOption = (props: TCustomOption & { component: (props: TCustomOption
33
34
  debugName={debugName}
34
35
  {...itemProps}
35
36
  styles={styles}
37
+ {...props?.data?.itemProps}
36
38
  />
37
39
  )
38
40
  } else {
@@ -1,11 +1,11 @@
1
- import { ComponentVariants, FormTypes, StylesOf, yup } from '@codeleap/common'
1
+ import { ComponentVariants, FormTypes, PropsOf, StylesOf, yup } from '@codeleap/common'
2
2
  import { CSSInterpolation } from '@emotion/css'
3
3
  import { CSSObject } from '@emotion/react'
4
4
  import { MutableRefObject } from 'react'
5
5
  import { GroupBase, NoticeProps, OptionProps, Props } from 'react-select'
6
6
  import { AsyncProps } from 'react-select/async'
7
7
  import { ComponentCommonProps } from '../../types'
8
- import { ButtonProps } from '../Button'
8
+ import { Button, ButtonProps } from '../Button'
9
9
  import { InputBaseProps } from '../InputBase'
10
10
  import { SelectPresets, SelectComposition, OptionState } from './styles'
11
11
 
@@ -27,7 +27,7 @@ type DynamicSelectProps<T, Multi extends boolean> =
27
27
  >)
28
28
 
29
29
  export type ReactSelectProps<T, Multi extends boolean = false> = Omit<InputBaseProps, 'styles' | 'variants'> &{
30
- options: FormTypes.Options<T>
30
+ options: FormTypes.Options<T> & { itemProps?: PropsOf<typeof Button> }
31
31
  value: SelectValue<T, Multi>
32
32
  onValueChange?: (value: SelectValue<T, Multi>) => void
33
33
  multiple?: Multi
@@ -47,6 +47,7 @@ export type TCustomOption = OptionProps & ComponentPartProps & ComponentCommonPr
47
47
  selectedIcon?: string
48
48
  itemProps?: ButtonProps
49
49
  styles?: OptionState['baseStyles']
50
+ data: OptionProps['data'] & { itemProps?: PropsOf<typeof Button>}
50
51
  }
51
52
 
52
53
  type SelectPlaceholderElement = string | ((props: PlaceholderProps) => JSX.Element) | JSX.Element