@codeleap/web 3.25.3 → 3.25.5

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.25.3",
3
+ "version": "3.25.5",
4
4
  "main": "src/index.ts",
5
5
  "repository": {
6
6
  "url": "https://github.com/codeleap-uk/internal-libs-monorepo.git",
@@ -1,5 +1,5 @@
1
1
  import React from 'react'
2
- import { StylesOf, TypeGuards } from '@codeleap/common'
2
+ import { StylesOf, TypeGuards, PropsOf } from '@codeleap/common'
3
3
  import { ListComposition, ListParts } from './styles'
4
4
  import { ListProps } from './types'
5
5
  import { View } from '../View'
@@ -11,6 +11,7 @@ export type ListLayoutProps = Omit<ListProps, 'renderItem'> & UseInfiniteScrollR
11
11
  variantStyles: StylesOf<ListComposition>
12
12
  children?: React.ReactNode
13
13
  showFooter?: boolean
14
+ wrapperProps?: Partial<PropsOf<typeof View>>
14
15
  }
15
16
 
16
17
  type ListRefreshControlComponent = Partial<ListLayoutProps> & {
@@ -67,6 +68,7 @@ export const ListLayout = (props: ListLayoutProps) => {
67
68
  ListLoadingIndicatorComponent,
68
69
  scrollableRef,
69
70
  showFooter = true,
71
+ wrapperProps = {},
70
72
  } = props
71
73
 
72
74
  const getKeyStyle = React.useCallback((key: ListParts) => ([
@@ -77,7 +79,7 @@ export const ListLayout = (props: ListLayoutProps) => {
77
79
 
78
80
  return (
79
81
  // @ts-ignore
80
- <View css={[getKeyStyle('wrapper'), style]} ref={scrollableRef}>
82
+ <View css={[getKeyStyle('wrapper'), style]} ref={scrollableRef} {...wrapperProps}>
81
83
  {!!ListHeaderComponent ? <ListHeaderComponent /> : null}
82
84
 
83
85
  {isEmpty ? <ListEmptyComponent debugName={debugName} {...placeholder} /> : null}
@@ -56,6 +56,7 @@ export function List<T = any>(props: ListProps<T>) {
56
56
  masonryProps = {},
57
57
  reloadTimeout,
58
58
  showFooter,
59
+ layoutWrapperProps = {},
59
60
  } = allProps
60
61
 
61
62
  const variantStyles = useDefaultComponentStyle<'u:List', typeof ListPresets>('u:List', {
@@ -102,6 +103,7 @@ export function List<T = any>(props: ListProps<T>) {
102
103
  <ListLayout
103
104
  {...allProps}
104
105
  {...layoutProps}
106
+ wrapperProps={layoutWrapperProps}
105
107
  variantStyles={variantStyles}
106
108
  showFooter={reloadingLayout ? false : showFooter}
107
109
  >
@@ -54,4 +54,5 @@ Data = T extends Array<infer D> ? D : never
54
54
  masonryProps?: Partial<ListMasonryProps<T>>
55
55
  reloadTimeout?: number
56
56
  showFooter?: boolean
57
+ layoutWrapperProps?: Partial<PropsOf<typeof View>>
57
58
  } & ComponentCommonProps & UseInfiniteScrollArgs
@@ -233,7 +233,7 @@ export const Select = forwardRef<HTMLInputElement, SelectProps>(
233
233
 
234
234
  const _innerInputRef = useRef<any>(null)
235
235
  const innerInputRef = selectRef || _innerInputRef
236
- const innerWrapperRef = useRef(null)
236
+ const innerWrapperRef = useRef<HTMLDivElement>(null)
237
237
 
238
238
  const hasSelectedOptionState = !TypeGuards.isNil(_selectedOption) && TypeGuards.isFunction(_setSelectedOption)
239
239
 
@@ -275,6 +275,7 @@ export const Select = forwardRef<HTMLInputElement, SelectProps>(
275
275
  error: !!hasError,
276
276
  focused: isFocused,
277
277
  disabled: isDisabled,
278
+ parentWidth: innerWrapperRef?.current?.clientWidth,
278
279
  })
279
280
 
280
281
  useImperativeHandle(inputRef, () => {
@@ -420,8 +421,7 @@ export const Select = forwardRef<HTMLInputElement, SelectProps>(
420
421
  tabSelectsValue={false}
421
422
  tabIndex={0}
422
423
  backspaceRemovesValue={true}
423
- // escapeRemoves={true}
424
- // deleteRemoves={true}
424
+ menuPortalTarget={document.body}
425
425
  {...otherProps}
426
426
  {..._props}
427
427
  onKeyDown={isFocused ? handleKeyDown : null}
@@ -436,7 +436,6 @@ export const Select = forwardRef<HTMLInputElement, SelectProps>(
436
436
  defaultOptions={loadOptionsOnMount}
437
437
  ref={innerInputRef}
438
438
  closeMenuOnSelect={closeOnSelect}
439
- menuPortalTarget={innerWrapperRef.current}
440
439
  placeholder={(loadOptionsOnMount && !loadedOptions) ? loadingMessage : placeholder}
441
440
  isDisabled={isDisabled}
442
441
  isClearable={clearable}
@@ -51,6 +51,7 @@ export type ComponentState = {
51
51
  error?: boolean
52
52
  focused?: boolean
53
53
  disabled?: boolean
54
+ parentWidth?: number
54
55
  }
55
56
 
56
57
  export type OptionState = {
@@ -70,6 +71,7 @@ export function useSelectStyles<T, Multi extends boolean>(props: SelectProps<T,
70
71
  error,
71
72
  focused,
72
73
  disabled,
74
+ parentWidth,
73
75
  } = state
74
76
 
75
77
  const variantStyles = useDefaultComponentStyle<'u:Select', typeof SelectPresets>(
@@ -138,10 +140,18 @@ export function useSelectStyles<T, Multi extends boolean>(props: SelectProps<T,
138
140
  wrapper: stylesKey('itemsWrapper'),
139
141
  }
140
142
 
143
+ const parseMenuPortalStyles = (baseStyles: CSSObjectWithLabel) => {
144
+ return {
145
+ ...baseStyles,
146
+ width: parentWidth,
147
+ left: `calc(${baseStyles.left}px - ((${parentWidth}px - ${baseStyles.width}px) / 2))`
148
+ }
149
+ }
150
+
141
151
  const reactSelectStyles: StylesConfig<FormTypes.Option<T>, Multi, GroupBase<FormTypes.Option<T>>> = {
142
152
  container: (baseStyles) => stylesKey('inputContainer', baseStyles),
143
153
  control: () => stylesKey('inputContainer'),
144
- menuPortal: (baseStyles) => stylesKey('listPortal', baseStyles),
154
+ menuPortal: (baseStyles) => stylesKey('listPortal', parseMenuPortalStyles(baseStyles)),
145
155
  menu: (baseStyles) => stylesKey('listWrapper', baseStyles),
146
156
  menuList: (baseStyles) => stylesKey('list', baseStyles),
147
157
  group: () => ({}),
@@ -22,6 +22,11 @@ export type ElementMap = {
22
22
  'section': WithChildren<JSX.IntrinsicElements['section']>
23
23
  'header': WithChildren<JSX.IntrinsicElements['header']>
24
24
  'footer': WithChildren<JSX.IntrinsicElements['footer']>
25
+ 'nav': WithChildren<JSX.IntrinsicElements['nav']>
26
+ 'article': WithChildren<JSX.IntrinsicElements['article']>
27
+ 'ul': WithChildren<JSX.IntrinsicElements['ul']>
28
+ 'ol': WithChildren<JSX.IntrinsicElements['ol']>
29
+ 'aside': WithChildren<JSX.IntrinsicElements['aside']>
25
30
  }
26
31
 
27
32
  export type NativeHTMLElement = keyof ElementMap