@startlibs/form 1.0.12 → 1.1.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.
Files changed (92) hide show
  1. package/lib/AutoComplete.mjs +550 -0
  2. package/lib/AutoComplete.mjs.map +1 -0
  3. package/lib/Checkbox.mjs +76 -0
  4. package/lib/Checkbox.mjs.map +1 -0
  5. package/lib/Combobox.mjs +544 -0
  6. package/lib/Combobox.mjs.map +1 -0
  7. package/lib/ComboboxWithCustom.mjs +77 -0
  8. package/lib/ComboboxWithCustom.mjs.map +1 -0
  9. package/lib/DatePicker.mjs +625 -0
  10. package/lib/DatePicker.mjs.map +1 -0
  11. package/lib/EditableBox.mjs +496 -0
  12. package/lib/EditableBox.mjs.map +1 -0
  13. package/lib/Errors.mjs +176 -0
  14. package/lib/Errors.mjs.map +1 -0
  15. package/lib/ExpandableBox.mjs +209 -0
  16. package/lib/ExpandableBox.mjs.map +1 -0
  17. package/lib/Field.mjs +65 -0
  18. package/lib/Field.mjs.map +1 -0
  19. package/lib/FieldBox.mjs +80 -0
  20. package/lib/FieldBox.mjs.map +1 -0
  21. package/lib/Form.mjs +322 -0
  22. package/lib/Form.mjs.map +1 -0
  23. package/lib/FormValue.mjs +111 -0
  24. package/lib/FormValue.mjs.map +1 -0
  25. package/lib/InputboxGroup.mjs +104 -0
  26. package/lib/InputboxGroup.mjs.map +1 -0
  27. package/lib/Radiobox.mjs +67 -0
  28. package/lib/Radiobox.mjs.map +1 -0
  29. package/lib/RichText.mjs +634 -0
  30. package/lib/RichText.mjs.map +1 -0
  31. package/lib/TextInput.mjs +359 -0
  32. package/lib/TextInput.mjs.map +1 -0
  33. package/lib/alt/checkbox/SimpleCheckbox.mjs +82 -0
  34. package/lib/alt/checkbox/SimpleCheckbox.mjs.map +1 -0
  35. package/lib/alt/checkbox/ToggleCheckbox.mjs +68 -0
  36. package/lib/alt/checkbox/ToggleCheckbox.mjs.map +1 -0
  37. package/lib/alt/radiobox/CleanTabRadiobox.mjs +44 -0
  38. package/lib/alt/radiobox/CleanTabRadiobox.mjs.map +1 -0
  39. package/lib/alt/radiobox/IconRadioBox.mjs +52 -0
  40. package/lib/alt/radiobox/IconRadioBox.mjs.map +1 -0
  41. package/lib/alt/radiobox/SimpleRadiobox.mjs +61 -0
  42. package/lib/alt/radiobox/SimpleRadiobox.mjs.map +1 -0
  43. package/lib/alt/radiobox/TabRadiobox.mjs +54 -0
  44. package/lib/alt/radiobox/TabRadiobox.mjs.map +1 -0
  45. package/lib/enhanceInput.mjs +131 -0
  46. package/lib/enhanceInput.mjs.map +1 -0
  47. package/lib/index.cjs +5345 -0
  48. package/lib/index.cjs.map +1 -0
  49. package/lib/index.mjs +28 -0
  50. package/lib/index.mjs.map +1 -0
  51. package/lib/useConfirmDialog.mjs +117 -0
  52. package/lib/useConfirmDialog.mjs.map +1 -0
  53. package/lib/useDraftConfirmation.mjs +56 -0
  54. package/lib/useDraftConfirmation.mjs.map +1 -0
  55. package/lib/validation.mjs +91 -0
  56. package/lib/validation.mjs.map +1 -0
  57. package/lib/withFormImageInput.mjs +281 -0
  58. package/lib/withFormImageInput.mjs.map +1 -0
  59. package/package.json +44 -25
  60. package/src/AutoComplete.jsx +642 -0
  61. package/src/Checkbox.jsx +45 -0
  62. package/src/Combobox.jsx +606 -0
  63. package/src/ComboboxWithCustom.jsx +68 -0
  64. package/src/DatePicker.jsx +733 -0
  65. package/src/EditableBox.jsx +502 -0
  66. package/src/Errors.jsx +174 -0
  67. package/src/ExpandableBox.jsx +207 -0
  68. package/src/Field.jsx +76 -0
  69. package/src/FieldBox.jsx +136 -0
  70. package/src/Form.jsx +291 -0
  71. package/src/FormValue.jsx +67 -0
  72. package/src/IconRadioBoxOldHubt.jsx +93 -0
  73. package/src/InputboxGroup.jsx +121 -0
  74. package/src/Radiobox.jsx +33 -0
  75. package/src/RichText.jsx +812 -0
  76. package/src/TextInput.jsx +519 -0
  77. package/src/alt/checkbox/SimpleCheckbox.jsx +162 -0
  78. package/src/alt/checkbox/ToggleCheckbox.jsx +143 -0
  79. package/src/alt/radiobox/CleanTabRadiobox.jsx +46 -0
  80. package/src/alt/radiobox/IconRadioBox.jsx +93 -0
  81. package/src/alt/radiobox/SimpleRadiobox.jsx +153 -0
  82. package/src/alt/radiobox/TabRadiobox.jsx +73 -0
  83. package/src/enhanceInput.jsx +107 -0
  84. package/src/index.js +27 -0
  85. package/src/useConfirmDialog.jsx +105 -0
  86. package/src/useDraftConfirmation.jsx +60 -0
  87. package/src/validation.js +92 -0
  88. package/src/withFormImageInput.jsx +297 -0
  89. package/.babelrc +0 -28
  90. package/lib/index.js +0 -6258
  91. package/rollup.config.js +0 -43
  92. package/yarn-error.log +0 -1607
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Field.mjs","sources":["../src/Field.jsx"],"sourcesContent":["import styled from 'styled-components'\nimport React from 'react'\nimport {getMargin, customTheme} from '@startlibs/utils'\n\n\nconst Mandatory = styled.span`\n color: #c3282d;\n margin-left: 1px;\n vertical-align: top;\n line-height: 100%;\n margin-top: -1px;\n ${props => typeof props.mandatory === 'string' && `color: ${props.mandatory};`}\n`\nconst Container = styled.div`\n position: relative;\n margin-bottom: ${props => getMargin(props.theme.Field.margins)(props)};\n text-align: left;\n`\nconst Label = styled.label`\n font-weight: 550;\n display: inline-block;\n font-size: ${props => props.labelFontSize ? props.labelFontSize : '15'}px;\n margin-bottom: .75rem;\n ${props => props.isOnImage && 'color: #fff;'}\n ${customTheme(\"FieldLabel\")}\n`\n\nexport const HelpText = styled.span`\n color: rgba(0,0,0,0.4);\n font-weight: 400;\n`\nexport const FieldDescription = styled.span`\n color: rgba(0,0,0,0.4);\n display: block;\n font-size: 12px;\n margin: 0.25rem 0 0;\n font-weight: 400;\n`\nexport const BellowFieldDescription = styled(FieldDescription)`\n margin: 0.5rem 0 0;\n`\n\nexport const Field = React.forwardRef((\n {\n label,\n helpText,\n descText,\n bellowDescText,\n className,\n labelClick,\n focused,\n mandatory,\n onImage,\n children,\n labelFontSize,\n ...rest\n }, ref) =>\n <Container ref={ref} {...rest} className={className}>\n {\n label &&\n <Label {...rest} onClick={labelClick} labelFontSize={labelFontSize}>\n {label}{mandatory && <Mandatory mandatory={mandatory}>*</Mandatory>}\n {helpText && <HelpText> {helpText}</HelpText>}\n {descText && <FieldDescription>{descText}</FieldDescription>}\n </Label>\n }\n {children}\n {bellowDescText && <BellowFieldDescription>{bellowDescText}</BellowFieldDescription>}\n </Container>\n)\n\nField.Label = Label\nField.Container = Container\nField.HelpText = HelpText\nField.Description = FieldDescription\nField.displayName = \"Field\""],"names":["Mandatory","styled","span","withConfig","displayName","componentId","props","mandatory","concat","Container","div","getMargin","theme","Field","margins","Label","label","labelFontSize","isOnImage","customTheme","HelpText","FieldDescription","BellowFieldDescription","React","forwardRef","_ref","ref","helpText","descText","bellowDescText","className","labelClick","focused","onImage","children","rest","_objectWithoutProperties","_excluded","createElement","_extends","onClick","Description"],"mappings":";;;;;;;AAKA,MAAMA,SAAS,gBAAGC,MAAM,CAACC,IAAI,CAAAC,UAAA,CAAA;EAAAC,WAAA,EAAA,kBAAA;EAAAC,WAAA,EAAA,aAAA;AAAA,CAAA,CAAA,CAAA,CAAA,oFAAA,EAAA,EAAA,CAAA,EAMzBC,KAAK,IAAI,OAAOA,KAAK,CAACC,SAAS,KAAK,QAAQ,IAAA,SAAA,CAAAC,MAAA,CAAcF,KAAK,CAACC,SAAS,MAAG,CAC/E,CAAA;AACD,MAAME,SAAS,gBAAGR,MAAM,CAACS,GAAG,CAAAP,UAAA,CAAA;EAAAC,WAAA,EAAA,kBAAA;EAAAC,WAAA,EAAA,aAAA;AAAA,CAAA,CAAA,CAAA,CAAA,kCAAA,EAAA,mBAAA,CAAA,EAETC,KAAK,IAAIK,SAAS,CAACL,KAAK,CAACM,KAAK,CAACC,KAAK,CAACC,OAAO,CAAC,CAACR,KAAK,CAAC,CAEtE,CAAA;AACD,MAAMS,KAAK,gBAAGd,MAAM,CAACe,KAAK,CAA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C7B,SAAS,EAAA8B,QAAA,CAAA;AAACb,IAAAA,GAAG,EAAEA,GAAAA;AAAI,GAAA,EAAKS,IAAI,EAAA;AAAEL,IAAAA,SAAS,EAAEA,SAAAA;GAEtCd,CAAAA,EAAAA,KAAK,iBACLO,KAAA,CAAAe,aAAA,CAACvB,KAAK,EAAAwB,QAAA,CAAA,EAAA,EAAKJ,IAAI,EAAA;AAAEK,IAAAA,OAAO,EAAET,UAAW;AAACd,IAAAA,aAAa,EAAEA,aAAAA;GAClDD,CAAAA,EAAAA,KAAK,EAAET,SAAS,iBAAIgB,KAAA,CAAAe,aAAA,CAACtC,SAAS,EAAA;AAACO,IAAAA,SAAS,EAAEA,SAAAA;AAAU,GAAA,EAAC,GAAY,CAAC,EAClEoB,QAAQ,iBAAIJ,KAAA,CAAAe,aAAA,CAAClB,QAAQ,EAAA,IAAA,EAAC,GAAC,EAACO,QAAmB,CAAC,EAC5CC,QAAQ,iBAAIL,KAAA,CAAAe,aAAA,CAACjB,gBAAgB,EAAEO,IAAAA,EAAAA,QAA2B,CACtD,CAAC,EAETM,QAAQ,EACRL,cAAc,iBAAIN,KAAA,CAAAe,aAAA,CAAChB,sBAAsB,EAAEO,IAAAA,EAAAA,cAAuC,CAC1E,CAAC,CAAA;AAAA,CACd,EAAC;AAEDhB,KAAK,CAACE,KAAK,GAAGA,KAAK,CAAA;AACnBF,KAAK,CAACJ,SAAS,GAAGA,SAAS,CAAA;AAC3BI,KAAK,CAACO,QAAQ,GAAGA,QAAQ,CAAA;AACzBP,KAAK,CAAC4B,WAAW,GAAGpB,gBAAgB,CAAA;AACpCR,KAAK,CAACT,WAAW,GAAG,OAAO;;;;"}
@@ -0,0 +1,80 @@
1
+ import _taggedTemplateLiteral from '@babel/runtime/helpers/taggedTemplateLiteral';
2
+ import _extends from '@babel/runtime/helpers/extends';
3
+ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
4
+ import React from 'react';
5
+ import { darken } from 'polished';
6
+ import styled, { css } from 'styled-components';
7
+ import { getColor, constrainEvent, callIfFunction, media } from '@startlibs/utils';
8
+ import { Icon, TextButton } from '@startlibs/components';
9
+ import { usePopupToggle } from '@startlibs/core';
10
+ import { HelpText } from './Field.mjs';
11
+
12
+ var _templateObject;
13
+ const _excluded = ["className", "label", "helpText", "descText", "actionLabel", "rightContainer", "onClick", "icon", "remove", "children", "dropDownMenu"];
14
+ const FieldBoxIcon = /*#__PURE__*/styled(Icon).withConfig({
15
+ displayName: "FieldBox__FieldBoxIcon",
16
+ componentId: "sc-18ntu84-0"
17
+ })(["font-size:25px;width:25px;text-align:center;margin-right:1rem;"]);
18
+ const FieldBoxAction = /*#__PURE__*/styled.div.withConfig({
19
+ displayName: "FieldBox__FieldBoxAction",
20
+ componentId: "sc-18ntu84-1"
21
+ })(["margin-left:auto;color:", ";padding-left:1rem;font-size:13px;font-weight:500;"], getColor('main'));
22
+ const FieldBoxHelpText = /*#__PURE__*/styled.span.withConfig({
23
+ displayName: "FieldBox__FieldBoxHelpText",
24
+ componentId: "sc-18ntu84-2"
25
+ })(["font-weight:400;color:rgba(0,0,0,0.4);font-size:12px;"]);
26
+ const FieldBoxContent = /*#__PURE__*/styled.div.withConfig({
27
+ displayName: "FieldBox__FieldBoxContent",
28
+ componentId: "sc-18ntu84-3"
29
+ })(["margin-right:auto;min-width:0;"]);
30
+ const DeleteButton = /*#__PURE__*/styled(Icon).attrs({
31
+ icon: 'x'
32
+ }).withConfig({
33
+ displayName: "FieldBox__DeleteButton",
34
+ componentId: "sc-18ntu84-4"
35
+ })(["width:24px;height:24px;line-height:24px;border-radius:50%;display:inline-block;font-size:18px;margin-left:0.75rem;text-align:center;cursor:pointer;color:", ";background-color:rgba(0,0,0,0.08);flex-shrink:0;:hover{background:rgba(0,0,0,0.11);}:active{background:rgba(0,0,0,0.13);}"], getColor('gray120'));
36
+ const DropdownButton = /*#__PURE__*/styled(Icon).attrs({
37
+ icon: 'arrow-down'
38
+ }).withConfig({
39
+ displayName: "FieldBox__DropdownButton",
40
+ componentId: "sc-18ntu84-5"
41
+ })(["width:24px;height:24px;line-height:24px;border-radius:50%;display:inline-block;font-size:14px;margin-left:0.75rem;text-align:center;cursor:pointer;color:", ";background-color:rgba(0,0,0,0.08);flex-shrink:0;position:relative;:hover{background:rgba(0,0,0,0.11);}:active{background:rgba(0,0,0,0.13);}"], getColor('gray120'));
42
+ const DescText = /*#__PURE__*/styled.div.withConfig({
43
+ displayName: "FieldBox__DescText",
44
+ componentId: "sc-18ntu84-6"
45
+ })(["font-weight:400;color:rgba(0,0,0,0.4);font-size:12px;margin-top:0.25rem;"]);
46
+ const FieldBox = /*#__PURE__*/styled(_ref => {
47
+ let {
48
+ className,
49
+ label,
50
+ helpText,
51
+ descText,
52
+ actionLabel,
53
+ rightContainer,
54
+ onClick,
55
+ icon,
56
+ remove,
57
+ children,
58
+ dropDownMenu
59
+ } = _ref,
60
+ props = _objectWithoutProperties(_ref, _excluded);
61
+ const menuToggle = usePopupToggle();
62
+ return /*#__PURE__*/React.createElement("div", _extends({
63
+ className: className,
64
+ onClick: onClick
65
+ }, props), icon && /*#__PURE__*/React.createElement(FieldBoxIcon, {
66
+ icon: icon
67
+ }), /*#__PURE__*/React.createElement(FieldBoxContent, null, label, helpText && /*#__PURE__*/React.createElement(HelpText, null, " ", helpText), descText && /*#__PURE__*/React.createElement(DescText, null, descText), children), actionLabel && /*#__PURE__*/React.createElement(TextButton, null, actionLabel), rightContainer && /*#__PURE__*/React.createElement("div", {
68
+ className: "rightContainer"
69
+ }, rightContainer), remove && /*#__PURE__*/React.createElement(DeleteButton, {
70
+ onClick: constrainEvent(remove)
71
+ }), dropDownMenu && /*#__PURE__*/React.createElement(DropdownButton, {
72
+ onClick: constrainEvent(menuToggle.toggle)
73
+ }, menuToggle.isOpen && callIfFunction(dropDownMenu)));
74
+ }).withConfig({
75
+ displayName: "FieldBox",
76
+ componentId: "sc-18ntu84-7"
77
+ })(["display:flex;align-items:center;width:100%;background:", ";border-radius:8px;min-height:42px;padding:1rem 1.25rem;align-items:center;font-size:14px;color:", ";position:relative;transition:border-radius 0.5s ease;", " & ~ &{margin-top:0.75rem;}", " ", ",.rightContainer{margin-left:1rem;}"], getColor('lightBluishGray'), getColor('gray60'), props => props.onClick && css(["cursor:pointer;:hover{background:", ";}:active{background:", ";transition:none;}"], props => darken(0.035, getColor('lightBluishGray')(props)), props => darken(0.05, getColor('lightBluishGray')(props))), media.mobile(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n min-height: 54px;\n font-size: 15px !important;\n "]))), TextButton);
78
+
79
+ export { FieldBox, FieldBoxAction, FieldBoxHelpText, FieldBoxIcon };
80
+ //# sourceMappingURL=FieldBox.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FieldBox.mjs","sources":["../src/FieldBox.jsx"],"sourcesContent":["import React from 'react'\nimport {darken} from 'polished'\nimport styled, {css} from 'styled-components'\nimport {media, callIfFunction, constrainEvent} from '@startlibs/utils';\nimport {Icon, TextButton} from '@startlibs/components'\nimport {getColor } from '@startlibs/utils';\nimport {usePopupToggle } from '@startlibs/core';\nimport {HelpText} from './Field'\n\nexport const FieldBoxIcon = styled(Icon)`\n font-size: 25px;\n width: 25px;\n text-align: center;\n margin-right: 1rem;\n`\nexport const FieldBoxAction = styled.div`\n margin-left: auto;\n color: ${getColor('main')};\n padding-left: 1rem;\n font-size: 13px;\n font-weight: 500;\n`\n \nexport const FieldBoxHelpText = styled.span`\n font-weight: 400;\n color: rgba(0,0,0,0.4);\n font-size: 12px;\n`\n\nconst FieldBoxContent = styled.div`\n margin-right: auto;\n min-width: 0;\n`\n\nconst DeleteButton = styled(Icon).attrs({icon: 'x'})`\n width: 24px;\n height: 24px;\n line-height: 24px;\n border-radius: 50%;\n display: inline-block;\n font-size: 18px;\n margin-left: 0.75rem;\n text-align: center;\n cursor: pointer;\n color: ${getColor('gray120')};\n background-color: rgba(0,0,0,0.08);\n flex-shrink: 0;\n :hover {\n background: rgba(0,0,0,0.11);\n }\n :active {\n background: rgba(0,0,0,0.13);\n }\n`\nconst DropdownButton = styled(Icon).attrs({icon: 'arrow-down'})`\n width: 24px;\n height: 24px;\n line-height: 24px;\n border-radius: 50%;\n display: inline-block;\n font-size: 14px;\n margin-left: 0.75rem;\n text-align: center;\n cursor: pointer;\n color: ${getColor('gray120')};\n background-color: rgba(0,0,0,0.08);\n flex-shrink: 0;\n position: relative;\n :hover {\n background: rgba(0,0,0,0.11);\n }\n :active {\n background: rgba(0,0,0,0.13);\n }\n`\n\nconst DescText = styled.div `\n font-weight: 400;\n color: rgba(0,0,0,0.4);\n font-size: 12px;\n margin-top: 0.25rem;\n`\n\n\nexport const FieldBox = styled(({className,label,helpText,descText,actionLabel,rightContainer,onClick,icon,remove,children,dropDownMenu,...props}) => {\n const menuToggle = usePopupToggle()\n return <div className={className} onClick={onClick} {...props}>\n {icon && <FieldBoxIcon icon={icon}/>}\n <FieldBoxContent>\n {label}{helpText && <HelpText> {helpText}</HelpText>}\n {descText && <DescText>{descText}</DescText>}\n {children}\n </FieldBoxContent>\n {actionLabel && <TextButton>{actionLabel}</TextButton>}\n {rightContainer && <div className=\"rightContainer\">{rightContainer}</div>}\n {remove && <DeleteButton onClick={constrainEvent(remove)}/>}\n {\n dropDownMenu && <DropdownButton onClick={constrainEvent(menuToggle.toggle)}>\n {menuToggle.isOpen && callIfFunction(dropDownMenu)}\n </DropdownButton>\n }\n </div>\n})`\n display: flex;\n align-items: center;\n width: 100%;\n background: ${getColor('lightBluishGray')};\n border-radius: 8px;\n min-height: 42px;\n padding: 1rem 1.25rem;\n align-items: center;\n font-size: 14px;\n color: ${getColor('gray60')};\n position: relative;\n transition: border-radius 0.5s ease;\n ${props => props.onClick && css`\n cursor: pointer;\n :hover {\n background: ${props => darken(0.035, getColor('lightBluishGray')(props))};\n }\n :active {\n background: ${props => darken(0.05, getColor('lightBluishGray')(props))};\n transition: none;\n }\n `}\n & ~ & {\n margin-top: 0.75rem;\n }\n ${media.mobile`\n min-height: 54px;\n font-size: 15px !important;\n `}\n ${TextButton}, .rightContainer {\n margin-left: 1rem;\n }\n`"],"names":["FieldBoxIcon","styled","Icon","withConfig","displayName","componentId","FieldBoxAction","div","getColor","FieldBoxHelpText","span","FieldBoxContent","DeleteButton","attrs","icon","DropdownButton","DescText","FieldBox","_ref","className","label","helpText","descText","actionLabel","rightContainer","onClick","remove","children","dropDownMenu","props","_objectWithoutProperties","_excluded","menuToggle","usePopupToggle","React","createElement","_extends","HelpText","TextButton","constrainEvent","toggle","isOpen","callIfFunction","css","darken","media","mobile","_templateObject","_taggedTemplateLiteral"],"mappings":";;;;;;;;;;;;;AASO,MAAMA,YAAY,gBAAGC,MAAM,CAACC,IAAI,CAAC,CAAAC,UAAA,CAAA;EAAAC,WAAA,EAAA,wBAAA;EAAAC,WAAA,EAAA,cAAA;AAAA,CAKvC,CAAA,CAAA,CAAA,gEAAA,CAAA,EAAA;MACYC,cAAc,gBAAGL,MAAM,CAACM,GAAG,CAAAJ,UAAA,CAAA;EAAAC,WAAA,EAAA,0BAAA;EAAAC,WAAA,EAAA,cAAA;AAAA,CAAA,CAAA,CAAA,CAAA,yBAAA,EAAA,oDAAA,CAAA,EAE7BG,QAAQ,CAAC,MAAM,CAAC,EAI1B;MAEYC,gBAAgB,gBAAGR,MAAM,CAACS,IAAI,CAAAP,UAAA,CAAA;EAAAC,WAAA,EAAA,4BAAA;EAAAC,WAAA,EAAA,cAAA;AAAA,CAI1C,CAAA,CAAA,CAAA,uDAAA,CAAA,EAAA;AAED,MAAMM,eAAe,gBAAGV,MAAM,CAACM,GAAG,CAAAJ,UAAA,CAAA;EAAAC,WAAA,EAAA,2BAAA;EAAAC,WAAA,EAAA,cAAA;AAAA,CAGjC,CAAA,CAAA,CAAA,gCAAA,CAAA,CAAA,CAAA;AAED,MAAMO,YAAY,gBAAGX,MAAM,CAACC,IAAI,CAAC,CAACW,KAAK,CAAC;AAACC,EAAAA,IAAI,EAAE,GAAA;AAAG,CAAC,CAAC,CAAAX,UA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M,CAAC,KAAK,EAAEpC,QAAQ,CAAC,iBAAiB,CAAC,CAACqB,KAAK,CAAC,CAAC,EAG1DA,KAAK,IAAIe,MAAM,CAAC,IAAI,EAAEpC,QAAQ,CAAC,iBAAiB,CAAC,CAACqB,KAAK,CAAC,CAAC,CAG1E,EAICgB,KAAK,CAACC,MAAM,CAAAC,eAAA,KAAAA,eAAA,GAAAC,sBAAA,CAIZV,CAAAA,8DAAAA,CAAAA,CAAAA,CAAAA,CAAAA,EAAAA,UAAU;;;;"}
package/lib/Form.mjs ADDED
@@ -0,0 +1,322 @@
1
+ import _extends from '@babel/runtime/helpers/extends';
2
+ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
3
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
4
+ import _set from 'lodash/fp/set';
5
+ import _update from 'lodash/fp/update';
6
+ import _isFunction from 'lodash/fp/isFunction';
7
+ import _get from 'lodash/fp/get';
8
+ import React, { useContext, useState, useMemo, useImperativeHandle, forwardRef } from 'react';
9
+ import { willUseSpreadState, useRefState, StartlibsContext, useToggle, useIsUnmounted, useConsumerCatalog } from '@startlibs/core';
10
+ import { _s, callIfFunction, ifUndefined } from '@startlibs/utils';
11
+ import { useProvideErrors } from './Errors.mjs';
12
+ import { useDraftConfirmation } from './useDraftConfirmation.mjs';
13
+
14
+ const _excluded = ["children"];
15
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
16
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
17
+ const getFormResponse = function (setter) {
18
+ let path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
19
+ return (_, v) => setter(_s.get(path, v));
20
+ };
21
+ const getFormValues = function (setter) {
22
+ let path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
23
+ return values => setter(_s.get(path, values));
24
+ };
25
+ const FormContext = /*#__PURE__*/React.createContext({});
26
+ const ComponentMetaContext = /*#__PURE__*/React.createContext({});
27
+ const [useProvideValues, useSpreadValue, FormValueContext] = willUseSpreadState();
28
+ const [useProvideMeta, useMeta] = willUseSpreadState();
29
+ const useFormValue = useSpreadValue;
30
+ const useFormValueRef = () => {
31
+ const [get, set] = useContext(FormValueContext);
32
+ return [get, set];
33
+ };
34
+ const useFormMeta = useMeta;
35
+ const useForm = (_ref, ref) => {
36
+ let {
37
+ action,
38
+ alwaysSave = false,
39
+ skipDom = false,
40
+ values: initialValues = {},
41
+ meta = {},
42
+ transform = v => v,
43
+ preValidation = () => false,
44
+ loadingBeforeValidate,
45
+ onSuccess = () => {},
46
+ onFailure = () => {},
47
+ onNonPreValidation,
48
+ onChange,
49
+ autoComplete
50
+ } = _ref;
51
+ const outerConfig = {
52
+ onSuccess,
53
+ onFailure,
54
+ transform,
55
+ preValidation,
56
+ alwaysSave,
57
+ action
58
+ };
59
+ const currentInitialValues = useRefState(initialValues);
60
+ currentInitialValues.set(initialValues);
61
+ const startlibs = useContext(StartlibsContext);
62
+ const [hasChanged, setHasChangedValue] = useState(false);
63
+ const hasChangedRef = useRefState(false);
64
+ const shouldResubmitForm = useToggle(false, (next, prev) => prev && !next && errorsUtils.removeErrorPath('_shouldResubmitForm'));
65
+ const resubmittingForm = useRefState(false);
66
+ const loading = useToggle();
67
+ const isUnmounted = useIsUnmounted();
68
+ const [ErrorsProvider, errorsContext, errorsUtils] = useProvideErrors();
69
+ const [registeredComponentMetas, componentMetasManager] = useConsumerCatalog();
70
+ const [confirmDraftContent, draftToggle, draftConfirmation] = useDraftConfirmation(() => submitForm(undefined, {
71
+ isConfirming: true
72
+ }));
73
+ const handleValuesChange = (prev, next) => {
74
+ if (!hasChangedRef.get()) {
75
+ setHasChanged(true);
76
+ }
77
+ callIfFunction(onChange, prev, next, utils);
78
+ };
79
+ const setHasChanged = v => {
80
+ shouldResubmitForm.close();
81
+ if (v !== hasChangedRef.get()) {
82
+ draftToggle.openWith(v);
83
+ setHasChangedValue(v);
84
+ hasChangedRef.set(v);
85
+ }
86
+ };
87
+ const [ValuesProvider, valuesManager, [getValues, setValues]] = useProvideValues(initialValues, handleValuesChange);
88
+ const [MetaProvider, metaManager, [getMeta, setMeta]] = useProvideMeta(callIfFunction(meta, initialValues), (prev, next) => {
89
+ if (prev.submittingFiles !== 0 && next.submittingFiles === 0) {
90
+ if (resubmittingForm.get()) {
91
+ if (shouldResubmitForm.get()) {
92
+ resubmittingForm.get().confirm();
93
+ } else {
94
+ resubmittingForm.get().cancel();
95
+ }
96
+ resubmittingForm.set(false);
97
+ }
98
+ }
99
+ });
100
+ const validate = async function () {
101
+ let values = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getValues();
102
+ let validation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : preValidation;
103
+ const errors = await callIfFunction(validation, values, utils);
104
+ if (errors) {
105
+ errorsUtils.setErrors(errors);
106
+ }
107
+ return errors;
108
+ };
109
+ const verifyImagesAndSubmitForm = values => {
110
+ if (values && getMeta('submittedFiles')) {
111
+ const valuesWithUploadedImages = getMeta('submittedFiles').reduce((acc, _ref2) => {
112
+ let {
113
+ path,
114
+ file,
115
+ image
116
+ } = _ref2;
117
+ if (_s.get(path, acc) === file) {
118
+ return _s.set(path, image, acc);
119
+ } else {
120
+ return acc;
121
+ }
122
+ }, values);
123
+ return submitForm(valuesWithUploadedImages);
124
+ } else {
125
+ return submitForm(values);
126
+ }
127
+ };
128
+ const submitForm = async function (optValues) {
129
+ let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
130
+ if (loading.get()) {
131
+ return new Promise(() => {});
132
+ }
133
+ const values = ifUndefined(callIfFunction(optValues, getValues()), getValues());
134
+ if (getMeta('submittingFiles')) {
135
+ shouldResubmitForm.open();
136
+ errorsUtils.setError('_shouldResubmitForm', startlibs.FormUploadingFileError || startlibs.FormUploadingImageError);
137
+ if (config.isConfirming) {
138
+ return Promise.reject();
139
+ }
140
+ return new Promise((resolve, reject) => {
141
+ resubmittingForm.set({
142
+ confirm: () => resolve(verifyImagesAndSubmitForm(values)),
143
+ cancel: () => reject()
144
+ });
145
+ });
146
+ }
147
+ const {
148
+ onSuccess,
149
+ onFailure,
150
+ transform,
151
+ alwaysSave,
152
+ preValidation,
153
+ action
154
+ } = _objectSpread(_objectSpread({}, outerConfig), config);
155
+ if (preValidation && loadingBeforeValidate) {
156
+ loading.open();
157
+ }
158
+ const errors = await validate(values, preValidation);
159
+ if (errors) {
160
+ loading.close();
161
+ callIfFunction(onNonPreValidation, values, errors);
162
+ throw {
163
+ unvalidated: errors
164
+ };
165
+ }
166
+ const request = await transform(values, {
167
+ meta: getMeta()
168
+ });
169
+ if (!request) {
170
+ loading.close();
171
+ return {
172
+ untransformed: true
173
+ };
174
+ } else {
175
+ loading.open();
176
+ errorsUtils.clearErrors();
177
+ if (!alwaysSave && !hasChangedRef.get() && (!values || values === getValues())) {
178
+ await onSuccess(request);
179
+ if (!isUnmounted()) {
180
+ loading.close();
181
+ }
182
+ return {
183
+ unrequested: request
184
+ };
185
+ }
186
+ try {
187
+ const response = await action(request);
188
+ await onSuccess(request, response);
189
+ if (!isUnmounted()) {
190
+ setHasChanged(false);
191
+ loading.close();
192
+ }
193
+ return {
194
+ request,
195
+ response
196
+ };
197
+ } catch (rejection) {
198
+ if (_get([0, 'errors'], rejection)) {
199
+ errorsUtils.setErrors(rejection[0].errors);
200
+ }
201
+ try {
202
+ await onFailure(request, rejection, utils);
203
+ } catch (e) {
204
+ console.log(e);
205
+ }
206
+ if (!isUnmounted()) {
207
+ loading.close();
208
+ }
209
+ throw {
210
+ request,
211
+ rejection
212
+ };
213
+ }
214
+ }
215
+ };
216
+ const willSubmitForm = e => {
217
+ if (e) {
218
+ e.preventDefault();
219
+ e.stopPropagation();
220
+ }
221
+ return submitForm();
222
+ };
223
+ const inputs = [loading, hasChanged, errorsContext, initialValues, transform, preValidation, onSuccess, onFailure, alwaysSave, action, shouldResubmitForm];
224
+ const utils = useMemo(() => _objectSpread({
225
+ setValue: function (path, value) {
226
+ let hasChanged = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
227
+ setValues(_isFunction(value) ? _update(path, value) : _set(path, value), path, hasChanged ? null : {
228
+ ignoreCallback: true
229
+ });
230
+ },
231
+ setValues: function (valuesSetter) {
232
+ let hasChanged = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
233
+ setValues(valuesSetter, undefined, hasChanged ? null : {
234
+ ignoreCallback: true
235
+ });
236
+ },
237
+ resetForm: () => {
238
+ setValues(ifUndefined(currentInitialValues.get(), {}));
239
+ setHasChanged(false);
240
+ },
241
+ resetField: path => {
242
+ const initialValue = _s.get(path, currentInitialValues.get());
243
+ if (initialValue !== getValues(path)) {
244
+ setValues(_s.set(path, initialValue));
245
+ }
246
+ },
247
+ getOriginalValues: () => currentInitialValues.get(),
248
+ getOriginalValue: path => _s.get(path, currentInitialValues.get()),
249
+ getValues,
250
+ getValue: getValues,
251
+ getTransformedValues: () => transform(getValues()),
252
+ setHasChanged,
253
+ setMeta,
254
+ getMeta,
255
+ confirm: draftConfirmation,
256
+ validate: (props, validation) => !validate(props, validation),
257
+ submitForm,
258
+ willSubmitForm,
259
+ isLoading: loading.isOpen || shouldResubmitForm.isOpen,
260
+ hasChanged,
261
+ getHasChanged: () => hasChangedRef.get()
262
+ }, errorsUtils), inputs);
263
+ useImperativeHandle(ref, () => utils, inputs);
264
+ return [children => /*#__PURE__*/React.createElement(FormContext.Provider, {
265
+ value: utils
266
+ }, /*#__PURE__*/React.createElement(ComponentMetaContext.Provider, {
267
+ value: componentMetasManager
268
+ }, /*#__PURE__*/React.createElement(ValuesProvider, {
269
+ value: valuesManager
270
+ }, /*#__PURE__*/React.createElement(MetaProvider, {
271
+ value: metaManager
272
+ }, /*#__PURE__*/React.createElement(ErrorsProvider, {
273
+ value: errorsContext
274
+ }, !skipDom ? /*#__PURE__*/React.createElement("form", {
275
+ autoComplete: autoComplete,
276
+ noValidate: true,
277
+ onSubmit: willSubmitForm
278
+ }, callIfFunction(children, utils)) : callIfFunction(children, utils))))), confirmDraftContent), utils];
279
+ };
280
+ const WithForm = /*#__PURE__*/forwardRef((_ref3, ref) => {
281
+ let {
282
+ children
283
+ } = _ref3,
284
+ rest = _objectWithoutProperties(_ref3, _excluded);
285
+ return useForm(rest, ref)[0](children);
286
+ });
287
+ const Form = _ref4 => {
288
+ let {
289
+ transform,
290
+ preValidation,
291
+ onSuccess,
292
+ onFailure,
293
+ children
294
+ } = _ref4;
295
+ const form = useContext(FormContext);
296
+ const onSubmit = e => {
297
+ if (e) e.preventDefault();
298
+ return form.submitForm(undefined, undefined, {
299
+ transform,
300
+ preValidation,
301
+ onSuccess,
302
+ onFailure
303
+ });
304
+ };
305
+ return typeof children === 'function' ? children(onSubmit) : /*#__PURE__*/React.createElement("form", {
306
+ noValidate: true,
307
+ onSubmit: onSubmit
308
+ }, children);
309
+ };
310
+ const withForm = Component => /*#__PURE__*/React.forwardRef((props, ref) => /*#__PURE__*/React.createElement(WithForm, props, form => /*#__PURE__*/React.createElement(Component, _extends({
311
+ form: form
312
+ }, props, {
313
+ ref: ref
314
+ }))));
315
+ const withForm2 = () => Component => /*#__PURE__*/React.forwardRef((props, ref) => /*#__PURE__*/React.createElement(WithForm, props, form => /*#__PURE__*/React.createElement(Component, _extends({
316
+ form: form
317
+ }, props, {
318
+ ref: ref
319
+ }))));
320
+
321
+ export { ComponentMetaContext, Form, FormContext, WithForm, getFormResponse, getFormValues, useForm, useFormMeta, useFormValue, useFormValueRef, withForm, withForm2 };
322
+ //# sourceMappingURL=Form.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Form.mjs","sources":["../src/Form.jsx"],"sourcesContent":["import React, {useState, useMemo, useImperativeHandle, useContext, forwardRef} from 'react'\nimport {useConsumerCatalog, useRefState, willUseSpreadState, useToggle, useIsUnmounted, StartlibsContext} from '@startlibs/core'\nimport {ifUndefined, _s, callIfFunction} from '@startlibs/utils'\nimport {useProvideErrors} from './Errors'\nimport {useDraftConfirmation} from './useDraftConfirmation'\nimport _ from 'lodash/fp'\n\nexport const getFormResponse = (setter, path = []) => (_, v) => setter(_s.get(path, v))\nexport const getFormValues = (setter, path = []) => (values) => setter(_s.get(path, values))\n\nexport const FormContext = React.createContext({})\nexport const ComponentMetaContext = React.createContext({})\n\nconst mergeMetas = (metas) => metas.reduce((acc, meta) => ({...acc, ...meta.props}), {})\n\nconst identityValidation = (props, meta) => ({success: props, meta: meta})\n\nconst [useProvideValues, useSpreadValue, FormValueContext] = willUseSpreadState()\nconst [useProvideMeta, useMeta] = willUseSpreadState()\n\nexport const useFormValue = useSpreadValue\nexport const useFormValueRef = () => {\n const [get, set] = useContext(FormValueContext)\n return [get, set]\n}\nexport const useFormMeta = useMeta\n\nexport const useForm =\n ({\n action,\n alwaysSave = false,\n skipDom = false,\n values: initialValues = {},\n meta = {},\n transform = (v) => v,\n preValidation = () => false,\n loadingBeforeValidate,\n onSuccess = () => {},\n onFailure = () => {},\n onNonPreValidation,\n onChange,\n autoComplete\n }, ref) => {\n const outerConfig = {onSuccess, onFailure, transform, preValidation, alwaysSave, action}\n const currentInitialValues = useRefState(initialValues)\n currentInitialValues.set(initialValues)\n const startlibs = useContext(StartlibsContext)\n const [hasChanged, setHasChangedValue] = useState(false)\n const hasChangedRef = useRefState(false)\n const shouldResubmitForm = useToggle(false, (next, prev) => prev && !next && errorsUtils.removeErrorPath('_shouldResubmitForm'))\n const resubmittingForm = useRefState(false)\n const loading = useToggle()\n const isUnmounted = useIsUnmounted()\n const [ErrorsProvider, errorsContext, errorsUtils] = useProvideErrors()\n const [registeredComponentMetas, componentMetasManager] = useConsumerCatalog()\n\n const [confirmDraftContent, draftToggle, draftConfirmation] = useDraftConfirmation(() => submitForm(undefined, {isConfirming: true}))\n\n const handleValuesChange = (prev, next) => {\n if (!hasChangedRef.get()) {\n setHasChanged(true)\n }\n callIfFunction(onChange, prev, next, utils)\n }\n\n const setHasChanged = (v) => {\n shouldResubmitForm.close()\n if (v !== hasChangedRef.get()) {\n draftToggle.openWith(v)\n setHasChangedValue(v)\n hasChangedRef.set(v)\n }\n }\n\n const [ValuesProvider, valuesManager, [getValues, setValues]] = useProvideValues(initialValues, handleValuesChange)\n const [MetaProvider, metaManager, [getMeta, setMeta]] = useProvideMeta(callIfFunction(meta,initialValues), (prev, next) => {\n if (prev.submittingFiles !== 0 && next.submittingFiles === 0) {\n if (resubmittingForm.get()) {\n if (shouldResubmitForm.get()) {\n resubmittingForm.get().confirm()\n } else {\n resubmittingForm.get().cancel()\n }\n resubmittingForm.set(false)\n }\n }\n })\n\n const validate = async (values = getValues(), validation = preValidation) => {\n const errors = await callIfFunction(validation, values, utils)\n if (errors) {\n errorsUtils.setErrors(errors)\n }\n return errors\n }\n\n const verifyImagesAndSubmitForm = (values) => {\n if (values && getMeta('submittedFiles')) {\n const valuesWithUploadedImages = getMeta('submittedFiles').reduce((acc, {path, file, image}) => {\n if (_s.get(path, acc) === file) {\n return _s.set(path, image, acc)\n } else {\n return acc\n }\n }, values)\n return submitForm(valuesWithUploadedImages)\n } else {\n return submitForm(values)\n }\n }\n\n const submitForm = async (optValues, config = {}) => {\n if (loading.get()) {\n return new Promise(() => {})\n }\n const values = ifUndefined(callIfFunction(optValues,getValues()), getValues())\n if (getMeta('submittingFiles')) {\n shouldResubmitForm.open()\n errorsUtils.setError('_shouldResubmitForm', startlibs.FormUploadingFileError || startlibs.FormUploadingImageError)\n if (config.isConfirming) {\n return Promise.reject()\n }\n return new Promise((resolve, reject) => {\n resubmittingForm.set({\n confirm: () => resolve(verifyImagesAndSubmitForm(values)),\n cancel: () => reject()\n })\n })\n }\n const {onSuccess, onFailure, transform, alwaysSave, preValidation, action} = {...outerConfig, ...config}\n\n if (preValidation && loadingBeforeValidate) {\n loading.open()\n }\n const errors = await validate(values, preValidation)\n if (errors) {\n loading.close()\n callIfFunction(onNonPreValidation,values,errors)\n throw {unvalidated: errors}\n }\n const request = await transform(values,{meta:getMeta()})\n if (!request) {\n loading.close()\n return {untransformed: true}\n } else {\n loading.open()\n errorsUtils.clearErrors()\n if (!alwaysSave && !hasChangedRef.get() && (!values || values === getValues())) {\n await onSuccess(request)\n if (!isUnmounted()) {\n loading.close()\n }\n return {unrequested: request}\n }\n try {\n const response = await action(request)\n await onSuccess(request, response)\n if (!isUnmounted()) {\n setHasChanged(false)\n loading.close()\n }\n return {request, response}\n } catch (rejection) {\n if (_.get([0,'errors'],rejection)) {\n errorsUtils.setErrors(rejection[0].errors)\n }\n try {\n await onFailure(request, rejection, utils)\n } catch (e) {\n console.log(e)\n }\n if (!isUnmounted()) {\n loading.close()\n }\n throw {request, rejection}\n }\n }\n }\n\n const willSubmitForm = (e) => {\n if (e) {\n e.preventDefault()\n e.stopPropagation()\n }\n return submitForm()\n }\n\n const inputs = [loading, hasChanged, errorsContext, initialValues, transform, preValidation, onSuccess, onFailure, alwaysSave, action, shouldResubmitForm]\n\n const utils = useMemo(() => ({\n setValue: (path, value, hasChanged = true) => {\n setValues(_.isFunction(value) ? _.update(path, value) : _.set(path, value), path, hasChanged ? null : {ignoreCallback: true})\n },\n setValues: (valuesSetter, hasChanged = true) => {\n setValues(valuesSetter, undefined, hasChanged ? null : {ignoreCallback: true})\n },\n resetForm: () => {\n setValues(ifUndefined(currentInitialValues.get(), {}))\n setHasChanged(false)\n },\n resetField: (path) => {\n const initialValue = _s.get(path, currentInitialValues.get())\n if (initialValue !== getValues(path)) {\n setValues(_s.set(path, initialValue))\n }\n },\n getOriginalValues: () => currentInitialValues.get(),\n getOriginalValue: (path) => _s.get(path, currentInitialValues.get()),\n getValues,\n getValue: getValues,\n getTransformedValues: () => transform(getValues()),\n setHasChanged,\n setMeta,\n getMeta,\n confirm: draftConfirmation,\n validate: (props, validation) => !validate(props, validation),\n submitForm,\n willSubmitForm,\n isLoading: loading.isOpen || shouldResubmitForm.isOpen,\n hasChanged,\n getHasChanged: () => hasChangedRef.get(),\n ...errorsUtils\n }),\n inputs\n )\n\n useImperativeHandle(ref, () => utils, inputs)\n\n return [\n (children) => <FormContext.Provider value={utils}>\n <ComponentMetaContext.Provider value={componentMetasManager}>\n <ValuesProvider value={valuesManager}>\n <MetaProvider value={metaManager}>\n <ErrorsProvider value={errorsContext}>\n {\n !skipDom\n ? <form autoComplete={autoComplete} noValidate onSubmit={willSubmitForm}>{callIfFunction(children, utils)}</form>\n : callIfFunction(children, utils)\n }\n </ErrorsProvider>\n </MetaProvider>\n </ValuesProvider>\n </ComponentMetaContext.Provider>\n {confirmDraftContent}\n </FormContext.Provider>,\n utils\n ]\n }\n\nexport const WithForm = forwardRef((\n {\n children,\n ...rest\n },\n ref) => {\n return useForm(rest, ref)[0](children)\n})\n\nexport const Form = ({transform, preValidation, onSuccess, onFailure, children}) => {\n const form = useContext(FormContext)\n const onSubmit = (e) => {\n if (e) e.preventDefault()\n return form.submitForm(\n undefined,\n undefined,\n {transform, preValidation, onSuccess, onFailure}\n )\n }\n\n return typeof children === 'function' ?\n children(onSubmit) :\n <form noValidate onSubmit={onSubmit}>\n {children}\n </form>\n}\n\nconst passProps = (action, props) => action(props)\n\nexport const withForm = (Component) =>\n React.forwardRef((props, ref) =>\n <WithForm {...props}>\n {form => <Component form={form} {...props} ref={ref}/>}\n </WithForm>\n )\n\nexport const withForm2 = () => (Component) =>\n React.forwardRef((props, ref) =>\n <WithForm {...props} >\n {form => <Component form={form} {...props} ref={ref}/>}\n </WithForm>\n )\n"],"names":["getFormResponse","setter","path","arguments","length","undefined","_","v","_s","get","getFormValues","values","FormContext","React","createContext","ComponentMetaContext","useProvideValues","useSpreadValue","FormValueContext","willUseSpreadState","useProvideMeta","useMeta","useFormValue","useFormValueRef","set","useContext","useFormMeta","useForm","_ref","ref","action","alwaysSave","skipDom","initialValues","meta","transform","preValidation","loadingBeforeValidate","onSuccess","onFailure","onNonPreValidation","onChange","autoComplete","outerConfig","currentInitialValues","useRefState","startlibs","StartlibsContext","hasChanged","setHasChangedValue","useState","hasChangedRef","shouldResubmitForm","useToggle","next","prev","errorsUtils","removeErrorPath","resubmittingForm","loading","isUnmounted","useIsUnmounted","ErrorsProvider","errorsContext","useProvideErrors","registeredComponentMetas","componentMetasManager","useConsumerCatalog","confirmDraftContent","draftToggle","draftConfirmation","useDraftConfirmation","submitForm","isConfirming","handleValuesChange","setHasChanged","callIfFunction","utils","close","openWith","ValuesProvider","valuesManager","getValues","setValues","MetaProvider","metaManager","getMeta","setMeta","submittingFiles","confirm","cancel","validate","validation","errors","setErrors","verifyImagesAndSubmitForm","valuesWithUploadedImages","reduce","acc","_ref2","file","image","optValues","config","Promise","ifUndefined","open","setError","FormUploadingFileError","FormUploadingImageError","reject","resolve","_objectSpread","unvalidated","request","untransformed","clearErrors","unrequested","response","rejection","_get","e","console","log","willSubmitForm","preventDefault","stopPropagation","inputs","useMemo","setValue","value","_isFunction","_update","_set","ignoreCallback","valuesSetter","resetForm","resetField","initialValue","getOriginalValues","getOriginalValue","getValue","getTransformedValues","props","isLoading","isOpen","getHasChanged","useImperativeHandle","children","createElement","Provider","noValidate","onSubmit","WithForm","forwardRef","_ref3","rest","_objectWithoutProperties","_excluded","Form","_ref4","form","withForm","Component","_extends","withForm2"],"mappings":";;;;;;;;;;;;;;;;AAOaA,MAAAA,eAAe,GAAG,UAACC,MAAM,EAAA;AAAA,EAAA,IAAEC,IAAI,GAAAC,SAAA,CAAAC,MAAA,GAAA,CAAA,IAAAD,SAAA,CAAA,CAAA,CAAA,KAAAE,SAAA,GAAAF,SAAA,CAAA,CAAA,CAAA,GAAG,EAAE,CAAA;AAAA,EAAA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SAAS,GAAGA,MAAOF,SAAS,iBACvCtJ,KAAK,CAAC6I,UAAU,CAAC,CAACX,KAAK,EAAElH,GAAG,kBAC1BhB,KAAA,CAAAwI,aAAA,CAACI,QAAQ,EAAKV,KAAK,EAChBkB,IAAI,iBAAIpJ,KAAA,CAAAwI,aAAA,CAACc,SAAS,EAAAC,QAAA,CAAA;AAACH,EAAAA,IAAI,EAAEA,IAAAA;AAAK,CAAA,EAAKlB,KAAK,EAAA;AAAElH,EAAAA,GAAG,EAAEA,GAAAA;AAAI,CAAC,CAAA,CAC7C,CACZ;;;;"}
@@ -0,0 +1,111 @@
1
+ import _extends from '@babel/runtime/helpers/extends';
2
+ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
3
+ import _isObject from 'lodash/fp/isObject';
4
+ import _identity from 'lodash/fp/identity';
5
+ import React, { useMemo, useState, useContext, useEffect } from 'react';
6
+ import { useUpdateEffect } from '@startlibs/core';
7
+ import { ifUndefined, callIfFunction, getUID } from '@startlibs/utils';
8
+ import { useFormValue, useFormMeta, FormContext } from './Form.mjs';
9
+ import { TransitionDiv, SwitchDiv } from '@startlibs/components';
10
+
11
+ const _excluded = ["path", "children", "inputs", "check", "invert"],
12
+ _excluded2 = ["path", "children", "inputs", "on", "off", "check", "invert", "map"],
13
+ _excluded3 = ["path", "children", "inputs", "check", "invert"];
14
+ const FormValue = _ref => {
15
+ let {
16
+ path,
17
+ children,
18
+ inputs,
19
+ format = _identity
20
+ } = _ref;
21
+ const [value, setValue] = useFormValue(path, inputs || []);
22
+ return ifUndefined(callIfFunction(children, format(value), setValue), _isObject(value) ? null : value, null);
23
+ };
24
+ const IfFormValue = _ref2 => {
25
+ let {
26
+ path,
27
+ children,
28
+ inputs,
29
+ check = _identity,
30
+ invert
31
+ } = _ref2,
32
+ rest = _objectWithoutProperties(_ref2, _excluded);
33
+ const [value, setValue] = useFormValue(path, inputs || []);
34
+ const doInvert = v => invert ? !v : !!v;
35
+ return /*#__PURE__*/React.createElement(TransitionDiv, rest, doInvert(callIfFunction(check, value)) ? ifUndefined(callIfFunction(children, value, setValue), _isObject(value) ? null : value, null) : null);
36
+ };
37
+ const IfFormValueUpdate = _ref3 => {
38
+ let {
39
+ path,
40
+ children,
41
+ updatePath
42
+ } = _ref3;
43
+ const [readValue] = useFormValue(path, []);
44
+ const [, setValue] = useFormValue(updatePath, []);
45
+ useUpdateEffect(() => {
46
+ setValue(callIfFunction(children, readValue));
47
+ }, [readValue]);
48
+ return null;
49
+ };
50
+ const SwitchOnFormValue = _ref4 => {
51
+ let {
52
+ path,
53
+ children,
54
+ inputs,
55
+ on,
56
+ off,
57
+ check,
58
+ invert,
59
+ map = _identity
60
+ } = _ref4,
61
+ rest = _objectWithoutProperties(_ref4, _excluded2);
62
+ const [value, setValue] = useFormValue(path, inputs || []);
63
+ const doInvert = v => invert ? !v : v;
64
+ const isOn = check || invert ? doInvert(callIfFunction(check, value)) : value;
65
+ const mappedValue = map(value);
66
+ const onKey = useMemo(() => getUID(), [isOn, mappedValue]);
67
+ return /*#__PURE__*/React.createElement(SwitchDiv, _extends({
68
+ on: onKey
69
+ }, rest), isOn ? on && on[mappedValue] ? callIfFunction(on[mappedValue], value, setValue) : ifUndefined(callIfFunction(on, value, setValue), _isObject(value) ? null : value, null) : ifUndefined(callIfFunction(off, value, setValue), _isObject(value) ? null : value, null));
70
+ };
71
+ const FormMeta = _ref5 => {
72
+ let {
73
+ path,
74
+ children,
75
+ inputs
76
+ } = _ref5;
77
+ const [value, setValue] = useFormMeta(path, inputs || []);
78
+ return ifUndefined(callIfFunction(children, value, setValue), value, null);
79
+ };
80
+ const IfFormMeta = _ref6 => {
81
+ let {
82
+ path,
83
+ children,
84
+ inputs,
85
+ check = _identity,
86
+ invert
87
+ } = _ref6,
88
+ rest = _objectWithoutProperties(_ref6, _excluded3);
89
+ const [value, setValue] = useFormMeta(path, inputs || []);
90
+ const doInvert = v => invert ? !v : !!v;
91
+ return /*#__PURE__*/React.createElement(TransitionDiv, rest, doInvert(callIfFunction(check, value)) ? ifUndefined(callIfFunction(children, value, setValue), _isObject(value) ? null : value, null) : null);
92
+ };
93
+ const LazyFormValues = _ref7 => {
94
+ let {
95
+ value,
96
+ format = _identity,
97
+ children
98
+ } = _ref7;
99
+ const currentValue = value.read();
100
+ const [loaded, setLoaded] = useState(false);
101
+ const formUtils = useContext(FormContext);
102
+ useEffect(() => {
103
+ formUtils.setValues(format(currentValue), false);
104
+ setLoaded(getUID);
105
+ return () => value.refresh();
106
+ }, []);
107
+ return callIfFunction(children, loaded);
108
+ };
109
+
110
+ export { FormMeta, FormValue, IfFormMeta, IfFormValue, IfFormValueUpdate, LazyFormValues, SwitchOnFormValue };
111
+ //# sourceMappingURL=FormValue.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormValue.mjs","sources":["../src/FormValue.jsx"],"sourcesContent":["import React, {useContext, useEffect, useState, useMemo} from 'react'\nimport {useUpdateEffect} from '@startlibs/core'\nimport {ifUndefined, callIfFunction, getUID} from '@startlibs/utils'\nimport {FormContext, useFormMeta, useFormValue} from './Form'\nimport _ from 'lodash/fp'\nimport {TransitionDiv,SwitchDiv} from '@startlibs/components'\n\nexport const FormValue = ({path,children,inputs,format=_.identity}) => {\n const [value,setValue] = useFormValue(path,inputs || [])\n return ifUndefined(callIfFunction(children,format(value),setValue),_.isObject(value) ? null : value,null)\n}\nexport const IfFormValue = ({path,children,inputs,check = _.identity,invert,...rest}) => {\n const [value,setValue] = useFormValue(path,inputs || [])\n const doInvert = (v) => invert ? !v : !!v\n return <TransitionDiv {...rest}>{\n doInvert(callIfFunction(check,value))\n ? ifUndefined(callIfFunction(children,value,setValue),_.isObject(value) ? null : value,null)\n : null\n }</TransitionDiv>\n}\nexport const IfFormValueUpdate = ({path,children,updatePath}) => {\n const [readValue] = useFormValue(path,[])\n const [,setValue] = useFormValue(updatePath,[])\n useUpdateEffect(() => {\n setValue(callIfFunction(children,readValue))\n },[readValue])\n return null\n}\nexport const SwitchOnFormValue = ({path,children,inputs,on,off,check,invert,map = _.identity,...rest}) => {\n const [value,setValue] = useFormValue(path,inputs || [])\n const doInvert = (v) => invert ? !v : v\n const isOn = (check || invert ) ? doInvert(callIfFunction(check,value)) : value\n const mappedValue = map(value)\n const onKey = useMemo(() => getUID() , [isOn,mappedValue])\n return <SwitchDiv on={onKey} {...rest}>{\n isOn\n ? (on && on[mappedValue])\n ? callIfFunction(on[mappedValue],value,setValue)\n : ifUndefined(callIfFunction(on,value,setValue),_.isObject(value) ? null : value,null)\n : ifUndefined(callIfFunction(off,value,setValue),_.isObject(value) ? null : value,null)\n }</SwitchDiv>\n}\n\nexport const FormMeta = ({path,children,inputs}) => {\n const [value,setValue] = useFormMeta(path,inputs || [])\n return ifUndefined(callIfFunction(children,value,setValue),value,null)\n}\nexport const IfFormMeta = ({path,children,inputs,check = _.identity,invert,...rest}) => {\n const [value,setValue] = useFormMeta(path,inputs || [])\n const doInvert = (v) => invert ? !v : !!v\n return <TransitionDiv {...rest}>{\n doInvert(callIfFunction(check,value))\n ? ifUndefined(callIfFunction(children,value,setValue),_.isObject(value) ? null : value,null)\n : null\n }</TransitionDiv>\n}\nexport const LazyFormValues = ({value,format = _.identity, children}) => {\n const currentValue = value.read()\n const [loaded,setLoaded] = useState(false)\n const formUtils = useContext(FormContext)\n useEffect(() => {\n formUtils.setValues(format(currentValue), false)\n setLoaded(getUID)\n return () => value.refresh()\n }, [])\n return callIfFunction(children,loaded)\n}"],"names":["FormValue","_ref","path","children","inputs","format","_identity","value","setValue","useFormValue","ifUndefined","callIfFunction","_isObject","IfFormValue","_ref2","check","invert","rest","_objectWithoutProperties","_excluded","doInvert","v","React","createElement","TransitionDiv","IfFormValueUpdate","_ref3","updatePath","readValue","useUpdateEffect","SwitchOnFormValue","_ref4","on","off","map","_excluded2","isOn","mappedValue","onKey","useMemo","getUID","SwitchDiv","_extends","FormMeta","_ref5","useFormMeta","IfFormMeta","_ref6","_excluded3","LazyFormValues","_ref7","currentValue","read","loaded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