@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.
Files changed (103) hide show
  1. package/.eslintrc.json +4 -0
  2. package/lib/cjs/iconNames.js +0 -1
  3. package/lib/cjs/iconNames.js.map +1 -1
  4. package/lib/cjs/iconSvgPaths.d.ts +1 -1
  5. package/lib/cjs/type-utils/camel-case.d.ts +63 -0
  6. package/lib/cjs/type-utils/camel-case.js +3 -0
  7. package/lib/cjs/type-utils/camel-case.js.map +1 -0
  8. package/lib/cjs/type-utils/delimiter-case.d.ts +64 -0
  9. package/lib/cjs/type-utils/delimiter-case.js +3 -0
  10. package/lib/cjs/type-utils/delimiter-case.js.map +1 -0
  11. package/lib/cjs/type-utils/includes.d.ts +22 -0
  12. package/lib/cjs/type-utils/includes.js +3 -0
  13. package/lib/cjs/type-utils/includes.js.map +1 -0
  14. package/lib/cjs/type-utils/index.d.ts +3 -0
  15. package/lib/cjs/type-utils/index.js +18 -0
  16. package/lib/cjs/type-utils/index.js.map +1 -0
  17. package/lib/cjs/type-utils/pascal-case.d.ts +34 -0
  18. package/lib/cjs/type-utils/pascal-case.js +3 -0
  19. package/lib/cjs/type-utils/pascal-case.js.map +1 -0
  20. package/lib/cjs/type-utils/screaming-snake-case.d.ts +23 -0
  21. package/lib/cjs/type-utils/screaming-snake-case.js +3 -0
  22. package/lib/cjs/type-utils/screaming-snake-case.js.map +1 -0
  23. package/lib/cjs/type-utils/snake-case.d.ts +36 -0
  24. package/lib/cjs/type-utils/snake-case.js +3 -0
  25. package/lib/cjs/type-utils/snake-case.js.map +1 -0
  26. package/lib/cjs/type-utils/sourceUtilities.d.ts +3 -0
  27. package/lib/cjs/type-utils/sourceUtilities.js +3 -0
  28. package/lib/cjs/type-utils/sourceUtilities.js.map +1 -0
  29. package/lib/cjs/type-utils/utilities.d.ts +4 -0
  30. package/lib/cjs/type-utils/utilities.js +3 -0
  31. package/lib/cjs/type-utils/utilities.js.map +1 -0
  32. package/lib/esm/iconNames.js +0 -1
  33. package/lib/esm/iconNames.js.map +1 -1
  34. package/lib/esm/iconSvgPaths.d.ts +1 -1
  35. package/lib/esm/type-utils/camel-case.d.ts +63 -0
  36. package/lib/esm/type-utils/camel-case.js +2 -0
  37. package/lib/esm/type-utils/camel-case.js.map +1 -0
  38. package/lib/esm/type-utils/delimiter-case.d.ts +64 -0
  39. package/lib/esm/type-utils/delimiter-case.js +2 -0
  40. package/lib/esm/type-utils/delimiter-case.js.map +1 -0
  41. package/lib/esm/type-utils/includes.d.ts +22 -0
  42. package/lib/esm/type-utils/includes.js +2 -0
  43. package/lib/esm/type-utils/includes.js.map +1 -0
  44. package/lib/esm/type-utils/index.d.ts +3 -0
  45. package/lib/esm/type-utils/index.js +17 -0
  46. package/lib/esm/type-utils/index.js.map +1 -0
  47. package/lib/esm/type-utils/pascal-case.d.ts +34 -0
  48. package/lib/esm/type-utils/pascal-case.js +2 -0
  49. package/lib/esm/type-utils/pascal-case.js.map +1 -0
  50. package/lib/esm/type-utils/screaming-snake-case.d.ts +23 -0
  51. package/lib/esm/type-utils/screaming-snake-case.js +2 -0
  52. package/lib/esm/type-utils/screaming-snake-case.js.map +1 -0
  53. package/lib/esm/type-utils/snake-case.d.ts +36 -0
  54. package/lib/esm/type-utils/snake-case.js +2 -0
  55. package/lib/esm/type-utils/snake-case.js.map +1 -0
  56. package/lib/esm/type-utils/sourceUtilities.d.ts +3 -0
  57. package/lib/esm/type-utils/sourceUtilities.js +2 -0
  58. package/lib/esm/type-utils/sourceUtilities.js.map +1 -0
  59. package/lib/esm/type-utils/utilities.d.ts +4 -0
  60. package/lib/esm/type-utils/utilities.js +2 -0
  61. package/lib/esm/type-utils/utilities.js.map +1 -0
  62. package/lib/esnext/iconNames.js +0 -1
  63. package/lib/esnext/iconNames.js.map +1 -1
  64. package/lib/esnext/iconSvgPaths.d.ts +1 -1
  65. package/lib/esnext/type-utils/camel-case.d.ts +63 -0
  66. package/lib/esnext/type-utils/camel-case.js +2 -0
  67. package/lib/esnext/type-utils/camel-case.js.map +1 -0
  68. package/lib/esnext/type-utils/delimiter-case.d.ts +64 -0
  69. package/lib/esnext/type-utils/delimiter-case.js +2 -0
  70. package/lib/esnext/type-utils/delimiter-case.js.map +1 -0
  71. package/lib/esnext/type-utils/includes.d.ts +22 -0
  72. package/lib/esnext/type-utils/includes.js +2 -0
  73. package/lib/esnext/type-utils/includes.js.map +1 -0
  74. package/lib/esnext/type-utils/index.d.ts +3 -0
  75. package/lib/esnext/type-utils/index.js +17 -0
  76. package/lib/esnext/type-utils/index.js.map +1 -0
  77. package/lib/esnext/type-utils/pascal-case.d.ts +34 -0
  78. package/lib/esnext/type-utils/pascal-case.js +2 -0
  79. package/lib/esnext/type-utils/pascal-case.js.map +1 -0
  80. package/lib/esnext/type-utils/screaming-snake-case.d.ts +23 -0
  81. package/lib/esnext/type-utils/screaming-snake-case.js +2 -0
  82. package/lib/esnext/type-utils/screaming-snake-case.js.map +1 -0
  83. package/lib/esnext/type-utils/snake-case.d.ts +36 -0
  84. package/lib/esnext/type-utils/snake-case.js +2 -0
  85. package/lib/esnext/type-utils/snake-case.js.map +1 -0
  86. package/lib/esnext/type-utils/sourceUtilities.d.ts +3 -0
  87. package/lib/esnext/type-utils/sourceUtilities.js +2 -0
  88. package/lib/esnext/type-utils/sourceUtilities.js.map +1 -0
  89. package/lib/esnext/type-utils/utilities.d.ts +4 -0
  90. package/lib/esnext/type-utils/utilities.js +2 -0
  91. package/lib/esnext/type-utils/utilities.js.map +1 -0
  92. package/package.json +2 -3
  93. package/src/iconNames.ts +3 -2
  94. package/src/iconSvgPaths.ts +1 -1
  95. package/src/type-utils/camel-case.ts +80 -0
  96. package/src/type-utils/delimiter-case.ts +105 -0
  97. package/src/type-utils/includes.ts +26 -0
  98. package/src/type-utils/index.ts +20 -0
  99. package/src/type-utils/pascal-case.ts +35 -0
  100. package/src/type-utils/screaming-snake-case.ts +32 -0
  101. package/src/type-utils/snake-case.ts +37 -0
  102. package/src/type-utils/sourceUtilities.ts +31 -0
  103. package/src/type-utils/utilities.ts +10 -0
