Skip to content

Commit

Permalink
Fix types for new withUtils build files
Browse files Browse the repository at this point in the history
  • Loading branch information
jackocnr committed May 11, 2024
1 parent d7ddd9b commit cf0010e
Show file tree
Hide file tree
Showing 21 changed files with 61 additions and 35 deletions.
4 changes: 2 additions & 2 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ build({
banner: {
js: getBanner("intlTelInput"),
},
entryPoints: ["src/js/intlTelInputWithUtils.js"],
entryPoints: ["src/js/intl-tel-input/intlTelInputWithUtils.ts"],
minify: false,
outfile: "build/js/intlTelInputWithUtils.js",
});
Expand All @@ -98,7 +98,7 @@ build({
banner: {
js: getBanner("intlTelInput"),
},
entryPoints: ["src/js/intlTelInputWithUtils.js"],
entryPoints: ["src/js/intl-tel-input/intlTelInputWithUtils.ts"],
minify: true,
outfile: "build/js/intlTelInputWithUtils.min.js",
});
14 changes: 8 additions & 6 deletions build/js/intlTelInput.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -580,12 +580,6 @@ declare module "intl-tel-input" {
};
numberType: object;
};
global {
interface Window {
intlTelInputUtils: ItiUtils;
intlTelInputUtilsBackup: ItiUtils;
}
}
type NumberType = "FIXED_LINE_OR_MOBILE" | "FIXED_LINE" | "MOBILE" | "PAGER" | "PERSONAL_NUMBER" | "PREMIUM_RATE" | "SHARED_COST" | "TOLL_FREE" | "UAN" | "UNKNOWN" | "VOICEMAIL" | "VOIP";
type SelectedCountryData = Country | {
name?: string;
Expand Down Expand Up @@ -977,3 +971,11 @@ declare module "intl-tel-input" {
const intlTelInput: IntlTelInputInterface;
export default intlTelInput;
}
declare module "intl-tel-input/utils-compiled" {
export default utils;
const utils: any;
}
declare module "intl-tel-input/intlTelInputWithUtils" {
import intlTelInput from "intl-tel-input";
export default intlTelInput;
}
4 changes: 2 additions & 2 deletions build/js/intlTelInputWithUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var factoryOutput = (() => {
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/js/intlTelInputWithUtils.js
// src/js/intl-tel-input/intlTelInputWithUtils.ts
var intlTelInputWithUtils_exports = {};
__export(intlTelInputWithUtils_exports, {
default: () => intlTelInputWithUtils_default
Expand Down Expand Up @@ -9151,7 +9151,7 @@ var factoryOutput = (() => {
delete window.intlTelInputUtilsTemp;
var utils_default = utils;

// src/js/intlTelInputWithUtils.js
// src/js/intl-tel-input/intlTelInputWithUtils.ts
intl_tel_input_default.utils = utils_default;
var intlTelInputWithUtils_default = intl_tel_input_default;
return __toCommonJS(intlTelInputWithUtils_exports);
Expand Down
2 changes: 1 addition & 1 deletion build/js/intlTelInputWithUtils.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion grunt/react_with_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const fs = require('fs');
module.exports = function(grunt) {
grunt.registerTask('react_with_utils', 'Generate react/src/intl-tel-input/reactWithUtils.tsx', function() {
const reactContents = fs.readFileSync('react/src/intl-tel-input/react.tsx', 'utf8');
const reactWithUtilsContents = reactContents.replace('import intlTelInput from "../intl-tel-input";', '//* THIS FILE IS AUTO-GENERATED. DO NOT EDIT.\nimport intlTelInput from "../intlTelInputWithUtils";');
const reactWithUtilsContents = reactContents.replace('import intlTelInput from "../intl-tel-input";', '//* THIS FILE IS AUTO-GENERATED. DO NOT EDIT.\nimport intlTelInput from "./intlTelInputWithUtils";');
fs.writeFileSync('react/src/intl-tel-input/reactWithUtils.tsx', reactWithUtilsContents);
});
};
10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,22 @@
"types": "./build/js/intlTelInput.d.ts",
"default": "./build/js/intlTelInput.js"
},
"./intlTelInputWithUtils": {
"types": "./build/js/intlTelInput.d.ts",
"default": "./build/js/intlTelInputWithUtils.js"
},
"./data": "./build/js/data.js",
"./react": {
"types": "./react/build/IntlTelInput.d.ts",
"require": "./react/build/IntlTelInput.cjs",
"default": "./react/build/IntlTelInput.js"
},
"./reactWithUtils": {
"types": "./react/build/IntlTelInput.d.ts",
"require": "./react/build/IntlTelInputWithUtils.cjs",
"default": "./react/build/IntlTelInputWithUtils.js"
},
"./i18n/*": "./build/js/i18n/*/index.js",
"./intlTelInputWithUtils": "./build/js/intlTelInputWithUtils.js",
"./*": "./*"
},
"typesVersions": {
Expand Down
2 changes: 1 addition & 1 deletion react/build/IntlTelInput.cjs

Large diffs are not rendered by default.

29 changes: 23 additions & 6 deletions react/build/IntlTelInput.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -581,12 +581,6 @@ declare module "intl-tel-input" {
};
numberType: object;
};
global {
interface Window {
intlTelInputUtils: ItiUtils;
intlTelInputUtilsBackup: ItiUtils;
}
}
type NumberType = "FIXED_LINE_OR_MOBILE" | "FIXED_LINE" | "MOBILE" | "PAGER" | "PERSONAL_NUMBER" | "PREMIUM_RATE" | "SHARED_COST" | "TOLL_FREE" | "UAN" | "UNKNOWN" | "VOICEMAIL" | "VOIP";
type SelectedCountryData = Country | {
name?: string;
Expand Down Expand Up @@ -993,3 +987,26 @@ declare module "intl-tel-input/react" {
}) => React.JSX.Element;
export default IntlTelInput;
}
declare module "intl-tel-input/utils-compiled" {
export default utils;
const utils: any;
}
declare module "intl-tel-input/intlTelInputWithUtils" {
import intlTelInput from "intl-tel-input";
export default intlTelInput;
}
declare module "intl-tel-input/reactWithUtils" {
import { SomeOptions } from "intl-tel-input";
import React from "react";
const IntlTelInput: ({ initialValue, onChangeNumber, onChangeCountry, onChangeValidity, onChangeErrorCode, usePreciseValidation, initOptions, inputProps, }: {
initialValue?: string;
onChangeNumber?: (number: string) => void;
onChangeCountry?: (country: string) => void;
onChangeValidity?: (valid: boolean) => void;
onChangeErrorCode?: (errorCode: number | null) => void;
usePreciseValidation?: boolean;
initOptions?: SomeOptions;
inputProps?: object;
}) => React.JSX.Element;
export default IntlTelInput;
}
2 changes: 1 addition & 1 deletion react/build/IntlTelInput.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion react/demo/simple-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -32669,7 +32669,7 @@
delete window.intlTelInputUtilsTemp;
var utils_default = utils;

// src/js/intlTelInputWithUtils.js
// src/js/intl-tel-input/intlTelInputWithUtils.ts
intl_tel_input_default.utils = utils_default;
var intlTelInputWithUtils_default = intl_tel_input_default;

Expand Down
2 changes: 1 addition & 1 deletion react/demo/validation-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -32669,7 +32669,7 @@
delete window.intlTelInputUtilsTemp;
var utils_default = utils;

// src/js/intlTelInputWithUtils.js
// src/js/intl-tel-input/intlTelInputWithUtils.ts
intl_tel_input_default.utils = utils_default;
var intlTelInputWithUtils_default = intl_tel_input_default;

Expand Down
1 change: 1 addition & 0 deletions react/src/intl-tel-input/intlTelInputWithUtils.ts
3 changes: 2 additions & 1 deletion react/src/intl-tel-input/reactWithUtils.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//* THIS FILE IS AUTO-GENERATED. DO NOT EDIT.
import intlTelInput from "../intlTelInputWithUtils";
import intlTelInput from "./intlTelInputWithUtils";
//* Keep the TS imports separate, as the above line gets substituted in the reactWithUtils build process.
import { Iti, SomeOptions } from "../intl-tel-input";
import React, { useRef, useEffect } from "react";

Expand Down
1 change: 1 addition & 0 deletions react/src/intl-tel-input/utils-compiled.js
1 change: 0 additions & 1 deletion react/src/intlTelInputWithUtils.js

This file was deleted.

1 change: 1 addition & 0 deletions react/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
},
"include": [
"src/intl-tel-input/react.tsx",
"src/intl-tel-input/reactWithUtils.tsx",
],
}
6 changes: 0 additions & 6 deletions src/js/intl-tel-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@ type ItiUtils = {
numberFormat: { NATIONAL: number, INTERNATIONAL: number, E164: number, RFC3966: number };
numberType: object;
};
declare global {
interface Window {
intlTelInputUtils: ItiUtils;
intlTelInputUtilsBackup: ItiUtils;
}
}
type NumberType =
"FIXED_LINE_OR_MOBILE"
| "FIXED_LINE"
Expand Down
4 changes: 4 additions & 0 deletions src/js/intl-tel-input/intlTelInputWithUtils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import intlTelInput from "../intl-tel-input";
import utils from "./utils-compiled";
intlTelInput.utils = utils;
export default intlTelInput;
1 change: 1 addition & 0 deletions src/js/intl-tel-input/utils-compiled.js
4 changes: 0 additions & 4 deletions src/js/intlTelInputWithUtils.js

This file was deleted.

1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
},
"include": [
"src/js/intl-tel-input.ts",
"src/js/intl-tel-input/intlTelInputWithUtils.ts",
],
}

0 comments on commit cf0010e

Please sign in to comment.