@wix/form-public 0.140.0 → 0.142.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/dist/index.cjs CHANGED
@@ -27203,7 +27203,7 @@ var InputField = (_ref) => {
27203
27203
  requiredIndicator,
27204
27204
  requiredIndicatorPlacement
27205
27205
  } = form.requiredIndicatorProperties || {};
27206
- const propsMapper = FIELD_PROPS_MAPPERS[field.fieldType];
27206
+ const propsMapper = FIELD_PROPS_MAPPERS[field.fieldType] || BaseMapper;
27207
27207
  const _onBlur = React45.useCallback(() => {
27208
27208
  const currentFieldValue = fieldValueRef.current;
27209
27209
  bi == null || bi.report(formFieldFocus({
@@ -27310,7 +27310,7 @@ var ReadOnlyField = (_ref) => {
27310
27310
  requiredIndicator,
27311
27311
  requiredIndicatorPlacement
27312
27312
  } = form.requiredIndicatorProperties || {};
27313
- const propsMapper = FIELD_PROPS_MAPPERS[field.fieldType];
27313
+ const propsMapper = FIELD_PROPS_MAPPERS[field.fieldType] || BaseMapper;
27314
27314
  const FieldComponent = componentsById[field.fieldType];
27315
27315
  if (!FieldComponent) {
27316
27316
  return null;
@@ -27360,7 +27360,7 @@ var NestedFormField = (_ref) => {
27360
27360
  requiredIndicator,
27361
27361
  requiredIndicatorPlacement
27362
27362
  } = form.requiredIndicatorProperties || {};
27363
- const propsMapper = FIELD_PROPS_MAPPERS[field.fieldType];
27363
+ const propsMapper = FIELD_PROPS_MAPPERS[field.fieldType] || BaseMapper;
27364
27364
  const handleChange = React45.useCallback((value) => {
27365
27365
  if (!value) {
27366
27366
  value = null;
@@ -27508,7 +27508,7 @@ var SubmitButtonField = (_ref) => {
27508
27508
  const submitButtonText = submitText || text || "";
27509
27509
  const previousButtonText = previousText || "";
27510
27510
  const nextButtonText = nextText || "";
27511
- const propsMapper = FIELD_PROPS_MAPPERS[field.fieldType];
27511
+ const propsMapper = FIELD_PROPS_MAPPERS[field.fieldType] || BaseMapper;
27512
27512
  const FieldComponent = componentsById[field.fieldType];
27513
27513
  if (!FieldComponent) {
27514
27514
  return null;
@@ -32039,11 +32039,16 @@ var normalizeValues = (form, values, recursive = true, config) => {
32039
32039
  if (recursive && nestedForm) {
32040
32040
  result2[fieldTarget] = normalizeValues(nestedForm, fieldValue, false, config);
32041
32041
  } else {
32042
- result2[fieldTarget] = NORMALIZED_VALUE[fieldType]({
32043
- field,
32044
- fieldValue,
32045
- config
32046
- });
32042
+ const normalizer = NORMALIZED_VALUE[fieldType];
32043
+ if (normalizer) {
32044
+ result2[fieldTarget] = normalizer({
32045
+ field,
32046
+ fieldValue,
32047
+ config
32048
+ });
32049
+ } else {
32050
+ result2[fieldTarget] = fieldValue;
32051
+ }
32047
32052
  }
32048
32053
  return result2;
32049
32054
  }, {});
@@ -40487,19 +40492,26 @@ var LoginBar = (_ref) => {
40487
40492
  var LoginBarInner = (_ref2) => {
40488
40493
  let {
40489
40494
  children,
40490
- className
40495
+ className,
40496
+ email,
40497
+ login,
40498
+ logout
40491
40499
  } = _ref2;
40492
- const {
40493
- userData
40494
- } = useConfig();
40495
- const labelElement = findChildOfType(children, LoginBar.Text);
40496
- const buttonElement = findChildOfType(children, LoginBar.Button);
40497
- const labelWithButton = !userData ? applyInternalProps(labelElement, {
40498
- buttonElement
40500
+ const labelElement = applyInternalProps(findChildOfType(children, LoginBar.Text), {
40501
+ email
40502
+ });
40503
+ const buttonElement = applyInternalProps(findChildOfType(children, LoginBar.Button), {
40504
+ email,
40505
+ login,
40506
+ logout
40507
+ });
40508
+ const labelWithButton = !email ? applyInternalProps(labelElement, {
40509
+ buttonElement,
40510
+ email
40499
40511
  }) : labelElement;
40500
40512
  return /* @__PURE__ */ React45__namespace.default.createElement("div", {
40501
40513
  className
40502
- }, userData ? /* @__PURE__ */ React45__namespace.default.createElement(React45__namespace.default.Fragment, null, labelElement, buttonElement) : labelWithButton);
40514
+ }, email ? /* @__PURE__ */ React45__namespace.default.createElement(React45__namespace.default.Fragment, null, labelElement, buttonElement) : labelWithButton);
40503
40515
  };
40504
40516
  var LoginBarText = (_ref3) => {
40505
40517
  let {
@@ -40507,43 +40519,34 @@ var LoginBarText = (_ref3) => {
40507
40519
  ...internal
40508
40520
  } = _ref3;
40509
40521
  const {
40510
- buttonElement
40522
+ buttonElement,
40523
+ email
40511
40524
  } = internal;
40512
- const {
40513
- userData
40514
- } = useConfig();
40515
40525
  const {
40516
40526
  t
40517
40527
  } = useTranslation();
40518
- const labelText = userData ? t("form.login-bar.title.logged-in-state", {
40519
- user: userData == null ? void 0 : userData.email
40528
+ const labelText = email ? t("form.login-bar.title.logged-in-state", {
40529
+ user: email
40520
40530
  }) : t("form.login-bar.title.logged-out-state");
40521
40531
  return /* @__PURE__ */ React45__namespace.default.createElement("div", {
40522
40532
  className
40523
- }, labelText, !userData && buttonElement);
40533
+ }, labelText, !email && buttonElement);
40524
40534
  };
40525
40535
  var LoginBarButton = (_ref4) => {
40526
40536
  let {
40527
- className
40537
+ className,
40538
+ ...internal
40528
40539
  } = _ref4;
40529
- const {
40530
- userData,
40531
- locale
40532
- } = useConfig();
40533
- const {
40534
- actions
40535
- } = useFieldActions();
40536
40540
  const {
40537
40541
  t
40538
40542
  } = useTranslation();
40539
- const buttonText = userData ? t("form.login-bar.action.logout") : t("form.login-bar.actions.login");
40540
- const handleClick = () => {
40541
- if (userData) {
40542
- actions == null || actions.requestLogout == null || actions.requestLogout();
40543
- } else {
40544
- actions == null || actions.requestLogin == null || actions.requestLogin(locale);
40545
- }
40546
- };
40543
+ const {
40544
+ email,
40545
+ login,
40546
+ logout
40547
+ } = internal;
40548
+ const buttonText = email ? t("form.login-bar.action.logout") : t("form.login-bar.actions.login");
40549
+ const handleClick = () => email ? logout == null ? void 0 : logout() : login == null ? void 0 : login();
40547
40550
  return /* @__PURE__ */ React45__namespace.default.createElement(reactAriaComponents.Button, {
40548
40551
  className,
40549
40552
  onPress: handleClick