@@ -0,0 +1,34 @@
1
+ import { CamelCase } from "./camel-case";
2
+ /**
3
+ Converts a string literal to pascal-case.
4
+
5
+ @example
6
+ ```
7
+ import {PascalCase} from 'type-fest';
8
+
9
+ // Simple
10
+
11
+ const someVariable: PascalCase<'foo-bar'> = 'FooBar';
12
+
13
+ // Advanced
14
+
15
+ type PascalCaseProps<T> = {
16
+ [K in keyof T as PascalCase<K>]: T[K]
17
+ };
18
+
19
+ interface RawOptions {
20
+ 'dry-run': boolean;
21
+ 'full_family_name': string;
22
+ foo: number;
23
+ }
24
+
25
+ const dbResult: CamelCasedProperties<ModelProps> = {
26
+ DryRun: true,
27
+ FullFamilyName: 'bar.js',
28
+ Foo: 123
29
+ };
30
+ ```
31
+
32
+ @category Template Literals
33
+ */
34
+ export declare type PascalCase<Value> = CamelCase<Value> extends string ? Capitalize<CamelCase<Value>> : CamelCase<Value>;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=pascal-case.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pascal-case.js","sourceRoot":"","sources":["../../../src/type-utils/pascal-case.ts"],"names":[],"mappings":""}
@@ -0,0 +1,23 @@
1
+ import { SplitIncludingDelimiters } from "./delimiter-case";
2
+ import { SnakeCase } from "./snake-case";
3
+ import { Includes } from "./includes";
4
+ /**
5
+ Returns a boolean for whether the string is screaming snake case.
6
+ */
7
+ declare type IsScreamingSnakeCase<Value extends string> = Value extends Uppercase<Value> ? Includes<SplitIncludingDelimiters<Lowercase<Value>, "_">, "_"> extends true ? true : false : false;
8
+ /**
9
+ Convert a string literal to screaming-snake-case.
10
+
11
+ This can be useful when, for example, converting a camel-cased object property to a screaming-snake-cased SQL column name.
12
+
13
+ @example
14
+ ```
15
+ import {ScreamingSnakeCase} from 'type-fest';
16
+
17
+ const someVariable: ScreamingSnakeCase<'fooBar'> = 'FOO_BAR';
18
+ ```
19
+
20
+ @category Template Literals
21
+ */
22
+ export declare type ScreamingSnakeCase<Value> = Value extends string ? IsScreamingSnakeCase<Value> extends true ? Value : Uppercase<SnakeCase<Value>> : Value;
23
+ export {};
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=screaming-snake-case.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"screaming-snake-case.js","sourceRoot":"","sources":["../../../src/type-utils/screaming-snake-case.ts"],"names":[],"mappings":""}
@@ -0,0 +1,36 @@
1
+ import { DelimiterCase } from "./delimiter-case";
2
+ /**
3
+ Convert a string literal to snake-case.
4
+
5
+ This can be useful when, for example, converting a camel-cased object property to a snake-cased SQL column name.
6
+
7
+ @example
8
+ ```
9
+ import {SnakeCase} from 'type-fest';
10
+
11
+ // Simple
12
+
13
+ const someVariable: SnakeCase<'fooBar'> = 'foo_bar';
14
+
15
+ // Advanced
16
+
17
+ type SnakeCasedProperties<T> = {
18
+ [K in keyof T as SnakeCase<K>]: T[K]
19
+ };
20
+
21
+ interface ModelProps {
22
+ isHappy: boolean;
23
+ fullFamilyName: string;
24
+ foo: number;
25
+ }
26
+
27
+ const dbResult: SnakeCasedProperties<ModelProps> = {
28
+ 'is_happy': true,
29
+ 'full_family_name': 'Carla Smith',
30
+ foo: 123
31
+ };
32
+ ```
33
+
34
+ @category Template Literals
35
+ */
36
+ export declare type SnakeCase<Value> = DelimiterCase<Value, "_">;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=snake-case.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snake-case.js","sourceRoot":"","sources":["../../../src/type-utils/snake-case.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ export declare type UpperCaseCharacters = "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z";
2
+ export declare type WordSeparators = "-" | "_" | " ";
3
+ export declare type StringDigit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9";
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=sourceUtilities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sourceUtilities.js","sourceRoot":"","sources":["../../../src/type-utils/sourceUtilities.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
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 declare type Split<S extends string, D extends string> = string extends S ? string[] : S extends "" ? [] : S extends `${infer T}${D}${infer U}` ? [T, ...Split<U, D>] : [S];
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=utilities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utilities.js","sourceRoot":"","sources":["../../../src/type-utils/utilities.ts"],"names":[],"mappings":""}
@@ -15,7 +15,6 @@
15
15
  */
