@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
package/.eslintrc.json ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "extends": "../../.eslintrc.js",
3
+ "ignorePatterns": ["src/type-utils/*"]
4
+ }
@@ -19,7 +19,6 @@ exports.IconNames = void 0;
19
19
  var tslib_1 = require("tslib");
20
20
  /* eslint-disable camelcase */
21
21
  var change_case_1 = require("change-case");
22
- // icon sets are identical aside from SVG paths, so we just import the info for the 16px set
23
22
  var blueprint_icons_16_1 = require("./generated/16px/blueprint-icons-16");
24
23
  var IconNamesNew = {};
25
24
  var IconNamesLegacy = {};
@@ -1 +1 @@
1
- {"version":3,"file":"iconNames.js","sourceRoot":"","sources":["../../src/iconNames.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;AAEH,8BAA8B;AAE9B,2CAAoD;AAGpD,4FAA4F;AAC5F,0EAAyG;AAIzG,IAAM,YAAY,GAAG,EAA4C,CAAC;AAClE,IAAM,eAAe,GAAG,EAAoD,CAAC;AAE7E,KAAmB,UAA8C,EAA9C,KAAA,MAAM,CAAC,MAAM,CAAC,sCAAiB,CAAe,EAA9C,cAA8C,EAA9C,IAA8C,EAAE;IAA9D,IAAM,MAAI,SAAA;IACX,YAAY,CAAC,wBAAU,CAAC,MAAI,CAAyB,CAAC,GAAG,MAAI,CAAC;IAC9D,eAAe,CAAC,uBAAS,CAAC,MAAI,CAAC,CAAC,WAAW,EAAkC,CAAC,GAAG,MAAI,CAAC;CACzF;AAEY,QAAA,SAAS,yCACf,YAAY,GACZ,eAAe,EACpB"}
1
+ {"version":3,"file":"iconNames.js","sourceRoot":"","sources":["../../src/iconNames.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;AAEH,8BAA8B;AAE9B,2CAAoD;AAEpD,0EAAyG;AAOzG,IAAM,YAAY,GAAG,EAA4C,CAAC;AAClE,IAAM,eAAe,GAAG,EAAoD,CAAC;AAE7E,KAAmB,UAA8C,EAA9C,KAAA,MAAM,CAAC,MAAM,CAAC,sCAAiB,CAAe,EAA9C,cAA8C,EAA9C,IAA8C,EAAE;IAA9D,IAAM,MAAI,SAAA;IACX,YAAY,CAAC,wBAAU,CAAC,MAAI,CAAyB,CAAC,GAAG,MAAI,CAAC;IAC9D,eAAe,CAAC,uBAAS,CAAC,MAAI,CAAC,CAAC,WAAW,EAAkC,CAAC,GAAG,MAAI,CAAC;CACzF;AAEY,QAAA,SAAS,yCACf,YAAY,GACZ,eAAe,EACpB"}
@@ -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,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# 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,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# 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,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# 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,18 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright 2021 Palantir Technologies, Inc. All rights reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ //# 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,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# 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,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# 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,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# 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,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# 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,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=utilities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utilities.js","sourceRoot":"","sources":["../../../src/type-utils/utilities.ts"],"names":[],"mappings":""}
@@ -16,7 +16,6 @@
16
16
  import { __assign } from "tslib";
17
17
  /* eslint-disable camelcase */
18
18
  import { pascalCase, snakeCase } from "change-case";
19
- // icon sets are identical aside from SVG paths, so we just import the info for the 16px set
20
19
  import { BlueprintIcons_16 } from "./generated/16px/blueprint-icons-16";
21
20
  var IconNamesNew = {};
22
21
  var 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,IAAM,YAAY,GAAG,EAA4C,CAAC;AAClE,IAAM,eAAe,GAAG,EAAoD,CAAC;AAE7E,KAAmB,UAA8C,EAA9C,KAAA,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAe,EAA9C,cAA8C,EAA9C,IAA8C,EAAE;IAA9D,IAAM,MAAI,SAAA;IACX,YAAY,CAAC,UAAU,CAAC,MAAI,CAAyB,CAAC,GAAG,MAAI,CAAC;IAC9D,eAAe,CAAC,SAAS,CAAC,MAAI,CAAC,CAAC,WAAW,EAAkC,CAAC,GAAG,MAAI,CAAC;CACzF;AAED,MAAM,CAAC,IAAM,SAAS,yBACf,YAAY,GACZ,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,IAAM,YAAY,GAAG,EAA4C,CAAC;AAClE,IAAM,eAAe,GAAG,EAAoD,CAAC;AAE7E,KAAmB,UAA8C,EAA9C,KAAA,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAe,EAA9C,cAA8C,EAA9C,IAA8C,EAAE;IAA9D,IAAM,MAAI,SAAA;IACX,YAAY,CAAC,UAAU,CAAC,MAAI,CAAyB,CAAC,GAAG,MAAI,CAAC;IAC9D,eAAe,CAAC,SAAS,CAAC,MAAI,CAAC,CAAC,WAAW,EAAkC,CAAC,GAAG,MAAI,CAAC;CACzF;AAED,MAAM,CAAC,IAAM,SAAS,yBACf,YAAY,GACZ,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"}