@app-studio/web 0.3.57 → 0.3.58

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.
@@ -3,4 +3,4 @@ import { CheckboxProps } from '../Form/Checkbox/Checkbox/Checkbox.props';
3
3
  /**
4
4
  * Checkbox allows users to select one or more options from a list of choices.
5
5
  */
6
- export declare const Checkbox: React.FC<CheckboxProps>;
6
+ export declare const FormikCheckbox: React.FC<CheckboxProps>;
@@ -3,4 +3,4 @@ import { CountryPickerProps } from '../Form/CountryPicker/CountryPicker/CountryP
3
3
  /**
4
4
  * Country picker allows users to select a country from a dropdown list or search field.
5
5
  */
6
- export declare const CountryPicker: React.FC<CountryPickerProps>;
6
+ export declare const FormikCountryPicker: React.FC<CountryPickerProps>;
@@ -3,4 +3,4 @@ import { DatePickerProps } from '../Form/DatePicker/DatePicker/DatePicker.props'
3
3
  /**
4
4
  * Date picker allows users to select a date from a calendar view.
5
5
  */
6
- export declare const DatePicker: React.FC<DatePickerProps>;
6
+ export declare const FormikDatePicker: React.FC<DatePickerProps>;
@@ -21,5 +21,5 @@ interface FocusContextType {
21
21
  setInputRef: (name: string, ref: HTMLInputElement | null) => void;
22
22
  }
23
23
  export declare const useFormFocus: () => FocusContextType;
24
- export declare const Form: <T extends {}>({ children, autoFocus, initFocus, }: any) => React.JSX.Element;
24
+ export declare const FormikForm: <T extends {}>({ children, autoFocus, initFocus, }: any) => React.JSX.Element;
25
25
  export {};
@@ -3,4 +3,4 @@ import { PasswordProps } from '../Form/Password/Password/Password.props';
3
3
  /**
4
4
  * To allow users to securely enter sensitive information
5
5
  */
6
- export declare const Password: React.FC<PasswordProps>;
6
+ export declare const FormikPassword: React.FC<PasswordProps>;
@@ -3,4 +3,4 @@ import { SelectProps } from '../Form/Select/Select/Select.props';
3
3
  /**
4
4
  * Select provides a dropdown list of options for the user to choose from.
5
5
  */
6
- export declare const Select: React.FC<SelectProps>;
6
+ export declare const FormikSelect: React.FC<SelectProps>;
@@ -1,3 +1,3 @@
1
1
  import React from 'react';
2
2
  import { SwitchProps } from '../Form/Switch/Switch/Switch.props';
3
- export declare const Switch: React.FC<SwitchProps>;
3
+ export declare const FormikSwitch: React.FC<SwitchProps>;
@@ -3,4 +3,4 @@ import { TextAreaProps } from '../Form/TextArea/TextArea/TextArea.props';
3
3
  /**
4
4
  * Text Area is an component used to create a multi-line input field.
5
5
  */
6
- export declare const TextArea: React.FC<TextAreaProps>;
6
+ export declare const FormikTextArea: React.FC<TextAreaProps>;
@@ -3,4 +3,4 @@ import { TextFieldProps } from '../Form/TextField/TextField/TextField.props';
3
3
  /**
4
4
  * TextField is used to capture text data from users.
5
5
  */
6
- export declare const TextField: React.FC<TextFieldProps>;
6
+ export declare const FormikTextField: React.FC<TextFieldProps>;
@@ -1,2 +1,2 @@
1
1
  import React from 'react';
2
- export declare const FormCheckbox: () => React.JSX.Element;
2
+ export declare const FormCheckboxExemple: () => React.JSX.Element;
@@ -1,2 +1,2 @@
1
1
  import React from 'react';
2
- export declare const FormikCountryPicker: () => React.JSX.Element;
2
+ export declare const FormikCountryPickerExemple: () => React.JSX.Element;
@@ -1,2 +1,2 @@
1
1
  import React from 'react';
