@app-studio/web 0.3.56 → 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.
Files changed (27) hide show
  1. package/dist/components/Form/TextField/TextField/TextField.state.d.ts +3 -3
  2. package/dist/components/Formik/Formik.Checkbox.d.ts +1 -1
  3. package/dist/components/Formik/Formik.CountryPicker.d.ts +1 -1
  4. package/dist/components/Formik/Formik.DatePicker.d.ts +1 -1
  5. package/dist/components/Formik/Formik.Form.d.ts +1 -1
  6. package/dist/components/Formik/Formik.Password.d.ts +1 -1
  7. package/dist/components/Formik/Formik.Select.d.ts +1 -1
  8. package/dist/components/Formik/Formik.Switch.d.ts +1 -1
  9. package/dist/components/Formik/Formik.TextArea.d.ts +1 -1
  10. package/dist/components/Formik/Formik.TextField.d.ts +1 -1
  11. package/dist/components/Formik/examples/FormikCheckbox.d.ts +1 -1
  12. package/dist/components/Formik/examples/FormikCountryPicker.d.ts +1 -1
  13. package/dist/components/Formik/examples/FormikDatePicker.d.ts +1 -1
  14. package/dist/components/Formik/examples/FormikPassword.d.ts +1 -1
  15. package/dist/components/Formik/examples/FormikSelect.d.ts +1 -1
  16. package/dist/components/Formik/examples/FormikSwitch.d.ts +1 -1
  17. package/dist/components/Formik/examples/FormikTextArea.d.ts +1 -1
  18. package/dist/components/Formik/examples/FormikTextField.d.ts +1 -1
  19. package/dist/components/Formik/index.d.ts +9 -9
  20. package/dist/components/index.d.ts +1 -0
  21. package/dist/web.cjs.development.js +273 -10
  22. package/dist/web.cjs.development.js.map +1 -1
  23. package/dist/web.cjs.production.min.js +1 -1
  24. package/dist/web.cjs.production.min.js.map +1 -1
  25. package/dist/web.esm.js +267 -13
  26. package/dist/web.esm.js.map +1 -1
  27. package/package.json +1 -1
package/dist/web.esm.js CHANGED
@@ -1,7 +1,8 @@
1
- import React, { useState, useEffect, useRef, useMemo, useCallback, Fragment } from 'react';
2
- import { View as View$1, Element, useTheme, Typography, Input, Image } from 'app-studio';
1
+ import React, { useState, useEffect, useRef, useMemo, useCallback, createContext, useContext, Fragment } from 'react';
2
+ import { View as View$1, Element, useTheme, Typography, Input, Form, Image } from 'app-studio';
3
3
  import { Link as Link$1 } from 'react-router-dom';
4
4
  import format from 'date-fns/format';
5
+ import { useFormikContext } from 'formik';
5
6
  import { create } from 'zustand';
6
7
 
