@codeleap/web 3.21.7 → 3.21.9

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.21.7",
3
+ "version": "3.21.9",
4
4
  "main": "src/index.ts",
5
5
  "repository": {
6
6
  "url": "https://github.com/codeleap-uk/internal-libs-monorepo.git",
@@ -225,17 +225,19 @@ export const Select = forwardRef<HTMLInputElement, SelectProps>(
225
225
  selectedOption: _selectedOption,
226
226
  setSelectedOption: _setSelectedOption,
227
227
  loadingMessage,
228
+ selectRef = null,
228
229
  ...otherProps
229
230
  } = selectProps
230
231
 
231
- const innerInputRef = useRef<any>(null)
232
+ const _innerInputRef = useRef<any>(null)
233
+ const innerInputRef = selectRef || _innerInputRef
232
234
  const innerWrapperRef = useRef(null)
233
235
 
234
236
  const hasSelectedOptionState = !TypeGuards.isNil(_selectedOption) && TypeGuards.isFunction(_setSelectedOption)
235
237
 
236
- const initialValue = (loadInitialValue && !TypeGuards.isNil(options))
237
- ? options?.find((option) => option?.value === value)
238
- : value
238
+ const initialValue = (loadInitialValue && !TypeGuards.isNil(options))
239
+ ? options?.find((option) => option?.value === value)
240
+ : value
239
241
 
240
242
  const [selectedOption, setSelectedOption] = hasSelectedOptionState ? [_selectedOption, _setSelectedOption] : useState(initialValue ?? value)
241
243
 
@@ -117,6 +117,10 @@ export const TextInputComponent = forwardRef<InputRef, TextInputProps>((props, i
117
117
  useImperativeHandle(inputRef, () => {
118
118
  return {
119
119
  focus: () => {
120
+ if (isMasked) {
121
+ innerInputRef.current?.getInputDOMNode()?.focus()
122
+ }
123
+
120
124
  innerInputRef.current?.focus?.()
121
125
  },
122
126
  isTextInput: true,
@@ -221,7 +225,9 @@ export const TextInputComponent = forwardRef<InputRef, TextInputProps>((props, i
221
225
  innerWrapperProps={{
222
226
  ...(inputBaseProps.innerWrapperProps || {}),
223
227
  [inputBaseAction]: () => {
224
- // if (isMasked) innerInputRef.current?.onFocus?.()
228
+ if (isMasked) {
229
+ innerInputRef.current?.getInputDOMNode()?.focus()
230
+ }
225
231
  innerInputRef.current?.focus?.()
226
232
  if (isPressable) onPress?.()
227
233
  },
@@ -1,9 +1,14 @@
1
1
  import { AnyFunction, useIsomorphicEffect, useUnmount } from '@codeleap/common'
2
2
 
3
3
  export const usePopState = (dependence: boolean, handler: AnyFunction) => {
4
+
4
5
  useIsomorphicEffect(() => {
5
6
  if (dependence) {
6
- window.history.pushState(null, null, window.location.pathname)
7
+ const pathname = location.pathname
8
+ const searchParams = location.search
9
+ const newUrl = pathname + searchParams
10
+
11
+ window.history.pushState(null, null, newUrl)
7
12
  window.addEventListener('popstate', handler)
8
13
  } else {
9
14
  window.removeEventListener('popstate', handler)