2
- export declare const FormikDatePicker: () => React.JSX.Element;
2
+ export declare const FormikDatePickerExemple: () => React.JSX.Element;
@@ -1,2 +1,2 @@
1
1
  import React from 'react';
2
- export declare const FormikPassword: () => React.JSX.Element;
2
+ export declare const FormikPasswordExemple: () => React.JSX.Element;
@@ -1,2 +1,2 @@
1
1
  import React from 'react';
2
- export declare const FormikSelect: () => React.JSX.Element;
2
+ export declare const FormikSelectExemple: () => React.JSX.Element;
@@ -1,2 +1,2 @@
1
1
  import React from 'react';
2
- export declare const FormikSwitch: () => React.JSX.Element;
2
+ export declare const FormikSwitchExemple: () => React.JSX.Element;
@@ -1,2 +1,2 @@
1
1
  import React from 'react';
2
- export declare const FormikTextArea: () => React.JSX.Element;
2
+ export declare const FormikTextAreaExemple: () => React.JSX.Element;
@@ -1,2 +1,2 @@
1
1
  import React from 'react';
2
- export declare const FormikTextField: () => React.JSX.Element;
2
+ export declare const FormikTextFieldExemple: () => React.JSX.Element;
@@ -1,9 +1,9 @@
1
- export { Checkbox } from './Formik.Checkbox';
2
- export { DatePicker } from './Formik.DatePicker';
3
- export { CountryPicker } from './Formik.CountryPicker';
4
- export { Select } from './Formik.Select';
5
- export { Switch } from './Formik.Switch';
6
- export { TextArea } from './Formik.TextArea';
7
- export { TextField } from './Formik.TextField';
8
- export { Password } from './Formik.Password';
9
- export { Form } from './Formik.Form';
1
+ export { FormikCheckbox } from './Formik.Checkbox';
2
+ export { FormikDatePicker } from './Formik.DatePicker';
3
+ export { FormikCountryPicker } from './Formik.CountryPicker';
4
+ export { FormikSelect } from './Formik.Select';
5
+ export { FormikSwitch } from './Formik.Switch';
6
+ export { FormikTextArea } from './Formik.TextArea';
7
+ export { FormikTextField } from './Formik.TextField';
8
+ export { FormikPassword } from './Formik.Password';
9
+ export { FormikForm } from './Formik.Form';
@@ -9,6 +9,7 @@ export * from './Form/Switch/Switch';
9
9
  export * from './Form/TextArea/TextArea';
10
10
  export * from './Form/TextField/TextField';
11
11
  export * from './Layout/Center/Center';
12
+ export * from './Formik';
12
13
  export * from './Layout/Horizontal/Horizontal';
13
14
  export * from './Layout/Vertical/Vertical';
14
15
  export * from './Layout/View/View';
@@ -9,6 +9,7 @@ var React__default = _interopDefault(React);
9
9
  var appStudio = require('app-studio');
10
10
  var reactRouterDom = require('react-router-dom');
11
11
  var format = _interopDefault(require('date-fns/format'));
12
+ var formik = require('formik');
12
13
  var zustand = require('zustand');
13
14
 
