@blueprintjs/icons 4.0.0-beta.5 → 4.0.0-beta.6
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/.eslintrc.json +4 -0
- package/lib/cjs/iconNames.js +0 -1
- package/lib/cjs/iconNames.js.map +1 -1
- package/lib/cjs/iconSvgPaths.d.ts +1 -1
- package/lib/cjs/type-utils/camel-case.d.ts +63 -0
- package/lib/cjs/type-utils/camel-case.js +3 -0
- package/lib/cjs/type-utils/camel-case.js.map +1 -0
- package/lib/cjs/type-utils/delimiter-case.d.ts +64 -0
- package/lib/cjs/type-utils/delimiter-case.js +3 -0
- package/lib/cjs/type-utils/delimiter-case.js.map +1 -0
- package/lib/cjs/type-utils/includes.d.ts +22 -0
- package/lib/cjs/type-utils/includes.js +3 -0
- package/lib/cjs/type-utils/includes.js.map +1 -0
- package/lib/cjs/type-utils/index.d.ts +3 -0
- package/lib/cjs/type-utils/index.js +18 -0
- package/lib/cjs/type-utils/index.js.map +1 -0
- package/lib/cjs/type-utils/pascal-case.d.ts +34 -0
- package/lib/cjs/type-utils/pascal-case.js +3 -0
- package/lib/cjs/type-utils/pascal-case.js.map +1 -0
- package/lib/cjs/type-utils/screaming-snake-case.d.ts +23 -0
- package/lib/cjs/type-utils/screaming-snake-case.js +3 -0
- package/lib/cjs/type-utils/screaming-snake-case.js.map +1 -0
- package/lib/cjs/type-utils/snake-case.d.ts +36 -0
- package/lib/cjs/type-utils/snake-case.js +3 -0
- package/lib/cjs/type-utils/snake-case.js.map +1 -0
- package/lib/cjs/type-utils/sourceUtilities.d.ts +3 -0
- package/lib/cjs/type-utils/sourceUtilities.js +3 -0
- package/lib/cjs/type-utils/sourceUtilities.js.map +1 -0
- package/lib/cjs/type-utils/utilities.d.ts +4 -0
- package/lib/cjs/type-utils/utilities.js +3 -0
- package/lib/cjs/type-utils/utilities.js.map +1 -0
- package/lib/esm/iconNames.js +0 -1
- package/lib/esm/iconNames.js.map +1 -1
- package/lib/esm/iconSvgPaths.d.ts +1 -1
- package/lib/esm/type-utils/camel-case.d.ts +63 -0
- package/lib/esm/type-utils/camel-case.js +2 -0
- package/lib/esm/type-utils/camel-case.js.map +1 -0
- package/lib/esm/type-utils/delimiter-case.d.ts +64 -0
- package/lib/esm/type-utils/delimiter-case.js +2 -0
- package/lib/esm/type-utils/delimiter-case.js.map +1 -0
- package/lib/esm/type-utils/includes.d.ts +22 -0
- package/lib/esm/type-utils/includes.js +2 -0
- package/lib/esm/type-utils/includes.js.map +1 -0
- package/lib/esm/type-utils/index.d.ts +3 -0
- package/lib/esm/type-utils/index.js +17 -0
- package/lib/esm/type-utils/index.js.map +1 -0
- package/lib/esm/type-utils/pascal-case.d.ts +34 -0
- package/lib/esm/type-utils/pascal-case.js +2 -0
- package/lib/esm/type-utils/pascal-case.js.map +1 -0
- package/lib/esm/type-utils/screaming-snake-case.d.ts +23 -0
- package/lib/esm/type-utils/screaming-snake-case.js +2 -0
- package/lib/esm/type-utils/screaming-snake-case.js.map +1 -0
- package/lib/esm/type-utils/snake-case.d.ts +36 -0
- package/lib/esm/type-utils/snake-case.js +2 -0
- package/lib/esm/type-utils/snake-case.js.map +1 -0
- package/lib/esm/type-utils/sourceUtilities.d.ts +3 -0
- package/lib/esm/type-utils/sourceUtilities.js +2 -0
- package/lib/esm/type-utils/sourceUtilities.js.map +1 -0
- package/lib/esm/type-utils/utilities.d.ts +4 -0
- package/lib/esm/type-utils/utilities.js +2 -0
- package/lib/esm/type-utils/utilities.js.map +1 -0
- package/lib/esnext/iconNames.js +0 -1
- package/lib/esnext/iconNames.js.map +1 -1
- package/lib/esnext/iconSvgPaths.d.ts +1 -1
- package/lib/esnext/type-utils/camel-case.d.ts +63 -0
- package/lib/esnext/type-utils/camel-case.js +2 -0
- package/lib/esnext/type-utils/camel-case.js.map +1 -0
- package/lib/esnext/type-utils/delimiter-case.d.ts +64 -0
- package/lib/esnext/type-utils/delimiter-case.js +2 -0
- package/lib/esnext/type-utils/delimiter-case.js.map +1 -0
- package/lib/esnext/type-utils/includes.d.ts +22 -0
- package/lib/esnext/type-utils/includes.js +2 -0
- package/lib/esnext/type-utils/includes.js.map +1 -0
- package/lib/esnext/type-utils/index.d.ts +3 -0
- package/lib/esnext/type-utils/index.js +17 -0
- package/lib/esnext/type-utils/index.js.map +1 -0
- package/lib/esnext/type-utils/pascal-case.d.ts +34 -0
- package/lib/esnext/type-utils/pascal-case.js +2 -0
- package/lib/esnext/type-utils/pascal-case.js.map +1 -0
- package/lib/esnext/type-utils/screaming-snake-case.d.ts +23 -0
- package/lib/esnext/type-utils/screaming-snake-case.js +2 -0
- package/lib/esnext/type-utils/screaming-snake-case.js.map +1 -0
- package/lib/esnext/type-utils/snake-case.d.ts +36 -0
- package/lib/esnext/type-utils/snake-case.js +2 -0
- package/lib/esnext/type-utils/snake-case.js.map +1 -0
- package/lib/esnext/type-utils/sourceUtilities.d.ts +3 -0
- package/lib/esnext/type-utils/sourceUtilities.js +2 -0
- package/lib/esnext/type-utils/sourceUtilities.js.map +1 -0
- package/lib/esnext/type-utils/utilities.d.ts +4 -0
- package/lib/esnext/type-utils/utilities.js +2 -0
- package/lib/esnext/type-utils/utilities.js.map +1 -0
- package/package.json +2 -3
- package/src/iconNames.ts +3 -2
- package/src/iconSvgPaths.ts +1 -1
- package/src/type-utils/camel-case.ts +80 -0
- package/src/type-utils/delimiter-case.ts +105 -0
- package/src/type-utils/includes.ts +26 -0
- package/src/type-utils/index.ts +20 -0
- package/src/type-utils/pascal-case.ts +35 -0
- package/src/type-utils/screaming-snake-case.ts +32 -0
- package/src/type-utils/snake-case.ts +37 -0
- package/src/type-utils/sourceUtilities.ts +31 -0
- package/src/type-utils/utilities.ts +10 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { UpperCaseCharacters, WordSeparators } from "./sourceUtilities";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
Unlike a simpler split, this one includes the delimiter splitted on in the resulting array literal. This is to enable splitting on, for example, upper-case characters.
|
|
5
|
+
|
|
6
|
+
@category Template Literals
|
|
7
|
+
*/
|
|
8
|
+
export type SplitIncludingDelimiters<Source extends string, Delimiter extends string> = Source extends ""
|
|
9
|
+
? []
|
|
10
|
+
: Source extends `${infer FirstPart}${Delimiter}${infer SecondPart}`
|
|
11
|
+
? Source extends `${FirstPart}${infer UsedDelimiter}${SecondPart}`
|
|
12
|
+
? UsedDelimiter extends Delimiter
|
|
13
|
+
? Source extends `${infer FirstPart}${UsedDelimiter}${infer SecondPart}`
|
|
14
|
+
? [
|
|
15
|
+
...SplitIncludingDelimiters<FirstPart, Delimiter>,
|
|
16
|
+
UsedDelimiter,
|
|
17
|
+
...SplitIncludingDelimiters<SecondPart, Delimiter>
|
|
18
|
+
]
|
|
19
|
+
: never
|
|
20
|
+
: never
|
|
21
|
+
: never
|
|
22
|
+
: [Source];
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
Format a specific part of the splitted string literal that `StringArrayToDelimiterCase<>` fuses together, ensuring desired casing.
|
|
26
|
+
|
|
27
|
+
@see StringArrayToDelimiterCase
|
|
28
|
+
*/
|
|
29
|
+
type StringPartToDelimiterCase<
|
|
30
|
+
StringPart extends string,
|
|
31
|
+
UsedWordSeparators extends string,
|
|
32
|
+
UsedUpperCaseCharacters extends string,
|
|
33
|
+
Delimiter extends string
|
|
34
|
+
> = StringPart extends UsedWordSeparators
|
|
35
|
+
? Delimiter
|
|
36
|
+
: StringPart extends UsedUpperCaseCharacters
|
|
37
|
+
? `${Delimiter}${Lowercase<StringPart>}`
|
|
38
|
+
: StringPart;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
Takes the result of a splitted string literal and recursively concatenates it together into the desired casing.
|
|
42
|
+
|
|
43
|
+
It receives `UsedWordSeparators` and `UsedUpperCaseCharacters` as input to ensure it's fully encapsulated.
|
|
44
|
+
|
|
45
|
+
@see SplitIncludingDelimiters
|
|
46
|
+
*/
|
|
47
|
+
type StringArrayToDelimiterCase<
|
|
48
|
+
Parts extends any[],
|
|
49
|
+
UsedWordSeparators extends string,
|
|
50
|
+
UsedUpperCaseCharacters extends string,
|
|
51
|
+
Delimiter extends string
|
|
52
|
+
> = Parts extends [`${infer FirstPart}`, ...infer RemainingParts]
|
|
53
|
+
? `${StringPartToDelimiterCase<
|
|
54
|
+
FirstPart,
|
|
55
|
+
UsedWordSeparators,
|
|
56
|
+
UsedUpperCaseCharacters,
|
|
57
|
+
Delimiter
|
|
58
|
+
>}${StringArrayToDelimiterCase<RemainingParts, UsedWordSeparators, UsedUpperCaseCharacters, Delimiter>}`
|
|
59
|
+
: "";
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
Convert a string literal to a custom string delimiter casing.
|
|
63
|
+
|
|
64
|
+
This can be useful when, for example, converting a camel-cased object property to an oddly cased one.
|
|
65
|
+
|
|
66
|
+
@see KebabCase
|
|
67
|
+
@see SnakeCase
|
|
68
|
+
|
|
69
|
+
@example
|
|
70
|
+
```
|
|
71
|
+
import {DelimiterCase} from 'type-fest';
|
|
72
|
+
|
|
73
|
+
// Simple
|
|
74
|
+
|
|
75
|
+
const someVariable: DelimiterCase<'fooBar', '#'> = 'foo#bar';
|
|
76
|
+
|
|
77
|
+
// Advanced
|
|
78
|
+
|
|
79
|
+
type OddlyCasedProperties<T> = {
|
|
80
|
+
[K in keyof T as DelimiterCase<K, '#'>]: T[K]
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
interface SomeOptions {
|
|
84
|
+
dryRun: boolean;
|
|
85
|
+
includeFile: string;
|
|
86
|
+
foo: number;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const rawCliOptions: OddlyCasedProperties<SomeOptions> = {
|
|
90
|
+
'dry#run': true,
|
|
91
|
+
'include#file': 'bar.js',
|
|
92
|
+
foo: 123
|
|
93
|
+
};
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
@category Template Literals
|
|
97
|
+
*/
|
|
98
|
+
export type DelimiterCase<Value, Delimiter extends string> = Value extends string
|
|
99
|
+
? StringArrayToDelimiterCase<
|
|
100
|
+
SplitIncludingDelimiters<Value, WordSeparators | UpperCaseCharacters>,
|
|
101
|
+
WordSeparators,
|
|
102
|
+
UpperCaseCharacters,
|
|
103
|
+
Delimiter
|
|
104
|
+
>
|
|
105
|
+
: Value;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Returns a boolean for whether given two types are equal.
|
|
3
|
+
|
|
4
|
+
@link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
|
|
5
|
+
*/
|
|
6
|
+
type IsEqual<T, U> = (<G>() => G extends T ? 1 : 2) extends <G>() => G extends U ? 1 : 2 ? true : false;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
Returns a boolean for whether the given array includes the given item.
|
|
10
|
+
|
|
11
|
+
This can be useful if another type wants to make a decision based on whether the array includes that item.
|
|
12
|
+
|
|
13
|
+
@example
|
|
14
|
+
```
|
|
15
|
+
import {Includes} from 'type-fest';
|
|
16
|
+
|
|
17
|
+
type hasRed<array extends any[]> = Includes<array, 'red'>;
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
@category Utilities
|
|
21
|
+
*/
|
|
22
|
+
export type Includes<Value extends any[], Item> = IsEqual<Value[0], Item> extends true
|
|
23
|
+
? true
|
|
24
|
+
: Value extends [Value[0], ...infer rest]
|
|
25
|
+
? Includes<rest, Item>
|
|
26
|
+
: false;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2021 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/** @fileoverview Mapped type utils copied from the "type-fest" package */
|
|
18
|
+
|
|
19
|
+
export { PascalCase } from "./pascal-case";
|
|
20
|
+
export { ScreamingSnakeCase } from "./screaming-snake-case";
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { CamelCase } from "./camel-case";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
Converts a string literal to pascal-case.
|
|
5
|
+
|
|
6
|
+
@example
|
|
7
|
+
```
|
|
8
|
+
import {PascalCase} from 'type-fest';
|
|
9
|
+
|
|
10
|
+
// Simple
|
|
11
|
+
|
|
12
|
+
const someVariable: PascalCase<'foo-bar'> = 'FooBar';
|
|
13
|
+
|
|
14
|
+
// Advanced
|
|
15
|
+
|
|
16
|
+
type PascalCaseProps<T> = {
|
|
17
|
+
[K in keyof T as PascalCase<K>]: T[K]
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
interface RawOptions {
|
|
21
|
+
'dry-run': boolean;
|
|
22
|
+
'full_family_name': string;
|
|
23
|
+
foo: number;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const dbResult: CamelCasedProperties<ModelProps> = {
|
|
27
|
+
DryRun: true,
|
|
28
|
+
FullFamilyName: 'bar.js',
|
|
29
|
+
Foo: 123
|
|
30
|
+
};
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
@category Template Literals
|
|
34
|
+
*/
|
|
35
|
+
export type PascalCase<Value> = CamelCase<Value> extends string ? Capitalize<CamelCase<Value>> : CamelCase<Value>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { SplitIncludingDelimiters } from "./delimiter-case";
|
|
2
|
+
import { SnakeCase } from "./snake-case";
|
|
3
|
+
import { Includes } from "./includes";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
Returns a boolean for whether the string is screaming snake case.
|
|
7
|
+
*/
|
|
8
|
+
type IsScreamingSnakeCase<Value extends string> = Value extends Uppercase<Value>
|
|
9
|
+
? Includes<SplitIncludingDelimiters<Lowercase<Value>, "_">, "_"> extends true
|
|
10
|
+
? true
|
|
11
|
+
: false
|
|
12
|
+
: false;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
Convert a string literal to screaming-snake-case.
|
|
16
|
+
|
|
17
|
+
This can be useful when, for example, converting a camel-cased object property to a screaming-snake-cased SQL column name.
|
|
18
|
+
|
|
19
|
+
@example
|
|
20
|
+
```
|
|
21
|
+
import {ScreamingSnakeCase} from 'type-fest';
|
|
22
|
+
|
|
23
|
+
const someVariable: ScreamingSnakeCase<'fooBar'> = 'FOO_BAR';
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
@category Template Literals
|
|
27
|
+
*/
|
|
28
|
+
export type ScreamingSnakeCase<Value> = Value extends string
|
|
29
|
+
? IsScreamingSnakeCase<Value> extends true
|
|
30
|
+
? Value
|
|
31
|
+
: Uppercase<SnakeCase<Value>>
|
|
32
|
+
: Value;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { DelimiterCase } from "./delimiter-case";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
Convert a string literal to snake-case.
|
|
5
|
+
|
|
6
|
+
This can be useful when, for example, converting a camel-cased object property to a snake-cased SQL column name.
|
|
7
|
+
|
|
8
|
+
@example
|
|
9
|
+
```
|
|
10
|
+
import {SnakeCase} from 'type-fest';
|
|
11
|
+
|
|
12
|
+
// Simple
|
|
13
|
+
|
|
14
|
+
const someVariable: SnakeCase<'fooBar'> = 'foo_bar';
|
|
15
|
+
|
|
16
|
+
// Advanced
|
|
17
|
+
|
|
18
|
+
type SnakeCasedProperties<T> = {
|
|
19
|
+
[K in keyof T as SnakeCase<K>]: T[K]
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
interface ModelProps {
|
|
23
|
+
isHappy: boolean;
|
|
24
|
+
fullFamilyName: string;
|
|
25
|
+
foo: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const dbResult: SnakeCasedProperties<ModelProps> = {
|
|
29
|
+
'is_happy': true,
|
|
30
|
+
'full_family_name': 'Carla Smith',
|
|
31
|
+
foo: 123
|
|
32
|
+
};
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
@category Template Literals
|
|
36
|
+
*/
|
|
37
|
+
export type SnakeCase<Value> = DelimiterCase<Value, "_">;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export type UpperCaseCharacters =
|
|
2
|
+
| "A"
|
|
3
|
+
| "B"
|
|
4
|
+
| "C"
|
|
5
|
+
| "D"
|
|
6
|
+
| "E"
|
|
7
|
+
| "F"
|
|
8
|
+
| "G"
|
|
9
|
+
| "H"
|
|
10
|
+
| "I"
|
|
11
|
+
| "J"
|
|
12
|
+
| "K"
|
|
13
|
+
| "L"
|
|
14
|
+
| "M"
|
|
15
|
+
| "N"
|
|
16
|
+
| "O"
|
|
17
|
+
| "P"
|
|
18
|
+
| "Q"
|
|
19
|
+
| "R"
|
|
20
|
+
| "S"
|
|
21
|
+
| "T"
|
|
22
|
+
| "U"
|
|
23
|
+
| "V"
|
|
24
|
+
| "W"
|
|
25
|
+
| "X"
|
|
26
|
+
| "Y"
|
|
27
|
+
| "Z";
|
|
28
|
+
|
|
29
|
+
export type WordSeparators = "-" | "_" | " ";
|
|
30
|
+
|
|
31
|
+
export type StringDigit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Recursively split a string literal into two parts on the first occurence of the given string, returning an array literal of all the separate parts.
|
|
3
|
+
*/
|
|
4
|
+
export type Split<S extends string, D extends string> = string extends S
|
|
5
|
+
? string[]
|
|
6
|
+
: S extends ""
|
|
7
|
+
? []
|
|
8
|
+
: S extends `${infer T}${D}${infer U}`
|
|
9
|
+
? [T, ...Split<U, D>]
|
|
10
|
+
: [S];
|