@jsenv/navi 0.18.21 → 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.
@@ -1596,6 +1596,9 @@ const createAction = (callback, rootOptions = {}) => {
1596
1596
  writable: true,
1597
1597
  value: name,
1598
1598
  });
1599
+ // Register the action function itself so that createAction(action) returns
1600
+ // the same action instead of creating a new one
1601
+ actionWeakMap.set(action, action);
1599
1602
  }
1600
1603
 
1601
1604
  const callSource = generateActionCallSource(name, params);
@@ -1914,7 +1917,7 @@ const createAction = (callback, rootOptions = {}) => {
1914
1917
  valueSignal.value = valueInitial;
1915
1918
  }
1916
1919
  if (outputSignal) {
1917
- outputSignal.value = null;
1920
+ outputSignal.value = undefined;
1918
1921
  }
1919
1922
  isPrerunSignal.value = true;
1920
1923
  runningStateSignal.value = IDLE;
@@ -6482,6 +6485,7 @@ const PSEUDO_CLASSES_DEFAULT = [];
6482
6485
  const PSEUDO_ELEMENTS_DEFAULT = [];
6483
6486
  const STYLE_CSS_VARS_DEFAULT = {};
6484
6487
  const PROPS_CSS_VARS_DEFAULT = {};
6488
+ const CHILD_PROP_SET_DEFAULT = new Set();
6485
6489
  const Box = props => {
6486
6490
  const {
6487
6491
  as = "div",
@@ -6508,6 +6512,7 @@ const Box = props => {
6508
6512
  // -> introduced for <Input /> with a wrapped for loading, checkboxes, etc
6509
6513
  pseudoStateSelector,
6510
6514
  hasChildFunction,
6515
+ childPropSet = CHILD_PROP_SET_DEFAULT,
6511
6516
  // preventInitialTransition can be used to prevent transition on mount
6512
6517
  // (when transition is set via props, this is done automatically)
6513
6518
  // so this prop is useful only when transition is enabled from "outside" (via CSS)
@@ -6762,6 +6767,10 @@ const Box = props => {
6762
6767
  }
6763
6768
  for (const propName of remainingPropKeySet) {
6764
6769
  const propValue = rest[propName];
6770
+ if (childPropSet.has(propName)) {
6771
+ childForwardedProps[propName] = propValue;
6772
+ continue;
6773
+ }
6765
6774
  const isDataAttribute = propName.startsWith("data-");
6766
6775
  if (isDataAttribute) {
6767
6776
  selfForwardedProps[propName] = propValue;
@@ -15733,6 +15742,8 @@ const fromSelectorAttribute = (messageAttributeValue) => {
15733
15742
  return mirror;
15734
15743
  };
15735
15744
 
15745
+ const CONSTRAINT_ATTRIBUTE_SET = new Set();
15746
+
15736
15747
  const generateFieldInvalidMessage = (template, { field }) => {
15737
15748
  return replaceStringVars(template, {
15738
15749
  "{field}": () => generateThisFieldText(field),
@@ -15788,7 +15799,7 @@ const MIN_LOWER_LETTER_CONSTRAINT = {
15788
15799
  }
15789
15800
  }
15790
15801
  if (numberOfLowercaseChars < min) {
15791
- if (min === 0) {
15802
+ if (min === 1) {
15792
15803
  return generateFieldInvalidMessage(
15793
15804
  `{field} doit contenir au moins une lettre minuscule.`,
15794
15805
  { field },
@@ -15802,6 +15813,9 @@ const MIN_LOWER_LETTER_CONSTRAINT = {
15802
15813
  return "";
15803
15814
  },
15804
15815
  };
15816
+ CONSTRAINT_ATTRIBUTE_SET.add("data-min-lower-letter");
15817
+ CONSTRAINT_ATTRIBUTE_SET.add("data-min-lower-letter-message");
15818
+
15805
15819
  const MIN_UPPER_LETTER_CONSTRAINT = {
15806
15820
  name: "min_upper_letter",
15807
15821
  messageAttribute: "data-min-upper-letter-message",
@@ -15822,7 +15836,7 @@ const MIN_UPPER_LETTER_CONSTRAINT = {
15822
15836
  }
15823
15837
  }
15824
15838
  if (numberOfUppercaseChars < min) {
15825
- if (min === 0) {
15839
+ if (min === 1) {
15826
15840
  return generateFieldInvalidMessage(
15827
15841
  `{field} doit contenir au moins une lettre majuscule.`,
15828
15842
  { field },
@@ -15836,6 +15850,9 @@ const MIN_UPPER_LETTER_CONSTRAINT = {
15836
15850
  return "";
15837
15851
  },
15838
15852
  };
15853
+ CONSTRAINT_ATTRIBUTE_SET.add("data-min-upper-letter");
15854
+ CONSTRAINT_ATTRIBUTE_SET.add("data-min-upper-letter-message");
15855
+
15839
15856
  const MIN_DIGIT_CONSTRAINT = {
15840
15857
  name: "min_digit",
15841
15858
  messageAttribute: "data-min-digit-message",
@@ -15856,7 +15873,7 @@ const MIN_DIGIT_CONSTRAINT = {
15856
15873
  }
15857
15874
  }
15858
15875
  if (numberOfDigitChars < min) {
15859
- if (min === 0) {
15876
+ if (min === 1) {
15860
15877
  return generateFieldInvalidMessage(
15861
15878
  `{field} doit contenir au moins un chiffre.`,
15862
15879
  { field },
@@ -15870,6 +15887,9 @@ const MIN_DIGIT_CONSTRAINT = {
15870
15887
  return "";
15871
15888
  },
15872
15889
  };
15890
+ CONSTRAINT_ATTRIBUTE_SET.add("data-min-digit");
15891
+ CONSTRAINT_ATTRIBUTE_SET.add("data-min-digit-message");
15892
+
15873
15893
  const MIN_SPECIAL_CHAR_CONSTRAINT = {
15874
15894
  name: "min_special_char",
15875
15895
  messageAttribute: "data-min-special-char-message",
@@ -15909,6 +15929,9 @@ const MIN_SPECIAL_CHAR_CONSTRAINT = {
15909
15929
  return "";
15910
15930
  },
15911
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");
15912
15935
 
15913
15936
  const READONLY_CONSTRAINT = {
15914
15937
  name: "readonly",
@@ -15945,6 +15968,10 @@ const READONLY_CONSTRAINT = {
15945
15968
  };
15946
15969
  },
15947
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");
15948
15975
 
15949
15976
  const SAME_AS_CONSTRAINT = {
15950
15977
  name: "same_as",
@@ -15983,6 +16010,8 @@ const SAME_AS_CONSTRAINT = {
15983
16010
  return `Ce champ doit être identique au précédent.`;
15984
16011
  },
15985
16012
  };
16013
+ CONSTRAINT_ATTRIBUTE_SET.add("data-same-as");
16014
+ CONSTRAINT_ATTRIBUTE_SET.add("data-same-as-message");
15986
16015
 
15987
16016
  const SINGLE_SPACE_CONSTRAINT = {
15988
16017
  name: "single_space",
@@ -16017,6 +16046,8 @@ const SINGLE_SPACE_CONSTRAINT = {
16017
16046
  return "";
16018
16047
  },
16019
16048
  };
16049
+ CONSTRAINT_ATTRIBUTE_SET.add("data-single-space");
16050
+ CONSTRAINT_ATTRIBUTE_SET.add("data-single-space-message");
16020
16051
 
16021
16052
  /**
16022
16053
  * https://developer.mozilla.org/en-US/docs/Web/HTML/Guides/Constraint_validation
@@ -16035,6 +16066,9 @@ const DISABLED_CONSTRAINT = {
16035
16066
  return null;
16036
16067
  },
16037
16068
  };
16069
+ CONSTRAINT_ATTRIBUTE_SET.add("disabled");
16070
+ CONSTRAINT_ATTRIBUTE_SET.add("data-disabled");
16071
+ CONSTRAINT_ATTRIBUTE_SET.add("data-disabled-message");
16038
16072
 
16039
16073
  const REQUIRED_CONSTRAINT = {
16040
16074
  name: "required",
@@ -16104,6 +16138,8 @@ const REQUIRED_CONSTRAINT = {
16104
16138
  : `Veuillez remplir ce champ.`;
16105
16139
  },
16106
16140
  };
16141
+ CONSTRAINT_ATTRIBUTE_SET.add("required");
16142
+ CONSTRAINT_ATTRIBUTE_SET.add("data-required-message");
16107
16143
 
16108
16144
  const PATTERN_CONSTRAINT = {
16109
16145
  name: "pattern",
@@ -16132,6 +16168,9 @@ const PATTERN_CONSTRAINT = {
16132
16168
  return message;
16133
16169
  },
16134
16170
  };
16171
+ CONSTRAINT_ATTRIBUTE_SET.add("pattern");
16172
+ CONSTRAINT_ATTRIBUTE_SET.add("data-pattern-message");
16173
+
16135
16174
  // https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input/email#validation
16136
16175
  const emailregex =
16137
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])?)*$/;
@@ -16155,6 +16194,7 @@ const TYPE_EMAIL_CONSTRAINT = {
16155
16194
  return null;
16156
16195
  },
16157
16196
  };
16197
+ CONSTRAINT_ATTRIBUTE_SET.add("data-type-message");
16158
16198
 
16159
16199
  const MIN_LENGTH_CONSTRAINT = {
16160
16200
  name: "min_length",
@@ -16167,7 +16207,6 @@ const MIN_LENGTH_CONSTRAINT = {
16167
16207
  } else if (field.tagName !== "TEXTAREA") {
16168
16208
  return null;
16169
16209
  }
16170
-
16171
16210
  const minLength = field.minLength;
16172
16211
  if (minLength === -1) {
16173
16212
  return null;
@@ -16192,6 +16231,8 @@ const MIN_LENGTH_CONSTRAINT = {
16192
16231
  );
16193
16232
  },
16194
16233
  };
16234
+ CONSTRAINT_ATTRIBUTE_SET.add("minLength");
16235
+ CONSTRAINT_ATTRIBUTE_SET.add("data-min-length-message");
16195
16236
  const INPUT_TYPE_SUPPORTING_MIN_LENGTH_SET = new Set([
16196
16237
  "text",
16197
16238
  "search",
@@ -16227,6 +16268,8 @@ const MAX_LENGTH_CONSTRAINT = {
16227
16268
  );
16228
16269
  },
16229
16270
  };
16271
+ CONSTRAINT_ATTRIBUTE_SET.add("maxLength");
16272
+ CONSTRAINT_ATTRIBUTE_SET.add("data-max-length-message");
16230
16273
  const INPUT_TYPE_SUPPORTING_MAX_LENGTH_SET = new Set(
16231
16274
  INPUT_TYPE_SUPPORTING_MIN_LENGTH_SET,
16232
16275
  );
@@ -16255,6 +16298,7 @@ const TYPE_NUMBER_CONSTRAINT = {
16255
16298
  return null;
16256
16299
  },
16257
16300
  };
16301
+ CONSTRAINT_ATTRIBUTE_SET.add("data-type-message");
16258
16302
 
16259
16303
  const MIN_CONSTRAINT = {
16260
16304
  name: "min",
@@ -16308,6 +16352,8 @@ const MIN_CONSTRAINT = {
16308
16352
  return null;
16309
16353
  },
16310
16354
  };
16355
+ CONSTRAINT_ATTRIBUTE_SET.add("min");
16356
+ CONSTRAINT_ATTRIBUTE_SET.add("data-min-message");
16311
16357
 
16312
16358
  const MAX_CONSTRAINT = {
16313
16359
  name: "max",
@@ -16356,6 +16402,8 @@ const MAX_CONSTRAINT = {
16356
16402
  return null;
16357
16403
  },
16358
16404
  };
16405
+ CONSTRAINT_ATTRIBUTE_SET.add("max");
16406
+ CONSTRAINT_ATTRIBUTE_SET.add("data-max-message");
16359
16407
 
16360
16408
  const listenInputValue = (
16361
16409
  input,
@@ -16809,6 +16857,8 @@ const installCustomConstraintValidation = (
16809
16857
  }
16810
16858
 
16811
16859
  const isForm = element.tagName === "FORM";
16860
+ const isInput = element.tagName === "INPUT" || element.tagName === "TEXTAREA";
16861
+ const isCheckbox = element.tagName === "INPUT" && element.type === "checkbox";
16812
16862
  if (isForm) {
16813
16863
  formInstrumentedWeakSet.add(element);
16814
16864
  addTeardown(() => {
@@ -17228,8 +17278,6 @@ const installCustomConstraintValidation = (
17228
17278
  }
17229
17279
 
17230
17280
  request_on_input_value_change: {
17231
- const isInput =
17232
- element.tagName === "INPUT" || element.tagName === "TEXTAREA";
17233
17281
  if (!isInput) {
17234
17282
  break request_on_input_value_change;
17235
17283
  }
@@ -17238,6 +17286,9 @@ const installCustomConstraintValidation = (
17238
17286
  break request_on_input_value_change;
17239
17287
  }
17240
17288
  const closestElementWithActionAttr = element.closest("[data-action]");
17289
+ if (closestElementWithActionAttr.tagName === "FORM") {
17290
+ break request_on_input_value_change;
17291
+ }
17241
17292
  const stop = listenInputValue(
17242
17293
  element,
17243
17294
  (e) => {
@@ -17265,8 +17316,6 @@ const installCustomConstraintValidation = (
17265
17316
  }
17266
17317
 
17267
17318
  request_on_checkbox_change: {
17268
- const isCheckbox =
17269
- element.tagName === "INPUT" && element.type === "checkbox";
17270
17319
  if (!isCheckbox) {
17271
17320
  break request_on_checkbox_change;
17272
17321
  }
@@ -17291,6 +17340,10 @@ const installCustomConstraintValidation = (
17291
17340
  }
17292
17341
  // We will dispatch "action" when "submit" occurs (code called from.submit() to bypass validation)
17293
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
17294
17347
  const removeListener = addEventListener(form, "submit", (e) => {
17295
17348
  e.preventDefault();
17296
17349
  const actionCustomEvent = new CustomEvent("action", {
@@ -22064,6 +22117,8 @@ const DetailsWithConnectedAction = props => {
22064
22117
  });
22065
22118
  };
22066
22119
 
22120
+ CONSTRAINT_ATTRIBUTE_SET.add("data-available-message");
22121
+
22067
22122
  const createAvailableConstraint = (
22068
22123
  // the set might be incomplete (the front usually don't have the full copy of all the items from the backend)
22069
22124
  // but this is already nice to help user with what we know
@@ -24325,6 +24380,7 @@ Object.assign(PSEUDO_CLASSES, {
24325
24380
  }
24326
24381
  });
24327
24382
  const InputPseudoElements = ["::-navi-loader"];
24383
+ const InputPropSet = new Set([...CONSTRAINT_ATTRIBUTE_SET]);
24328
24384
  const InputTextualBasic = props => {
24329
24385
  const contextReadOnly = useContext(ReadOnlyContext);
24330
24386
  const contextDisabled = useContext(DisabledContext);
@@ -24395,7 +24451,8 @@ const InputTextualBasic = props => {
24395
24451
  }
24396
24452
  // style management
24397
24453
  ,
24398
- baseClassName: "navi_native_input"
24454
+ baseClassName: "navi_native_input",
24455
+ "data-rendered-by": ".navi_input"
24399
24456
  });
24400
24457
  };
24401
24458
  const renderInputMemoized = useCallback(renderInput, [type, uiState, innerValue, innerOnInput, innerId]);
@@ -24426,6 +24483,7 @@ const InputTextualBasic = props => {
24426
24483
  pseudoClasses: InputPseudoClasses,
24427
24484
  pseudoElements: InputPseudoElements,
24428
24485
  hasChildFunction: true,
24486
+ childPropSet: InputPropSet,
24429
24487
  "data-start-icon": innerIcon ? "" : undefined,
24430
24488
  "data-end-icon": cancelButton ? "" : undefined,
24431
24489
  ...remainingProps,