@youngonesworks/ui 0.1.117 → 0.1.119
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/globals.css +1 -23
- package/dist/index.cjs +57 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +55 -2
- package/dist/index.js.map +1 -1
- package/dist/styles/editor.css +27 -0
- package/dist/styles/index.d.ts +1 -0
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -13,8 +13,8 @@ import { addMonths, format, setMonth } from "date-fns";
|
|
|
13
13
|
import { enGB, fr, nl, nlBE } from "date-fns/locale";
|
|
14
14
|
import { createPortal } from "react-dom";
|
|
15
15
|
import { Tooltip as Tooltip$1 } from "react-tooltip";
|
|
16
|
-
import
|
|
17
|
-
import
|
|
16
|
+
import phone from "phone";
|
|
17
|
+
import CountryList from "country-list-with-dial-code-and-flag";
|
|
18
18
|
import { Placeholder } from "@tiptap/extension-placeholder";
|
|
19
19
|
import { Underline } from "@tiptap/extension-underline";
|
|
20
20
|
import { EditorContent, useEditor } from "@tiptap/react";
|
|
@@ -3056,6 +3056,59 @@ const UnorderedListItem = ({ children, actionItem, className, header = false,...
|
|
|
3056
3056
|
})]
|
|
3057
3057
|
});
|
|
3058
3058
|
|
|
3059
|
+
//#endregion
|
|
3060
|
+
//#region src/hooks/phone/usePhoneNumber.ts
|
|
3061
|
+
function usePhoneNumber() {
|
|
3062
|
+
/**
|
|
3063
|
+
* Validates a phone number and returns parsing results
|
|
3064
|
+
*/
|
|
3065
|
+
const validatePhone = useCallback((phoneNumber, options) => phone(phoneNumber, options), []);
|
|
3066
|
+
/**
|
|
3067
|
+
* Strips the country code from a phone number
|
|
3068
|
+
* Example: +85265698900 -> 65698900
|
|
3069
|
+
*/
|
|
3070
|
+
const stripCountryCode = useCallback((phoneNumber) => {
|
|
3071
|
+
const result = phone(phoneNumber);
|
|
3072
|
+
if (!result.isValid) return phoneNumber;
|
|
3073
|
+
return result.phoneNumber.replace(result.countryCode, "");
|
|
3074
|
+
}, []);
|
|
3075
|
+
/**
|
|
3076
|
+
* Returns the country code from a phone number
|
|
3077
|
+
* Example: +85265698900 -> +852
|
|
3078
|
+
*/
|
|
3079
|
+
const getCountryCode = useCallback((phoneNumber) => {
|
|
3080
|
+
const result = phone(phoneNumber);
|
|
3081
|
+
if (!result.isValid) return phoneNumber;
|
|
3082
|
+
return result.countryCode;
|
|
3083
|
+
}, []);
|
|
3084
|
+
/**
|
|
3085
|
+
* Formats a phone number to international format with country code
|
|
3086
|
+
* Example: 0648711212 (with country: 'NL') -> +31648711212
|
|
3087
|
+
*/
|
|
3088
|
+
const formatToInternational = useCallback((phoneNumber, options) => {
|
|
3089
|
+
const result = phone(phoneNumber, options);
|
|
3090
|
+
if (!result.isValid) return phoneNumber;
|
|
3091
|
+
return result.phoneNumber;
|
|
3092
|
+
}, []);
|
|
3093
|
+
return {
|
|
3094
|
+
validatePhone,
|
|
3095
|
+
stripCountryCode,
|
|
3096
|
+
getCountryCode,
|
|
3097
|
+
formatToInternational
|
|
3098
|
+
};
|
|
3099
|
+
}
|
|
3100
|
+
|
|
3101
|
+
//#endregion
|
|
3102
|
+
//#region src/hooks/phone/usePhoneNumberPrefix.ts
|
|
3103
|
+
const usePhoneNumberPrefix = (defaultCountry) => {
|
|
3104
|
+
const countryList = CountryList.getAll();
|
|
3105
|
+
return countryList.filter((country) => country.dial_code).sort((a, b) => {
|
|
3106
|
+
if (a?.code === defaultCountry) return -1;
|
|
3107
|
+
if (b?.code === defaultCountry) return 1;
|
|
3108
|
+
return a.name.localeCompare(b.name);
|
|
3109
|
+
});
|
|
3110
|
+
};
|
|
3111
|
+
|
|
3059
3112
|
//#endregion
|
|
3060
3113
|
//#region src/components/phoneInput/index.tsx
|
|
3061
3114
|
const CountrySelector = ({ searchPlaceholder, defaultCountry, ref }) => {
|