@bigbinary/neeto-form-frontend 3.3.1 → 3.3.2

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/README.md CHANGED
@@ -129,18 +129,18 @@ The engine adds setup for form on backend and allows us to attach forms to any m
129
129
  site_key: <%= ENV["FORM_NANO_RECAPTCHA_V2_SITE_KEY"] %>
130
130
  secret_key: <%= ENV["FORM_NANO_RECAPTCHA_V2_SECRET_KEY"] %>
131
131
  ```
132
- 3. Include the site key in `global_props`
133
- ```ruby
134
- module ApplicationHelper
135
- def get_client_props
136
- # other variables
137
- custom_props = {
138
- # other props
139
- form_nano_recaptcha_v2_site_key: Rails.application.secrets.form_nano.dig(:recaptcha_v2, :site_key)
140
- }
141
- end
132
+ 3. Include the site key in `global_props`
133
+ ```ruby
134
+ module ApplicationHelper
135
+ def get_client_props
136
+ # other variables
137
+ custom_props = {
138
+ # other props
139
+ form_nano_recaptcha_v2_site_key: Rails.application.secrets.form_nano.dig(:recaptcha_v2, :site_key)
140
+ }
142
141
  end
143
- ```
142
+ end
143
+ ```
144
144
 
145
145
  ## Frontend package
146
146
  The frontend package allows us to create forms across neeto products.
package/dist/index.cjs.js CHANGED
@@ -3069,6 +3069,13 @@ var Options = function Options(_ref) {
3069
3069
  var questionProps = _ref.questionProps;
3070
3070
  var _useTranslation = reactI18next.useTranslation(),
3071
3071
  t = _useTranslation.t;
3072
+ var _useBuildFormStore = useBuildFormStore(function (store) {
3073
+ var _store$formState;
3074
+ return {
3075
+ selectedLanguage: (_store$formState = store["formState"]) === null || _store$formState === void 0 ? void 0 : _store$formState["selectedLanguage"]
3076
+ };
3077
+ }, shallow.shallow),
3078
+ selectedLanguage = _useBuildFormStore.selectedLanguage;
3072
3079
  var _useField = formik.useField("optionsAttributes"),
3073
3080
  _useField2 = _slicedToArray__default["default"](_useField, 3),
3074
3081
  optionsAttributes = _useField2[0].value;
@@ -3078,11 +3085,18 @@ var Options = function Options(_ref) {
3078
3085
  _ref2$optionLabelProp = _ref2.optionLabelProps,
3079
3086
  optionLabelProps = _ref2$optionLabelProp === void 0 ? {} : _ref2$optionLabelProp,
3080
3087
  _ref2$freezeOptions = _ref2.freezeOptions,
3081
- freezeOptions = _ref2$freezeOptions === void 0 ? false : _ref2$freezeOptions;
3088
+ freezeOptions = _ref2$freezeOptions === void 0 ? false : _ref2$freezeOptions,
3089
+ _ref2$disableAddOptio = _ref2.disableAddOption,
3090
+ disableAddOption = _ref2$disableAddOptio === void 0 ? false : _ref2$disableAddOptio,
3091
+ _ref2$disableRemoveOp = _ref2.disableRemoveOption,
3092
+ disableRemoveOption = _ref2$disableRemoveOp === void 0 ? false : _ref2$disableRemoveOp;
3082
3093
  var handleRemoveOption = function handleRemoveOption(index) {
3083
3094
  var nextOptions = formHelpers.destroyFromList(optionsAttributes, index);
3084
3095
  setOptionsAttributes(nextOptions);
3085
3096
  };
3097
+ var isManageOptionDisabled = isFunction$1(freezeOptions) ? freezeOptions(selectedLanguage) : freezeOptions;
3098
+ var isAddOptionDisabled = disableAddOption || isManageOptionDisabled;
3099
+ var isRemoveOptionDisabled = disableRemoveOption || isManageOptionDisabled;
3086
3100
  return /*#__PURE__*/jsxRuntime.jsx("div", {
3087
3101
  className: "w-full",
3088
3102
  children: /*#__PURE__*/jsxRuntime.jsx(formik.FieldArray, {
@@ -3103,12 +3117,12 @@ var Options = function Options(_ref) {
3103
3117
  "data-cy": "neeto-form-engine-option-".concat(index),
3104
3118
  children: [/*#__PURE__*/jsxRuntime.jsx(InputWithMaxLength, {
3105
3119
  required: true,
3106
- disabled: freezeOptions,
3120
+ disabled: isManageOptionDisabled,
3107
3121
  name: "optionsAttributes.".concat(index, ".label"),
3108
3122
  placeholder: t("neetoForm.questions.common.questionFields.field.numberedOption", {
3109
3123
  number: index + 1
3110
3124
  })
3111
- }), !freezeOptions && /*#__PURE__*/jsxRuntime.jsx(Button__default["default"], {
3125
+ }), !isRemoveOptionDisabled && /*#__PURE__*/jsxRuntime.jsx(Button__default["default"], {
3112
3126
  "data-cy": "neeto-form-engine-delete-option-button",
3113
3127
  icon: Delete__default["default"],
3114
3128
  size: "small",
@@ -3126,7 +3140,7 @@ var Options = function Options(_ref) {
3126
3140
  })]
3127
3141
  }, "question-option-".concat((_option$id = option.id) !== null && _option$id !== void 0 ? _option$id : index));
3128
3142
  })
3129
- }), !freezeOptions && /*#__PURE__*/jsxRuntime.jsx("div", {
3143
+ }), !isAddOptionDisabled && /*#__PURE__*/jsxRuntime.jsx("div", {
3130
3144
  className: "mt-3 w-full",
3131
3145
  children: /*#__PURE__*/jsxRuntime.jsx(Button__default["default"], {
3132
3146
  "data-cy": "neeto-form-engine-add-option-button",