@putkoff/abstract-utilities 0.1.142 → 0.1.145
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/cjs/functions/string_utils/src/string_utils.d.ts +0 -8
- package/dist/cjs/index.js +6 -13
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/utils/src/Input.d.ts +6 -6
- package/dist/esm/functions/string_utils/src/string_utils.d.ts +0 -8
- package/dist/esm/index.js +6 -13
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utils/src/Input.d.ts +6 -6
- package/dist/functions/string_utils/src/string_utils.d.ts +0 -8
- package/dist/index.d.ts +0 -8
- package/dist/utils/src/Input.d.ts +6 -6
- package/package.json +1 -1
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
export interface InputProps {
|
|
2
|
-
label?:
|
|
3
|
-
type?:
|
|
3
|
+
label?: React.ReactNode;
|
|
4
|
+
type?: string;
|
|
4
5
|
value?: any;
|
|
5
|
-
onValueChange?: any;
|
|
6
|
-
disabled?:
|
|
7
|
-
placeholder?:
|
|
6
|
+
onValueChange?: (value: any) => void;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
placeholder?: string;
|
|
8
9
|
error?: string;
|
|
9
10
|
}
|
|
10
11
|
export interface FileInputExtra {
|
|
@@ -12,6 +13,5 @@ export interface FileInputExtra {
|
|
|
12
13
|
multiple?: boolean;
|
|
13
14
|
accept?: string;
|
|
14
15
|
}
|
|
15
|
-
/** keep other InputProps fields … */
|
|
16
16
|
export type EnhancedInputProps = InputProps & FileInputExtra;
|
|
17
17
|
export declare const Input: React.FC<EnhancedInputProps>;
|
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
export declare function getSubstring(obj: string, maxLength?: number | null, minLength?: number | null): string;
|
|
2
2
|
export declare function truncateString(obj: string, maxLength?: number): string;
|
|
3
|
-
/**
|
|
4
|
-
* Remove *every* occurrence of any prefix in `bases` from the *beginning*
|
|
5
|
-
* of `str`, looping until no prefix matches.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* stripPrefixes('/site/site/docs', ['/site', '/static']);
|
|
9
|
-
* // → '/docs'
|
|
10
|
-
*/
|
|
11
3
|
export declare function stripPrefixes(str: string, bases?: string | string[]): string;
|
|
12
4
|
/**
|
|
13
5
|
* Removes characters from the beginning of the string
|
package/dist/esm/index.js
CHANGED
|
@@ -718,28 +718,21 @@ function truncateString(obj, maxLength = 20) {
|
|
|
718
718
|
}
|
|
719
719
|
return obj;
|
|
720
720
|
}
|
|
721
|
-
|
|
722
|
-
* Remove *every* occurrence of any prefix in `bases` from the *beginning*
|
|
723
|
-
* of `str`, looping until no prefix matches.
|
|
724
|
-
*
|
|
725
|
-
* @example
|
|
726
|
-
* stripPrefixes('/site/site/docs', ['/site', '/static']);
|
|
727
|
-
* // → '/docs'
|
|
728
|
-
*/
|
|
721
|
+
// string_utils/src/string_utils.ts
|
|
729
722
|
function stripPrefixes(str, bases = []) {
|
|
730
|
-
|
|
723
|
+
/* NEW: coerce whatever arrives into a string */
|
|
724
|
+
str = String(str);
|
|
731
725
|
const prefixes = (Array.isArray(bases) ? bases : [bases])
|
|
732
726
|
.filter(Boolean)
|
|
733
|
-
|
|
734
|
-
.sort((a, b) => b.length - a.length);
|
|
727
|
+
.sort((a, b) => b.length - a.length); // longest first
|
|
735
728
|
let changed = true;
|
|
736
729
|
while (changed) {
|
|
737
730
|
changed = false;
|
|
738
731
|
for (const prefix of prefixes) {
|
|
739
732
|
if (str.startsWith(prefix)) {
|
|
740
733
|
str = str.slice(prefix.length);
|
|
741
|
-
changed = true;
|
|
742
|
-
break; // restart
|
|
734
|
+
changed = true;
|
|
735
|
+
break; // restart from longest prefix
|
|
743
736
|
}
|
|
744
737
|
}
|
|
745
738
|
}
|