datastake-daf 0.6.558 → 0.6.559

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.
@@ -40497,187 +40497,6 @@ const Navigation = _ref => {
40497
40497
  }) : null;
40498
40498
  };
40499
40499
 
40500
- function AuthForm(_ref) {
40501
- var _steps$currentStep;
40502
- let {
40503
- steps,
40504
- fields,
40505
- onSubmit,
40506
- initialValues = {},
40507
- submitText = "Submit",
40508
- form,
40509
- errors,
40510
- t = key => key,
40511
- executeRecaptcha = () => {}
40512
- } = _ref;
40513
- const [formInstance] = antd.Form.useForm(form);
40514
- const [currentStep, setCurrentStep] = React.useState(0);
40515
- const [allFormValues, setAllFormValues] = React.useState(initialValues);
40516
- const [formErrors, setFormErrors] = React.useState(null);
40517
- const isMultiStep = !!steps;
40518
- const currentFields = isMultiStep ? steps === null || steps === void 0 || (_steps$currentStep = steps[currentStep]) === null || _steps$currentStep === void 0 ? void 0 : _steps$currentStep.fields : fields || [];
40519
- React.useEffect(() => {
40520
- if (isMultiStep && Object.keys(allFormValues).length > 0) {
40521
- formInstance.setFieldsValue(allFormValues);
40522
- }
40523
- }, [currentStep, allFormValues, formInstance, isMultiStep]);
40524
- const handleReCaptchaVerify = React.useCallback(async () => {
40525
- if (!executeRecaptcha) {
40526
- console.log('Execute recaptcha not yet available');
40527
- return;
40528
- }
40529
- const token = await executeRecaptcha('submit');
40530
- return token;
40531
- }, [executeRecaptcha]);
40532
- const next = async () => {
40533
- try {
40534
- await formInstance.validateFields(currentFields.map(f => f.name));
40535
- // Save current step values before moving to next step
40536
- const currentValues = formInstance.getFieldsValue();
40537
- setAllFormValues(prev => _objectSpread2(_objectSpread2({}, prev), currentValues));
40538
- setCurrentStep(prev => prev + 1);
40539
- } catch (err) {
40540
- console.error("Please fix the validation errors before continuing.");
40541
- }
40542
- };
40543
- const prev = () => setCurrentStep(prev => prev - 1);
40544
- const handleSubmit = async values => {
40545
- const token = await handleReCaptchaVerify();
40546
- if (!token) {
40547
- console.error('reCAPTCHA verification failed');
40548
- return;
40549
- }
40550
- setFormErrors(null);
40551
- if (!isMultiStep) return onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(values);
40552
- if (currentStep < (steps === null || steps === void 0 ? void 0 : steps.length) - 1) return next();
40553
- const finalValues = _objectSpread2(_objectSpread2({}, allFormValues), values);
40554
- onSubmit === null || onSubmit === void 0 || onSubmit(finalValues);
40555
- };
40556
- const checkRequiredFieldsFilled = (changedValues, allValues) => {
40557
- const requiredFields = currentFields.filter(f => f.required).map(f => f.name);
40558
- return requiredFields.every(fieldName => {
40559
- const value = allValues[fieldName];
40560
- return value !== undefined && value !== null && value !== '';
40561
- });
40562
- };
40563
- React.useEffect(() => {
40564
- setFormErrors(errors);
40565
- }, [errors]);
40566
- const renderErrors = (err, t) => {
40567
- document.querySelectorAll('.ant-form-item').forEach(input => input.classList.add('ant-form-item-has-error'));
40568
- return Object.keys(err).map(key => {
40569
- return err[key].map(error => /*#__PURE__*/jsxRuntime.jsx("div", {
40570
- className: "ant-form-item-explain errors-cont",
40571
- style: {
40572
- color: '#ff4d4f'
40573
- },
40574
- children: t(error)
40575
- }, error));
40576
- });
40577
- };
40578
- const renderField = field => {
40579
- var _field$options;
40580
- const rules = [...(field.required ? [{
40581
- required: true,
40582
- message: "".concat(field.label, " is required")
40583
- }] : []), ...(field.rules || [])];
40584
- let inputNode = null;
40585
- switch (field.type) {
40586
- case "input":
40587
- case "email":
40588
- case "number":
40589
- inputNode = /*#__PURE__*/jsxRuntime.jsx(antd.Input, _objectSpread2({
40590
- type: field.type,
40591
- placeholder: field.placeholder
40592
- }, field.props));
40593
- break;
40594
- case "password":
40595
- inputNode = /*#__PURE__*/jsxRuntime.jsx(antd.Input.Password, _objectSpread2({
40596
- placeholder: field.placeholder
40597
- }, field.props));
40598
- break;
40599
- case "textarea":
40600
- inputNode = /*#__PURE__*/jsxRuntime.jsx(antd.Input.TextArea, _objectSpread2({
40601
- placeholder: field.placeholder
40602
- }, field.props));
40603
- break;
40604
- case "select":
40605
- inputNode = /*#__PURE__*/jsxRuntime.jsx(antd.Select, _objectSpread2(_objectSpread2({
40606
- placeholder: field.placeholder
40607
- }, field.props), {}, {
40608
- children: (_field$options = field.options) === null || _field$options === void 0 ? void 0 : _field$options.map(opt => /*#__PURE__*/jsxRuntime.jsx(antd.Select.Option, {
40609
- value: opt.value,
40610
- children: opt.label
40611
- }, opt.value))
40612
- }));
40613
- break;
40614
- case "custom":
40615
- inputNode = field.component;
40616
- break;
40617
- default:
40618
- inputNode = /*#__PURE__*/jsxRuntime.jsx(antd.Input, _objectSpread2({
40619
- placeholder: field.placeholder
40620
- }, field.props));
40621
- }
40622
- return /*#__PURE__*/jsxRuntime.jsx(antd.Form.Item, {
40623
- name: field.name,
40624
- label: field.label,
40625
- rules: rules,
40626
- children: inputNode
40627
- }, field.name);
40628
- };
40629
- return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
40630
- children: /*#__PURE__*/jsxRuntime.jsxs(antd.Form, {
40631
- form: formInstance,
40632
- layout: "vertical",
40633
- initialValues: initialValues,
40634
- onFinish: handleSubmit,
40635
- children: [currentFields.map(renderField), formErrors ? renderErrors(formErrors, t) : null, isMultiStep && currentStep > 0 ? /*#__PURE__*/jsxRuntime.jsxs("div", {
40636
- className: "flex flex-column gap-2 mt-4",
40637
- style: {
40638
- width: '100%'
40639
- },
40640
- children: [/*#__PURE__*/jsxRuntime.jsx(antd.Form.Item, {
40641
- noStyle: true,
40642
- shouldUpdate: true,
40643
- children: form => {
40644
- const isLastStep = currentStep === (steps === null || steps === void 0 ? void 0 : steps.length) - 1;
40645
- const allFieldsFilled = checkRequiredFieldsFilled({}, form.getFieldsValue());
40646
- return /*#__PURE__*/jsxRuntime.jsx("div", {
40647
- className: "buttons",
40648
- children: /*#__PURE__*/jsxRuntime.jsx(BorderedButton, {
40649
- type: "primary",
40650
- htmlType: "submit",
40651
- disabled: isLastStep && !allFieldsFilled,
40652
- block: true,
40653
- className: "normal-br",
40654
- children: isLastStep ? submitText : t("Next")
40655
- })
40656
- });
40657
- }
40658
- }), /*#__PURE__*/jsxRuntime.jsx("div", {
40659
- className: "buttons",
40660
- children: /*#__PURE__*/jsxRuntime.jsx(BorderedButton, {
40661
- onClick: prev,
40662
- block: true,
40663
- className: "normal-br",
40664
- children: t("Back")
40665
- })
40666
- })]
40667
- }) : /*#__PURE__*/jsxRuntime.jsx("div", {
40668
- className: "buttons",
40669
- children: /*#__PURE__*/jsxRuntime.jsx(BorderedButton, {
40670
- type: "primary",
40671
- htmlType: "submit",
40672
- block: true,
40673
- className: "normal-br",
40674
- children: isMultiStep ? t("Next") : submitText
40675
- })
40676
- })]
40677
- })
40678
- });
40679
- }
40680
-
40681
40500
  var _templateObject$6;
40682
40501
  const Style$s = dt.div(_templateObject$6 || (_templateObject$6 = _taggedTemplateLiteral(["\n width: 99px;\n height: 10px;\n border-radius: 8px;\n background: var(--base-gray-40);\n overflow: hidden;\n\n .bar {\n height: 100%;\n background: var(--color-primary-70);\n }\n"])));
40683
40502
  function ProgressBar(_ref) {
@@ -59583,7 +59402,6 @@ exports.AjaxSelect = AjaxSelectMain;
59583
59402
  exports.Animated = Animated;
59584
59403
  exports.Applications = Applications;
59585
59404
  exports.AreaChart = AreaChart;
59586
- exports.AuthForm = AuthForm;
59587
59405
  exports.AvatarGroup = AvatarGroup;
59588
59406
  exports.Badge = Badge;
59589
59407
  exports.BarChart = BarChart;