@crowdin/app-project-module 2.1.0 → 2.3.0
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/out/index.d.ts +1 -0
- package/out/index.js +5 -1
- package/out/middlewares/ui-module.js +1 -2
- package/out/modules/about.d.ts +4 -0
- package/out/modules/about.js +25 -3
- package/out/modules/advisor-inspector/handlers/recheck.d.ts +4 -0
- package/out/modules/advisor-inspector/handlers/recheck.js +44 -0
- package/out/modules/advisor-inspector/index.d.ts +6 -0
- package/out/modules/advisor-inspector/index.js +35 -0
- package/out/modules/advisor-inspector/key.d.ts +4 -0
- package/out/modules/advisor-inspector/key.js +13 -0
- package/out/modules/advisor-inspector/report-insight.d.ts +3 -0
- package/out/modules/advisor-inspector/report-insight.js +61 -0
- package/out/modules/advisor-inspector/types.d.ts +59 -0
- package/out/modules/advisor-inspector/types.js +2 -0
- package/out/modules/manifest.js +15 -0
- package/out/static/css/styles.css +2 -342
- package/out/static/ui/about.bundle.js +542 -0
- package/out/static/ui/about.bundle.js.map +1 -0
- package/out/static/ui/error.bundle.js +120 -2
- package/out/static/ui/error.bundle.js.map +1 -1
- package/out/static/ui/form.bundle.js +164 -12
- package/out/static/ui/form.bundle.js.map +1 -1
- package/out/static/ui/install.bundle.js +8 -2
- package/out/static/ui/install.bundle.js.map +1 -1
- package/out/static/ui/login.bundle.js +425 -35
- package/out/static/ui/login.bundle.js.map +1 -1
- package/out/static/ui/main.bundle.js +718 -366
- package/out/static/ui/main.bundle.js.map +1 -1
- package/out/static/ui/oauth.bundle.js +8 -2
- package/out/static/ui/oauth.bundle.js.map +1 -1
- package/out/static/ui/subscription.bundle.js +542 -0
- package/out/static/ui/subscription.bundle.js.map +1 -0
- package/out/storage/drizzle/postgresql/migrations/0002_equal_skrulls.sql +3 -0
- package/out/storage/drizzle/postgresql/migrations/meta/0002_snapshot.json +646 -0
- package/out/storage/drizzle/postgresql/migrations/meta/_journal.json +7 -0
- package/out/storage/drizzle/postgresql/schema.js +2 -1
- package/out/storage/drizzle/sqlite/migrations/0001_new_rhodey.sql +26 -0
- package/out/storage/drizzle/sqlite/migrations/meta/0001_snapshot.json +687 -0
- package/out/storage/drizzle/sqlite/migrations/meta/_journal.json +7 -0
- package/out/storage/drizzle/sqlite/schema.js +2 -1
- package/out/types.d.ts +6 -0
- package/out/util/jsx-renderer.d.ts +2 -1
- package/out/util/jsx-renderer.js +8 -8
- package/out/views/FormPage.js +2 -2
- package/out/views/index.d.ts +0 -2
- package/out/views/index.js +1 -5
- package/out/views/layout/Head.js +0 -10
- package/package.json +5 -2
- package/out/static/css/about.css +0 -128
- package/out/static/css/crowdin-ui-colors.css +0 -115
- package/out/static/js/dependent.js +0 -315
- package/out/static/js/main.js +0 -96
- package/out/static/js/polyfills/fetch.js +0 -494
- package/out/static/js/polyfills/promise.js +0 -375
- package/out/views/AboutPage.d.ts +0 -10
- package/out/views/AboutPage.js +0 -88
- package/out/views/SubscriptionPage.d.ts +0 -7
- package/out/views/SubscriptionPage.js +0 -26
|
@@ -518,9 +518,368 @@
|
|
|
518
518
|
|
|
519
519
|
var clientExports = requireClient();
|
|
520
520
|
|
|
521
|
+
/// <reference path="../types.d.ts" />
|
|
522
|
+
const postPromises = {};
|
|
523
|
+
let isInitialized = false;
|
|
524
|
+
let origin = null;
|
|
525
|
+
let clientId = null;
|
|
526
|
+
let restParams = '';
|
|
527
|
+
function parseJson(value) {
|
|
528
|
+
try {
|
|
529
|
+
return JSON.parse(value);
|
|
530
|
+
}
|
|
531
|
+
catch {
|
|
532
|
+
return undefined;
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
function handleMessage(event) {
|
|
536
|
+
if (event.origin !== window.location.origin || typeof event.data !== 'string') {
|
|
537
|
+
return;
|
|
538
|
+
}
|
|
539
|
+
const eventData = parseJson(event.data);
|
|
540
|
+
if (!(eventData === null || eventData === void 0 ? void 0 : eventData.uid)) {
|
|
541
|
+
return;
|
|
542
|
+
}
|
|
543
|
+
const postPromise = postPromises[eventData.uid];
|
|
544
|
+
if (postPromise) {
|
|
545
|
+
delete postPromises[eventData.uid];
|
|
546
|
+
if (postPromise.timer) {
|
|
547
|
+
clearTimeout(postPromise.timer);
|
|
548
|
+
}
|
|
549
|
+
postPromise.resolve(eventData.data);
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
function initializeCrowdinIframeContext() {
|
|
553
|
+
if (isInitialized) {
|
|
554
|
+
return;
|
|
555
|
+
}
|
|
556
|
+
const urlParams = new URLSearchParams(window.location.search);
|
|
557
|
+
origin = urlParams.get('origin');
|
|
558
|
+
clientId = urlParams.get('client_id');
|
|
559
|
+
restParams = window.location.search;
|
|
560
|
+
JSON.parse(window.name);
|
|
561
|
+
window.addEventListener('message', handleMessage);
|
|
562
|
+
isInitialized = true;
|
|
563
|
+
}
|
|
564
|
+
function ensureInitialized() {
|
|
565
|
+
if (!isInitialized) {
|
|
566
|
+
initializeCrowdinIframeContext();
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
function getPostPromises() {
|
|
570
|
+
ensureInitialized();
|
|
571
|
+
return postPromises;
|
|
572
|
+
}
|
|
573
|
+
function showToast(message) {
|
|
574
|
+
if (message) {
|
|
575
|
+
const toasts = document.querySelector('crowdin-toasts');
|
|
576
|
+
if (toasts && toasts.pushToasts) {
|
|
577
|
+
toasts.pushToasts([message]);
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
function reloadLocation() {
|
|
582
|
+
ensureInitialized();
|
|
583
|
+
window.location.href =
|
|
584
|
+
window.location.protocol + '//' + window.location.host + window.location.pathname + restParams;
|
|
585
|
+
}
|
|
586
|
+
function catchRejection(e, message) {
|
|
587
|
+
var _a;
|
|
588
|
+
// session expired
|
|
589
|
+
if (e.code && e.code === 401) {
|
|
590
|
+
reloadLocation();
|
|
591
|
+
return;
|
|
592
|
+
}
|
|
593
|
+
// payment required
|
|
594
|
+
if (e.code && e.code === 402 && ((_a = window.app) === null || _a === void 0 ? void 0 : _a.subscriptionModal.current)) {
|
|
595
|
+
if (window.app.subscriptionLink) {
|
|
596
|
+
window.app.subscriptionLink.current = e.message || message;
|
|
597
|
+
}
|
|
598
|
+
window.app.openModal(window.app.subscriptionModal.current);
|
|
599
|
+
return;
|
|
600
|
+
}
|
|
601
|
+
showToast(e.message || message);
|
|
602
|
+
}
|
|
603
|
+
function checkResponse(response) {
|
|
604
|
+
return new Promise((resolve, reject) => {
|
|
605
|
+
if (response.status === 204) {
|
|
606
|
+
return resolve(undefined);
|
|
607
|
+
}
|
|
608
|
+
response
|
|
609
|
+
.json()
|
|
610
|
+
.then((res) => {
|
|
611
|
+
if (![200, 201, 202, 304].includes(response.status)) {
|
|
612
|
+
reject(res);
|
|
613
|
+
}
|
|
614
|
+
else {
|
|
615
|
+
if (res.message) {
|
|
616
|
+
setTimeout(() => showToast(res.message), 100);
|
|
617
|
+
}
|
|
618
|
+
resolve(res);
|
|
619
|
+
}
|
|
620
|
+
})
|
|
621
|
+
.catch((e) => {
|
|
622
|
+
reject(e);
|
|
623
|
+
});
|
|
624
|
+
});
|
|
625
|
+
}
|
|
626
|
+
function checkOrigin() {
|
|
627
|
+
ensureInitialized();
|
|
628
|
+
return new Promise((resolve) => {
|
|
629
|
+
AP.getJwtToken((jwtToken) => {
|
|
630
|
+
restParams = `?origin=${origin}&client_id=${clientId}&jwtToken=${jwtToken}`;
|
|
631
|
+
resolve(restParams);
|
|
632
|
+
});
|
|
633
|
+
});
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
function readPageProps() {
|
|
637
|
+
const element = document.getElementById('__PAGE_PROPS__');
|
|
638
|
+
return JSON.parse((element === null || element === void 0 ? void 0 : element.textContent) || '{}');
|
|
639
|
+
}
|
|
640
|
+
|
|
521
641
|
var reactExports = requireReact();
|
|
522
642
|
|
|
523
|
-
const
|
|
643
|
+
const dependencyShowClassName = 'dependency-show';
|
|
644
|
+
const events = ['input', 'change'];
|
|
645
|
+
function useFieldDependencies(refreshKey) {
|
|
646
|
+
const cleanupRef = reactExports.useRef(() => undefined);
|
|
647
|
+
const refreshDependencies = reactExports.useCallback(() => {
|
|
648
|
+
cleanupRef.current();
|
|
649
|
+
cleanupRef.current = initializeFieldDependencies();
|
|
650
|
+
}, []);
|
|
651
|
+
reactExports.useEffect(() => {
|
|
652
|
+
refreshDependencies();
|
|
653
|
+
return () => {
|
|
654
|
+
cleanupRef.current();
|
|
655
|
+
cleanupRef.current = () => undefined;
|
|
656
|
+
};
|
|
657
|
+
}, [refreshDependencies, refreshKey]);
|
|
658
|
+
return refreshDependencies;
|
|
659
|
+
}
|
|
660
|
+
function initializeFieldDependencies(root = document) {
|
|
661
|
+
const cleanupCallbacks = [];
|
|
662
|
+
const fields = Array.from(root.querySelectorAll('[data-dependency]'));
|
|
663
|
+
fields.forEach((field) => {
|
|
664
|
+
const dependency = field.dataset.dependency;
|
|
665
|
+
if (!dependency) {
|
|
666
|
+
return;
|
|
667
|
+
}
|
|
668
|
+
try {
|
|
669
|
+
const conditions = JSON.parse(dependency);
|
|
670
|
+
applyDependencyState(field, conditions);
|
|
671
|
+
cleanupCallbacks.push(...bindDependencyListeners(field, conditions));
|
|
672
|
+
}
|
|
673
|
+
catch (e) {
|
|
674
|
+
console.error('[Dependencies] Error parsing conditions for field:', field, e);
|
|
675
|
+
}
|
|
676
|
+
});
|
|
677
|
+
return () => {
|
|
678
|
+
cleanupCallbacks.forEach((cleanup) => cleanup());
|
|
679
|
+
};
|
|
680
|
+
}
|
|
681
|
+
function bindDependencyListeners(field, conditions) {
|
|
682
|
+
const cleanupCallbacks = [];
|
|
683
|
+
conditions.forEach((rules) => {
|
|
684
|
+
Object.keys(rules).forEach((selector) => {
|
|
685
|
+
const element = document.querySelector(selector);
|
|
686
|
+
if (!element) {
|
|
687
|
+
return;
|
|
688
|
+
}
|
|
689
|
+
events.forEach((event) => {
|
|
690
|
+
const listener = () => applyDependencyState(field, conditions);
|
|
691
|
+
element.addEventListener(event, listener);
|
|
692
|
+
cleanupCallbacks.push(() => element.removeEventListener(event, listener));
|
|
693
|
+
});
|
|
694
|
+
});
|
|
695
|
+
});
|
|
696
|
+
return cleanupCallbacks;
|
|
697
|
+
}
|
|
698
|
+
function applyDependencyState(field, conditions) {
|
|
699
|
+
if (checkConditions(conditions)) {
|
|
700
|
+
field.classList.add(dependencyShowClassName);
|
|
701
|
+
}
|
|
702
|
+
else {
|
|
703
|
+
field.classList.remove(dependencyShowClassName);
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
function checkConditions(conditions) {
|
|
707
|
+
return conditions.every((conditionObj) => {
|
|
708
|
+
const selectors = Object.keys(conditionObj);
|
|
709
|
+
return selectors.every((selector) => evaluateDependencyRule(selector, conditionObj[selector]));
|
|
710
|
+
});
|
|
711
|
+
}
|
|
712
|
+
function evaluateDependencyRule(selector, condition) {
|
|
713
|
+
const type = condition.type;
|
|
714
|
+
const currentValue = getValue(selector);
|
|
715
|
+
const checkValue = typeof condition.value === 'undefined' ? false : condition.value;
|
|
716
|
+
let minValue = typeof condition.min === 'undefined' ? false : Number.parseInt(String(condition.min), 10);
|
|
717
|
+
let maxValue = typeof condition.max === 'undefined' ? false : Number.parseInt(String(condition.max), 10);
|
|
718
|
+
const allowEmpty = typeof condition.empty === 'undefined' ? false : condition.empty;
|
|
719
|
+
const isEmpty = !allowEmpty && currentValue.length < 1;
|
|
720
|
+
const likeSelector = typeof condition.like === 'undefined' ? false : condition.like;
|
|
721
|
+
const likeSelectorValue = getValue(likeSelector);
|
|
722
|
+
const regExpPattern = typeof condition.pattern === 'undefined' ? false : condition.pattern;
|
|
723
|
+
const regExpModifier = typeof condition.modifier === 'undefined' ? 'gi' : condition.modifier;
|
|
724
|
+
const sign = typeof condition.sign === 'undefined' ? false : condition.sign;
|
|
725
|
+
const strict = typeof condition.strict === 'undefined' ? false : condition.strict;
|
|
726
|
+
const emptyTypes = ['empty', 'blank'];
|
|
727
|
+
const notEmptyTypes = ['!empty', 'notEmpty', 'not-empty', 'notempty'];
|
|
728
|
+
const equalTypes = ['equal', '=', '==', '==='];
|
|
729
|
+
const notEqualTypes = ['!equal', '!=', '!==', '!===', 'notEqual', 'not-equal', 'notequal'];
|
|
730
|
+
const regularExpressionTypes = ['regexp', 'exp', 'expression', 'match'];
|
|
731
|
+
if (type && emptyTypes.includes(type)) {
|
|
732
|
+
return currentValue.length < 1;
|
|
733
|
+
}
|
|
734
|
+
if (type && notEmptyTypes.includes(type)) {
|
|
735
|
+
return currentValue.length > 0;
|
|
736
|
+
}
|
|
737
|
+
if (type && equalTypes.includes(type)) {
|
|
738
|
+
if (isEmpty) {
|
|
739
|
+
return false;
|
|
740
|
+
}
|
|
741
|
+
if (likeSelector) {
|
|
742
|
+
return strict
|
|
743
|
+
? likeSelectorValue.every((value) => currentValue.includes(value))
|
|
744
|
+
: likeSelectorValue.some((value) => currentValue.includes(value));
|
|
745
|
+
}
|
|
746
|
+
if (strict) {
|
|
747
|
+
if (checkValue && Array.isArray(checkValue)) {
|
|
748
|
+
return checkValue.every((value) => currentValue.includes(value));
|
|
749
|
+
}
|
|
750
|
+
if (checkValue && !Array.isArray(checkValue)) {
|
|
751
|
+
return currentValue.includes(checkValue);
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
else {
|
|
755
|
+
if (checkValue && Array.isArray(checkValue)) {
|
|
756
|
+
return checkValue.some((value) => currentValue.includes(value));
|
|
757
|
+
}
|
|
758
|
+
if (checkValue && !Array.isArray(checkValue)) {
|
|
759
|
+
return currentValue.includes(checkValue);
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
if (type && notEqualTypes.includes(type)) {
|
|
764
|
+
if (isEmpty) {
|
|
765
|
+
return false;
|
|
766
|
+
}
|
|
767
|
+
if (likeSelector) {
|
|
768
|
+
return strict
|
|
769
|
+
? likeSelectorValue.every((value) => !currentValue.includes(value))
|
|
770
|
+
: likeSelectorValue.some((value) => !currentValue.includes(value));
|
|
771
|
+
}
|
|
772
|
+
if (strict) {
|
|
773
|
+
if (checkValue && Array.isArray(checkValue)) {
|
|
774
|
+
return checkValue.every((value) => !currentValue.includes(value));
|
|
775
|
+
}
|
|
776
|
+
if (checkValue && !Array.isArray(checkValue)) {
|
|
777
|
+
return !currentValue.includes(checkValue);
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
else {
|
|
781
|
+
if (checkValue && Array.isArray(checkValue)) {
|
|
782
|
+
return checkValue.some((value) => !currentValue.includes(value));
|
|
783
|
+
}
|
|
784
|
+
if (checkValue && !Array.isArray(checkValue)) {
|
|
785
|
+
return !currentValue.includes(checkValue);
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
if (type && regularExpressionTypes.includes(type) && regExpPattern) {
|
|
790
|
+
if (isEmpty) {
|
|
791
|
+
return false;
|
|
792
|
+
}
|
|
793
|
+
const exp = new RegExp(regExpPattern, regExpModifier);
|
|
794
|
+
return currentValue.every((value) => exp.test(String(value)));
|
|
795
|
+
}
|
|
796
|
+
if (type === 'length') {
|
|
797
|
+
if (isEmpty) {
|
|
798
|
+
return false;
|
|
799
|
+
}
|
|
800
|
+
if (checkValue && Array.isArray(checkValue)) {
|
|
801
|
+
minValue = Number.parseInt(String(checkValue[0]), 10);
|
|
802
|
+
maxValue = typeof checkValue[1] === 'undefined' ? false : Number.parseInt(String(checkValue[1]), 10);
|
|
803
|
+
}
|
|
804
|
+
if (checkValue && !Array.isArray(checkValue)) {
|
|
805
|
+
minValue = Number.parseInt(String(checkValue), 10);
|
|
806
|
+
maxValue = false;
|
|
807
|
+
}
|
|
808
|
+
const minBoundary = minValue === false ? 0 : minValue;
|
|
809
|
+
const maxBoundary = maxValue === false ? 0 : maxValue;
|
|
810
|
+
return currentValue.every((value) => {
|
|
811
|
+
const valueLength = String(value).length;
|
|
812
|
+
if (!maxValue) {
|
|
813
|
+
return valueLength >= minBoundary;
|
|
814
|
+
}
|
|
815
|
+
if (!minValue) {
|
|
816
|
+
return valueLength <= maxBoundary;
|
|
817
|
+
}
|
|
818
|
+
return valueLength >= minBoundary && valueLength <= maxBoundary;
|
|
819
|
+
});
|
|
820
|
+
}
|
|
821
|
+
if (type === 'range') {
|
|
822
|
+
if (isEmpty) {
|
|
823
|
+
return false;
|
|
824
|
+
}
|
|
825
|
+
if (checkValue && Array.isArray(checkValue)) {
|
|
826
|
+
minValue = Number.parseInt(String(checkValue[0]), 10);
|
|
827
|
+
maxValue = typeof checkValue[1] === 'undefined' ? false : Number.parseInt(String(checkValue[1]), 10);
|
|
828
|
+
}
|
|
829
|
+
const minBoundary = minValue === false ? 0 : minValue;
|
|
830
|
+
const maxBoundary = maxValue === false ? 0 : maxValue;
|
|
831
|
+
return currentValue.every((value) => {
|
|
832
|
+
const numericValue = Number.parseInt(String(value), 10);
|
|
833
|
+
if (!maxValue) {
|
|
834
|
+
return numericValue > minBoundary;
|
|
835
|
+
}
|
|
836
|
+
if (!minValue) {
|
|
837
|
+
return numericValue < maxBoundary;
|
|
838
|
+
}
|
|
839
|
+
return numericValue > minBoundary && numericValue < maxBoundary;
|
|
840
|
+
});
|
|
841
|
+
}
|
|
842
|
+
if (type === 'compare' && sign && checkValue) {
|
|
843
|
+
if (isEmpty) {
|
|
844
|
+
return false;
|
|
845
|
+
}
|
|
846
|
+
const numericCheckValue = Number.parseInt(String(checkValue), 10);
|
|
847
|
+
switch (sign) {
|
|
848
|
+
case '<':
|
|
849
|
+
return currentValue.every((value) => Number.parseInt(String(value), 10) < numericCheckValue);
|
|
850
|
+
case '<=':
|
|
851
|
+
return currentValue.every((value) => Number.parseInt(String(value), 10) <= numericCheckValue);
|
|
852
|
+
case '>':
|
|
853
|
+
return currentValue.every((value) => Number.parseInt(String(value), 10) > numericCheckValue);
|
|
854
|
+
case '>=':
|
|
855
|
+
return currentValue.every((value) => Number.parseInt(String(value), 10) >= numericCheckValue);
|
|
856
|
+
case '=':
|
|
857
|
+
case '==':
|
|
858
|
+
return currentValue.every((value) => Number.parseInt(String(value), 10) === numericCheckValue);
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
return false;
|
|
862
|
+
}
|
|
863
|
+
function getValue(selector) {
|
|
864
|
+
const values = [];
|
|
865
|
+
if (selector && document.querySelector(selector)) {
|
|
866
|
+
const inputType = document.querySelector(selector).tagName.toLowerCase();
|
|
867
|
+
let currentSelector = selector;
|
|
868
|
+
if (inputType === 'crowdin-select') {
|
|
869
|
+
currentSelector = `${selector} option:checked`;
|
|
870
|
+
}
|
|
871
|
+
if (inputType === 'crowdin-checkbox') {
|
|
872
|
+
currentSelector = `${selector}:not(input)`;
|
|
873
|
+
}
|
|
874
|
+
document.querySelectorAll(currentSelector).forEach((element) => {
|
|
875
|
+
const value = element.value || element.checked;
|
|
876
|
+
values.push(value);
|
|
877
|
+
});
|
|
878
|
+
}
|
|
879
|
+
return values.filter((value) => value !== '');
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
const renderField = (field, { fileNames, fileValues, readFileData, registerField, registerFileInput, uploadFiles }) => {
|
|
524
883
|
var _a;
|
|
525
884
|
if (!field.key) {
|
|
526
885
|
// Label-only field
|
|
@@ -537,31 +896,30 @@
|
|
|
537
896
|
if (['checkbox', 'select', 'textarea', 'file', 'notice'].includes(field.type || '')) {
|
|
538
897
|
switch (field.type) {
|
|
539
898
|
case 'checkbox':
|
|
540
|
-
return (jsxRuntimeExports.jsx("crowdin-checkbox", { ...commonProps, value: "false", "use-switch": true, ...(field.defaultValue === true ? { checked: String(field.defaultValue) } : {}) }));
|
|
899
|
+
return (jsxRuntimeExports.jsx("crowdin-checkbox", { ref: registerField(field.key), ...commonProps, value: "false", "use-switch": true, ...(field.defaultValue === true ? { checked: String(field.defaultValue) } : {}) }));
|
|
541
900
|
case 'select':
|
|
542
|
-
return (jsxRuntimeExports.jsx("crowdin-select", { ...commonProps, ...(field.isMulti ? { 'is-multi': true, 'close-on-select': 'false' } : {}), ...(field.isSearchable ? { 'is-searchable': true } : {}), children: (_a = field.options) === null || _a === void 0 ? void 0 : _a.map((option) => (jsxRuntimeExports.jsx("option", { value: option.value, ...(field.defaultValue === option.value ? { selected: true } : {}), children: option.label }))) }));
|
|
901
|
+
return (jsxRuntimeExports.jsx("crowdin-select", { ref: registerField(field.key), ...commonProps, ...(field.isMulti ? { 'is-multi': true, 'close-on-select': 'false' } : {}), ...(field.isSearchable ? { 'is-searchable': true } : {}), children: (_a = field.options) === null || _a === void 0 ? void 0 : _a.map((option) => (jsxRuntimeExports.jsx("option", { value: option.value, ...(field.defaultValue === option.value ? { selected: true } : {}), children: option.label }, option.value))) }));
|
|
543
902
|
case 'textarea':
|
|
544
|
-
return jsxRuntimeExports.jsx("crowdin-textarea", { ...commonProps, value: field.defaultValue || '' });
|
|
903
|
+
return (jsxRuntimeExports.jsx("crowdin-textarea", { ref: registerField(field.key), ...commonProps, value: field.defaultValue || '' }));
|
|
545
904
|
case 'notice':
|
|
546
905
|
return (jsxRuntimeExports.jsx("crowdin-alert", { ...(field.noticeType ? { type: field.noticeType } : {}), ...(field.label ? { title: field.label } : {}), ...(field.noIcon ? { 'no-icon': String(field.noIcon) } : {}), ...(field.dependencySettings ? { 'data-dependency': field.dependencySettings } : {}), dangerouslySetInnerHTML: { __html: field.helpTextHtml || field.helpText || '' } }));
|
|
547
906
|
case 'file':
|
|
548
|
-
return (jsxRuntimeExports.jsxs("div", { className: "
|
|
907
|
+
return (jsxRuntimeExports.jsxs("div", { className: "text-sm leading-6 font-normal text-[rgba(38,50,56,.87)] antialiased", children: [field.helpText && jsxRuntimeExports.jsx("div", { className: "text-xs text-[rgba(38,50,56,.54)]", children: field.helpText }), field.helpTextHtml && (jsxRuntimeExports.jsx("div", { className: "text-xs text-[rgba(38,50,56,.54)]", children: field.helpTextHtml })), jsxRuntimeExports.jsxs("div", { className: "mt-2 flex items-center justify-between", children: [jsxRuntimeExports.jsx("crowdin-button", { outlined: true, onClick: () => uploadFiles(field.key), children: field.label }), jsxRuntimeExports.jsx("textarea", { ref: registerField(field.key), hidden: true, id: field.key, value: fileValues[field.key] || '', readOnly: true }), jsxRuntimeExports.jsx("input", { ref: registerFileInput(field.key), id: `store_${field.key}`, "data-id": field.key, ...(field.accept ? { accept: field.accept } : {}), onChange: (e) => readFileData(e, field.key), hidden: true, type: field.type }), jsxRuntimeExports.jsx("div", { className: "flex items-center italic", children: jsxRuntimeExports.jsx("i", { children: fileNames[field.key] || 'No file' }) })] })] }));
|
|
549
908
|
}
|
|
550
909
|
}
|
|
551
910
|
// Default input field
|
|
552
|
-
return (jsxRuntimeExports.jsx("crowdin-input", { ...commonProps, ...(field.type ? { type: field.type } : {}), value: field.defaultValue || '' }));
|
|
911
|
+
return (jsxRuntimeExports.jsx("crowdin-input", { ref: registerField(field.key), ...commonProps, class: "mb-2 block", ...(field.type ? { type: field.type } : {}), value: field.defaultValue || '' }));
|
|
553
912
|
};
|
|
554
913
|
const LoginPage = ({ name, loginFields, oauthLogin, oauthUrl, oauthMode }) => {
|
|
555
914
|
const refreshIntervalId = reactExports.useRef(null);
|
|
915
|
+
const fieldRefs = reactExports.useRef({});
|
|
916
|
+
const fileInputRefs = reactExports.useRef({});
|
|
917
|
+
const [fileNames, setFileNames] = reactExports.useState({});
|
|
918
|
+
const [fileValues, setFileValues] = reactExports.useState({});
|
|
556
919
|
const [isLoading, setIsLoading] = reactExports.useState(false);
|
|
920
|
+
useFieldDependencies(loginFields);
|
|
557
921
|
// Cleanup interval on component unmount
|
|
558
922
|
reactExports.useEffect(() => {
|
|
559
|
-
// Initialize dependencies after component is mounted
|
|
560
|
-
setTimeout(() => {
|
|
561
|
-
if (window.initializeDependencies) {
|
|
562
|
-
window.initializeDependencies();
|
|
563
|
-
}
|
|
564
|
-
}, 100);
|
|
565
923
|
return () => {
|
|
566
924
|
if (refreshIntervalId.current) {
|
|
567
925
|
clearInterval(refreshIntervalId.current);
|
|
@@ -613,7 +971,7 @@
|
|
|
613
971
|
}), 2000);
|
|
614
972
|
return;
|
|
615
973
|
}
|
|
616
|
-
|
|
974
|
+
getPostPromises()['oauth_popup'] = {
|
|
617
975
|
resolve: (data) => {
|
|
618
976
|
if (data.error) {
|
|
619
977
|
showToast(data.error);
|
|
@@ -651,49 +1009,81 @@
|
|
|
651
1009
|
return loginFields
|
|
652
1010
|
.filter((f) => f.key)
|
|
653
1011
|
.reduce((acc, f) => {
|
|
654
|
-
var _a
|
|
1012
|
+
var _a;
|
|
1013
|
+
const key = f.key;
|
|
1014
|
+
const field = fieldRefs.current[key];
|
|
655
1015
|
if (f.type === 'checkbox') {
|
|
656
|
-
|
|
657
|
-
|
|
1016
|
+
acc[key] = !!(field === null || field === void 0 ? void 0 : field.checked);
|
|
1017
|
+
}
|
|
1018
|
+
else if (f.type === 'file') {
|
|
1019
|
+
acc[key] = fileValues[key] || (field === null || field === void 0 ? void 0 : field.value) || '';
|
|
658
1020
|
}
|
|
659
1021
|
else {
|
|
660
|
-
acc[
|
|
661
|
-
((_a = document.querySelector(`#${f.key}`)) === null || _a === void 0 ? void 0 : _a.getAttribute('value')) ||
|
|
662
|
-
((_b = document.querySelector(`#${f.key}`)) === null || _b === void 0 ? void 0 : _b.value);
|
|
1022
|
+
acc[key] = ((_a = field === null || field === void 0 ? void 0 : field.getAttribute) === null || _a === void 0 ? void 0 : _a.call(field, 'value')) || (field === null || field === void 0 ? void 0 : field.value);
|
|
663
1023
|
}
|
|
664
1024
|
return acc;
|
|
665
1025
|
}, {});
|
|
666
1026
|
}
|
|
667
1027
|
function uploadFiles(id) {
|
|
668
|
-
const input =
|
|
669
|
-
input
|
|
670
|
-
|
|
1028
|
+
const input = fileInputRefs.current[id];
|
|
1029
|
+
if (input) {
|
|
1030
|
+
input.value = '';
|
|
1031
|
+
input.click();
|
|
1032
|
+
}
|
|
671
1033
|
}
|
|
672
|
-
function readFileData(event) {
|
|
1034
|
+
function readFileData(event, identifier) {
|
|
673
1035
|
const reader = new FileReader();
|
|
674
|
-
const identifier = event.target.getAttribute('data-id');
|
|
675
|
-
const fileName = document.querySelector('.uploaded-file');
|
|
676
|
-
const input = document.querySelector(`#${identifier}`);
|
|
677
1036
|
const file = event.target.files[0];
|
|
678
|
-
if (
|
|
679
|
-
|
|
1037
|
+
if (!file) {
|
|
1038
|
+
return;
|
|
680
1039
|
}
|
|
1040
|
+
setFileNames((currentFileNames) => ({ ...currentFileNames, [identifier]: file.name }));
|
|
681
1041
|
reader.onloadstart = () => setIsLoading(true);
|
|
682
1042
|
reader.onloadend = () => setIsLoading(false);
|
|
683
1043
|
reader.onload = () => {
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
}
|
|
1044
|
+
setFileValues((currentFileValues) => ({
|
|
1045
|
+
...currentFileValues,
|
|
1046
|
+
[identifier]: typeof reader.result === 'string' ? reader.result : '',
|
|
1047
|
+
}));
|
|
688
1048
|
};
|
|
689
1049
|
reader.readAsText(file);
|
|
690
1050
|
}
|
|
691
|
-
|
|
1051
|
+
function registerField(key) {
|
|
1052
|
+
return (element) => {
|
|
1053
|
+
if (!key) {
|
|
1054
|
+
return;
|
|
1055
|
+
}
|
|
1056
|
+
if (element) {
|
|
1057
|
+
fieldRefs.current[key] = element;
|
|
1058
|
+
}
|
|
1059
|
+
else {
|
|
1060
|
+
delete fieldRefs.current[key];
|
|
1061
|
+
}
|
|
1062
|
+
};
|
|
1063
|
+
}
|
|
1064
|
+
function registerFileInput(key) {
|
|
1065
|
+
return (element) => {
|
|
1066
|
+
if (!key) {
|
|
1067
|
+
return;
|
|
1068
|
+
}
|
|
1069
|
+
fileInputRefs.current[key] = element;
|
|
1070
|
+
};
|
|
1071
|
+
}
|
|
1072
|
+
return (jsxRuntimeExports.jsxs("div", { children: [jsxRuntimeExports.jsx("div", { className: "mx-auto flex min-h-[calc(100vh-64px)] max-w-[1420px] items-center justify-around px-6 py-4 text-center", children: jsxRuntimeExports.jsx("div", { children: jsxRuntimeExports.jsxs("crowdin-card", { "is-shadowed": true, "is-padding-lg": true, class: "mb-2.5 overflow-visible", children: [jsxRuntimeExports.jsx("img", { alt: `${name} logo`, src: "logo.png", className: "mx-auto h-auto max-h-[70px] w-auto max-w-[70px]" }), jsxRuntimeExports.jsx("crowdin-h4", { id: "integration-name", class: "my-2 mb-4", children: name }), jsxRuntimeExports.jsx("div", { className: "mb-6 text-left", children: loginFields.map((field, fieldIndex) => (jsxRuntimeExports.jsxs(reactExports.Fragment, { children: [renderField(field, {
|
|
1073
|
+
fileNames,
|
|
1074
|
+
fileValues,
|
|
1075
|
+
readFileData,
|
|
1076
|
+
registerField,
|
|
1077
|
+
registerFileInput,
|
|
1078
|
+
uploadFiles,
|
|
1079
|
+
}), jsxRuntimeExports.jsx("div", { style: { padding: '8px' }, ...(field.dependencySettings
|
|
692
1080
|
? { 'data-dependency': field.dependencySettings }
|
|
693
|
-
: {}) })] }))) }), jsxRuntimeExports.jsxs("crowdin-button", { id: "login-button", disabled: isLoading, "is-loading": isLoading, outlined: true, "icon-after": "arrow_forward", onClick: oauthLogin ? () => oauthLoginHandler() : () => integrationLogin(), children: ["Log In With ", name] })] }) }) }), jsxRuntimeExports.jsx("crowdin-toasts", {})] }));
|
|
1081
|
+
: {}) })] }, field.key || field.label || field.labelHtml || fieldIndex))) }), jsxRuntimeExports.jsxs("crowdin-button", { id: "login-button", disabled: isLoading, "is-loading": isLoading, outlined: true, "icon-after": "arrow_forward", onClick: oauthLogin ? () => oauthLoginHandler() : () => integrationLogin(), children: ["Log In With ", name] })] }) }) }), jsxRuntimeExports.jsx("crowdin-toasts", {})] }));
|
|
694
1082
|
};
|
|
695
1083
|
|
|
696
|
-
|
|
1084
|
+
initializeCrowdinIframeContext();
|
|
1085
|
+
const props = readPageProps();
|
|
1086
|
+
clientExports.createRoot(document.getElementById('root')).render(jsxRuntimeExports.jsx(LoginPage, { ...props }));
|
|
697
1087
|
|
|
698
1088
|
})();
|
|
699
1089
|
//# sourceMappingURL=login.bundle.js.map
|