7
8
  var useButtonState = function useButtonState() {
@@ -3342,7 +3343,8 @@ var DatePicker = DatePickerComponent;
3342
3343
 
3343
3344
  var useTextFieldState = function useTextFieldState(_ref) {
3344
3345
  var label = _ref.label,
3345
- placeholder = _ref.placeholder;
3346
+ placeholder = _ref.placeholder,
3347
+ defaultValue = _ref.value;
3346
3348
  var _useState = useState(label != null ? label : placeholder),
3347
3349
  hint = _useState[0],
3348
3350
  setHint = _useState[1];
@@ -3352,7 +3354,7 @@ var useTextFieldState = function useTextFieldState(_ref) {
3352
3354
  var _useState3 = useState(false),
3353
3355
  isHovered = _useState3[0],
3354
3356
  setIsHovered = _useState3[1];
3355
- var _useState4 = useState(''),
3357
+ var _useState4 = useState(defaultValue),
3356
3358
  value = _useState4[0],
3357
3359
  setValue = _useState4[1];
3358
3360
  useMemo(function () {
@@ -4384,6 +4386,258 @@ var TextFieldComponent = function TextFieldComponent(props) {
4384
4386
  */
4385
4387
  var TextField = TextFieldComponent;
4386
4388
 
4389
+ var FocusContext = /*#__PURE__*/createContext({
4390
+ active: false,
4391
+ focusNextInput: function focusNextInput() {},
4392
+ setInputRef: function setInputRef() {},
4393
+ handleSubmitEditing: function handleSubmitEditing() {},
4394
+ getReturnKeyType: function getReturnKeyType() {
4395
+ return 'next';
4396
+ }
4397
+ });
4398
+ var useFormFocus = function useFormFocus() {
4399
+ return useContext(FocusContext);
4400
+ };
4401
+ var FormikForm = function FormikForm(_ref) {
4402
+ var children = _ref.children,
4403
+ _ref$autoFocus = _ref.autoFocus,
4404
+ autoFocus = _ref$autoFocus === void 0 ? false : _ref$autoFocus,
4405
+ initFocus = _ref.initFocus;
4406
+ var formik = useFormikContext();
4407
+ var inputRefs = useRef({});
4408
+ var inputNames = useRef([]);
4409
+ var setInputRef = function setInputRef(name, ref) {
4410
+ inputRefs.current[name] = ref;
4411
+ if (!inputNames.current.includes(name)) {
4412
+ inputNames.current.push(name);
4413
+ }
4414
+ };
4415
+ var focusNextInput = function focusNextInput(currentName) {
4416
+ if (autoFocus) {
4417
+ var currentIndex = inputNames.current.indexOf(currentName);
4418
+ var nextIndex = currentIndex + 1;
4419
+ if (nextIndex < inputNames.current.length) {
4420
+ var _inputRefs$current$in;
4421
+ (_inputRefs$current$in = inputRefs.current[inputNames.current[nextIndex]]) == null || _inputRefs$current$in.focus();
4422
+ } else if (formik.onSubmit) {
4423
+ formik.onSubmit(formik.values);
4424
+ }
4425
+ }
4426
+ };
4427
+ var contextValue = {
4428
+ active: autoFocus,
4429
+ focusNextInput: focusNextInput,
4430
+ setInputRef: setInputRef,
4431
+ handleSubmitEditing: focusNextInput,
4432
+ getReturnKeyType: function getReturnKeyType(name) {
4433
+ return inputNames.current.indexOf(name) === inputNames.current.length - 1 ? 'done' : 'next';
4434
+ }
4435
+ };
4436
+ useEffect(function () {
4437
+ if (autoFocus) {
4438
+ if (initFocus && inputRefs.current[initFocus]) {
4439
+ var _inputRefs$current$in2;
4440
+ (_inputRefs$current$in2 = inputRefs.current[initFocus]) == null || _inputRefs$current$in2.focus();
4441
+ } else if (inputNames.current[0]) {
4442
+ var _inputRefs$current$in3;
4443
+ (_inputRefs$current$in3 = inputRefs.current[inputNames.current[0]]) == null || _inputRefs$current$in3.focus();
4444
+ }
4445
+ }
4446
+ }, [autoFocus, initFocus]);
4447
+ return React.createElement(FocusContext.Provider, {
4448
+ value: contextValue
4449
+ }, React.createElement(Form, null, children));
4450
+ };
4451
+
4452
+ var _excluded$u = ["name", "type"];
4453
+ var getInputTypeProps = function getInputTypeProps(type) {
4454
+ switch (type) {
4455
+ case 'email':
4456
+ return {
4457
+ autoCorrect: 'off',
4458
+ keyboardType: 'email-address',
4459
+ autoCapitalize: 'none'
4460
+ };
4461
+ case 'password':
4462
+ return {
4463
+ autoCorrect: 'off',
4464
+ secureTextEntry: true,
4465
+ autoCapitalize: 'none'
4466
+ };
4467
+ case 'digits':
4468
+ return {
4469
+ keyboardType: 'phone-pad'
4470
+ };
4471
+ case 'name':
4472
+ return {
4473
+ autoCorrect: 'off'
4474
+ };
4475
+ default:
4476
+ return {};
4477
+ }
4478
+ };
4479
+ var useFormikInput = function useFormikInput(_ref) {
4480
+ var name = _ref.name,
4481
+ type = _ref.type,
4482
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$u);
4483
+ var focus = useFormFocus();
4484
+ var _useFormikContext = useFormikContext(),
4485
+ touched = _useFormikContext.touched,
4486
+ errors = _useFormikContext.errors,
4487
+ submitCount = _useFormikContext.submitCount,
4488
+ values = _useFormikContext.values,
4489
+ setFieldTouched = _useFormikContext.setFieldTouched,
4490
+ setFieldValue = _useFormikContext.setFieldValue;
4491
+ var error = touched[name] || submitCount > 0 ? errors[name] : undefined;
4492
+ var onChangeText = function onChangeText(text) {
4493
+ setFieldValue(name, text);
4494
+ props.onChangeText == null || props.onChangeText(text);
4495
+ };
4496
+ var onChange = function onChange(value) {
4497
+ setFieldValue(name, value);
4498
+ props.onChange == null || props.onChange(value);
4499
+ };
4500
+ var handleBlur = function handleBlur() {
4501
+ setFieldTouched(name, true);
4502
+ // if(props.onBlur)props.onBlur();
4503
+ };
4504
+
4505
+ var handleKeyPress = function handleKeyPress(e) {
4506
+ if (e.key === 'Enter') {
4507
+ e.preventDefault();
4508
+ focus.focusNextInput(name);
4509
+ }
4510
+ };
4511
+ var isText = ['text', 'password', 'email', 'digits'].includes(type);
4512
+ return _extends({}, getInputTypeProps(type), props, {
4513
+ value: values[name],
4514
+ error: error,
4515
+ onBlur: handleBlur,
4516
+ onKeyPress: handleKeyPress
4517
+ }, isText ? {
4518
+ onChangeText: onChangeText
4519
+ } : {
4520
+ onChange: onChange
4521
+ }, focus.active ? {
4522
+ handleKeyPress: handleKeyPress
4523
+ } : {});
4524
+ };
4525
+ // import FormPicker from 'src/Picker/Picker';
4526
+ // import FormRater from 'src/Rate/Rate';
4527
+ // import Upload from 'src/Upload/Upload';
4528
+
4529
+ var _excluded$v = ["value"];
4530
+ var CheckboxComponent$1 = function CheckboxComponent(props) {
4531
+ var _useFormikInput = useFormikInput(props),
4532
+ value = _useFormikInput.value,
4533
+ formProps = _objectWithoutPropertiesLoose(_useFormikInput, _excluded$v);
4534
+ formProps.isChecked = value;
4535
+ var checkboxStates = useCheckboxState(props);
4536
+ return React.createElement(CheckboxView, Object.assign({}, checkboxStates, formProps));
4537
+ };
4538
+ /**
4539
+ * Checkbox allows users to select one or more options from a list of choices.
4540
+ */
4541
+ var FormikCheckbox = CheckboxComponent$1;
4542
+
4543
+ var DatePickerComponent$1 = function DatePickerComponent(props) {
4544
+ var formProps = useFormikInput(props);
4545
+ var datePickerStates = useDatePickerState();
4546
+ return React.createElement(DatePickerView, Object.assign({}, datePickerStates, formProps));
4547
+ };
4548
+ /**
4549
+ * Date picker allows users to select a date from a calendar view.
4550
+ */
4551
+ var FormikDatePicker = DatePickerComponent$1;
4552
+
4553
+ var CountryPickerComponent$1 = function CountryPickerComponent(props) {
4554
+ var formProps = useFormikInput(props);
4555
+ var countryPickerStates = useCountryPickerState(props);
4556
+ return React.createElement(CountryPickerView, Object.assign({}, countryPickerStates, formProps));
4557
+ };
4558
+ /**
4559
+ * Country picker allows users to select a country from a dropdown list or search field.
4560
+ */
4561
+ var FormikCountryPicker = CountryPickerComponent$1;
4562
+
4563
+ var SelectComponent$1 = function SelectComponent(props) {
4564
+ var formProps = useFormikInput(props);
4565
+ formProps.selected = formProps.value;
4566
+ var selectStates = useSelectState(props);
4567
+ return React.createElement(SelectView, Object.assign({}, selectStates, formProps));
4568
+ };
4569
+ /**
4570
+ * Select provides a dropdown list of options for the user to choose from.
4571
+ */
4572
+ var FormikSelect = SelectComponent$1;
4573
+
4574
+ var _excluded$w = ["value"];
4575
+ var SwitchComponent$1 = function SwitchComponent(props) {
4576
+ var _useFormikInput = useFormikInput(props),
4577
+ value = _useFormikInput.value,
4578
+ formProps = _objectWithoutPropertiesLoose(_useFormikInput, _excluded$w);
4579
+ formProps.isChecked = value;
4580
+ var switchStates = useSwitchState(props);
4581
+ return React.createElement(SwitchView, Object.assign({}, switchStates, formProps));
4582
+ };
4583
+ var FormikSwitch = SwitchComponent$1;
4584
+
4585
+ var TextAreaComponent$1 = function TextAreaComponent(props) {
4586
+ var formProps = useFormikInput(props);
4587
+ var textAreaState = useTextAreaState(props);
4588
+ return React.createElement(TextAreaView, Object.assign({}, textAreaState, formProps));
4589
+ };
4590
+ /**
4591
+ * Text Area is an component used to create a multi-line input field.
4592
+ */
4593
+ var FormikTextArea = TextAreaComponent$1;
4594
+
4595
+ var _excluded$x = ["value"];
4596
+ var TextFieldComponent$1 = function TextFieldComponent(props) {
4597
+ var formProps = useFormikInput(props);
4598
+ var _useTextFieldState = useTextFieldState(props),
4599
+ textFieldStates = _objectWithoutPropertiesLoose(_useTextFieldState, _excluded$x);
4600
+ return React.createElement(TextFieldView, Object.assign({}, textFieldStates, formProps));
4601
+ };
4602
+ /**
4603
+ * TextField is used to capture text data from users.
4604
+ */
4605
+ var FormikTextField = TextFieldComponent$1;
4606
+
4607
+ var _excluded$y = ["visibleIcon", "hiddenIcon"],
4608
+ _excluded2$3 = ["isVisible", "setIsVisible"];
4609
+ var PasswordComponent$1 = function PasswordComponent(_ref) {
4610
+ var _ref$visibleIcon = _ref.visibleIcon,
4611
+ visibleIcon = _ref$visibleIcon === void 0 ? React.createElement(OpenEyeSvg, {
4612
+ size: 14
4613
+ }) : _ref$visibleIcon,
4614
+ _ref$hiddenIcon = _ref.hiddenIcon,
4615
+ hiddenIcon = _ref$hiddenIcon === void 0 ? React.createElement(CloseEyeSvg, {
4616
+ size: 14
4617
+ }) : _ref$hiddenIcon,
4618
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$y);
4619
+ var formProps = useFormikInput(props);
4620
+ var _usePasswordState = usePasswordState(formProps),
4621
+ isVisible = _usePasswordState.isVisible,
4622
+ setIsVisible = _usePasswordState.setIsVisible,
4623
+ passwordProps = _objectWithoutPropertiesLoose(_usePasswordState, _excluded2$3);
4624
+ return React.createElement(TextFieldView, Object.assign({}, passwordProps, {
4625
+ type: isVisible ? 'text' : 'password',
4626
+ isClearable: false,
4627
+ rightChild: React.createElement(View$1, {
4628
+ onClick: function onClick() {
4629
+ if (!props.isDisabled) {
4630
+ setIsVisible(!isVisible);
4631
+ }
4632
+ }
4633
+ }, isVisible ? visibleIcon : hiddenIcon)
4634
+ }));
4635
+ };
4636
+ /**
4637
+ * To allow users to securely enter sensitive information
4638
+ */
4639
+ var FormikPassword = PasswordComponent$1;
4640
+
4387
4641
  var useModalStore = /*#__PURE__*/create(function (set) {
4388
4642
  return {
4389
4643
  modal: false,
@@ -4469,8 +4723,8 @@ var HeaderIconSizes = {
4469
4723
  xl: 28
4470
4724
  };
4471
4725
 
4472
- var _excluded$u = ["children", "blur", "isOpen", "isClosePrevented", "onClose", "position"],
4473
- _excluded2$3 = ["children", "shadow", "isFullScreen", "shape"],
4726
+ var _excluded$z = ["children", "blur", "isOpen", "isClosePrevented", "onClose", "position"],
4727
+ _excluded2$4 = ["children", "shadow", "isFullScreen", "shape"],
4474
4728
  _excluded3$2 = ["children", "buttonColor", "iconSize", "buttonPosition"],
4475
4729
  _excluded4$2 = ["children"],
4476
4730
  _excluded5 = ["children"];
@@ -4485,7 +4739,7 @@ var ModalOverlay = function ModalOverlay(_ref) {
4485
4739
  onClose = _ref$onClose === void 0 ? function () {} : _ref$onClose,
4486
4740
  _ref$position = _ref.position,
4487
4741
  position = _ref$position === void 0 ? 'center' : _ref$position,
4488
- props = _objectWithoutPropertiesLoose(_ref, _excluded$u);
4742
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$z);
4489
4743
  var handleClick = function handleClick() {
4490
4744
  if (!isClosePrevented) onClose();
4491
4745
  };
@@ -4518,7 +4772,7 @@ var ModalContainer = function ModalContainer(_ref2) {
4518
4772
  isFullScreen = _ref2$isFullScreen === void 0 ? false : _ref2$isFullScreen,
4519
4773
  _ref2$shape = _ref2.shape,
4520
4774
  shape = _ref2$shape === void 0 ? 'rounded' : _ref2$shape,
4521
- props = _objectWithoutPropertiesLoose(_ref2, _excluded2$3);
4775
+ props = _objectWithoutPropertiesLoose(_ref2, _excluded2$4);
4522
4776
  var defaultShadow = typeof document !== undefined ? {
4523
4777
  boxShadow: '0px 2px 8px rgba(0, 0, 0, 0.3)'
4524
4778
  } : {
@@ -4641,12 +4895,12 @@ Modal.Body = ModalBody;
4641
4895
  Modal.Footer = ModalFooter;
4642
4896
  Modal.Layout = ModalLayout;
4643
4897
 
4644
- var _excluded$v = ["src", "color"],
4645
- _excluded2$4 = ["path"];
4898
+ var _excluded$A = ["src", "color"],
4899
+ _excluded2$5 = ["path"];
4646
4900
  var FileSVG = function FileSVG(_ref) {
4647
4901
  var src = _ref.src,
4648
4902
  color = _ref.color,
4649
- props = _objectWithoutPropertiesLoose(_ref, _excluded$v);
4903
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$A);
4650
4904
  var _useTheme = useTheme(),
4651
4905
  getColor = _useTheme.getColor;
4652
4906
  var Colorprops = color ? {
@@ -4661,11 +4915,11 @@ var FileSVG = function FileSVG(_ref) {
4661
4915
  };
4662
4916
  var FileImage = function FileImage(_ref2) {
4663
4917
  var path = _ref2.path,
4664
- props = _objectWithoutPropertiesLoose(_ref2, _excluded2$4);
4918
+ props = _objectWithoutPropertiesLoose(_ref2, _excluded2$5);
4665
4919
  return React.createElement(Image, Object.assign({
4666
4920
  src: path
4667
4921
  }, props));
4668
4922
  };
4669
4923
 
4670
- export { Bottom, Button, Center, Checkbox, CountryPicker, DatePicker, FileImage, FileSVG, Horizontal, Inline, Left, Link, Loader, Modal, Password, Right, Select, Switch, Text, TextArea, TextField, Top, Vertical, View, hideModal, showModal, useModalStore };
4924
+ export { Bottom, Button, Center, Checkbox, CountryPicker, DatePicker, FileImage, FileSVG, FormikCheckbox, FormikCountryPicker, FormikDatePicker, FormikForm, FormikPassword, FormikSelect, FormikSwitch, FormikTextArea, FormikTextField, Horizontal, Inline, Left, Link, Loader, Modal, Password, Right, Select, Switch, Text, TextArea, TextField, Top, Vertical, View, hideModal, showModal, useModalStore };
4671
4925
  //# sourceMappingURL=web.esm.js.map