@jsenv/navi 0.18.22 → 0.18.24

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.
@@ -6511,6 +6511,8 @@ const Box = props => {
6511
6511
  // -> introduced for <Input /> with a wrapped for loading, checkboxes, etc
6512
6512
  pseudoStateSelector,
6513
6513
  hasChildFunction,
6514
+ baseChildPropSet,
6515
+ childPropSet,
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 (baseChildPropSet?.has(propName) || 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
@@ -22227,6 +22279,11 @@ const normalizeColorString = (color, el) => {
22227
22279
  return String(colorRgba);
22228
22280
  };
22229
22281
 
22282
+ const fieldPropSet = new Set([
22283
+ ...CONSTRAINT_ATTRIBUTE_SET,
22284
+ "data-testid",
22285
+ ]);
22286
+
22230
22287
  installImportMetaCss(import.meta);import.meta.css = /* css */`
22231
22288
  @layer navi {
22232
22289
  label {
@@ -22684,6 +22741,7 @@ const CheckboxButtonStyleCSSVars = {
22684
22741
  };
22685
22742
  const CheckboxPseudoClasses = [":hover", ":active", ":focus", ":focus-visible", ":read-only", ":disabled", ":checked", ":-navi-loading"];
22686
22743
  const CheckboxPseudoElements = ["::-navi-loader", "::-navi-checkmark"];
22744
+ const CheckboxChildPropSet = new Set([...fieldPropSet]);
22687
22745
  const InputCheckboxBasic = props => {
22688
22746
  const contextFieldName = useContext(FieldNameContext);
22689
22747
  const contextReadOnly = useContext(ReadOnlyContext);
@@ -22786,6 +22844,7 @@ const InputCheckboxBasic = props => {
22786
22844
  },
22787
22845
  accentColor: accentColor,
22788
22846
  hasChildFunction: true,
22847
+ baseChildPropSet: CheckboxChildPropSet,
22789
22848
  preventInitialTransition: true,
22790
22849
  children: [jsx(LoaderBackground, {
22791
22850
  loading: innerLoading,
@@ -23405,6 +23464,7 @@ const RadioButtonStyleCSSVars = {
23405
23464
  };
23406
23465
  const RadioPseudoClasses = [":hover", ":active", ":focus", ":focus-visible", ":read-only", ":disabled", ":checked", ":-navi-loading"];
23407
23466
  const RadioPseudoElements = ["::-navi-loader", "::-navi-radiomark"];
23467
+ const RadioChildPropSet = new Set([...fieldPropSet]);
23408
23468
  const InputRadioBasic = props => {
23409
23469
  const contextName = useContext(FieldNameContext);
23410
23470
  const contextReadOnly = useContext(ReadOnlyContext);
@@ -23533,6 +23593,7 @@ const InputRadioBasic = props => {
23533
23593
  },
23534
23594
  color: color,
23535
23595
  hasChildFunction: true,
23596
+ baseChildPropSet: RadioChildPropSet,
23536
23597
  children: [jsx(LoaderBackground, {
23537
23598
  loading: innerLoading,
23538
23599
  inset: -1,
@@ -23795,7 +23856,7 @@ const InputRange = props => {
23795
23856
  })
23796
23857
  });
23797
23858
  };
23798
- const InputStyleCSSVars$1 = {
23859
+ const RangeStyleCSSVars = {
23799
23860
  "outlineWidth": "--outline-width",
23800
23861
  "borderRadius": "--border-radius",
23801
23862
  "borderColor": "--border-color",
@@ -23826,8 +23887,9 @@ const InputStyleCSSVars$1 = {
23826
23887
  thumbColor: "--thumb-color-disabled"
23827
23888
  }
23828
23889
  };
23829
- const InputPseudoClasses$1 = [":hover", ":active", ":focus", ":focus-visible", ":read-only", ":disabled", ":-navi-loading"];
23830
- const InputPseudoElements$1 = ["::-navi-loader"];
23890
+ const RangePseudoClasses = [":hover", ":active", ":focus", ":focus-visible", ":read-only", ":disabled", ":-navi-loading"];
23891
+ const RangePseudoElements = ["::-navi-loader"];
23892
+ const RangeChildPropSet = new Set([...fieldPropSet]);
23831
23893
  const InputRangeBasic = props => {
23832
23894
  const contextReadOnly = useContext(ReadOnlyContext);
23833
23895
  const contextDisabled = useContext(DisabledContext);
@@ -23938,7 +24000,7 @@ const InputRangeBasic = props => {
23938
24000
  as: "span",
23939
24001
  box: true,
23940
24002
  baseClassName: "navi_input_range",
23941
- styleCSSVars: InputStyleCSSVars$1,
24003
+ styleCSSVars: RangeStyleCSSVars,
23942
24004
  pseudoStateSelector: ".navi_native_input",
23943
24005
  visualSelector: ".navi_native_input",
23944
24006
  basePseudoState: {
@@ -23946,9 +24008,10 @@ const InputRangeBasic = props => {
23946
24008
  ":disabled": innerDisabled,
23947
24009
  ":-navi-loading": innerLoading
23948
24010
  },
23949
- pseudoClasses: InputPseudoClasses$1,
23950
- pseudoElements: InputPseudoElements$1,
24011
+ pseudoClasses: RangePseudoClasses,
24012
+ pseudoElements: RangePseudoElements,
23951
24013
  hasChildFunction: true,
24014
+ baseChildPropSet: RangeChildPropSet,
23952
24015
  ...remainingProps,
23953
24016
  ref: undefined,
23954
24017
  children: [jsx(LoaderBackground, {
@@ -24328,6 +24391,7 @@ Object.assign(PSEUDO_CLASSES, {
24328
24391
  }
24329
24392
  });
24330
24393
  const InputPseudoElements = ["::-navi-loader"];
24394
+ const InputChildPropSet = new Set([...fieldPropSet]);
24331
24395
  const InputTextualBasic = props => {
24332
24396
  const contextReadOnly = useContext(ReadOnlyContext);
24333
24397
  const contextDisabled = useContext(DisabledContext);
@@ -24398,7 +24462,8 @@ const InputTextualBasic = props => {
24398
24462
  }
24399
24463
  // style management
24400
24464
  ,
24401
- baseClassName: "navi_native_input"
24465
+ baseClassName: "navi_native_input",
24466
+ "data-rendered-by": ".navi_input"
24402
24467
  });
24403
24468
  };
24404
24469
  const renderInputMemoized = useCallback(renderInput, [type, uiState, innerValue, innerOnInput, innerId]);
@@ -24429,6 +24494,7 @@ const InputTextualBasic = props => {
24429
24494
  pseudoClasses: InputPseudoClasses,
24430
24495
  pseudoElements: InputPseudoElements,
24431
24496
  hasChildFunction: true,
24497
+ baseChildPropSet: InputChildPropSet,
24432
24498
  "data-start-icon": innerIcon ? "" : undefined,
24433
24499
  "data-end-icon": cancelButton ? "" : undefined,
24434
24500
  ...remainingProps,