@codeleap/web 3.22.1 → 3.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codeleap/web",
3
- "version": "3.22.1",
3
+ "version": "3.23.0",
4
4
  "main": "src/index.ts",
5
5
  "repository": {
6
6
  "url": "https://github.com/codeleap-uk/internal-libs-monorepo.git",
@@ -177,7 +177,7 @@ const DropzoneComponent = (props: DropzoneProps, ref: React.ForwardedRef<Dropzon
177
177
  open,
178
178
  }))
179
179
 
180
- const hasFiles = acceptedFiles.length > 0 || rejectedFiles.length > 0
180
+ const hasFiles = acceptedFiles?.length > 0 || rejectedFiles?.length > 0
181
181
 
182
182
  const fileProps = {
183
183
  fileLeftIcon,
@@ -199,7 +199,7 @@ const DropzoneComponent = (props: DropzoneProps, ref: React.ForwardedRef<Dropzon
199
199
 
200
200
  {hasFiles && (
201
201
  <View css={variantStyles.filesWrapper}>
202
- {acceptedFiles.map((file, index) => (
202
+ {acceptedFiles?.map?.((file, index) => (
203
203
  <FilePreview
204
204
  {...fileProps}
205
205
  index={index}
@@ -209,7 +209,7 @@ const DropzoneComponent = (props: DropzoneProps, ref: React.ForwardedRef<Dropzon
209
209
  FilePreviewComponent={FilePreviewComponent}
210
210
  />))}
211
211
 
212
- {rejectedFiles.map(({ file, errors }, index) => (
212
+ {rejectedFiles?.map?.(({ file, errors }, index) => (
213
213
  <FilePreview
214
214
  {...fileProps}
215
215
  index={index}
@@ -386,6 +386,10 @@ export const Modal = (props) => {
386
386
  setIndex(visible, modalId.current)
387
387
  }, visible ? 0 : 500)
388
388
  }
389
+
390
+ return () => {
391
+ if (scrollLock) modalScrollLock(false, modalId.current)
392
+ }
389
393
  }, [visible])
390
394
 
391
395
  const content = <ModalContent {...props} visible={visible} toggle={toggle} id={modalId.current} />
@@ -1,7 +1,7 @@
1
1
  /** @jsx jsx */
2
2
  import { jsx } from '@emotion/react'
3
3
  import React, { useRef, forwardRef, useImperativeHandle } from 'react'
4
- import { FormTypes, useValidate, useState, TypeGuards, onUpdate, IconPlaceholder } from '@codeleap/common'
4
+ import { FormTypes, useValidate, useState, TypeGuards, onUpdate, IconPlaceholder, useEffect } from '@codeleap/common'
5
5
  import _Select, { components, MenuListProps, MenuProps, MultiValueProps, NoticeProps } from 'react-select'
6
6
  import Async from 'react-select/async'
7
7
  import { useSelectStyles } from './styles'
@@ -241,6 +241,12 @@ export const Select = forwardRef<HTMLInputElement, SelectProps>(
241
241
 
242
242
  const [selectedOption, setSelectedOption] = hasSelectedOptionState ? [_selectedOption, _setSelectedOption] : useState(initialValue ?? value)
243
243
 
244
+ useEffect(() => {
245
+ if (loadInitialValue && !selectedOption && !!initialValue) {
246
+ setSelectedOption(initialValue)
247
+ }
248
+ }, [!!initialValue])
249
+
244
250
  const [_isFocused, setIsFocused] = useState(false)
245
251
  const [loadedOptions, setLoadedOptions] = useState(false)
246
252
  const [keyDownActive, setKeyDownActive] = useState(false)