@codebit-programando-solucoes/codebit-web-antd 1.1.35 → 1.1.39
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/components/PhoneInput.d.ts +49 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/index.cjs +486 -110
- package/dist/index.css +16 -3
- package/package.json +1 -1
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { JSX } from 'react';
|
|
2
|
+
|
|
3
|
+
/** Props for the PhoneInput component */
|
|
4
|
+
export interface PhoneInputProps {
|
|
5
|
+
/**
|
|
6
|
+
* Full phone number as raw digits including the dial code prefix.
|
|
7
|
+
*
|
|
8
|
+
* @example "5516991234567" // Brazilian number
|
|
9
|
+
* @example "15551234567" // US number
|
|
10
|
+
*/
|
|
11
|
+
value?: string;
|
|
12
|
+
|
|
13
|
+
/** Called with raw digits (dial code + local) whenever the value changes */
|
|
14
|
+
onChange?: (value: string) => void;
|
|
15
|
+
|
|
16
|
+
/** Whether the input is disabled */
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
|
|
19
|
+
/** Size variant, forwarded to the underlying Ant Design components */
|
|
20
|
+
size?: 'large' | 'middle' | 'small';
|
|
21
|
+
|
|
22
|
+
/** Placeholder text shown inside the phone number input */
|
|
23
|
+
placeholder?: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* International phone input with a country selector.
|
|
28
|
+
*
|
|
29
|
+
* Integrates with antd Form: `value` and `onChange` deal in raw digits that include the
|
|
30
|
+
* dial code prefix — e.g. `"5516991234567"` for a Brazilian number or `"15551234567"` for
|
|
31
|
+
* a US number. The visible input applies a per-country mask for readability; `onChange`
|
|
32
|
+
* always fires with clean digits.
|
|
33
|
+
*/
|
|
34
|
+
export function PhoneInput(props: PhoneInputProps): JSX.Element;
|
|
35
|
+
|
|
36
|
+
export namespace PhoneInput {
|
|
37
|
+
/**
|
|
38
|
+
* Formats a raw international phone number (digits only, with dial code prefix) into a
|
|
39
|
+
* human-readable string that includes the country flag, dial code, and local mask.
|
|
40
|
+
*
|
|
41
|
+
* Returns an empty string when `fullDigits` is falsy.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* PhoneInput.format("5516991234567") // "🇧🇷 +55 (16) 99123-4567"
|
|
45
|
+
* PhoneInput.format("15551234567") // "🇺🇸 +1 (555) 123-4567"
|
|
46
|
+
* PhoneInput.format("351912345678") // "🇵🇹 +351 (91) 234-567"
|
|
47
|
+
*/
|
|
48
|
+
function format(fullDigits?: string): string;
|
|
49
|
+
}
|
package/dist/index.cjs
CHANGED
|
@@ -316,113 +316,10 @@ var __webpack_exports__ = {};
|
|
|
316
316
|
CodebitConfigProvider: ()=>CodebitConfigProvider,
|
|
317
317
|
ElectronicBrainOutlinedIcon: ()=>ElectronicBrainOutlinedIcon,
|
|
318
318
|
OllamaOutlinedIcon: ()=>OllamaOutlinedIcon,
|
|
319
|
+
PhoneInput: ()=>PhoneInput,
|
|
319
320
|
ThemeToggle: ()=>ThemeToggle
|
|
320
321
|
});
|
|
321
|
-
|
|
322
|
-
const icons_namespaceObject = require("@ant-design/icons");
|
|
323
|
-
var icons_default = /*#__PURE__*/ __webpack_require__.n(icons_namespaceObject);
|
|
324
|
-
const external_antd_namespaceObject = require("antd");
|
|
325
|
-
const external_prop_types_namespaceObject = require("prop-types");
|
|
326
|
-
var external_prop_types_default = /*#__PURE__*/ __webpack_require__.n(external_prop_types_namespaceObject);
|
|
327
|
-
var external_react_ = __webpack_require__("react");
|
|
328
|
-
const external_react_router_namespaceObject = require("react-router");
|
|
329
|
-
const react_namespaceObject = require("@sentry/react");
|
|
330
|
-
const codebit_web_namespaceObject = require("@codebit-programando-solucoes/codebit-web");
|
|
331
|
-
const logger = new codebit_web_namespaceObject.Logger('CodebitConfigContext');
|
|
332
|
-
const CodebitConfigContext = /*#__PURE__*/ (0, external_react_.createContext)(null);
|
|
333
|
-
function CodebitConfigProvider({ children, menuItems, version = '1.0', showVersion = ()=>true, secondarySidebar, secondarySidebarWidth = 280, bottomMenuItems, doLogout, checkLogin, onMenuClick }) {
|
|
334
|
-
const [isLogged, setIsLogged] = (0, external_react_.useState)(null);
|
|
335
|
-
const [user, setUser] = (0, external_react_.useState)(null);
|
|
336
|
-
const logout = async ()=>{
|
|
337
|
-
await doLogout();
|
|
338
|
-
setIsLogged(false);
|
|
339
|
-
setUser(null);
|
|
340
|
-
react_namespaceObject.setUser(null);
|
|
341
|
-
};
|
|
342
|
-
(0, external_react_.useEffect)(()=>{
|
|
343
|
-
if (null === isLogged) checkLogin().then((loggedUser)=>{
|
|
344
|
-
if (loggedUser) {
|
|
345
|
-
logger.trace('User data.', loggedUser);
|
|
346
|
-
setIsLogged(true);
|
|
347
|
-
setUser(loggedUser);
|
|
348
|
-
react_namespaceObject.setUser({
|
|
349
|
-
id: loggedUser.id,
|
|
350
|
-
email: loggedUser.email,
|
|
351
|
-
name: loggedUser.name
|
|
352
|
-
});
|
|
353
|
-
} else {
|
|
354
|
-
logger.trace('User not logged in.');
|
|
355
|
-
setIsLogged(false);
|
|
356
|
-
setUser(null);
|
|
357
|
-
react_namespaceObject.setUser(null);
|
|
358
|
-
}
|
|
359
|
-
}).catch((e)=>{
|
|
360
|
-
logger.error('Error fetching session state.', e);
|
|
361
|
-
setIsLogged(false);
|
|
362
|
-
setUser(null);
|
|
363
|
-
});
|
|
364
|
-
}, [
|
|
365
|
-
isLogged
|
|
366
|
-
]);
|
|
367
|
-
const contextValue = (0, external_react_.useMemo)(()=>({
|
|
368
|
-
menuItems,
|
|
369
|
-
isLogged,
|
|
370
|
-
setIsLogged,
|
|
371
|
-
user,
|
|
372
|
-
logout,
|
|
373
|
-
version,
|
|
374
|
-
showVersion,
|
|
375
|
-
secondarySidebar,
|
|
376
|
-
secondarySidebarWidth,
|
|
377
|
-
bottomMenuItems,
|
|
378
|
-
onMenuClick
|
|
379
|
-
}), [
|
|
380
|
-
menuItems,
|
|
381
|
-
isLogged,
|
|
382
|
-
user,
|
|
383
|
-
version,
|
|
384
|
-
showVersion,
|
|
385
|
-
secondarySidebar,
|
|
386
|
-
secondarySidebarWidth,
|
|
387
|
-
bottomMenuItems,
|
|
388
|
-
onMenuClick
|
|
389
|
-
]);
|
|
390
|
-
return /*#__PURE__*/ (0, jsx_runtime.jsx)(CodebitConfigContext.Provider, {
|
|
391
|
-
value: contextValue,
|
|
392
|
-
children: children
|
|
393
|
-
});
|
|
394
|
-
}
|
|
395
|
-
CodebitConfigProvider.propTypes = {
|
|
396
|
-
children: external_prop_types_default().node.isRequired,
|
|
397
|
-
menuItems: external_prop_types_default().func.isRequired,
|
|
398
|
-
version: external_prop_types_default().string,
|
|
399
|
-
showVersion: external_prop_types_default().func,
|
|
400
|
-
secondarySidebar: external_prop_types_default().func,
|
|
401
|
-
secondarySidebarWidth: external_prop_types_default().number,
|
|
402
|
-
bottomMenuItems: external_prop_types_default().func,
|
|
403
|
-
doLogout: external_prop_types_default().func.isRequired,
|
|
404
|
-
checkLogin: external_prop_types_default().func.isRequired,
|
|
405
|
-
onMenuClick: external_prop_types_default().func
|
|
406
|
-
};
|
|
407
|
-
const ThemeToggle = ()=>{
|
|
408
|
-
const config = (0, external_react_.useContext)(CodebitThemeContext);
|
|
409
|
-
if (!config) throw new Error('ThemeToggle must be used within CodebitThemeContext');
|
|
410
|
-
(0, external_react_.useEffect)(()=>{
|
|
411
|
-
document.documentElement.style.colorScheme = config.isDarkMode ? 'dark' : 'light';
|
|
412
|
-
}, [
|
|
413
|
-
config.isDarkMode
|
|
414
|
-
]);
|
|
415
|
-
return /*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.Switch, {
|
|
416
|
-
theme: config.isDarkMode ? 'dark' : 'light',
|
|
417
|
-
checked: config.isDarkMode,
|
|
418
|
-
onChange: (value)=>config.setIsDarkMode(value),
|
|
419
|
-
checkedChildren: /*#__PURE__*/ (0, jsx_runtime.jsx)(icons_namespaceObject.MoonOutlined, {}),
|
|
420
|
-
unCheckedChildren: /*#__PURE__*/ (0, jsx_runtime.jsx)(icons_namespaceObject.SunOutlined, {})
|
|
421
|
-
});
|
|
422
|
-
};
|
|
423
|
-
const external_react_i18next_namespaceObject = require("react-i18next");
|
|
424
|
-
const external_i18next_namespaceObject = require("i18next");
|
|
425
|
-
const pt = {
|
|
322
|
+
const locales_pt = {
|
|
426
323
|
codebitWebAntd: {
|
|
427
324
|
LoggedMainContainer: {
|
|
428
325
|
theme: 'Tema',
|
|
@@ -525,6 +422,35 @@ var __webpack_exports__ = {};
|
|
|
525
422
|
muteAudio: 'Ativar som',
|
|
526
423
|
unmuteAudio: 'Desativar som'
|
|
527
424
|
},
|
|
425
|
+
PhoneInput: {
|
|
426
|
+
countries: {
|
|
427
|
+
BR: 'Brasil',
|
|
428
|
+
US: 'EUA',
|
|
429
|
+
CA: 'Canadá',
|
|
430
|
+
MX: 'México',
|
|
431
|
+
AR: 'Argentina',
|
|
432
|
+
CL: 'Chile',
|
|
433
|
+
CO: 'Colômbia',
|
|
434
|
+
PE: 'Peru',
|
|
435
|
+
VE: 'Venezuela',
|
|
436
|
+
UY: 'Uruguai',
|
|
437
|
+
PY: 'Paraguai',
|
|
438
|
+
BO: 'Bolívia',
|
|
439
|
+
PT: 'Portugal',
|
|
440
|
+
ES: 'Espanha',
|
|
441
|
+
IT: 'Itália',
|
|
442
|
+
FR: 'França',
|
|
443
|
+
DE: 'Alemanha',
|
|
444
|
+
GB: 'Reino Unido',
|
|
445
|
+
AO: 'Angola',
|
|
446
|
+
MZ: 'Moçambique',
|
|
447
|
+
ZA: 'África do Sul',
|
|
448
|
+
CN: 'China',
|
|
449
|
+
JP: 'Japão',
|
|
450
|
+
IN: 'Índia',
|
|
451
|
+
AU: 'Austrália'
|
|
452
|
+
}
|
|
453
|
+
},
|
|
528
454
|
Common: {
|
|
529
455
|
ok: 'Ok',
|
|
530
456
|
close: 'Fechar',
|
|
@@ -534,7 +460,7 @@ var __webpack_exports__ = {};
|
|
|
534
460
|
}
|
|
535
461
|
}
|
|
536
462
|
};
|
|
537
|
-
const
|
|
463
|
+
const locales_en = {
|
|
538
464
|
codebitWebAntd: {
|
|
539
465
|
LoggedMainContainer: {
|
|
540
466
|
theme: 'Theme',
|
|
@@ -637,6 +563,35 @@ var __webpack_exports__ = {};
|
|
|
637
563
|
muteAudio: 'Mute audio',
|
|
638
564
|
unmuteAudio: 'Unmute audio'
|
|
639
565
|
},
|
|
566
|
+
PhoneInput: {
|
|
567
|
+
countries: {
|
|
568
|
+
BR: 'Brazil',
|
|
569
|
+
US: 'USA',
|
|
570
|
+
CA: 'Canada',
|
|
571
|
+
MX: 'Mexico',
|
|
572
|
+
AR: 'Argentina',
|
|
573
|
+
CL: 'Chile',
|
|
574
|
+
CO: 'Colombia',
|
|
575
|
+
PE: 'Peru',
|
|
576
|
+
VE: 'Venezuela',
|
|
577
|
+
UY: 'Uruguay',
|
|
578
|
+
PY: 'Paraguay',
|
|
579
|
+
BO: 'Bolivia',
|
|
580
|
+
PT: 'Portugal',
|
|
581
|
+
ES: 'Spain',
|
|
582
|
+
IT: 'Italy',
|
|
583
|
+
FR: 'France',
|
|
584
|
+
DE: 'Germany',
|
|
585
|
+
GB: 'United Kingdom',
|
|
586
|
+
AO: 'Angola',
|
|
587
|
+
MZ: 'Mozambique',
|
|
588
|
+
ZA: 'South Africa',
|
|
589
|
+
CN: 'China',
|
|
590
|
+
JP: 'Japan',
|
|
591
|
+
IN: 'India',
|
|
592
|
+
AU: 'Australia'
|
|
593
|
+
}
|
|
594
|
+
},
|
|
640
595
|
Common: {
|
|
641
596
|
ok: 'Ok',
|
|
642
597
|
close: 'Close',
|
|
@@ -646,11 +601,115 @@ var __webpack_exports__ = {};
|
|
|
646
601
|
}
|
|
647
602
|
}
|
|
648
603
|
};
|
|
604
|
+
var jsx_runtime = __webpack_require__("../../node_modules/.pnpm/react@19.2.3/node_modules/react/jsx-runtime.js");
|
|
605
|
+
const icons_namespaceObject = require("@ant-design/icons");
|
|
606
|
+
var icons_default = /*#__PURE__*/ __webpack_require__.n(icons_namespaceObject);
|
|
607
|
+
const external_antd_namespaceObject = require("antd");
|
|
608
|
+
const external_prop_types_namespaceObject = require("prop-types");
|
|
609
|
+
var external_prop_types_default = /*#__PURE__*/ __webpack_require__.n(external_prop_types_namespaceObject);
|
|
610
|
+
var external_react_ = __webpack_require__("react");
|
|
611
|
+
const external_react_router_namespaceObject = require("react-router");
|
|
612
|
+
const react_namespaceObject = require("@sentry/react");
|
|
613
|
+
const codebit_web_namespaceObject = require("@codebit-programando-solucoes/codebit-web");
|
|
614
|
+
const logger = new codebit_web_namespaceObject.Logger('CodebitConfigContext');
|
|
615
|
+
const CodebitConfigContext = /*#__PURE__*/ (0, external_react_.createContext)(null);
|
|
616
|
+
function CodebitConfigProvider({ children, menuItems, version = '1.0', showVersion = ()=>true, secondarySidebar, secondarySidebarWidth = 280, bottomMenuItems, doLogout, checkLogin, onMenuClick }) {
|
|
617
|
+
const [isLogged, setIsLogged] = (0, external_react_.useState)(null);
|
|
618
|
+
const [user, setUser] = (0, external_react_.useState)(null);
|
|
619
|
+
const logout = async ()=>{
|
|
620
|
+
await doLogout();
|
|
621
|
+
setIsLogged(false);
|
|
622
|
+
setUser(null);
|
|
623
|
+
react_namespaceObject.setUser(null);
|
|
624
|
+
};
|
|
625
|
+
(0, external_react_.useEffect)(()=>{
|
|
626
|
+
if (null === isLogged) checkLogin().then((loggedUser)=>{
|
|
627
|
+
if (loggedUser) {
|
|
628
|
+
logger.trace('User data.', loggedUser);
|
|
629
|
+
setIsLogged(true);
|
|
630
|
+
setUser(loggedUser);
|
|
631
|
+
react_namespaceObject.setUser({
|
|
632
|
+
id: loggedUser.id,
|
|
633
|
+
email: loggedUser.email,
|
|
634
|
+
name: loggedUser.name
|
|
635
|
+
});
|
|
636
|
+
} else {
|
|
637
|
+
logger.trace('User not logged in.');
|
|
638
|
+
setIsLogged(false);
|
|
639
|
+
setUser(null);
|
|
640
|
+
react_namespaceObject.setUser(null);
|
|
641
|
+
}
|
|
642
|
+
}).catch((e)=>{
|
|
643
|
+
logger.error('Error fetching session state.', e);
|
|
644
|
+
setIsLogged(false);
|
|
645
|
+
setUser(null);
|
|
646
|
+
});
|
|
647
|
+
}, [
|
|
648
|
+
isLogged
|
|
649
|
+
]);
|
|
650
|
+
const contextValue = (0, external_react_.useMemo)(()=>({
|
|
651
|
+
menuItems,
|
|
652
|
+
isLogged,
|
|
653
|
+
setIsLogged,
|
|
654
|
+
user,
|
|
655
|
+
logout,
|
|
656
|
+
version,
|
|
657
|
+
showVersion,
|
|
658
|
+
secondarySidebar,
|
|
659
|
+
secondarySidebarWidth,
|
|
660
|
+
bottomMenuItems,
|
|
661
|
+
onMenuClick
|
|
662
|
+
}), [
|
|
663
|
+
menuItems,
|
|
664
|
+
isLogged,
|
|
665
|
+
user,
|
|
666
|
+
version,
|
|
667
|
+
showVersion,
|
|
668
|
+
secondarySidebar,
|
|
669
|
+
secondarySidebarWidth,
|
|
670
|
+
bottomMenuItems,
|
|
671
|
+
onMenuClick
|
|
672
|
+
]);
|
|
673
|
+
return /*#__PURE__*/ (0, jsx_runtime.jsx)(CodebitConfigContext.Provider, {
|
|
674
|
+
value: contextValue,
|
|
675
|
+
children: children
|
|
676
|
+
});
|
|
677
|
+
}
|
|
678
|
+
CodebitConfigProvider.propTypes = {
|
|
679
|
+
children: external_prop_types_default().node.isRequired,
|
|
680
|
+
menuItems: external_prop_types_default().func.isRequired,
|
|
681
|
+
version: external_prop_types_default().string,
|
|
682
|
+
showVersion: external_prop_types_default().func,
|
|
683
|
+
secondarySidebar: external_prop_types_default().func,
|
|
684
|
+
secondarySidebarWidth: external_prop_types_default().number,
|
|
685
|
+
bottomMenuItems: external_prop_types_default().func,
|
|
686
|
+
doLogout: external_prop_types_default().func.isRequired,
|
|
687
|
+
checkLogin: external_prop_types_default().func.isRequired,
|
|
688
|
+
onMenuClick: external_prop_types_default().func
|
|
689
|
+
};
|
|
690
|
+
const ThemeToggle = ()=>{
|
|
691
|
+
const config = (0, external_react_.useContext)(CodebitThemeContext);
|
|
692
|
+
if (!config) throw new Error('ThemeToggle must be used within CodebitThemeContext');
|
|
693
|
+
(0, external_react_.useEffect)(()=>{
|
|
694
|
+
document.documentElement.style.colorScheme = config.isDarkMode ? 'dark' : 'light';
|
|
695
|
+
}, [
|
|
696
|
+
config.isDarkMode
|
|
697
|
+
]);
|
|
698
|
+
return /*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.Switch, {
|
|
699
|
+
theme: config.isDarkMode ? 'dark' : 'light',
|
|
700
|
+
checked: config.isDarkMode,
|
|
701
|
+
onChange: (value)=>config.setIsDarkMode(value),
|
|
702
|
+
checkedChildren: /*#__PURE__*/ (0, jsx_runtime.jsx)(icons_namespaceObject.MoonOutlined, {}),
|
|
703
|
+
unCheckedChildren: /*#__PURE__*/ (0, jsx_runtime.jsx)(icons_namespaceObject.SunOutlined, {})
|
|
704
|
+
});
|
|
705
|
+
};
|
|
706
|
+
const external_react_i18next_namespaceObject = require("react-i18next");
|
|
707
|
+
const external_i18next_namespaceObject = require("i18next");
|
|
649
708
|
const i18nLib = external_i18next_namespaceObject.createInstance();
|
|
650
709
|
i18nLib.use(external_react_i18next_namespaceObject.initReactI18next).init({
|
|
651
710
|
resources: {
|
|
652
|
-
pt:
|
|
653
|
-
en:
|
|
711
|
+
pt: locales_pt,
|
|
712
|
+
en: locales_en
|
|
654
713
|
},
|
|
655
714
|
lng: 'pt',
|
|
656
715
|
fallbackLng: 'pt',
|
|
@@ -1114,10 +1173,9 @@ var __webpack_exports__ = {};
|
|
|
1114
1173
|
})
|
|
1115
1174
|
]
|
|
1116
1175
|
}),
|
|
1117
|
-
/*#__PURE__*/ (0, jsx_runtime.jsx)(
|
|
1176
|
+
/*#__PURE__*/ (0, jsx_runtime.jsx)("div", {
|
|
1118
1177
|
className: AudioPlayer_module.durationTimeContainer,
|
|
1119
1178
|
children: /*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.Typography.Text, {
|
|
1120
|
-
strong: true,
|
|
1121
1179
|
children: `${formatTime(currentTime)} / ${formatTime(duration)}`
|
|
1122
1180
|
})
|
|
1123
1181
|
})
|
|
@@ -1148,6 +1206,322 @@ var __webpack_exports__ = {};
|
|
|
1148
1206
|
AudioPlayer.propTypes = {
|
|
1149
1207
|
audioUrl: external_prop_types_default().string.isRequired
|
|
1150
1208
|
};
|
|
1209
|
+
const PhoneInput_module = {
|
|
1210
|
+
container: "container-IJ_oCC",
|
|
1211
|
+
countrySelect: "countrySelect-hsVqWh",
|
|
1212
|
+
phoneInput: "phoneInput-Pz8eaz"
|
|
1213
|
+
};
|
|
1214
|
+
const COUNTRIES = [
|
|
1215
|
+
{
|
|
1216
|
+
code: 'BR',
|
|
1217
|
+
dialCode: '55',
|
|
1218
|
+
flag: '🇧🇷',
|
|
1219
|
+
maxLocalDigits: 11
|
|
1220
|
+
},
|
|
1221
|
+
{
|
|
1222
|
+
code: 'US',
|
|
1223
|
+
dialCode: '1',
|
|
1224
|
+
flag: '🇺🇸',
|
|
1225
|
+
maxLocalDigits: 10
|
|
1226
|
+
},
|
|
1227
|
+
{
|
|
1228
|
+
code: 'CA',
|
|
1229
|
+
dialCode: '1',
|
|
1230
|
+
flag: '🇨🇦',
|
|
1231
|
+
maxLocalDigits: 10
|
|
1232
|
+
},
|
|
1233
|
+
{
|
|
1234
|
+
code: 'MX',
|
|
1235
|
+
dialCode: '52',
|
|
1236
|
+
flag: '🇲🇽',
|
|
1237
|
+
maxLocalDigits: 10
|
|
1238
|
+
},
|
|
1239
|
+
{
|
|
1240
|
+
code: 'AR',
|
|
1241
|
+
dialCode: '54',
|
|
1242
|
+
flag: '🇦🇷',
|
|
1243
|
+
maxLocalDigits: 10
|
|
1244
|
+
},
|
|
1245
|
+
{
|
|
1246
|
+
code: 'CL',
|
|
1247
|
+
dialCode: '56',
|
|
1248
|
+
flag: '🇨🇱',
|
|
1249
|
+
maxLocalDigits: 9
|
|
1250
|
+
},
|
|
1251
|
+
{
|
|
1252
|
+
code: 'CO',
|
|
1253
|
+
dialCode: '57',
|
|
1254
|
+
flag: '🇨🇴',
|
|
1255
|
+
maxLocalDigits: 10
|
|
1256
|
+
},
|
|
1257
|
+
{
|
|
1258
|
+
code: 'PE',
|
|
1259
|
+
dialCode: '51',
|
|
1260
|
+
flag: '🇵🇪',
|
|
1261
|
+
maxLocalDigits: 9
|
|
1262
|
+
},
|
|
1263
|
+
{
|
|
1264
|
+
code: 'VE',
|
|
1265
|
+
dialCode: '58',
|
|
1266
|
+
flag: '🇻🇪',
|
|
1267
|
+
maxLocalDigits: 10
|
|
1268
|
+
},
|
|
1269
|
+
{
|
|
1270
|
+
code: 'UY',
|
|
1271
|
+
dialCode: '598',
|
|
1272
|
+
flag: '🇺🇾',
|
|
1273
|
+
maxLocalDigits: 8
|
|
1274
|
+
},
|
|
1275
|
+
{
|
|
1276
|
+
code: 'PY',
|
|
1277
|
+
dialCode: '595',
|
|
1278
|
+
flag: '🇵🇾',
|
|
1279
|
+
maxLocalDigits: 9
|
|
1280
|
+
},
|
|
1281
|
+
{
|
|
1282
|
+
code: 'BO',
|
|
1283
|
+
dialCode: '591',
|
|
1284
|
+
flag: '🇧🇴',
|
|
1285
|
+
maxLocalDigits: 8
|
|
1286
|
+
},
|
|
1287
|
+
{
|
|
1288
|
+
code: 'PT',
|
|
1289
|
+
dialCode: '351',
|
|
1290
|
+
flag: '🇵🇹',
|
|
1291
|
+
maxLocalDigits: 9
|
|
1292
|
+
},
|
|
1293
|
+
{
|
|
1294
|
+
code: 'ES',
|
|
1295
|
+
dialCode: '34',
|
|
1296
|
+
flag: '🇪🇸',
|
|
1297
|
+
maxLocalDigits: 9
|
|
1298
|
+
},
|
|
1299
|
+
{
|
|
1300
|
+
code: 'IT',
|
|
1301
|
+
dialCode: '39',
|
|
1302
|
+
flag: '🇮🇹',
|
|
1303
|
+
maxLocalDigits: 10
|
|
1304
|
+
},
|
|
1305
|
+
{
|
|
1306
|
+
code: 'FR',
|
|
1307
|
+
dialCode: '33',
|
|
1308
|
+
flag: '🇫🇷',
|
|
1309
|
+
maxLocalDigits: 9
|
|
1310
|
+
},
|
|
1311
|
+
{
|
|
1312
|
+
code: 'DE',
|
|
1313
|
+
dialCode: '49',
|
|
1314
|
+
flag: '🇩🇪',
|
|
1315
|
+
maxLocalDigits: 11
|
|
1316
|
+
},
|
|
1317
|
+
{
|
|
1318
|
+
code: 'GB',
|
|
1319
|
+
dialCode: '44',
|
|
1320
|
+
flag: '🇬🇧',
|
|
1321
|
+
maxLocalDigits: 10
|
|
1322
|
+
},
|
|
1323
|
+
{
|
|
1324
|
+
code: 'AO',
|
|
1325
|
+
dialCode: '244',
|
|
1326
|
+
flag: '🇦🇴',
|
|
1327
|
+
maxLocalDigits: 9
|
|
1328
|
+
},
|
|
1329
|
+
{
|
|
1330
|
+
code: 'MZ',
|
|
1331
|
+
dialCode: '258',
|
|
1332
|
+
flag: '🇲🇿',
|
|
1333
|
+
maxLocalDigits: 9
|
|
1334
|
+
},
|
|
1335
|
+
{
|
|
1336
|
+
code: 'ZA',
|
|
1337
|
+
dialCode: '27',
|
|
1338
|
+
flag: '🇿🇦',
|
|
1339
|
+
maxLocalDigits: 9
|
|
1340
|
+
},
|
|
1341
|
+
{
|
|
1342
|
+
code: 'CN',
|
|
1343
|
+
dialCode: '86',
|
|
1344
|
+
flag: '🇨🇳',
|
|
1345
|
+
maxLocalDigits: 11
|
|
1346
|
+
},
|
|
1347
|
+
{
|
|
1348
|
+
code: 'JP',
|
|
1349
|
+
dialCode: '81',
|
|
1350
|
+
flag: '🇯🇵',
|
|
1351
|
+
maxLocalDigits: 10
|
|
1352
|
+
},
|
|
1353
|
+
{
|
|
1354
|
+
code: 'IN',
|
|
1355
|
+
dialCode: '91',
|
|
1356
|
+
flag: '🇮🇳',
|
|
1357
|
+
maxLocalDigits: 10
|
|
1358
|
+
},
|
|
1359
|
+
{
|
|
1360
|
+
code: 'AU',
|
|
1361
|
+
dialCode: '61',
|
|
1362
|
+
flag: '🇦🇺',
|
|
1363
|
+
maxLocalDigits: 9
|
|
1364
|
+
}
|
|
1365
|
+
];
|
|
1366
|
+
function applyBrMask(digits) {
|
|
1367
|
+
if (digits.length <= 2) return `(${digits}`;
|
|
1368
|
+
if (digits.length <= 7) return `(${digits.slice(0, 2)}) ${digits.slice(2)}`;
|
|
1369
|
+
if (digits.length <= 10) return `(${digits.slice(0, 2)}) ${digits.slice(2, 6)}-${digits.slice(6)}`;
|
|
1370
|
+
return `(${digits.slice(0, 2)}) ${digits.slice(2, 7)}-${digits.slice(7, 11)}`;
|
|
1371
|
+
}
|
|
1372
|
+
function applyUsMask(digits) {
|
|
1373
|
+
if (digits.length <= 3) return `(${digits}`;
|
|
1374
|
+
if (digits.length <= 6) return `(${digits.slice(0, 3)}) ${digits.slice(3)}`;
|
|
1375
|
+
return `(${digits.slice(0, 3)}) ${digits.slice(3, 6)}-${digits.slice(6, 10)}`;
|
|
1376
|
+
}
|
|
1377
|
+
function applyArMask(digits) {
|
|
1378
|
+
if (digits.length <= 2) return `(${digits}`;
|
|
1379
|
+
if (digits.length <= 6) return `(${digits.slice(0, 2)}) ${digits.slice(2)}`;
|
|
1380
|
+
return `(${digits.slice(0, 2)}) ${digits.slice(2, 6)}-${digits.slice(6, 10)}`;
|
|
1381
|
+
}
|
|
1382
|
+
function applyGenericMask(digits, areaLen, totalLen) {
|
|
1383
|
+
if (digits.length <= areaLen) return `(${digits}`;
|
|
1384
|
+
const area = digits.slice(0, areaLen);
|
|
1385
|
+
const rest = digits.slice(areaLen, totalLen);
|
|
1386
|
+
const mid = Math.floor(rest.length / 2 + rest.length % 2);
|
|
1387
|
+
if (rest.length <= mid) return `(${area}) ${rest}`;
|
|
1388
|
+
return `(${area}) ${rest.slice(0, mid)}-${rest.slice(mid)}`;
|
|
1389
|
+
}
|
|
1390
|
+
function applyMask(digits, countryCode) {
|
|
1391
|
+
switch(countryCode){
|
|
1392
|
+
case 'BR':
|
|
1393
|
+
return applyBrMask(digits);
|
|
1394
|
+
case 'US':
|
|
1395
|
+
case 'CA':
|
|
1396
|
+
return applyUsMask(digits);
|
|
1397
|
+
case 'MX':
|
|
1398
|
+
case 'CO':
|
|
1399
|
+
case 'VE':
|
|
1400
|
+
return applyGenericMask(digits, 2, 10);
|
|
1401
|
+
case 'AR':
|
|
1402
|
+
return applyArMask(digits);
|
|
1403
|
+
case 'CL':
|
|
1404
|
+
case 'PE':
|
|
1405
|
+
case 'PT':
|
|
1406
|
+
case 'ES':
|
|
1407
|
+
case 'AU':
|
|
1408
|
+
case 'ZA':
|
|
1409
|
+
case 'AO':
|
|
1410
|
+
case 'MZ':
|
|
1411
|
+
return applyGenericMask(digits, 2, 9);
|
|
1412
|
+
case 'UY':
|
|
1413
|
+
case 'BO':
|
|
1414
|
+
return applyGenericMask(digits, 1, 8);
|
|
1415
|
+
case 'PY':
|
|
1416
|
+
return applyGenericMask(digits, 3, 9);
|
|
1417
|
+
case 'FR':
|
|
1418
|
+
return applyGenericMask(digits, 2, 9);
|
|
1419
|
+
case 'IT':
|
|
1420
|
+
return applyGenericMask(digits, 3, 10);
|
|
1421
|
+
case 'DE':
|
|
1422
|
+
return applyGenericMask(digits, 3, 11);
|
|
1423
|
+
case 'GB':
|
|
1424
|
+
return applyGenericMask(digits, 4, 10);
|
|
1425
|
+
case 'CN':
|
|
1426
|
+
return applyGenericMask(digits, 3, 11);
|
|
1427
|
+
case 'JP':
|
|
1428
|
+
return applyGenericMask(digits, 3, 10);
|
|
1429
|
+
case 'IN':
|
|
1430
|
+
return applyGenericMask(digits, 5, 10);
|
|
1431
|
+
default:
|
|
1432
|
+
return digits;
|
|
1433
|
+
}
|
|
1434
|
+
}
|
|
1435
|
+
function detectCountry(fullDigits) {
|
|
1436
|
+
if (!fullDigits) return COUNTRIES[0];
|
|
1437
|
+
const sorted = [
|
|
1438
|
+
...COUNTRIES
|
|
1439
|
+
].sort((a, b)=>b.dialCode.length - a.dialCode.length);
|
|
1440
|
+
for (const c of sorted)if (fullDigits.startsWith(c.dialCode)) return c;
|
|
1441
|
+
return COUNTRIES[0];
|
|
1442
|
+
}
|
|
1443
|
+
const PhoneInput = ({ value, onChange, disabled, size, placeholder })=>{
|
|
1444
|
+
const { t } = useCodebitWebAntdTranslation();
|
|
1445
|
+
const countrySearchLabel = (c)=>{
|
|
1446
|
+
const name = t(`PhoneInput.countries.${c.code}`);
|
|
1447
|
+
return `${c.flag} ${name} +${c.dialCode}`;
|
|
1448
|
+
};
|
|
1449
|
+
const [selectedCountry, setSelectedCountry] = (0, external_react_.useState)(()=>detectCountry(value));
|
|
1450
|
+
const [displayValue, setDisplayValue] = (0, external_react_.useState)(()=>{
|
|
1451
|
+
if (!value) return '';
|
|
1452
|
+
const country = detectCountry(value);
|
|
1453
|
+
const localDigits = value.slice(country.dialCode.length);
|
|
1454
|
+
return applyMask(localDigits, country.code);
|
|
1455
|
+
});
|
|
1456
|
+
(0, external_react_.useEffect)(()=>{
|
|
1457
|
+
if (!value) return void setDisplayValue('');
|
|
1458
|
+
const country = detectCountry(value);
|
|
1459
|
+
setSelectedCountry(country);
|
|
1460
|
+
const localDigits = value.slice(country.dialCode.length);
|
|
1461
|
+
setDisplayValue(applyMask(localDigits, country.code));
|
|
1462
|
+
}, [
|
|
1463
|
+
value
|
|
1464
|
+
]);
|
|
1465
|
+
const handleCountryChange = (countryCode)=>{
|
|
1466
|
+
const country = COUNTRIES.find((c)=>c.code === countryCode) ?? COUNTRIES[0];
|
|
1467
|
+
setSelectedCountry(country);
|
|
1468
|
+
setDisplayValue('');
|
|
1469
|
+
onChange?.('');
|
|
1470
|
+
};
|
|
1471
|
+
const handleInputChange = (e)=>{
|
|
1472
|
+
const rawDigits = e.target.value.replaceAll(/\D/g, '').slice(0, selectedCountry.maxLocalDigits);
|
|
1473
|
+
setDisplayValue(applyMask(rawDigits, selectedCountry.code));
|
|
1474
|
+
onChange?.(selectedCountry.dialCode + rawDigits);
|
|
1475
|
+
};
|
|
1476
|
+
return /*#__PURE__*/ (0, jsx_runtime.jsxs)(external_antd_namespaceObject.Input.Group, {
|
|
1477
|
+
compact: true,
|
|
1478
|
+
className: PhoneInput_module.container,
|
|
1479
|
+
children: [
|
|
1480
|
+
/*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.Select, {
|
|
1481
|
+
value: selectedCountry.code,
|
|
1482
|
+
onChange: handleCountryChange,
|
|
1483
|
+
disabled: disabled,
|
|
1484
|
+
size: size,
|
|
1485
|
+
className: PhoneInput_module.countrySelect,
|
|
1486
|
+
popupMatchSelectWidth: false,
|
|
1487
|
+
showSearch: true,
|
|
1488
|
+
filterOption: (input, option)=>option?.searchLabel?.toLowerCase().includes(input.toLowerCase()) ?? false,
|
|
1489
|
+
options: COUNTRIES.map((c)=>({
|
|
1490
|
+
value: c.code,
|
|
1491
|
+
label: `${c.flag} +${c.dialCode}`,
|
|
1492
|
+
searchLabel: countrySearchLabel(c)
|
|
1493
|
+
})),
|
|
1494
|
+
optionRender: (option)=>option.data.searchLabel
|
|
1495
|
+
}),
|
|
1496
|
+
/*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.Input, {
|
|
1497
|
+
value: displayValue,
|
|
1498
|
+
onChange: handleInputChange,
|
|
1499
|
+
disabled: disabled,
|
|
1500
|
+
size: size,
|
|
1501
|
+
placeholder: placeholder,
|
|
1502
|
+
className: PhoneInput_module.phoneInput
|
|
1503
|
+
})
|
|
1504
|
+
]
|
|
1505
|
+
});
|
|
1506
|
+
};
|
|
1507
|
+
PhoneInput.propTypes = {
|
|
1508
|
+
value: external_prop_types_default().string,
|
|
1509
|
+
onChange: external_prop_types_default().func,
|
|
1510
|
+
disabled: external_prop_types_default().bool,
|
|
1511
|
+
size: external_prop_types_default().oneOf([
|
|
1512
|
+
'large',
|
|
1513
|
+
'middle',
|
|
1514
|
+
'small'
|
|
1515
|
+
]),
|
|
1516
|
+
placeholder: external_prop_types_default().string
|
|
1517
|
+
};
|
|
1518
|
+
PhoneInput.format = (fullDigits)=>{
|
|
1519
|
+
if (!fullDigits) return '';
|
|
1520
|
+
const country = detectCountry(fullDigits);
|
|
1521
|
+
const localDigits = fullDigits.slice(country.dialCode.length);
|
|
1522
|
+
const masked = applyMask(localDigits, country.code);
|
|
1523
|
+
return `${country.flag} +${country.dialCode} ${masked}`;
|
|
1524
|
+
};
|
|
1151
1525
|
const CodebitThemeContext = /*#__PURE__*/ (0, external_react_.createContext)(null);
|
|
1152
1526
|
const CodebitThemeProvider = ({ children, storeThemeInLocalStorage = true, containerId = 'root', forcedTheme = null, ...props })=>{
|
|
1153
1527
|
const hasLoaded = (0, external_react_.useRef)(false);
|
|
@@ -2320,6 +2694,7 @@ exports.LoggedMainContainer = __webpack_exports__.LoggedMainContainer;
|
|
|
2320
2694
|
exports.Login = __webpack_exports__.Login;
|
|
2321
2695
|
exports.LoginContainer = __webpack_exports__.LoginContainer;
|
|
2322
2696
|
exports.OllamaOutlinedIcon = __webpack_exports__.OllamaOutlinedIcon;
|
|
2697
|
+
exports.PhoneInput = __webpack_exports__.PhoneInput;
|
|
2323
2698
|
exports.TableContainer = __webpack_exports__.TableContainer;
|
|
2324
2699
|
exports.ThemeToggle = __webpack_exports__.ThemeToggle;
|
|
2325
2700
|
exports.useErrorMessage = __webpack_exports__.useErrorMessage;
|
|
@@ -2346,6 +2721,7 @@ for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
|
2346
2721
|
"Login",
|
|
2347
2722
|
"LoginContainer",
|
|
2348
2723
|
"OllamaOutlinedIcon",
|
|
2724
|
+
"PhoneInput",
|
|
2349
2725
|
"TableContainer",
|
|
2350
2726
|
"ThemeToggle",
|
|
2351
2727
|
"useErrorMessage",
|
package/dist/index.css
CHANGED
|
@@ -74,7 +74,6 @@ html.dark-theme {
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
.audioPlayer-a4xARM {
|
|
77
|
-
padding: var(--antd-padding);
|
|
78
77
|
gap: var(--antd-padding-sm);
|
|
79
78
|
border-radius: 8px;
|
|
80
79
|
flex-direction: column;
|
|
@@ -82,8 +81,7 @@ html.dark-theme {
|
|
|
82
81
|
}
|
|
83
82
|
|
|
84
83
|
.audioPlayer-a4xARM .durationTimeContainer-kmkK6M {
|
|
85
|
-
|
|
86
|
-
width: 100%;
|
|
84
|
+
text-align: right;
|
|
87
85
|
}
|
|
88
86
|
|
|
89
87
|
.audioPlayer-a4xARM .slider-bdta4v {
|
|
@@ -91,6 +89,21 @@ html.dark-theme {
|
|
|
91
89
|
min-width: 100px;
|
|
92
90
|
}
|
|
93
91
|
|
|
92
|
+
.container-IJ_oCC {
|
|
93
|
+
width: 100%;
|
|
94
|
+
display: flex !important;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.countrySelect-hsVqWh {
|
|
98
|
+
flex-shrink: 0;
|
|
99
|
+
width: 110px !important;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.phoneInput-Pz8eaz {
|
|
103
|
+
flex: 1;
|
|
104
|
+
min-width: 0;
|
|
105
|
+
}
|
|
106
|
+
|
|
94
107
|
.layout-mL5o6I {
|
|
95
108
|
height: 100vh;
|
|
96
109
|
position: fixed;
|