@bigbinary/neeto-form-frontend 4.1.10 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/javascript/src/translations/en.json +5 -1
- package/dist/BuildForm.js +69 -26
- package/dist/BuildForm.js.map +1 -1
- package/dist/ExternalForm.js +3 -2
- package/dist/ExternalForm.js.map +1 -1
- package/dist/UrlBuilder.js +3 -2
- package/dist/UrlBuilder.js.map +1 -1
- package/dist/{buildForm-BwhLCvEE.js → buildForm-CooylMLL.js} +3 -2
- package/dist/buildForm-CooylMLL.js.map +1 -0
- package/dist/{buildForm-CsVQHcC7.js → buildForm-DcE5kFvR.js} +3 -2
- package/dist/buildForm-DcE5kFvR.js.map +1 -0
- package/dist/cjs/BuildForm.js +69 -26
- package/dist/cjs/BuildForm.js.map +1 -1
- package/dist/cjs/ExternalForm.js +3 -2
- package/dist/cjs/ExternalForm.js.map +1 -1
- package/dist/cjs/UrlBuilder.js +3 -2
- package/dist/cjs/UrlBuilder.js.map +1 -1
- package/dist/cjs/hooks.js +1 -1
- package/dist/cjs/index.js +5 -3
- package/dist/cjs/index.js.map +1 -1
- package/dist/{constants-BSbkmQ4t.js → constants-BjWWA3Oq.js} +10 -1
- package/dist/constants-BjWWA3Oq.js.map +1 -0
- package/dist/{constants-Da_Y-J4N.js → constants-QPLZ_r-D.js} +9 -2
- package/dist/constants-QPLZ_r-D.js.map +1 -0
- package/dist/hooks.js +1 -1
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/dist/main.css +1 -1
- package/dist/main.css.map +1 -1
- package/dist/{utils-BdTASoGp.js → utils-BwFLBXs2.js} +88 -13
- package/dist/utils-BwFLBXs2.js.map +1 -0
- package/dist/{utils-BUXD94aD.js → utils-GRfGBny0.js} +88 -13
- package/dist/utils-GRfGBny0.js.map +1 -0
- package/package.json +17 -17
- package/dist/buildForm-BwhLCvEE.js.map +0 -1
- package/dist/buildForm-CsVQHcC7.js.map +0 -1
- package/dist/constants-BSbkmQ4t.js.map +0 -1
- package/dist/constants-Da_Y-J4N.js.map +0 -1
- package/dist/utils-BUXD94aD.js.map +0 -1
- package/dist/utils-BdTASoGp.js.map +0 -1
|
@@ -22,7 +22,7 @@ import * as yup from 'yup';
|
|
|
22
22
|
import i18next from 'i18next';
|
|
23
23
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
24
24
|
import _toArray from '@babel/runtime/helpers/toArray';
|
|
25
|
-
import { a as QUESTION_KIND, P as PARENTHESES_REGEX, E as EMAIL_REGEX, R as RATING_VALUES, S as SCHEMA_LESS_QUESTION_KINDS, c as SIX_DIGIT_NUMBER_REGEX, d as LABEL_FIELDS, e as RATING_OPTIONS, I as ICONS_MAP, g as generateArray } from './constants-
|
|
25
|
+
import { a as QUESTION_KIND, P as PARENTHESES_REGEX, E as EMAIL_REGEX, R as RATING_VALUES, S as SCHEMA_LESS_QUESTION_KINDS, c as SIX_DIGIT_NUMBER_REGEX, d as LABEL_FIELDS, D as DEFAULT_CHOICE_QUESTION_ATTRIBUTES, e as RATING_OPTIONS, I as ICONS_MAP, g as generateArray } from './constants-QPLZ_r-D.js';
|
|
26
26
|
import classnames from 'classnames';
|
|
27
27
|
import { useUpdateEffect, useStateWithDependency, useDebounce } from '@bigbinary/neeto-commons-frontend/react-utils';
|
|
28
28
|
import Refresh from '@bigbinary/neeto-icons/Refresh';
|
|
@@ -42,6 +42,7 @@ import { FileUpload } from '@bigbinary/neeto-molecules/FileUpload';
|
|
|
42
42
|
import Label from '@bigbinary/neetoui/Label';
|
|
43
43
|
import Select from '@bigbinary/neetoui/Select';
|
|
44
44
|
import Radio from '@bigbinary/neetoui/Radio';
|
|
45
|
+
import Image from '@bigbinary/neeto-icons/Image';
|
|
45
46
|
import NeetoEditor from '@bigbinary/neeto-editor/Editor';
|
|
46
47
|
import Textarea from '@bigbinary/neetoui/Textarea';
|
|
47
48
|
|
|
@@ -1725,6 +1726,56 @@ var NameField = function NameField(props) {
|
|
|
1725
1726
|
}));
|
|
1726
1727
|
};
|
|
1727
1728
|
|
|
1729
|
+
var ChoiceImage = function ChoiceImage(_ref) {
|
|
1730
|
+
var src = _ref.src,
|
|
1731
|
+
alt = _ref.alt,
|
|
1732
|
+
height = _ref.height,
|
|
1733
|
+
shouldFitImages = _ref.shouldFitImages;
|
|
1734
|
+
var _useState = useState(false),
|
|
1735
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1736
|
+
hasError = _useState2[0],
|
|
1737
|
+
setHasError = _useState2[1];
|
|
1738
|
+
var _useState3 = useState(true),
|
|
1739
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
1740
|
+
isLoading = _useState4[0],
|
|
1741
|
+
setIsLoading = _useState4[1];
|
|
1742
|
+
var handleLoad = function handleLoad() {
|
|
1743
|
+
return setIsLoading(false);
|
|
1744
|
+
};
|
|
1745
|
+
var handleError = function handleError() {
|
|
1746
|
+
setHasError(true);
|
|
1747
|
+
setIsLoading(false);
|
|
1748
|
+
};
|
|
1749
|
+
if (hasError || !src) {
|
|
1750
|
+
return /*#__PURE__*/jsx("div", {
|
|
1751
|
+
className: "neeto-form-engine-choice__image-placeholder neeto-ui-bg-gray-100",
|
|
1752
|
+
style: {
|
|
1753
|
+
height: height
|
|
1754
|
+
},
|
|
1755
|
+
children: /*#__PURE__*/jsx(Image, {
|
|
1756
|
+
size: 32
|
|
1757
|
+
})
|
|
1758
|
+
});
|
|
1759
|
+
}
|
|
1760
|
+
return /*#__PURE__*/jsx("div", {
|
|
1761
|
+
style: {
|
|
1762
|
+
height: height
|
|
1763
|
+
},
|
|
1764
|
+
className: classnames("neeto-form-engine-choice__image-wrapper", {
|
|
1765
|
+
"neeto-form-engine-choice__image-wrapper--loading": isLoading
|
|
1766
|
+
}),
|
|
1767
|
+
children: /*#__PURE__*/jsx("img", {
|
|
1768
|
+
alt: alt,
|
|
1769
|
+
src: src,
|
|
1770
|
+
className: classnames("neeto-form-engine-choice__image", {
|
|
1771
|
+
"neeto-form-engine-choice__image--fit": shouldFitImages
|
|
1772
|
+
}),
|
|
1773
|
+
onError: handleError,
|
|
1774
|
+
onLoad: handleLoad
|
|
1775
|
+
})
|
|
1776
|
+
});
|
|
1777
|
+
};
|
|
1778
|
+
|
|
1728
1779
|
var Choices = function Choices(_ref) {
|
|
1729
1780
|
var label = _ref.label,
|
|
1730
1781
|
options = _ref.options,
|
|
@@ -1733,7 +1784,13 @@ var Choices = function Choices(_ref) {
|
|
|
1733
1784
|
value = _ref.value,
|
|
1734
1785
|
onChange = _ref.onChange,
|
|
1735
1786
|
error = _ref.error,
|
|
1736
|
-
disabled = _ref.isDisabled
|
|
1787
|
+
disabled = _ref.isDisabled,
|
|
1788
|
+
_ref$isPictureChoice = _ref.isPictureChoice,
|
|
1789
|
+
isPictureChoice = _ref$isPictureChoice === void 0 ? DEFAULT_CHOICE_QUESTION_ATTRIBUTES.isPictureChoice : _ref$isPictureChoice,
|
|
1790
|
+
_ref$imageHeight = _ref.imageHeight,
|
|
1791
|
+
imageHeight = _ref$imageHeight === void 0 ? DEFAULT_CHOICE_QUESTION_ATTRIBUTES.imageHeight : _ref$imageHeight,
|
|
1792
|
+
_ref$shouldFitImages = _ref.shouldFitImages,
|
|
1793
|
+
shouldFitImages = _ref$shouldFitImages === void 0 ? DEFAULT_CHOICE_QUESTION_ATTRIBUTES.shouldFitImages : _ref$shouldFitImages;
|
|
1737
1794
|
var isCheckBox = type === "checkbox";
|
|
1738
1795
|
var ChoiceWrapper = isCheckBox ? "div" : Radio;
|
|
1739
1796
|
var Component = isCheckBox ? Checkbox : Radio.Item;
|
|
@@ -1745,20 +1802,30 @@ var Choices = function Choices(_ref) {
|
|
|
1745
1802
|
"data-testid": "".concat(hyphenate(label), "-input-label"),
|
|
1746
1803
|
children: label
|
|
1747
1804
|
}), /*#__PURE__*/jsx(ChoiceWrapper, {
|
|
1748
|
-
className: "neeto-form-engine-choices",
|
|
1749
1805
|
stacked: !isCheckBox,
|
|
1806
|
+
className: classnames("neeto-form-engine-choices", {
|
|
1807
|
+
"neeto-form-engine-choices--picture": isPictureChoice
|
|
1808
|
+
}),
|
|
1750
1809
|
children: options.map(function (option, index) {
|
|
1751
|
-
var _value$index;
|
|
1752
|
-
|
|
1810
|
+
var _value$index, _option$image;
|
|
1811
|
+
var isChecked = isCheckBox ? (_value$index = value === null || value === void 0 ? void 0 : value[index]) !== null && _value$index !== void 0 ? _value$index : false : value === option.id;
|
|
1812
|
+
return /*#__PURE__*/jsxs("label", {
|
|
1753
1813
|
htmlFor: option.id,
|
|
1754
1814
|
className: classnames("neeto-form-engine-choice", {
|
|
1755
|
-
|
|
1815
|
+
"neeto-form-engine-choice--picture": isPictureChoice,
|
|
1816
|
+
"neeto-form-engine-choice--selected": isChecked,
|
|
1756
1817
|
"cursor-not-allowed": disabled
|
|
1757
1818
|
}),
|
|
1758
|
-
children: /*#__PURE__*/jsx(
|
|
1819
|
+
children: [isPictureChoice && /*#__PURE__*/jsx(ChoiceImage, {
|
|
1820
|
+
shouldFitImages: shouldFitImages,
|
|
1821
|
+
alt: option.label,
|
|
1822
|
+
height: imageHeight,
|
|
1823
|
+
src: (_option$image = option.image) === null || _option$image === void 0 ? void 0 : _option$image.url
|
|
1824
|
+
}), /*#__PURE__*/jsx(Component, {
|
|
1759
1825
|
disabled: disabled,
|
|
1760
1826
|
onChange: onChange,
|
|
1761
1827
|
type: type,
|
|
1828
|
+
checked: isChecked,
|
|
1762
1829
|
className: classnames({
|
|
1763
1830
|
"cursor-not-allowed": disabled
|
|
1764
1831
|
}),
|
|
@@ -1766,13 +1833,12 @@ var Choices = function Choices(_ref) {
|
|
|
1766
1833
|
label: option.label,
|
|
1767
1834
|
name: isCheckBox ? "".concat(name, ".").concat(index) : name,
|
|
1768
1835
|
value: option.id,
|
|
1769
|
-
checked: isCheckBox ? (_value$index = value === null || value === void 0 ? void 0 : value[index]) !== null && _value$index !== void 0 ? _value$index : false : value === option.id,
|
|
1770
1836
|
labelProps: {
|
|
1771
1837
|
className: classnames({
|
|
1772
1838
|
"cursor-not-allowed": disabled
|
|
1773
1839
|
})
|
|
1774
1840
|
}
|
|
1775
|
-
})
|
|
1841
|
+
})]
|
|
1776
1842
|
}, option.id);
|
|
1777
1843
|
})
|
|
1778
1844
|
}), !!error && typeof error === "string" && /*#__PURE__*/jsx("p", {
|
|
@@ -1798,8 +1864,12 @@ var OptionsField = function OptionsField(_ref) {
|
|
|
1798
1864
|
kind = question.kind,
|
|
1799
1865
|
isRequired = question.isRequired,
|
|
1800
1866
|
isReadOnly = question.isReadOnly,
|
|
1867
|
+
isPictureChoiceFromQuestion = question.isPictureChoice,
|
|
1868
|
+
imageHeight = question.imageHeight,
|
|
1869
|
+
shouldFitImages = question.shouldFitImages,
|
|
1801
1870
|
_question$optionsAttr = question.optionsAttributes,
|
|
1802
1871
|
options = _question$optionsAttr === void 0 ? [] : _question$optionsAttr;
|
|
1872
|
+
var isPictureChoice = isPictureChoiceFromQuestion;
|
|
1803
1873
|
var isDropdown = kind === QUESTION_KIND.DROPDOWN.value;
|
|
1804
1874
|
var label = fieldWithFallback(question, "label");
|
|
1805
1875
|
var Component = isDropdown ? Select : Choices$1;
|
|
@@ -1839,17 +1909,22 @@ var OptionsField = function OptionsField(_ref) {
|
|
|
1839
1909
|
var onChange = field.onChange,
|
|
1840
1910
|
value = field.value;
|
|
1841
1911
|
return /*#__PURE__*/jsx(Component, _objectSpread$8(_objectSpread$8({
|
|
1842
|
-
isRequired: isRequired,
|
|
1843
|
-
name: name,
|
|
1844
1912
|
error: getError(meta),
|
|
1845
1913
|
isDisabled: isReadOnly,
|
|
1846
1914
|
label: getLabel(label, isRequired),
|
|
1847
1915
|
options: transformedOptions,
|
|
1848
1916
|
strategy: "fixed",
|
|
1849
1917
|
type: kind
|
|
1918
|
+
}, _objectSpread$8(_objectSpread$8({
|
|
1919
|
+
isRequired: isRequired,
|
|
1920
|
+
name: name
|
|
1850
1921
|
}, isDropdown && {
|
|
1851
1922
|
filterOption: customFilter
|
|
1852
|
-
}),
|
|
1923
|
+
}), !isDropdown && {
|
|
1924
|
+
imageHeight: imageHeight,
|
|
1925
|
+
isPictureChoice: isPictureChoice,
|
|
1926
|
+
shouldFitImages: shouldFitImages
|
|
1927
|
+
})), {}, {
|
|
1853
1928
|
value: isDropdown ? findBy({
|
|
1854
1929
|
value: value
|
|
1855
1930
|
}, transformedOptions) || null : value,
|
|
@@ -2325,4 +2400,4 @@ var containsIgnoreCase = function containsIgnoreCase(string, substring) {
|
|
|
2325
2400
|
};
|
|
2326
2401
|
|
|
2327
2402
|
export { FormikWrap as F, getFieldComponent as a, buildAutoCompleteAttribute as b, clientI18nInstance as c, getWithExpiry as d, clearEmailVerificationDetails as e, generateFormResponse as f, generateInitValues as g, clearLocalStorageValues as h, mergeRefs as m, renderButtonsInOrder as r };
|
|
2328
|
-
//# sourceMappingURL=utils-
|
|
2403
|
+
//# sourceMappingURL=utils-GRfGBny0.js.map
|