@jsenv/navi 0.18.22 → 0.18.23

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.
@@ -6485,6 +6485,7 @@ const PSEUDO_CLASSES_DEFAULT = [];
6485
6485
  const PSEUDO_ELEMENTS_DEFAULT = [];
6486
6486
  const STYLE_CSS_VARS_DEFAULT = {};
6487
6487
  const PROPS_CSS_VARS_DEFAULT = {};
6488
+ const CHILD_PROP_SET_DEFAULT = new Set();
6488
6489
  const Box = props => {
6489
6490
  const {
6490
6491
  as = "div",
@@ -6511,6 +6512,7 @@ const Box = props => {
6511
6512
  // -> introduced for <Input /> with a wrapped for loading, checkboxes, etc
6512
6513
  pseudoStateSelector,
6513
6514
  hasChildFunction,
6515
+ childPropSet = CHILD_PROP_SET_DEFAULT,
6514
6516
  // preventInitialTransition can be used to prevent transition on mount
6515
6517
  // (when transition is set via props, this is done automatically)
6516
6518
  // so this prop is useful only when transition is enabled from "outside" (via CSS)
@@ -6765,6 +6767,10 @@ const Box = props => {
6765
6767
  }
6766
6768
  for (const propName of remainingPropKeySet) {
6767
6769
  const propValue = rest[propName];
6770
+ if (childPropSet.has(propName)) {
6771
+ childForwardedProps[propName] = propValue;
6772
+ continue;
6773
+ }
6768
6774
  const isDataAttribute = propName.startsWith("data-");
6769
6775
  if (isDataAttribute) {
6770
6776
  selfForwardedProps[propName] = propValue;
@@ -15736,6 +15742,8 @@ const fromSelectorAttribute = (messageAttributeValue) => {
15736
15742
  return mirror;
15737
15743
  };
15738
15744
 
15745
+ const CONSTRAINT_ATTRIBUTE_SET = new Set();
15746
+
15739
15747
  const generateFieldInvalidMessage = (template, { field }) => {
15740
15748
  return replaceStringVars(template, {
15741
15749
  "{field}": () => generateThisFieldText(field),
@@ -15791,7 +15799,7 @@ const MIN_LOWER_LETTER_CONSTRAINT = {
15791
15799
  }
15792
15800
  }
15793
15801
  if (numberOfLowercaseChars < min) {
15794
- if (min === 0) {
15802
+ if (min === 1) {
15795
15803
  return generateFieldInvalidMessage(
15796
15804
  `{field} doit contenir au moins une lettre minuscule.`,
15797
15805
  { field },
@@ -15805,6 +15813,9 @@ const MIN_LOWER_LETTER_CONSTRAINT = {
15805
15813
  return "";
15806
15814
  },
15807
15815
  };
15816
+ CONSTRAINT_ATTRIBUTE_SET.add("data-min-lower-letter");
15817
+ CONSTRAINT_ATTRIBUTE_SET.add("data-min-lower-letter-message");
15818
+
15808
15819
  const MIN_UPPER_LETTER_CONSTRAINT = {
15809
15820
  name: "min_upper_letter",
15810
15821
  messageAttribute: "data-min-upper-letter-message",
@@ -15825,7 +15836,7 @@ const MIN_UPPER_LETTER_CONSTRAINT = {
15825
15836
  }
15826
15837
  }
15827
15838
  if (numberOfUppercaseChars < min) {
15828
- if (min === 0) {
15839
+ if (min === 1) {
15829
15840
  return generateFieldInvalidMessage(
15830
15841
  `{field} doit contenir au moins une lettre majuscule.`,
15831
15842
  { field },
@@ -15839,6 +15850,9 @@ const MIN_UPPER_LETTER_CONSTRAINT = {
15839
15850
  return "";
15840
15851
  },
15841
15852
  };
15853
+ CONSTRAINT_ATTRIBUTE_SET.add("data-min-upper-letter");
15854
+ CONSTRAINT_ATTRIBUTE_SET.add("data-min-upper-letter-message");
15855
+
15842
15856
  const MIN_DIGIT_CONSTRAINT = {
15843
15857
  name: "min_digit",
15844
15858
  messageAttribute: "data-min-digit-message",
@@ -15859,7 +15873,7 @@ const MIN_DIGIT_CONSTRAINT = {
15859
15873
  }
15860
15874
  }
15861
15875
  if (numberOfDigitChars < min) {
15862
- if (min === 0) {
15876
+ if (min === 1) {
15863
15877
  return generateFieldInvalidMessage(
15864
15878
  `{field} doit contenir au moins un chiffre.`,
15865
15879
  { field },
@@ -15873,6 +15887,9 @@ const MIN_DIGIT_CONSTRAINT = {
15873
15887
  return "";
15874
15888
  },
15875
15889
  };
15890
+ CONSTRAINT_ATTRIBUTE_SET.add("data-min-digit");
15891
+ CONSTRAINT_ATTRIBUTE_SET.add("data-min-digit-message");
15892
+
15876
15893
  const MIN_SPECIAL_CHAR_CONSTRAINT = {
15877
15894
  name: "min_special_char",
15878
15895
  messageAttribute: "data-min-special-char-message",
@@ -15912,6 +15929,9 @@ const MIN_SPECIAL_CHAR_CONSTRAINT = {
15912
15929
  return "";
15913
15930
  },
15914
15931
  };
15932
+ CONSTRAINT_ATTRIBUTE_SET.add("data-special-charset");
15933
+ CONSTRAINT_ATTRIBUTE_SET.add("data-min-special-char");
15934
+ CONSTRAINT_ATTRIBUTE_SET.add("data-min-special-char-message");
15915
15935
 
15916
15936
  const READONLY_CONSTRAINT = {
15917
15937
  name: "readonly",
@@ -15948,6 +15968,10 @@ const READONLY_CONSTRAINT = {
15948
15968
  };
15949
15969
  },
15950
15970
  };
15971
+ CONSTRAINT_ATTRIBUTE_SET.add("readOnly");
15972
+ CONSTRAINT_ATTRIBUTE_SET.add("data-readonly");
15973
+ CONSTRAINT_ATTRIBUTE_SET.add("data-readonly-message");
15974
+ CONSTRAINT_ATTRIBUTE_SET.add("data-readonly-silent");
15951
15975
 
15952
15976
  const SAME_AS_CONSTRAINT = {
15953
15977
  name: "same_as",
@@ -15986,6 +16010,8 @@ const SAME_AS_CONSTRAINT = {
15986
16010
  return `Ce champ doit être identique au précédent.`;
15987
16011
  },
15988
16012
  };
16013
+ CONSTRAINT_ATTRIBUTE_SET.add("data-same-as");
16014
+ CONSTRAINT_ATTRIBUTE_SET.add("data-same-as-message");
15989
16015
 
15990
16016
  const SINGLE_SPACE_CONSTRAINT = {
15991
16017
  name: "single_space",
@@ -16020,6 +16046,8 @@ const SINGLE_SPACE_CONSTRAINT = {
16020
16046
  return "";
16021
16047
  },
16022
16048
  };
16049
+ CONSTRAINT_ATTRIBUTE_SET.add("data-single-space");
16050
+ CONSTRAINT_ATTRIBUTE_SET.add("data-single-space-message");
16023
16051
 
16024
16052
  /**
16025
16053
  * https://developer.mozilla.org/en-US/docs/Web/HTML/Guides/Constraint_validation
@@ -16038,6 +16066,9 @@ const DISABLED_CONSTRAINT = {
16038
16066
  return null;
16039
16067
  },
16040
16068
  };
16069
+ CONSTRAINT_ATTRIBUTE_SET.add("disabled");
16070
+ CONSTRAINT_ATTRIBUTE_SET.add("data-disabled");
16071
+ CONSTRAINT_ATTRIBUTE_SET.add("data-disabled-message");
16041
16072
 
16042
16073
  const REQUIRED_CONSTRAINT = {
16043
16074
  name: "required",
@@ -16107,6 +16138,8 @@ const REQUIRED_CONSTRAINT = {
16107
16138
  : `Veuillez remplir ce champ.`;
16108
16139
  },
16109
16140
  };
16141
+ CONSTRAINT_ATTRIBUTE_SET.add("required");
16142
+ CONSTRAINT_ATTRIBUTE_SET.add("data-required-message");
16110
16143
 
16111
16144
  const PATTERN_CONSTRAINT = {
16112
16145
  name: "pattern",
@@ -16135,6 +16168,9 @@ const PATTERN_CONSTRAINT = {
16135
16168
  return message;
16136
16169
  },
16137
16170
  };
16171
+ CONSTRAINT_ATTRIBUTE_SET.add("pattern");
16172
+ CONSTRAINT_ATTRIBUTE_SET.add("data-pattern-message");
16173
+
16138
16174
  // https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input/email#validation
16139
16175
  const emailregex =
16140
16176
  /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
@@ -16158,6 +16194,7 @@ const TYPE_EMAIL_CONSTRAINT = {
16158
16194
  return null;
16159
16195
  },
16160
16196
  };
16197
+ CONSTRAINT_ATTRIBUTE_SET.add("data-type-message");
16161
16198
 
16162
16199
  const MIN_LENGTH_CONSTRAINT = {
16163
16200
  name: "min_length",
@@ -16170,7 +16207,6 @@ const MIN_LENGTH_CONSTRAINT = {
16170
16207
  } else if (field.tagName !== "TEXTAREA") {
16171
16208
  return null;
16172
16209
  }
16173
-
16174
16210
  const minLength = field.minLength;
16175
16211
  if (minLength === -1) {
16176
16212
  return null;
@@ -16195,6 +16231,8 @@ const MIN_LENGTH_CONSTRAINT = {
16195
16231
  );
16196
16232
  },
16197
16233
  };
16234
+ CONSTRAINT_ATTRIBUTE_SET.add("minLength");
16235
+ CONSTRAINT_ATTRIBUTE_SET.add("data-min-length-message");
16198
16236
  const INPUT_TYPE_SUPPORTING_MIN_LENGTH_SET = new Set([
16199
16237
  "text",
16200
16238
  "search",
@@ -16230,6 +16268,8 @@ const MAX_LENGTH_CONSTRAINT = {
16230
16268
  );
16231
16269
  },
16232
16270
  };
16271
+ CONSTRAINT_ATTRIBUTE_SET.add("maxLength");
16272
+ CONSTRAINT_ATTRIBUTE_SET.add("data-max-length-message");
16233
16273
  const INPUT_TYPE_SUPPORTING_MAX_LENGTH_SET = new Set(
16234
16274
  INPUT_TYPE_SUPPORTING_MIN_LENGTH_SET,
16235
16275
  );
@@ -16258,6 +16298,7 @@ const TYPE_NUMBER_CONSTRAINT = {
16258
16298
  return null;
16259
16299
  },
16260
16300
  };
16301
+ CONSTRAINT_ATTRIBUTE_SET.add("data-type-message");
16261
16302
 
16262
16303
  const MIN_CONSTRAINT = {
16263
16304
  name: "min",
@@ -16311,6 +16352,8 @@ const MIN_CONSTRAINT = {
16311
16352
  return null;
16312
16353
  },
16313
16354
  };
16355
+ CONSTRAINT_ATTRIBUTE_SET.add("min");
16356
+ CONSTRAINT_ATTRIBUTE_SET.add("data-min-message");
16314
16357
 
16315
16358
  const MAX_CONSTRAINT = {
16316
16359
  name: "max",
@@ -16359,6 +16402,8 @@ const MAX_CONSTRAINT = {
16359
16402
  return null;
16360
16403
  },
16361
16404
  };
16405
+ CONSTRAINT_ATTRIBUTE_SET.add("max");
16406
+ CONSTRAINT_ATTRIBUTE_SET.add("data-max-message");
16362
16407
 
16363
16408
  const listenInputValue = (
16364
16409
  input,
@@ -16812,6 +16857,8 @@ const installCustomConstraintValidation = (
16812
16857
  }
16813
16858
 
16814
16859
  const isForm = element.tagName === "FORM";
16860
+ const isInput = element.tagName === "INPUT" || element.tagName === "TEXTAREA";
16861
+ const isCheckbox = element.tagName === "INPUT" && element.type === "checkbox";
16815
16862
  if (isForm) {
16816
16863
  formInstrumentedWeakSet.add(element);
16817
16864
  addTeardown(() => {
@@ -17231,8 +17278,6 @@ const installCustomConstraintValidation = (
17231
17278
  }
17232
17279
 
17233
17280
  request_on_input_value_change: {
17234
- const isInput =
17235
- element.tagName === "INPUT" || element.tagName === "TEXTAREA";
17236
17281
  if (!isInput) {
17237
17282
  break request_on_input_value_change;
17238
17283
  }
@@ -17241,6 +17286,9 @@ const installCustomConstraintValidation = (
17241
17286
  break request_on_input_value_change;
17242
17287
  }
17243
17288
  const closestElementWithActionAttr = element.closest("[data-action]");
17289
+ if (closestElementWithActionAttr.tagName === "FORM") {
17290
+ break request_on_input_value_change;
17291
+ }
17244
17292
  const stop = listenInputValue(
17245
17293
  element,
17246
17294
  (e) => {
@@ -17268,8 +17316,6 @@ const installCustomConstraintValidation = (
17268
17316
  }
17269
17317
 
17270
17318
  request_on_checkbox_change: {
17271
- const isCheckbox =
17272
- element.tagName === "INPUT" && element.type === "checkbox";
17273
17319
  if (!isCheckbox) {
17274
17320
  break request_on_checkbox_change;
17275
17321
  }
@@ -17294,6 +17340,10 @@ const installCustomConstraintValidation = (
17294
17340
  }
17295
17341
  // We will dispatch "action" when "submit" occurs (code called from.submit() to bypass validation)
17296
17342
  const form = element;
17343
+ if (!form.hasAttribute("data-action")) {
17344
+ form.setAttribute("data-action", "toto");
17345
+ }
17346
+ form.setAttribute("novalidate", ""); // make sure browser don't prevent "submit" nor display messages
17297
17347
  const removeListener = addEventListener(form, "submit", (e) => {
17298
17348
  e.preventDefault();
17299
17349
  const actionCustomEvent = new CustomEvent("action", {
@@ -22067,6 +22117,8 @@ const DetailsWithConnectedAction = props => {
22067
22117
  });
22068
22118
  };
22069
22119
 
22120
+ CONSTRAINT_ATTRIBUTE_SET.add("data-available-message");
22121
+
22070
22122
  const createAvailableConstraint = (
22071
22123
  // the set might be incomplete (the front usually don't have the full copy of all the items from the backend)
22072
22124
  // but this is already nice to help user with what we know
@@ -24328,6 +24380,7 @@ Object.assign(PSEUDO_CLASSES, {
24328
24380
  }
24329
24381
  });
24330
24382
  const InputPseudoElements = ["::-navi-loader"];
24383
+ const InputPropSet = new Set([...CONSTRAINT_ATTRIBUTE_SET]);
24331
24384
  const InputTextualBasic = props => {
24332
24385
  const contextReadOnly = useContext(ReadOnlyContext);
24333
24386
  const contextDisabled = useContext(DisabledContext);
@@ -24398,7 +24451,8 @@ const InputTextualBasic = props => {
24398
24451
  }
24399
24452
  // style management
24400
24453
  ,
24401
- baseClassName: "navi_native_input"
24454
+ baseClassName: "navi_native_input",
24455
+ "data-rendered-by": ".navi_input"
24402
24456
  });
24403
24457
  };
24404
24458
  const renderInputMemoized = useCallback(renderInput, [type, uiState, innerValue, innerOnInput, innerId]);
@@ -24429,6 +24483,7 @@ const InputTextualBasic = props => {
24429
24483
  pseudoClasses: InputPseudoClasses,
24430
24484
  pseudoElements: InputPseudoElements,
24431
24485
  hasChildFunction: true,
24486
+ childPropSet: InputPropSet,
24432
24487
  "data-start-icon": innerIcon ? "" : undefined,
24433
24488
  "data-end-icon": cancelButton ? "" : undefined,
24434
24489
  ...remainingProps,