@codeleap/web 5.4.4 → 5.5.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/dist/components/ActionIcon/types.d.ts +1 -1
- package/dist/components/Checkbox/index.js +14 -10
- package/dist/components/Checkbox/index.js.map +1 -1
- package/dist/components/Checkbox/types.d.ts +4 -2
- package/dist/components/DatePicker/components/DayContent.d.ts +11 -0
- package/dist/components/DatePicker/components/DayContent.js +43 -0
- package/dist/components/DatePicker/components/DayContent.js.map +1 -0
- package/dist/components/DatePicker/components/OuterInput.js +2 -2
- package/dist/components/DatePicker/components/OuterInput.js.map +1 -1
- package/dist/components/DatePicker/components/YearContent.d.ts +9 -0
- package/dist/components/DatePicker/components/YearContent.js +33 -0
- package/dist/components/DatePicker/components/YearContent.js.map +1 -0
- package/dist/components/DatePicker/components/index.d.ts +2 -0
- package/dist/components/DatePicker/components/index.js +2 -0
- package/dist/components/DatePicker/components/index.js.map +1 -1
- package/dist/components/DatePicker/index.js +10 -33
- package/dist/components/DatePicker/index.js.map +1 -1
- package/dist/components/DatePicker/types.d.ts +5 -6
- package/dist/components/InputBase/index.d.ts +2 -5
- package/dist/components/InputBase/index.js +19 -11
- package/dist/components/InputBase/index.js.map +1 -1
- package/dist/components/InputBase/types.d.ts +2 -1
- package/dist/components/InputBase/useInputBase.d.ts +60 -0
- package/dist/components/InputBase/useInputBase.js +55 -0
- package/dist/components/InputBase/useInputBase.js.map +1 -0
- package/dist/components/InputBase/useInputBasePartialStyles.d.ts +2 -0
- package/dist/components/InputBase/useInputBasePartialStyles.js +40 -0
- package/dist/components/InputBase/useInputBasePartialStyles.js.map +1 -0
- package/dist/components/Modal/index.d.ts +0 -3
- package/dist/components/Modal/index.js +35 -52
- package/dist/components/Modal/index.js.map +1 -1
- package/dist/components/Modal/types.d.ts +0 -4
- package/dist/components/NumberIncrement/index.js +18 -124
- package/dist/components/NumberIncrement/index.js.map +1 -1
- package/dist/components/NumberIncrement/types.d.ts +5 -6
- package/dist/components/NumberIncrement/useNumberIncrement.d.ts +60 -0
- package/dist/components/NumberIncrement/useNumberIncrement.js +115 -0
- package/dist/components/NumberIncrement/useNumberIncrement.js.map +1 -0
- package/dist/components/RadioInput/index.js +14 -14
- package/dist/components/RadioInput/index.js.map +1 -1
- package/dist/components/RadioInput/types.d.ts +9 -9
- package/dist/components/SearchInput/index.js +1 -1
- package/dist/components/SearchInput/index.js.map +1 -1
- package/dist/components/Select/index.js +5 -7
- package/dist/components/Select/index.js.map +1 -1
- package/dist/components/Select/styles.d.ts +2 -8
- package/dist/components/Select/styles.js.map +1 -1
- package/dist/components/Select/types.d.ts +10 -9
- package/dist/components/Slider/index.js +16 -46
- package/dist/components/Slider/index.js.map +1 -1
- package/dist/components/Slider/types.d.ts +4 -2
- package/dist/components/Switch/index.js +13 -11
- package/dist/components/Switch/index.js.map +1 -1
- package/dist/components/Switch/types.d.ts +4 -2
- package/dist/components/TextEditor/index.js +7 -14
- package/dist/components/TextEditor/index.js.map +1 -1
- package/dist/components/TextEditor/types.d.ts +2 -3
- package/dist/components/TextInput/index.js +31 -92
- package/dist/components/TextInput/index.js.map +1 -1
- package/dist/components/TextInput/types.d.ts +8 -7
- package/dist/components/TextInput/useTextInput.d.ts +90 -0
- package/dist/components/TextInput/useTextInput.js +74 -0
- package/dist/components/TextInput/useTextInput.js.map +1 -0
- package/dist/lib/tools/index.d.ts +0 -1
- package/dist/lib/tools/index.js +0 -1
- package/dist/lib/tools/index.js.map +1 -1
- package/dist/lib/tools/modal.d.ts +2 -2
- package/dist/lib/tools/modal.js +5 -4
- package/dist/lib/tools/modal.js.map +1 -1
- package/dist/types/utility.d.ts +1 -1
- package/package.json +17 -19
- package/package.json.bak +1 -3
- package/src/components/ActionIcon/types.ts +1 -1
- package/src/components/Checkbox/index.tsx +23 -9
- package/src/components/Checkbox/types.ts +4 -2
- package/src/components/DatePicker/components/DayContent.tsx +52 -0
- package/src/components/DatePicker/components/OuterInput.tsx +1 -2
- package/src/components/DatePicker/components/YearContent.tsx +39 -0
- package/src/components/DatePicker/components/index.tsx +2 -0
- package/src/components/DatePicker/index.tsx +33 -84
- package/src/components/DatePicker/types.ts +5 -6
- package/src/components/InputBase/index.tsx +9 -8
- package/src/components/InputBase/types.ts +2 -1
- package/src/components/InputBase/useInputBase.ts +56 -0
- package/src/components/InputBase/useInputBasePartialStyles.ts +37 -0
- package/src/components/Modal/index.tsx +64 -64
- package/src/components/Modal/types.ts +0 -4
- package/src/components/NumberIncrement/index.tsx +44 -141
- package/src/components/NumberIncrement/types.ts +5 -6
- package/src/components/NumberIncrement/useNumberIncrement.ts +149 -0
- package/src/components/RadioInput/index.tsx +32 -17
- package/src/components/RadioInput/types.ts +16 -15
- package/src/components/SearchInput/index.tsx +1 -1
- package/src/components/Select/index.tsx +6 -11
- package/src/components/Select/styles.ts +2 -2
- package/src/components/Select/types.ts +10 -9
- package/src/components/Slider/index.tsx +28 -52
- package/src/components/Slider/types.ts +4 -2
- package/src/components/Switch/index.tsx +19 -8
- package/src/components/Switch/types.ts +4 -2
- package/src/components/TextEditor/index.tsx +6 -14
- package/src/components/TextEditor/types.ts +2 -3
- package/src/components/TextInput/index.tsx +54 -103
- package/src/components/TextInput/types.ts +8 -7
- package/src/components/TextInput/useTextInput.ts +101 -0
- package/src/lib/tools/index.ts +0 -1
- package/src/lib/tools/modal.ts +3 -3
- package/src/types/utility.ts +1 -1
- package/dist/lib/tools/navigation/index.d.ts +0 -58
- package/dist/lib/tools/navigation/index.js +0 -235
- package/dist/lib/tools/navigation/index.js.map +0 -1
- package/dist/lib/tools/navigation/types.d.ts +0 -32
- package/dist/lib/tools/navigation/types.js +0 -3
- package/dist/lib/tools/navigation/types.js.map +0 -1
- package/src/lib/tools/navigation/index.tsx +0 -282
- package/src/lib/tools/navigation/types.ts +0 -53
|
@@ -1,32 +1,33 @@
|
|
|
1
|
-
import { FormTypes, yup } from '@codeleap/deprecated'
|
|
2
1
|
import { TouchableProps } from '../Touchable'
|
|
3
2
|
import { AppIcon, StyledProp } from '@codeleap/styles'
|
|
4
3
|
import { InputBaseProps } from '../InputBase'
|
|
5
4
|
import { HTMLProps } from '../../types'
|
|
6
5
|
import { TextInputComposition } from './styles'
|
|
6
|
+
import { Field } from '@codeleap/form'
|
|
7
|
+
import { AnyFunction } from '@codeleap/types'
|
|
7
8
|
|
|
8
9
|
type NativeTextInputProps = HTMLProps<'input'>
|
|
9
10
|
|
|
10
11
|
export type TextInputProps =
|
|
11
|
-
Omit<InputBaseProps, 'style'> &
|
|
12
|
+
Omit<InputBaseProps, 'style' | 'ref'> &
|
|
12
13
|
Omit<NativeTextInputProps, 'value' | 'crossOrigin' | 'ref' | 'style'> &
|
|
13
14
|
{
|
|
14
15
|
style?: StyledProp<TextInputComposition>
|
|
15
16
|
password?: boolean
|
|
16
|
-
validate?: FormTypes.ValidatorWithoutForm<string> | yup.Schema<string>
|
|
17
17
|
debugName?: string
|
|
18
18
|
visibilityToggle?: boolean
|
|
19
|
-
value?: NativeTextInputProps['value']
|
|
20
19
|
multiline?: boolean
|
|
21
20
|
onPress?: TouchableProps['onPress']
|
|
22
|
-
onChangeText?: (textValue: string) => void
|
|
23
21
|
caretColor?: string
|
|
24
22
|
focused?: boolean
|
|
25
|
-
|
|
23
|
+
forceError?: string
|
|
26
24
|
rows?: number
|
|
27
25
|
masking?: TextInputMaskingProps
|
|
28
26
|
visibleIcon?: AppIcon
|
|
29
27
|
hiddenIcon?: AppIcon
|
|
28
|
+
field?: Field<string, any, any>
|
|
29
|
+
value?: string
|
|
30
|
+
onValueChange?: (value: string) => void
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
export type InputRef = {
|
|
@@ -56,7 +57,7 @@ export type MaskProps = {
|
|
|
56
57
|
maskChar?: string
|
|
57
58
|
formatChars?: Record<string, FormatChar>
|
|
58
59
|
alwaysShowMask?: boolean
|
|
59
|
-
validator?:
|
|
60
|
+
validator?: AnyFunction
|
|
60
61
|
maskType?: 'BRL' | 'INTERNATIONAL'
|
|
61
62
|
getRawValue?: (value: any) => string
|
|
62
63
|
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import React, { useCallback, useState, useMemo } from 'react'
|
|
2
|
+
import { TextInputProps } from './types'
|
|
3
|
+
import { TypeGuards } from '@codeleap/types'
|
|
4
|
+
import { getMaskInputProps } from './mask'
|
|
5
|
+
import { useInputBase } from '../InputBase/useInputBase'
|
|
6
|
+
import { fields } from '@codeleap/form'
|
|
7
|
+
|
|
8
|
+
export function useTextInput(props: Partial<TextInputProps>) {
|
|
9
|
+
const {
|
|
10
|
+
onFocus,
|
|
11
|
+
onBlur,
|
|
12
|
+
field,
|
|
13
|
+
masking,
|
|
14
|
+
multiline: isMultiline,
|
|
15
|
+
forceError,
|
|
16
|
+
value,
|
|
17
|
+
onValueChange,
|
|
18
|
+
rows: providedRows,
|
|
19
|
+
} = props
|
|
20
|
+
|
|
21
|
+
const [isFocused, setIsFocused] = useState(false)
|
|
22
|
+
|
|
23
|
+
const [secureTextEntry, setSecureTextEntry] = useState(true)
|
|
24
|
+
|
|
25
|
+
const toggleSecureTextEntry = () => setSecureTextEntry(s => !s)
|
|
26
|
+
|
|
27
|
+
const isMasked = !TypeGuards.isNil(masking)
|
|
28
|
+
|
|
29
|
+
const maskProps = useMemo(() => {
|
|
30
|
+
return isMasked ? getMaskInputProps({ masking }) : null
|
|
31
|
+
}, [masking])
|
|
32
|
+
|
|
33
|
+
const {
|
|
34
|
+
fieldHandle,
|
|
35
|
+
validation,
|
|
36
|
+
innerInputRef,
|
|
37
|
+
wrapperRef,
|
|
38
|
+
onInputValueChange,
|
|
39
|
+
inputValue,
|
|
40
|
+
} = useInputBase<string>(field, fields.text, { value, onValueChange }, {
|
|
41
|
+
revealValue() {
|
|
42
|
+
setSecureTextEntry(false)
|
|
43
|
+
},
|
|
44
|
+
hideValue() {
|
|
45
|
+
setSecureTextEntry(true)
|
|
46
|
+
},
|
|
47
|
+
toggleValueVisibility() {
|
|
48
|
+
toggleSecureTextEntry()
|
|
49
|
+
},
|
|
50
|
+
}, [setSecureTextEntry])
|
|
51
|
+
|
|
52
|
+
const handleBlur = useCallback((e: React.FocusEvent<HTMLInputElement, Element>) => {
|
|
53
|
+
validation?.onInputBlurred?.()
|
|
54
|
+
setIsFocused(false)
|
|
55
|
+
onBlur?.(e)
|
|
56
|
+
}, [validation?.onInputBlurred, onBlur])
|
|
57
|
+
|
|
58
|
+
const handleFocus = useCallback((e: React.FocusEvent<HTMLInputElement, Element>) => {
|
|
59
|
+
setIsFocused(true)
|
|
60
|
+
onFocus?.(e)
|
|
61
|
+
}, [onFocus])
|
|
62
|
+
|
|
63
|
+
const handleChange = useCallback((event: React.ChangeEvent<HTMLInputElement>) => {
|
|
64
|
+
const inputValue = event?.target?.value
|
|
65
|
+
|
|
66
|
+
const value = isMasked && maskProps?.notSaveFormatted
|
|
67
|
+
? maskProps?.getRawValue(inputValue)
|
|
68
|
+
: inputValue
|
|
69
|
+
|
|
70
|
+
onInputValueChange(value)
|
|
71
|
+
}, [onInputValueChange])
|
|
72
|
+
|
|
73
|
+
const rows = providedRows ?? (isMultiline ? 2 : undefined)
|
|
74
|
+
|
|
75
|
+
const hasMultipleLines = isMultiline && (String(inputValue)?.includes('\n') || !!rows)
|
|
76
|
+
|
|
77
|
+
const hasError = validation?.showError || forceError
|
|
78
|
+
|
|
79
|
+
const errorMessage = validation?.message || forceError
|
|
80
|
+
|
|
81
|
+
return {
|
|
82
|
+
maskProps,
|
|
83
|
+
isMultiline,
|
|
84
|
+
isMasked,
|
|
85
|
+
isFocused,
|
|
86
|
+
secureTextEntry,
|
|
87
|
+
handleBlur,
|
|
88
|
+
handleFocus,
|
|
89
|
+
handleChange,
|
|
90
|
+
fieldHandle,
|
|
91
|
+
validation,
|
|
92
|
+
innerInputRef,
|
|
93
|
+
wrapperRef,
|
|
94
|
+
errorMessage,
|
|
95
|
+
toggleSecureTextEntry,
|
|
96
|
+
hasMultipleLines,
|
|
97
|
+
hasError,
|
|
98
|
+
inputValue: inputValue || '',
|
|
99
|
+
onInputValueChange,
|
|
100
|
+
}
|
|
101
|
+
}
|
package/src/lib/tools/index.ts
CHANGED
package/src/lib/tools/modal.ts
CHANGED
|
@@ -3,10 +3,10 @@ import { globalState } from '@codeleap/store'
|
|
|
3
3
|
|
|
4
4
|
const overlapIndex = 99
|
|
5
5
|
|
|
6
|
-
export const modalsState = globalState({ currentModal: null, indexes: {} })
|
|
6
|
+
export const modalsState = globalState<{ currentModal: string | null; indexes: Record<string, number> }>({ currentModal: null, indexes: {} })
|
|
7
7
|
|
|
8
8
|
export function modalInferIndexes(visible: boolean, id: string) {
|
|
9
|
-
const indexes = { ...modalsState.value
|
|
9
|
+
const indexes = { ...modalsState.value?.indexes }
|
|
10
10
|
|
|
11
11
|
if (!visible) {
|
|
12
12
|
indexes[id] = overlapIndex
|
|
@@ -26,7 +26,7 @@ export function modalInferIndexes(visible: boolean, id: string) {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
export function modalScrollLock(to: boolean, modalIdentifier: string) {
|
|
29
|
-
let modalId = modalsState.value
|
|
29
|
+
let modalId = modalsState.value?.currentModal
|
|
30
30
|
|
|
31
31
|
const alreadyDifferentOpenedModal = !TypeGuards.isNil(modalId) && modalIdentifier !== modalId
|
|
32
32
|
|
package/src/types/utility.ts
CHANGED
|
@@ -36,7 +36,7 @@ export type HTMLProps<T extends NativeHTMLElement> = ElementMap[T]
|
|
|
36
36
|
export type ComponentWithDefaultProps<P> = ((props: P) => JSX.Element) & { defaultProps?: Partial<P> }
|
|
37
37
|
|
|
38
38
|
export type ComponentCommonProps = {
|
|
39
|
-
debugName
|
|
39
|
+
debugName?: string
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
export type SelectProperties<T extends Record<string | number | symbol, any>, K extends keyof T> = {
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { Config, History, Navigator, RouteParams, RoutePath, Routes } from './types';
|
|
2
|
-
export type { Navigator, Routes, };
|
|
3
|
-
export declare class Navigation<O extends object, R extends object = {}, C extends Record<string, any> = {}> {
|
|
4
|
-
private _history;
|
|
5
|
-
private config;
|
|
6
|
-
get history(): History;
|
|
7
|
-
context: C;
|
|
8
|
-
private putHistory;
|
|
9
|
-
private merge;
|
|
10
|
-
private navigator;
|
|
11
|
-
private routes;
|
|
12
|
-
constructor(routes: R, navigator: Navigator<O, C>, config?: Config);
|
|
13
|
-
/**
|
|
14
|
-
* Checks if the user is on a certain route based on the parameters passed
|
|
15
|
-
* @param route Route that will be used to direct
|
|
16
|
-
* @param routeParams Parameters that will be applied to the route
|
|
17
|
-
* @param exact Accurate path checking - default false
|
|
18
|
-
* @returns Is on the route - boolean
|
|
19
|
-
*/
|
|
20
|
-
isCurrentRoute<T extends keyof Routes<R>>(route: T, routeParams?: Record<Routes<R>[T], string | number>, exact?: boolean): boolean;
|
|
21
|
-
/**
|
|
22
|
-
* Get the path from the route
|
|
23
|
-
* @param route Route that will be used to direct
|
|
24
|
-
* @returns Path - string
|
|
25
|
-
*/
|
|
26
|
-
getPath(route: keyof Routes<R>): string;
|
|
27
|
-
/**
|
|
28
|
-
* Get the path from the route and route params
|
|
29
|
-
* @param route Route that will be used to direct
|
|
30
|
-
* @param routeParams Parameters that will be applied to the route
|
|
31
|
-
* @returns Path - string
|
|
32
|
-
*/
|
|
33
|
-
getPathWithParams<T extends keyof Routes<R>>(route: T, routeParams?: Record<Routes<R>[T], string | number>): string;
|
|
34
|
-
/**
|
|
35
|
-
* Function to navigate to the previous page, if history is enabled, the penultimate record will be used,
|
|
36
|
-
* otherwise the browser's own api with "history.back()"
|
|
37
|
-
*/
|
|
38
|
-
goBack(): void;
|
|
39
|
-
/**
|
|
40
|
-
* Main function to navigate between the app using the route system with dynamic parameters
|
|
41
|
-
* @param route Route that will be used to direct
|
|
42
|
-
* @param options Route parameters (marked by {{}}), which will be automatically shown if they exist, and navigator options and route queryParams can also be passed through the "params" property
|
|
43
|
-
*/
|
|
44
|
-
navigate<T extends keyof Routes<R>>(route: T, options?: Record<Routes<R>[T], string | number> & O & {
|
|
45
|
-
params?: RouteParams;
|
|
46
|
-
}): void;
|
|
47
|
-
/**
|
|
48
|
-
* Calls the navigator to direct the user to a page
|
|
49
|
-
* @param path Path to which the user will be taken
|
|
50
|
-
* @param options Options that will be passed to the navigator
|
|
51
|
-
* @param info Information that will be added to the history
|
|
52
|
-
*/
|
|
53
|
-
to(path: RoutePath, options?: O, info?: {}): void;
|
|
54
|
-
/**
|
|
55
|
-
* Clear history data
|
|
56
|
-
*/
|
|
57
|
-
wipeHistory(): void;
|
|
58
|
-
}
|
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Navigation = void 0;
|
|
7
|
-
var deepmerge_1 = __importDefault(require("@fastify/deepmerge"));
|
|
8
|
-
var IS_SSR = typeof window === 'undefined' || typeof history === 'undefined';
|
|
9
|
-
var defaultConfig = {
|
|
10
|
-
historyEnabled: false,
|
|
11
|
-
getMetadata: function () { },
|
|
12
|
-
};
|
|
13
|
-
var Navigation = /** @class */ (function () {
|
|
14
|
-
function Navigation(routes, navigator, config) {
|
|
15
|
-
if (config === void 0) { config = {}; }
|
|
16
|
-
this._history = {};
|
|
17
|
-
this.config = defaultConfig;
|
|
18
|
-
this.context = {};
|
|
19
|
-
this.navigator = null;
|
|
20
|
-
this.routes = {};
|
|
21
|
-
this.navigator = navigator;
|
|
22
|
-
this.routes = routes;
|
|
23
|
-
this.config = this.merge(this.config, config);
|
|
24
|
-
}
|
|
25
|
-
Object.defineProperty(Navigation.prototype, "history", {
|
|
26
|
-
get: function () {
|
|
27
|
-
return this._history;
|
|
28
|
-
},
|
|
29
|
-
enumerable: false,
|
|
30
|
-
configurable: true
|
|
31
|
-
});
|
|
32
|
-
Navigation.prototype.putHistory = function (path, info) {
|
|
33
|
-
var _a;
|
|
34
|
-
var _b, _c, _d;
|
|
35
|
-
if (info === void 0) { info = {}; }
|
|
36
|
-
var idx = Object.keys(this._history).length + 1;
|
|
37
|
-
var origin = IS_SSR ? null : (_b = window === null || window === void 0 ? void 0 : window.location) === null || _b === void 0 ? void 0 : _b.origin;
|
|
38
|
-
var value = (_a = {},
|
|
39
|
-
_a[idx] = {
|
|
40
|
-
origin: origin,
|
|
41
|
-
date: new Date(),
|
|
42
|
-
path: path,
|
|
43
|
-
metadata: (_d = (_c = this.config) === null || _c === void 0 ? void 0 : _c.getMetadata) === null || _d === void 0 ? void 0 : _d.call(_c),
|
|
44
|
-
info: info,
|
|
45
|
-
},
|
|
46
|
-
_a);
|
|
47
|
-
this._history = this.merge(this._history, value);
|
|
48
|
-
};
|
|
49
|
-
Navigation.prototype.merge = function (obj, addObj) {
|
|
50
|
-
return (0, deepmerge_1.default)({ all: true })(obj !== null && obj !== void 0 ? obj : {}, addObj !== null && addObj !== void 0 ? addObj : {});
|
|
51
|
-
};
|
|
52
|
-
/**
|
|
53
|
-
* Checks if the user is on a certain route based on the parameters passed
|
|
54
|
-
* @param route Route that will be used to direct
|
|
55
|
-
* @param routeParams Parameters that will be applied to the route
|
|
56
|
-
* @param exact Accurate path checking - default false
|
|
57
|
-
* @returns Is on the route - boolean
|
|
58
|
-
*/
|
|
59
|
-
Navigation.prototype.isCurrentRoute = function (route,
|
|
60
|
-
// @ts-expect-error
|
|
61
|
-
routeParams, exact) {
|
|
62
|
-
var _a;
|
|
63
|
-
if (routeParams === void 0) { routeParams = {}; }
|
|
64
|
-
if (exact === void 0) { exact = false; }
|
|
65
|
-
if (IS_SSR)
|
|
66
|
-
return false;
|
|
67
|
-
var path = (_a = window === null || window === void 0 ? void 0 : window.location) === null || _a === void 0 ? void 0 : _a.pathname;
|
|
68
|
-
// @ts-ignore
|
|
69
|
-
var routePath = this.getPathWithParams(route, routeParams);
|
|
70
|
-
var isRootPath = routePath === '/';
|
|
71
|
-
if (isRootPath) {
|
|
72
|
-
var _b = window.location || {}, pathname = _b.pathname, origin_1 = _b.origin, href = _b.href;
|
|
73
|
-
path = href === null || href === void 0 ? void 0 : href.replace(path, '');
|
|
74
|
-
path = path === null || path === void 0 ? void 0 : path.replace(origin_1, '');
|
|
75
|
-
return !path || pathname == routePath;
|
|
76
|
-
}
|
|
77
|
-
if (exact) {
|
|
78
|
-
return path === null || path === void 0 ? void 0 : path.endsWith(routePath);
|
|
79
|
-
}
|
|
80
|
-
if (path === null || path === void 0 ? void 0 : path.includes(routePath)) {
|
|
81
|
-
return true;
|
|
82
|
-
}
|
|
83
|
-
return false;
|
|
84
|
-
};
|
|
85
|
-
/**
|
|
86
|
-
* Get the path from the route
|
|
87
|
-
* @param route Route that will be used to direct
|
|
88
|
-
* @returns Path - string
|
|
89
|
-
*/
|
|
90
|
-
Navigation.prototype.getPath = function (route) {
|
|
91
|
-
var _a, _b;
|
|
92
|
-
var path = this.routes;
|
|
93
|
-
// @ts-ignore
|
|
94
|
-
if (route === null || route === void 0 ? void 0 : route.includes('.')) {
|
|
95
|
-
// @ts-ignore
|
|
96
|
-
var indexesAccess = route === null || route === void 0 ? void 0 : route.split('.');
|
|
97
|
-
for (var _i = 0, indexesAccess_1 = indexesAccess; _i < indexesAccess_1.length; _i++) {
|
|
98
|
-
var index = indexesAccess_1[_i];
|
|
99
|
-
path = path === null || path === void 0 ? void 0 : path[index];
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
else {
|
|
103
|
-
// @ts-ignore
|
|
104
|
-
path = path === null || path === void 0 ? void 0 : path[route];
|
|
105
|
-
}
|
|
106
|
-
return (_b = (_a = String(path)) === null || _a === void 0 ? void 0 : _a.trim) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
107
|
-
};
|
|
108
|
-
/**
|
|
109
|
-
* Get the path from the route and route params
|
|
110
|
-
* @param route Route that will be used to direct
|
|
111
|
-
* @param routeParams Parameters that will be applied to the route
|
|
112
|
-
* @returns Path - string
|
|
113
|
-
*/
|
|
114
|
-
Navigation.prototype.getPathWithParams = function (route,
|
|
115
|
-
// @ts-expect-error
|
|
116
|
-
routeParams) {
|
|
117
|
-
if (routeParams === void 0) { routeParams = {}; }
|
|
118
|
-
var path = this.getPath(route);
|
|
119
|
-
for (var key in routeParams) {
|
|
120
|
-
var value = String(routeParams === null || routeParams === void 0 ? void 0 : routeParams[key]);
|
|
121
|
-
var searchPartial = "{{".concat(key, "}}");
|
|
122
|
-
if (path === null || path === void 0 ? void 0 : path.includes(searchPartial)) {
|
|
123
|
-
path = path === null || path === void 0 ? void 0 : path.replace(searchPartial, encodeURIComponent(value));
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
if (!(path === null || path === void 0 ? void 0 : path.startsWith('/'))) {
|
|
127
|
-
path = '/' + path;
|
|
128
|
-
}
|
|
129
|
-
if (!(path === null || path === void 0 ? void 0 : path.endsWith('/'))) {
|
|
130
|
-
path = path + '/';
|
|
131
|
-
}
|
|
132
|
-
return path === null || path === void 0 ? void 0 : path.trim();
|
|
133
|
-
};
|
|
134
|
-
/**
|
|
135
|
-
* Function to navigate to the previous page, if history is enabled, the penultimate record will be used,
|
|
136
|
-
* otherwise the browser's own api with "history.back()"
|
|
137
|
-
*/
|
|
138
|
-
Navigation.prototype.goBack = function () {
|
|
139
|
-
var _a, _b, _c, _d;
|
|
140
|
-
if (IS_SSR)
|
|
141
|
-
return;
|
|
142
|
-
if (!this.config.historyEnabled) {
|
|
143
|
-
(_a = history === null || history === void 0 ? void 0 : history.back) === null || _a === void 0 ? void 0 : _a.call(history);
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
var lastIdx = (_b = Object.keys(this.history)) === null || _b === void 0 ? void 0 : _b.length;
|
|
147
|
-
var historyData = this.history[lastIdx - 1];
|
|
148
|
-
if (!historyData) {
|
|
149
|
-
throw new Error('Not find back route');
|
|
150
|
-
}
|
|
151
|
-
var info = this.merge(historyData === null || historyData === void 0 ? void 0 : historyData.info, {
|
|
152
|
-
'action': 'goBack',
|
|
153
|
-
});
|
|
154
|
-
this.to(historyData === null || historyData === void 0 ? void 0 : historyData.path, (_d = (_c = historyData === null || historyData === void 0 ? void 0 : historyData.info) === null || _c === void 0 ? void 0 : _c.options) !== null && _d !== void 0 ? _d : {}, info);
|
|
155
|
-
};
|
|
156
|
-
/**
|
|
157
|
-
* Main function to navigate between the app using the route system with dynamic parameters
|
|
158
|
-
* @param route Route that will be used to direct
|
|
159
|
-
* @param options Route parameters (marked by {{}}), which will be automatically shown if they exist, and navigator options and route queryParams can also be passed through the "params" property
|
|
160
|
-
*/
|
|
161
|
-
Navigation.prototype.navigate = function (route,
|
|
162
|
-
// @ts-expect-error
|
|
163
|
-
options) {
|
|
164
|
-
var _a, _b;
|
|
165
|
-
if (options === void 0) { options = {}; }
|
|
166
|
-
// @ts-ignore
|
|
167
|
-
var path = this.getPath(route);
|
|
168
|
-
var _options = {};
|
|
169
|
-
var params = null;
|
|
170
|
-
var routeParams = {};
|
|
171
|
-
var queryParamsKey = 'params';
|
|
172
|
-
for (var key in options) {
|
|
173
|
-
var value = options === null || options === void 0 ? void 0 : options[key];
|
|
174
|
-
var searchPartial = "{{".concat(key, "}}");
|
|
175
|
-
if (path === null || path === void 0 ? void 0 : path.includes(searchPartial)) {
|
|
176
|
-
path = path === null || path === void 0 ? void 0 : path.replace(searchPartial, encodeURIComponent(String(value)));
|
|
177
|
-
routeParams = this.merge(routeParams, (_a = {}, _a[key] = String(value), _a));
|
|
178
|
-
}
|
|
179
|
-
else if (key == queryParamsKey) {
|
|
180
|
-
params = value;
|
|
181
|
-
}
|
|
182
|
-
else {
|
|
183
|
-
_options = this.merge(_options, (_b = {}, _b[key] = value, _b));
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
if (!(path === null || path === void 0 ? void 0 : path.startsWith('/'))) {
|
|
187
|
-
path = '/' + path;
|
|
188
|
-
}
|
|
189
|
-
if (typeof params === 'object') {
|
|
190
|
-
var searchParams = null;
|
|
191
|
-
for (var paramKey in (params !== null && params !== void 0 ? params : {})) {
|
|
192
|
-
var value = params === null || params === void 0 ? void 0 : params[paramKey];
|
|
193
|
-
var param = "".concat(paramKey, "=").concat(encodeURIComponent(value));
|
|
194
|
-
var separator = searchParams == null ? '' : '&';
|
|
195
|
-
searchParams = "".concat(searchParams !== null && searchParams !== void 0 ? searchParams : '').concat(separator).concat(param);
|
|
196
|
-
}
|
|
197
|
-
if (typeof searchParams === 'string') {
|
|
198
|
-
if (path === null || path === void 0 ? void 0 : path.endsWith('/')) {
|
|
199
|
-
path = path.slice(0, -1);
|
|
200
|
-
}
|
|
201
|
-
path = "".concat(path, "?").concat(searchParams);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
if (!(path === null || path === void 0 ? void 0 : path.endsWith('/')) && !params) {
|
|
205
|
-
path = path + '/';
|
|
206
|
-
}
|
|
207
|
-
this.to(path === null || path === void 0 ? void 0 : path.trim(), _options, {
|
|
208
|
-
params: params,
|
|
209
|
-
routeParams: routeParams,
|
|
210
|
-
});
|
|
211
|
-
};
|
|
212
|
-
/**
|
|
213
|
-
* Calls the navigator to direct the user to a page
|
|
214
|
-
* @param path Path to which the user will be taken
|
|
215
|
-
* @param options Options that will be passed to the navigator
|
|
216
|
-
* @param info Information that will be added to the history
|
|
217
|
-
*/
|
|
218
|
-
Navigation.prototype.to = function (path, options, info) {
|
|
219
|
-
if (options === void 0) { options = null; }
|
|
220
|
-
if (info === void 0) { info = {}; }
|
|
221
|
-
if (this.config.historyEnabled) {
|
|
222
|
-
this.putHistory(path, this.merge(options, info));
|
|
223
|
-
}
|
|
224
|
-
this.navigator(path, options, this.context);
|
|
225
|
-
};
|
|
226
|
-
/**
|
|
227
|
-
* Clear history data
|
|
228
|
-
*/
|
|
229
|
-
Navigation.prototype.wipeHistory = function () {
|
|
230
|
-
this._history = {};
|
|
231
|
-
};
|
|
232
|
-
return Navigation;
|
|
233
|
-
}());
|
|
234
|
-
exports.Navigation = Navigation;
|
|
235
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/tools/navigation/index.tsx"],"names":[],"mappings":";;;;;;AACA,iEAA0C;AAE1C,IAAM,MAAM,GAAG,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,OAAO,KAAK,WAAW,CAAA;AAE9E,IAAM,aAAa,GAAoB;IACrC,cAAc,EAAE,KAAK;IACrB,WAAW,EAAE,cAAO,CAAC;CACtB,CAAA;AAOD;IAwCE,oBACE,MAAS,EACT,SAA0B,EAC1B,MAAmB;QAAnB,uBAAA,EAAA,WAAmB;QA1Cb,aAAQ,GAAY,EAAE,CAAA;QAEtB,WAAM,GAAW,aAAa,CAAA;QAM/B,YAAO,GAAM,EAAO,CAAA;QA2BnB,cAAS,GAAiB,IAAI,CAAA;QAE9B,WAAM,GAAM,EAAO,CAAA;QAOzB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;QAC1B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC/C,CAAC;IA3CD,sBAAI,+BAAO;aAAX;YACE,OAAO,IAAI,CAAC,QAAQ,CAAA;QACtB,CAAC;;;OAAA;IAIO,+BAAU,GAAlB,UAAmB,IAAe,EAAE,IAAc;;;QAAd,qBAAA,EAAA,SAAc;QAChD,IAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,GAAG,CAAC,CAAA;QAEjD,IAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,QAAQ,0CAAE,MAAM,CAAA;Q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AAI,CAAC,MAAM,EAAE;YACnC,IAAI,GAAG,IAAI,GAAG,GAAG,CAAA;SAClB;QAED,IAAI,CAAC,EAAE,CAAC,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,EAAE,EAAE,QAAa,EAAE;YACnC,MAAM,QAAA;YACN,WAAW,aAAA;SACZ,CAAC,CAAA;IACJ,CAAC;IAED;;;;;OAKG;IACI,uBAAE,GAAT,UAAU,IAAe,EAAE,OAAsB,EAAE,IAAS;QAAjC,wBAAA,EAAA,UAAa,IAAS;QAAE,qBAAA,EAAA,SAAS;QAC1D,IAAI,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE;YAC9B,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAA;SACjD;QAED,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,CAAA;IAC7C,CAAC;IAED;;OAEG;IACI,gCAAW,GAAlB;QACE,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAA;IACpB,CAAC;IACH,iBAAC;AAAD,CAAC,AA1QD,IA0QC;AA1QY,gCAAU"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
export type ExtractParams<T extends string> = T extends `${infer _Start}{{${infer Param}}}${infer Rest}` ? Param | ExtractParams<Rest> : never;
|
|
2
|
-
type Params<T> = {
|
|
3
|
-
[K in keyof T]: T[K] extends string ? ExtractParams<T[K]> : Params<T[K]>;
|
|
4
|
-
};
|
|
5
|
-
type ExtractRoutes<T, PM, Prefix extends string = ''> = {
|
|
6
|
-
[K in keyof T & string]: T[K] extends string ? {
|
|
7
|
-
[P in `${Prefix}${Prefix extends '' ? '' : '.'}${K}`]: PM[K];
|
|
8
|
-
} : ExtractRoutes<T[K], PM[K], `${Prefix}${Prefix extends '' ? '' : '.'}${K}`>;
|
|
9
|
-
}[keyof T];
|
|
10
|
-
type UnionToIntersection<U> = (U extends any ? (x: U) => void : never) extends ((x: infer I) => void) ? I : never;
|
|
11
|
-
export type Routes<T> = UnionToIntersection<ExtractRoutes<T, Params<T>>>;
|
|
12
|
-
export type RoutePath = string;
|
|
13
|
-
export type RouteParams = {
|
|
14
|
-
[x: string]: string;
|
|
15
|
-
};
|
|
16
|
-
export type Navigator<O extends object = {}, C extends Record<string, any> = {}> = (path: RoutePath, options: O, context?: C) => void;
|
|
17
|
-
export type AnyValue = {
|
|
18
|
-
[key: string]: any;
|
|
19
|
-
};
|
|
20
|
-
export type HistoryData = {
|
|
21
|
-
origin: string;
|
|
22
|
-
date: Date;
|
|
23
|
-
path: RoutePath;
|
|
24
|
-
metadata: any;
|
|
25
|
-
info: any;
|
|
26
|
-
};
|
|
27
|
-
export type History = Record<number, HistoryData>;
|
|
28
|
-
export type Config = {
|
|
29
|
-
historyEnabled?: boolean;
|
|
30
|
-
getMetadata?: () => any;
|
|
31
|
-
};
|
|
32
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/lib/tools/navigation/types.ts"],"names":[],"mappings":""}
|