16
16
  /* eslint-disable camelcase */
17
17
  import { pascalCase, snakeCase } from "change-case";
18
- // icon sets are identical aside from SVG paths, so we just import the info for the 16px set
19
18
  import { BlueprintIcons_16 } from "./generated/16px/blueprint-icons-16";
20
19
  const IconNamesNew = {};
21
20
  const IconNamesLegacy = {};
@@ -1 +1 @@
1
- {"version":3,"file":"iconNames.js","sourceRoot":"","sources":["../../src/iconNames.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,8BAA8B;AAE9B,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGpD,4FAA4F;AAC5F,OAAO,EAAE,iBAAiB,EAAmC,MAAM,qCAAqC,CAAC;AAIzG,MAAM,YAAY,GAAG,EAA4C,CAAC;AAClE,MAAM,eAAe,GAAG,EAAoD,CAAC;AAE7E,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAe,EAAE;IAC/D,YAAY,CAAC,UAAU,CAAC,IAAI,CAAyB,CAAC,GAAG,IAAI,CAAC;IAC9D,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,WAAW,EAAkC,CAAC,GAAG,IAAI,CAAC;CACzF;AAED,MAAM,CAAC,MAAM,SAAS,GAAG;IACrB,GAAG,YAAY;IACf,GAAG,eAAe;CACrB,CAAC"}
1
+ {"version":3,"file":"iconNames.js","sourceRoot":"","sources":["../../src/iconNames.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,8BAA8B;AAE9B,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAEpD,OAAO,EAAE,iBAAiB,EAAmC,MAAM,qCAAqC,CAAC;AAOzG,MAAM,YAAY,GAAG,EAA4C,CAAC;AAClE,MAAM,eAAe,GAAG,EAAoD,CAAC;AAE7E,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAe,EAAE;IAC/D,YAAY,CAAC,UAAU,CAAC,IAAI,CAAyB,CAAC,GAAG,IAAI,CAAC;IAC9D,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,WAAW,EAAkC,CAAC,GAAG,IAAI,CAAC;CACzF;AAED,MAAM,CAAC,MAAM,SAAS,GAAG;IACrB,GAAG,YAAY;IACf,GAAG,eAAe;CACrB,CAAC"}
@@ -1,5 +1,5 @@
1
- import type { PascalCase } from "type-fest";
2
1
  import type { IconName } from "./iconNames";
2
+ import type { PascalCase } from "./type-utils";
3
3
  export declare const IconSvgPaths16: Record<import("./generated/16px/blueprint-icons-16").BlueprintIcons_16Key, string[]>;
4
4
  export declare const IconSvgPaths20: Record<import("./generated/16px/blueprint-icons-16").BlueprintIcons_16Key, string[]>;
5
5
  /**
@@ -0,0 +1,63 @@
1
+ import { WordSeparators } from "./sourceUtilities";
2
+ import { Split } from "./utilities";
3
+ /**
4
+ Step by step takes the first item in an array literal, formats it and adds it to a string literal, and then recursively appends the remainder.
5
+
6
+ Only to be used by `CamelCaseStringArray<>`.
7
+
8
+ @see CamelCaseStringArray
9
+ */
10
+ declare type InnerCamelCaseStringArray<Parts extends any[], PreviousPart> = Parts extends [
11
+ `${infer FirstPart}`,
12
+ ...infer RemainingParts
13
+ ] ? FirstPart extends undefined ? "" : FirstPart extends "" ? InnerCamelCaseStringArray<RemainingParts, PreviousPart> : `${PreviousPart extends "" ? FirstPart : Capitalize<FirstPart>}${InnerCamelCaseStringArray<RemainingParts, FirstPart>}` : "";
14
+ /**
15
+ Starts fusing the output of `Split<>`, an array literal of strings, into a camel-cased string literal.
16
+
17
+ It's separate from `InnerCamelCaseStringArray<>` to keep a clean API outwards to the rest of the code.
18
+
19
+ @see Split
20
+ */
21
+ declare type CamelCaseStringArray<Parts extends string[]> = Parts extends [`${infer FirstPart}`, ...infer RemainingParts] ? Uncapitalize<`${FirstPart}${InnerCamelCaseStringArray<RemainingParts, FirstPart>}`> : never;
22
+ /**
23
+ Convert a string literal to camel-case.
24
+
25
+ This can be useful when, for example, converting some kebab-cased command-line flags or a snake-cased database result.
26
+
27
+ @example
28
+ ```
29
+ import {CamelCase} from 'type-fest';
30
+
31
+ // Simple
32
+
33
+ const someVariable: CamelCase<'foo-bar'> = 'fooBar';
34
+
35
+ // Advanced
36
+
37
+ type CamelCasedProperties<T> = {
38
+ [K in keyof T as CamelCase<K>]: T[K]
39
+ };
40
+
41
+ interface RawOptions {
42
+ 'dry-run': boolean;
43
+ 'full_family_name': string;
44
+ foo: number;
45
+ BAR: string;
46
+ QUZ_QUX: number;
47
+ 'OTHER-FIELD': boolean;
48
+ }
49
+
50
+ const dbResult: CamelCasedProperties<ModelProps> = {
51
+ dryRun: true,
52
+ fullFamilyName: 'bar.js',
53
+ foo: 123,
54
+ bar: 'foo',
55
+ quzQux: 6,
56
+ otherField: false
57
+ };
58
+ ```
59
+
60
+ @category Template Literals
61
+ */
62
+ export declare type CamelCase<K> = K extends string ? K extends Uppercase<K> ? CamelCaseStringArray<Split<Lowercase<K>, WordSeparators>> : CamelCaseStringArray<Split<K, WordSeparators>> : K;
63
+ export {};
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=camel-case.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"camel-case.js","sourceRoot":"","sources":["../../../src/type-utils/camel-case.ts"],"names":[],"mappings":""}
@@ -0,0 +1,64 @@
1
+ import { UpperCaseCharacters, WordSeparators } from "./sourceUtilities";
2
+ /**
3
+ 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.
4
+
5
+ @category Template Literals
6
+ */
7
+ export declare type SplitIncludingDelimiters<Source extends string, Delimiter extends string> = Source extends "" ? [] : Source extends `${infer FirstPart}${Delimiter}${infer SecondPart}` ? Source extends `${FirstPart}${infer UsedDelimiter}${SecondPart}` ? UsedDelimiter extends Delimiter ? Source extends `${infer FirstPart}${UsedDelimiter}${infer SecondPart}` ? [
8
+ ...SplitIncludingDelimiters<FirstPart, Delimiter>,
9
+ UsedDelimiter,
10
+ ...SplitIncludingDelimiters<SecondPart, Delimiter>
11
+ ] : never : never : never : [Source];
12
+ /**
13
+ Format a specific part of the splitted string literal that `StringArrayToDelimiterCase<>` fuses together, ensuring desired casing.
14
+
15
+ @see StringArrayToDelimiterCase
16
+ */
17
+ declare type StringPartToDelimiterCase<StringPart extends string, UsedWordSeparators extends string, UsedUpperCaseCharacters extends string, Delimiter extends string> = StringPart extends UsedWordSeparators ? Delimiter : StringPart extends UsedUpperCaseCharacters ? `${Delimiter}${Lowercase<StringPart>}` : StringPart;
18
+ /**
19
+ Takes the result of a splitted string literal and recursively concatenates it together into the desired casing.
20
+
21
+ It receives `UsedWordSeparators` and `UsedUpperCaseCharacters` as input to ensure it's fully encapsulated.
22
+
23
+ @see SplitIncludingDelimiters
24
+ */
25
+ declare type StringArrayToDelimiterCase<Parts extends any[], UsedWordSeparators extends string, UsedUpperCaseCharacters extends string, Delimiter extends string> = Parts extends [`${infer FirstPart}`, ...infer RemainingParts] ? `${StringPartToDelimiterCase<FirstPart, UsedWordSeparators, UsedUpperCaseCharacters, Delimiter>}${StringArrayToDelimiterCase<RemainingParts, UsedWordSeparators, UsedUpperCaseCharacters, Delimiter>}` : "";
26
+ /**
27
+ Convert a string literal to a custom string delimiter casing.
28
+
29
+ This can be useful when, for example, converting a camel-cased object property to an oddly cased one.
30
+
31
+ @see KebabCase
32
+ @see SnakeCase
33
+
34
+ @example
35
+ ```
36
+ import {DelimiterCase} from 'type-fest';
37
+
38
+ // Simple
39
+
40
+ const someVariable: DelimiterCase<'fooBar', '#'> = 'foo#bar';
41
+
42
+ // Advanced
43
+
44
+ type OddlyCasedProperties<T> = {
45
+ [K in keyof T as DelimiterCase<K, '#'>]: T[K]
46
+ };
47
+
48
+ interface SomeOptions {
49
+ dryRun: boolean;
50
+ includeFile: string;
51
+ foo: number;
52
+ }
53
+
54
+ const rawCliOptions: OddlyCasedProperties<SomeOptions> = {
55
+ 'dry#run': true,
56
+ 'include#file': 'bar.js',
57
+ foo: 123
58
+ };
59
+ ```
60
+
61
+ @category Template Literals
62
+ */
63
+ export declare type DelimiterCase<Value, Delimiter extends string> = Value extends string ? StringArrayToDelimiterCase<SplitIncludingDelimiters<Value, WordSeparators | UpperCaseCharacters>, WordSeparators, UpperCaseCharacters, Delimiter> : Value;
64
+ export {};
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=delimiter-case.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delimiter-case.js","sourceRoot":"","sources":["../../../src/type-utils/delimiter-case.ts"],"names":[],"mappings":""}
@@ -0,0 +1,22 @@
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
+ declare type IsEqual<T, U> = (<G>() => G extends T ? 1 : 2) extends <G>() => G extends U ? 1 : 2 ? true : false;
7
+ /**
8
+ Returns a boolean for whether the given array includes the given item.
9
+
10
+ This can be useful if another type wants to make a decision based on whether the array includes that item.
11
+
12
+ @example
13
+ ```
14
+ import {Includes} from 'type-fest';
15
+
16
+ type hasRed<array extends any[]> = Includes<array, 'red'>;
17
+ ```
18
+
19
+ @category Utilities
20
+ */
21
+ export declare type Includes<Value extends any[], Item> = IsEqual<Value[0], Item> extends true ? true : Value extends [Value[0], ...infer rest] ? Includes<rest, Item> : false;
22
+ export {};
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=includes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"includes.js","sourceRoot":"","sources":["../../../src/type-utils/includes.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ /** @fileoverview Mapped type utils copied from the "type-fest" package */
2
+ export { PascalCase } from "./pascal-case";
3
+ export { ScreamingSnakeCase } from "./screaming-snake-case";
@@ -0,0 +1,17 @@
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
+ export {};
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/type-utils/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG"}
@@ -0,0 +1,34 @@
1
+ import { CamelCase } from "./camel-case";
2
+ /**
3
+ Converts a string literal to pascal-case.
4
+
5
+ @example
6
+ ```
7
+ import {PascalCase} from 'type-fest';
8
+
9
+ // Simple
10
+
11
+ const someVariable: PascalCase<'foo-bar'> = 'FooBar';
12
+
13
+ // Advanced
14
+
15
+ type PascalCaseProps<T> = {
16
+ [K in keyof T as PascalCase<K>]: T[K]
17
+ };
18
+
19
+ interface RawOptions {
20
+ 'dry-run': boolean;
21
+ 'full_family_name': string;
22
+ foo: number;
23
+ }
24
+
25
+ const dbResult: CamelCasedProperties<ModelProps> = {
26
+ DryRun: true,
27
+ FullFamilyName: 'bar.js',
28
+ Foo: 123
29
+ };
30
+ ```
31
+
32
+ @category Template Literals
33
+ */
34
+ export declare type PascalCase<Value> = CamelCase<Value> extends string ? Capitalize<CamelCase<Value>> : CamelCase<Value>;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=pascal-case.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pascal-case.js","sourceRoot":"","sources":["../../../src/type-utils/pascal-case.ts"],"names":[],"mappings":""}
@@ -0,0 +1,23 @@
1
+ import { SplitIncludingDelimiters } from "./delimiter-case";
2
+ import { SnakeCase } from "./snake-case";
3
+ import { Includes } from "./includes";
4
+ /**
5
+ Returns a boolean for whether the string is screaming snake case.
6
+ */
7
+ declare type IsScreamingSnakeCase<Value extends string> = Value extends Uppercase<Value> ? Includes<SplitIncludingDelimiters<Lowercase<Value>, "_">, "_"> extends true ? true : false : false;
8
+ /**
9
+ Convert a string literal to screaming-snake-case.
10
+
11
+ This can be useful when, for example, converting a camel-cased object property to a screaming-snake-cased SQL column name.
12
+
13
+ @example
14
+ ```
15
+ import {ScreamingSnakeCase} from 'type-fest';
16
+
17
+ const someVariable: ScreamingSnakeCase<'fooBar'> = 'FOO_BAR';
18
+ ```
19
+
20
+ @category Template Literals
21
+ */
22
+ export declare type ScreamingSnakeCase<Value> = Value extends string ? IsScreamingSnakeCase<Value> extends true ? Value : Uppercase<SnakeCase<Value>> : Value;
23
+ export {};
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=screaming-snake-case.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"screaming-snake-case.js","sourceRoot":"","sources":["../../../src/type-utils/screaming-snake-case.ts"],"names":[],"mappings":""}
@@ -0,0 +1,36 @@
1
+ import { DelimiterCase } from "./delimiter-case";
2
+ /**
3
+ Convert a string literal to snake-case.
4
+
5
+ This can be useful when, for example, converting a camel-cased object property to a snake-cased SQL column name.
6
+
7
+ @example
8
+ ```
9
+ import {SnakeCase} from 'type-fest';
10
+
11
+ // Simple
12
+
13
+ const someVariable: SnakeCase<'fooBar'> = 'foo_bar';
14
+
15
+ // Advanced
16
+
17
+ type SnakeCasedProperties<T> = {
18
+ [K in keyof T as SnakeCase<K>]: T[K]
19
+ };
20
+
21
+ interface ModelProps {
22
+ isHappy: boolean;
23
+ fullFamilyName: string;
24
+ foo: number;
25
+ }
26
+
27
+ const dbResult: SnakeCasedProperties<ModelProps> = {
28
+ 'is_happy': true,
29
+ 'full_family_name': 'Carla Smith',
30
+ foo: 123
31
+ };
32
+ ```
33
+
34
+ @category Template Literals
35
+ */
36
+ export declare type SnakeCase<Value> = DelimiterCase<Value, "_">;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=snake-case.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snake-case.js","sourceRoot":"","sources":["../../../src/type-utils/snake-case.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ export declare type UpperCaseCharacters = "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z";
2
+ export declare type WordSeparators = "-" | "_" | " ";
3
+ export declare type StringDigit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9";
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=sourceUtilities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sourceUtilities.js","sourceRoot":"","sources":["../../../src/type-utils/sourceUtilities.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
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 declare type Split<S extends string, D extends string> = string extends S ? string[] : S extends "" ? [] : S extends `${infer T}${D}${infer U}` ? [T, ...Split<U, D>] : [S];
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=utilities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utilities.js","sourceRoot":"","sources":["../../../src/type-utils/utilities.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blueprintjs/icons",
3
- "version": "4.0.0-beta.5",
3
+ "version": "4.0.0-beta.6",
4
4
  "description": "Components, fonts, icons, and css files for creating and displaying icons.",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/esm/index.js",
@@ -38,8 +38,7 @@
38
38
  "dependencies": {
39
39
  "change-case": "^4.1.2",
40
40
  "classnames": "^2.2",
41
- "tslib": "~1.13.0",
42
- "type-fest": "^1.4.0"
41
+ "tslib": "~1.13.0"
43
42
  },
44
43
  "devDependencies": {
45
44
  "@blueprintjs/node-build-scripts": "^2.0.0-beta.1",
package/src/iconNames.ts CHANGED
@@ -17,10 +17,11 @@
17
17
  /* eslint-disable camelcase */
18
18
 
19
19
  import { pascalCase, snakeCase } from "change-case";
20
- import type { PascalCase, ScreamingSnakeCase } from "type-fest";
21
20
 
22
- // icon sets are identical aside from SVG paths, so we just import the info for the 16px set
23
21
  import { BlueprintIcons_16, BlueprintIcons_16Id as IconName } from "./generated/16px/blueprint-icons-16";
22
+ import type { PascalCase, ScreamingSnakeCase } from "./type-utils";
23
+
24
+ // icon sets are identical aside from SVG paths, so we just import the info for the 16px set
24
25
 
25
26
  export type { IconName };
26
27
 
@@ -15,9 +15,9 @@
15
15
  */
16
16
 
17
17
  import { pascalCase } from "change-case";
18
- import type { PascalCase } from "type-fest";
19
18
 
20
19
  import type { IconName } from "./iconNames";
20
+ import type { PascalCase } from "./type-utils";
21
21
 
22
22
  /* eslint-disable @typescript-eslint/no-var-requires */
23
23
  export const IconSvgPaths16 = require("./generated/16px/paths") as Record<PascalCase<IconName>, string[]>;
@@ -0,0 +1,80 @@
1
+ import { WordSeparators } from "./sourceUtilities";
2
+ import { Split } from "./utilities";
3
+
4
+ /**
5
+ Step by step takes the first item in an array literal, formats it and adds it to a string literal, and then recursively appends the remainder.
6
+
7
+ Only to be used by `CamelCaseStringArray<>`.
8
+
9
+ @see CamelCaseStringArray
10
+ */
11
+ type InnerCamelCaseStringArray<Parts extends any[], PreviousPart> = Parts extends [
12
+ `${infer FirstPart}`,
13
+ ...infer RemainingParts
14
+ ]
15
+ ? FirstPart extends undefined
16
+ ? ""
17
+ : FirstPart extends ""
18
+ ? InnerCamelCaseStringArray<RemainingParts, PreviousPart>
19
+ : `${PreviousPart extends "" ? FirstPart : Capitalize<FirstPart>}${InnerCamelCaseStringArray<
20
+ RemainingParts,
21
+ FirstPart
22
+ >}`
23
+ : "";
24
+
25
+ /**
26
+ Starts fusing the output of `Split<>`, an array literal of strings, into a camel-cased string literal.
27
+
28
+ It's separate from `InnerCamelCaseStringArray<>` to keep a clean API outwards to the rest of the code.
29
+
30
+ @see Split
31
+ */
32
+ type CamelCaseStringArray<Parts extends string[]> = Parts extends [`${infer FirstPart}`, ...infer RemainingParts]
33
+ ? Uncapitalize<`${FirstPart}${InnerCamelCaseStringArray<RemainingParts, FirstPart>}`>
34
+ : never;
35
+
36
+ /**
37
+ Convert a string literal to camel-case.
38
+
39
+ This can be useful when, for example, converting some kebab-cased command-line flags or a snake-cased database result.
40
+
41
+ @example
42
+ ```
43
+ import {CamelCase} from 'type-fest';
44
+
45
+ // Simple
46
+
47
+ const someVariable: CamelCase<'foo-bar'> = 'fooBar';
48
+
49
+ // Advanced
50
+
51
+ type CamelCasedProperties<T> = {
52
+ [K in keyof T as CamelCase<K>]: T[K]
53
+ };
54
+
55
+ interface RawOptions {
56
+ 'dry-run': boolean;
57
+ 'full_family_name': string;
58
+ foo: number;
59
+ BAR: string;
60
+ QUZ_QUX: number;
61
+ 'OTHER-FIELD': boolean;
62
+ }
63
+
64
+ const dbResult: CamelCasedProperties<ModelProps> = {
65
+ dryRun: true,
66
+ fullFamilyName: 'bar.js',
67
+ foo: 123,
68
+ bar: 'foo',
69
+ quzQux: 6,
70
+ otherField: false
71
+ };
72
+ ```
73
+
74
+ @category Template Literals
75
+ */
76
+ export type CamelCase<K> = K extends string
77
+ ? K extends Uppercase<K>
78
+ ? CamelCaseStringArray<Split<Lowercase<K>, WordSeparators>>
79
+ : CamelCaseStringArray<Split<K, WordSeparators>>
80
+ : K;