design-zystem 1.0.429 → 1.0.430

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/ui/index.js CHANGED
@@ -9028,6 +9028,15 @@ var parseTypedRange = (text, minDate, maxDate) => {
9028
9028
  if (!start || !end || start > end) return null;
9029
9029
  return [start, end];
9030
9030
  };
9031
+ var formatDigitsAsDate = (digits) => [digits.slice(0, 2), digits.slice(2, 4), digits.slice(4, 8)].filter(Boolean).join("/");
9032
+ var autoFormatTypedInput = (raw, isRange) => {
9033
+ const digits = raw.replace(/\D/g, "").slice(0, isRange ? 16 : 8);
9034
+ if (!isRange) return formatDigitsAsDate(digits);
9035
+ const first = digits.slice(0, 8);
9036
+ const second = digits.slice(8, 16);
9037
+ if (!second) return formatDigitsAsDate(first);
9038
+ return `${formatDigitsAsDate(first)} - ${formatDigitsAsDate(second)}`;
9039
+ };
9031
9040
  var RANGE_PRESETS = [
9032
9041
  {
9033
9042
  label: "Mois pr\xE9c\xE9dent",
@@ -9226,7 +9235,7 @@ var DatePicker = ({
9226
9235
  placeholder: isRange ? "jj/mm/aaaa - jj/mm/aaaa" : "jj/mm/aaaa",
9227
9236
  onFocus: startEditing,
9228
9237
  onChange: (event) => {
9229
- setDraftValue(event.target.value);
9238
+ setDraftValue(autoFormatTypedInput(event.target.value, isRange));
9230
9239
  setIsDirty(true);
9231
9240
  },
9232
9241
  onBlur: commitDraft,
package/dist/ui/index.mjs CHANGED
@@ -8854,6 +8854,15 @@ var parseTypedRange = (text, minDate, maxDate) => {
8854
8854
  if (!start || !end || start > end) return null;
8855
8855
  return [start, end];
8856
8856
  };
8857
+ var formatDigitsAsDate = (digits) => [digits.slice(0, 2), digits.slice(2, 4), digits.slice(4, 8)].filter(Boolean).join("/");
8858
+ var autoFormatTypedInput = (raw, isRange) => {
8859
+ const digits = raw.replace(/\D/g, "").slice(0, isRange ? 16 : 8);
8860
+ if (!isRange) return formatDigitsAsDate(digits);
8861
+ const first = digits.slice(0, 8);
8862
+ const second = digits.slice(8, 16);
8863
+ if (!second) return formatDigitsAsDate(first);
8864
+ return `${formatDigitsAsDate(first)} - ${formatDigitsAsDate(second)}`;
8865
+ };
8857
8866
  var RANGE_PRESETS = [
8858
8867
  {
8859
8868
  label: "Mois pr\xE9c\xE9dent",
@@ -9052,7 +9061,7 @@ var DatePicker = ({
9052
9061
  placeholder: isRange ? "jj/mm/aaaa - jj/mm/aaaa" : "jj/mm/aaaa",
9053
9062
  onFocus: startEditing,
9054
9063
  onChange: (event) => {
9055
- setDraftValue(event.target.value);
9064
+ setDraftValue(autoFormatTypedInput(event.target.value, isRange));
9056
9065
  setIsDirty(true);
9057
9066
  },
9058
9067
  onBlur: commitDraft,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "design-zystem",
3
- "version": "1.0.429",
3
+ "version": "1.0.430",
4
4
  "description": "A React design system of importable components",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",