14
15
  var useButtonState = function useButtonState() {
@@ -4392,6 +4393,258 @@ var TextFieldComponent = function TextFieldComponent(props) {
4392
4393
  */
4393
4394
  var TextField = TextFieldComponent;
4394
4395
 
4396
+ var FocusContext = /*#__PURE__*/React.createContext({
4397
+ active: false,
4398
+ focusNextInput: function focusNextInput() {},
4399
+ setInputRef: function setInputRef() {},
4400
+ handleSubmitEditing: function handleSubmitEditing() {},
4401
+ getReturnKeyType: function getReturnKeyType() {
4402
+ return 'next';
4403
+ }
4404
+ });
4405
+ var useFormFocus = function useFormFocus() {
4406
+ return React.useContext(FocusContext);
4407
+ };
4408
+ var FormikForm = function FormikForm(_ref) {
4409
+ var children = _ref.children,
4410
+ _ref$autoFocus = _ref.autoFocus,
4411
+ autoFocus = _ref$autoFocus === void 0 ? false : _ref$autoFocus,
4412
+ initFocus = _ref.initFocus;
4413
+ var formik$1 = formik.useFormikContext();
4414
+ var inputRefs = React.useRef({});
4415
+ var inputNames = React.useRef([]);
4416
+ var setInputRef = function setInputRef(name, ref) {
4417
+ inputRefs.current[name] = ref;
4418
+ if (!inputNames.current.includes(name)) {
4419
+ inputNames.current.push(name);
4420
+ }
4421
+ };
4422
+ var focusNextInput = function focusNextInput(currentName) {
4423
+ if (autoFocus) {
4424
+ var currentIndex = inputNames.current.indexOf(currentName);
4425
+ var nextIndex = currentIndex + 1;
4426
+ if (nextIndex < inputNames.current.length) {
4427
+ var _inputRefs$current$in;
4428
+ (_inputRefs$current$in = inputRefs.current[inputNames.current[nextIndex]]) == null || _inputRefs$current$in.focus();
4429
+ } else if (formik$1.onSubmit) {
4430
+ formik$1.onSubmit(formik$1.values);
4431
+ }
4432
+ }
4433
+ };
4434
+ var contextValue = {
4435
+ active: autoFocus,
4436
+ focusNextInput: focusNextInput,
4437
+ setInputRef: setInputRef,
4438
+ handleSubmitEditing: focusNextInput,
4439
+ getReturnKeyType: function getReturnKeyType(name) {
4440
+ return inputNames.current.indexOf(name) === inputNames.current.length - 1 ? 'done' : 'next';
4441
+ }
4442
+ };
4443
+ React.useEffect(function () {
4444
+ if (autoFocus) {
4445
+ if (initFocus && inputRefs.current[initFocus]) {
4446
+ var _inputRefs$current$in2;
4447
+ (_inputRefs$current$in2 = inputRefs.current[initFocus]) == null || _inputRefs$current$in2.focus();
4448
+ } else if (inputNames.current[0]) {
4449
+ var _inputRefs$current$in3;
4450
+ (_inputRefs$current$in3 = inputRefs.current[inputNames.current[0]]) == null || _inputRefs$current$in3.focus();
4451
+ }
4452
+ }
4453
+ }, [autoFocus, initFocus]);
4454
+ return React__default.createElement(FocusContext.Provider, {
4455
+ value: contextValue
4456
+ }, React__default.createElement(appStudio.Form, null, children));
4457
+ };
4458
+
4459
+ var _excluded$u = ["name", "type"];
4460
+ var getInputTypeProps = function getInputTypeProps(type) {
4461
+ switch (type) {
4462
+ case 'email':
4463
+ return {
4464
+ autoCorrect: 'off',
4465
+ keyboardType: 'email-address',
4466
+ autoCapitalize: 'none'
4467
+ };
4468
+ case 'password':
4469
+ return {
4470
+ autoCorrect: 'off',
4471
+ secureTextEntry: true,
4472
+ autoCapitalize: 'none'
4473
+ };
4474
+ case 'digits':
4475
+ return {
4476
+ keyboardType: 'phone-pad'
4477
+ };
4478
+ case 'name':
4479
+ return {
4480
+ autoCorrect: 'off'
4481
+ };
4482
+ default:
4483
+ return {};
4484
+ }
4485
+ };
4486
+ var useFormikInput = function useFormikInput(_ref) {
4487
+ var name = _ref.name,
4488
+ type = _ref.type,
4489
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$u);
4490
+ var focus = useFormFocus();
4491
+ var _useFormikContext = formik.useFormikContext(),
4492
+ touched = _useFormikContext.touched,
4493
+ errors = _useFormikContext.errors,
4494
+ submitCount = _useFormikContext.submitCount,
4495
+ values = _useFormikContext.values,
4496
+ setFieldTouched = _useFormikContext.setFieldTouched,
4497
+ setFieldValue = _useFormikContext.setFieldValue;
4498
+ var error = touched[name] || submitCount > 0 ? errors[name] : undefined;
4499
+ var onChangeText = function onChangeText(text) {
4500
+ setFieldValue(name, text);
4501
+ props.onChangeText == null || props.onChangeText(text);
4502
+ };
4503
+ var onChange = function onChange(value) {
4504
+ setFieldValue(name, value);
4505
+ props.onChange == null || props.onChange(value);
4506
+ };
4507
+ var handleBlur = function handleBlur() {
4508
+ setFieldTouched(name, true);
4509
+ // if(props.onBlur)props.onBlur();
4510
+ };
4511
+
4512
+ var handleKeyPress = function handleKeyPress(e) {
4513
+ if (e.key === 'Enter') {
4514
+ e.preventDefault();
4515
+ focus.focusNextInput(name);
4516
+ }
4517
+ };
4518
+ var isText = ['text', 'password', 'email', 'digits'].includes(type);
4519
+ return _extends({}, getInputTypeProps(type), props, {
4520
+ value: values[name],
4521
+ error: error,
4522
+ onBlur: handleBlur,
4523
+ onKeyPress: handleKeyPress
4524
+ }, isText ? {
4525
+ onChangeText: onChangeText
4526
+ } : {
4527
+ onChange: onChange
4528
+ }, focus.active ? {
4529
+ handleKeyPress: handleKeyPress
4530
+ } : {});
4531
+ };
4532
+ // import FormPicker from 'src/Picker/Picker';
4533
+ // import FormRater from 'src/Rate/Rate';
4534
+ // import Upload from 'src/Upload/Upload';
4535
+
4536
+ var _excluded$v = ["value"];
4537
+ var CheckboxComponent$1 = function CheckboxComponent(props) {
4538
+ var _useFormikInput = useFormikInput(props),
4539
+ value = _useFormikInput.value,
4540
+ formProps = _objectWithoutPropertiesLoose(_useFormikInput, _excluded$v);
4541
+ formProps.isChecked = value;
4542
+ var checkboxStates = useCheckboxState(props);
4543
+ return React__default.createElement(CheckboxView, Object.assign({}, checkboxStates, formProps));
4544
+ };
4545
+ /**
4546
+ * Checkbox allows users to select one or more options from a list of choices.
4547
+ */
4548
+ var FormikCheckbox = CheckboxComponent$1;
4549
+
4550
+ var DatePickerComponent$1 = function DatePickerComponent(props) {
4551
+ var formProps = useFormikInput(props);
4552
+ var datePickerStates = useDatePickerState();
4553
+ return React__default.createElement(DatePickerView, Object.assign({}, datePickerStates, formProps));
4554
+ };
4555
+ /**
4556
+ * Date picker allows users to select a date from a calendar view.
4557
+ */
4558
+ var FormikDatePicker = DatePickerComponent$1;
4559
+
4560
+ var CountryPickerComponent$1 = function CountryPickerComponent(props) {
4561
+ var formProps = useFormikInput(props);
4562
+ var countryPickerStates = useCountryPickerState(props);
4563
+ return React__default.createElement(CountryPickerView, Object.assign({}, countryPickerStates, formProps));
4564
+ };
4565
+ /**
4566
+ * Country picker allows users to select a country from a dropdown list or search field.
4567
+ */
4568
+ var FormikCountryPicker = CountryPickerComponent$1;
4569
+
4570
+ var SelectComponent$1 = function SelectComponent(props) {
4571
+ var formProps = useFormikInput(props);
4572
+ formProps.selected = formProps.value;
4573
+ var selectStates = useSelectState(props);
4574
+ return React__default.createElement(SelectView, Object.assign({}, selectStates, formProps));
4575
+ };
4576
+ /**
4577
+ * Select provides a dropdown list of options for the user to choose from.
4578
+ */
4579
+ var FormikSelect = SelectComponent$1;
4580
+
4581
+ var _excluded$w = ["value"];
4582
+ var SwitchComponent$1 = function SwitchComponent(props) {
4583
+ var _useFormikInput = useFormikInput(props),
4584
+ value = _useFormikInput.value,
4585
+ formProps = _objectWithoutPropertiesLoose(_useFormikInput, _excluded$w);
4586
+ formProps.isChecked = value;
4587
+ var switchStates = useSwitchState(props);
4588
+ return React__default.createElement(SwitchView, Object.assign({}, switchStates, formProps));
4589
+ };
4590
+ var FormikSwitch = SwitchComponent$1;
4591
+
4592
+ var TextAreaComponent$1 = function TextAreaComponent(props) {
4593
+ var formProps = useFormikInput(props);
4594
+ var textAreaState = useTextAreaState(props);
4595
+ return React__default.createElement(TextAreaView, Object.assign({}, textAreaState, formProps));
4596
+ };
4597
+ /**
4598
+ * Text Area is an component used to create a multi-line input field.
4599
+ */
4600
+ var FormikTextArea = TextAreaComponent$1;
4601
+
4602
+ var _excluded$x = ["value"];
4603
+ var TextFieldComponent$1 = function TextFieldComponent(props) {
4604
+ var formProps = useFormikInput(props);
4605
+ var _useTextFieldState = useTextFieldState(props),
4606
+ textFieldStates = _objectWithoutPropertiesLoose(_useTextFieldState, _excluded$x);
4607
+ return React__default.createElement(TextFieldView, Object.assign({}, textFieldStates, formProps));
4608
+ };
4609
+ /**
4610
+ * TextField is used to capture text data from users.
4611
+ */
4612
+ var FormikTextField = TextFieldComponent$1;
4613
+
4614
+ var _excluded$y = ["visibleIcon", "hiddenIcon"],
4615
+ _excluded2$3 = ["isVisible", "setIsVisible"];
4616
+ var PasswordComponent$1 = function PasswordComponent(_ref) {
4617
+ var _ref$visibleIcon = _ref.visibleIcon,
4618
+ visibleIcon = _ref$visibleIcon === void 0 ? React__default.createElement(OpenEyeSvg, {
4619
+ size: 14
4620
+ }) : _ref$visibleIcon,
4621
+ _ref$hiddenIcon = _ref.hiddenIcon,
4622
+ hiddenIcon = _ref$hiddenIcon === void 0 ? React__default.createElement(CloseEyeSvg, {
4623
+ size: 14
4624
+ }) : _ref$hiddenIcon,
4625
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$y);
4626
+ var formProps = useFormikInput(props);
4627
+ var _usePasswordState = usePasswordState(formProps),
4628
+ isVisible = _usePasswordState.isVisible,
4629
+ setIsVisible = _usePasswordState.setIsVisible,
4630
+ passwordProps = _objectWithoutPropertiesLoose(_usePasswordState, _excluded2$3);
4631
+ return React__default.createElement(TextFieldView, Object.assign({}, passwordProps, {
4632
+ type: isVisible ? 'text' : 'password',
4633
+ isClearable: false,
4634
+ rightChild: React__default.createElement(appStudio.View, {
4635
+ onClick: function onClick() {
4636
+ if (!props.isDisabled) {
4637
+ setIsVisible(!isVisible);
4638
+ }
4639
+ }
4640
+ }, isVisible ? visibleIcon : hiddenIcon)
4641
+ }));
4642
+ };
4643
+ /**
4644
+ * To allow users to securely enter sensitive information
4645
+ */
4646
+ var FormikPassword = PasswordComponent$1;
4647
+
4395
4648
  var useModalStore = /*#__PURE__*/zustand.create(function (set) {
4396
4649
  return {
4397
4650
  modal: false,
@@ -4477,8 +4730,8 @@ var HeaderIconSizes = {
4477
4730
  xl: 28
4478
4731
  };
4479
4732
 
4480
- var _excluded$u = ["children", "blur", "isOpen", "isClosePrevented", "onClose", "position"],
4481
- _excluded2$3 = ["children", "shadow", "isFullScreen", "shape"],
4733
+ var _excluded$z = ["children", "blur", "isOpen", "isClosePrevented", "onClose", "position"],
4734
+ _excluded2$4 = ["children", "shadow", "isFullScreen", "shape"],
4482
4735
  _excluded3$2 = ["children", "buttonColor", "iconSize", "buttonPosition"],
4483
4736
  _excluded4$2 = ["children"],
4484
4737
  _excluded5 = ["children"];
@@ -4493,7 +4746,7 @@ var ModalOverlay = function ModalOverlay(_ref) {
4493
4746
  onClose = _ref$onClose === void 0 ? function () {} : _ref$onClose,
4494
4747
  _ref$position = _ref.position,
4495
4748
  position = _ref$position === void 0 ? 'center' : _ref$position,
4496
- props = _objectWithoutPropertiesLoose(_ref, _excluded$u);
4749
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$z);
4497
4750
  var handleClick = function handleClick() {
4498
4751
  if (!isClosePrevented) onClose();
4499
4752
  };
@@ -4526,7 +4779,7 @@ var ModalContainer = function ModalContainer(_ref2) {
4526
4779
  isFullScreen = _ref2$isFullScreen === void 0 ? false : _ref2$isFullScreen,
4527
4780
  _ref2$shape = _ref2.shape,
4528
4781
  shape = _ref2$shape === void 0 ? 'rounded' : _ref2$shape,
4529
- props = _objectWithoutPropertiesLoose(_ref2, _excluded2$3);
4782
+ props = _objectWithoutPropertiesLoose(_ref2, _excluded2$4);
4530
4783
  var defaultShadow = typeof document !== undefined ? {
4531
4784
  boxShadow: '0px 2px 8px rgba(0, 0, 0, 0.3)'
4532
4785
  } : {
@@ -4649,12 +4902,12 @@ Modal.Body = ModalBody;
4649
4902
  Modal.Footer = ModalFooter;
4650
4903
  Modal.Layout = ModalLayout;
4651
4904
 
4652
- var _excluded$v = ["src", "color"],
4653
- _excluded2$4 = ["path"];
4905
+ var _excluded$A = ["src", "color"],
4906
+ _excluded2$5 = ["path"];
4654
4907
  var FileSVG = function FileSVG(_ref) {
4655
4908
  var src = _ref.src,
4656
4909
  color = _ref.color,
4657
- props = _objectWithoutPropertiesLoose(_ref, _excluded$v);
4910
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$A);
4658
4911
  var _useTheme = appStudio.useTheme(),
4659
4912
  getColor = _useTheme.getColor;
4660
4913
  var Colorprops = color ? {
@@ -4669,7 +4922,7 @@ var FileSVG = function FileSVG(_ref) {
4669
4922
  };
4670
4923
  var FileImage = function FileImage(_ref2) {
4671
4924
  var path = _ref2.path,
4672
- props = _objectWithoutPropertiesLoose(_ref2, _excluded2$4);
4925
+ props = _objectWithoutPropertiesLoose(_ref2, _excluded2$5);
4673
4926
  return React__default.createElement(appStudio.Image, Object.assign({
4674
4927
  src: path
4675
4928
  }, props));
@@ -4683,6 +4936,15 @@ exports.CountryPicker = CountryPicker;
4683
4936
  exports.DatePicker = DatePicker;
4684
4937
  exports.FileImage = FileImage;
4685
4938
  exports.FileSVG = FileSVG;
4939
+ exports.FormikCheckbox = FormikCheckbox;
4940
+ exports.FormikCountryPicker = FormikCountryPicker;
4941
+ exports.FormikDatePicker = FormikDatePicker;
4942
+ exports.FormikForm = FormikForm;
4943
+ exports.FormikPassword = FormikPassword;
4944
+ exports.FormikSelect = FormikSelect;
4945
+ exports.FormikSwitch = FormikSwitch;
4946
+ exports.FormikTextArea = FormikTextArea;
4947
+ exports.FormikTextField = FormikTextField;
4686
4948
  exports.Horizontal = Horizontal;
4687
4949
  exports.Inline = Inline;
4688
4950
  exports.Left = Left;