@mtes-mct/monitor-ui 6.4.0 → 6.5.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/CHANGELOG.md CHANGED
@@ -1,3 +1,22 @@
1
+ ## [6.4.1](https://github.com/MTES-MCT/monitor-ui/compare/v6.4.0...v6.4.1) (2023-05-25)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **fields:** don't display list when no value ([7fa81b3](https://github.com/MTES-MCT/monitor-ui/commit/7fa81b367b23f993800addaa5d5667a73c4407d8))
7
+
8
+ # [6.4.0](https://github.com/MTES-MCT/monitor-ui/compare/v6.3.3...v6.4.0) (2023-05-25)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **formiks:** delete setTouched in handleChange and delete touched condition for error ([17a9e24](https://github.com/MTES-MCT/monitor-ui/commit/17a9e249a74352f0696a9cc2146aa4e88422a542))
14
+
15
+
16
+ ### Features
17
+
18
+ * **fields:** add customSearch prop to Search ([53e993a](https://github.com/MTES-MCT/monitor-ui/commit/53e993ac1cd8c218a3bddbd5cef0d36778589166))
19
+
1
20
  ## [6.3.3](https://github.com/MTES-MCT/monitor-ui/compare/v6.3.2...v6.3.3) (2023-05-25)
2
21
 
3
22
 
package/cypress/index.js CHANGED
@@ -941,132 +941,137 @@ function waitFor(inMs) {
941
941
  /* eslint-disable cypress/no-assigning-return-values */
942
942
  const RETRIES = 5;
943
943
  function fill(label, value, leftRetries = RETRIES) {
944
- // -------------------------------------------------------------------------
945
- // If this is a `<label />` element
946
- const labelElement = findElementBytext('label', label);
947
- if (labelElement) {
944
+ try {
948
945
  // -------------------------------------------------------------------------
949
- // If the label has a `for` attribute
950
- if (!isEmpty$1(labelElement.htmlFor)) {
951
- const htmlforElement = findElementBySelector(`[id="${labelElement.htmlFor}"]`);
952
- if (!htmlforElement) {
953
- throw new Error(`Could not find the element with [id="${labelElement.htmlFor}"] targetted by label "${label}" (via its \`for\` attribute).`);
954
- }
955
- const cypressHtmlforElement = cy.get(`[id="${labelElement.htmlFor}"]`);
956
- cypressHtmlforElement.then((() => {
957
- if (htmlforElement.classList.contains('rs-picker-toggle-textbox')) {
958
- const rsuitePickerElement = htmlforElement.parentElement &&
959
- htmlforElement.parentElement.parentElement &&
960
- htmlforElement.parentElement.parentElement.parentElement
961
- ? htmlforElement.parentElement.parentElement.parentElement.parentElement
962
- : undefined;
963
- if (!rsuitePickerElement) {
964
- throw new Error('This should never happen.');
946
+ // If this is a `<label />` element
947
+ const labelElement = findElementBytext('label', label);
948
+ if (labelElement) {
949
+ // -------------------------------------------------------------------------
950
+ // If the label has a `for` attribute
951
+ if (!isEmpty$1(labelElement.htmlFor)) {
952
+ const htmlforElement = findElementBySelector(`[id="${labelElement.htmlFor}"]`);
953
+ if (!htmlforElement) {
954
+ throw new Error(`Could not find the element with [id="${labelElement.htmlFor}"] targetted by label "${label}" (via its \`for\` attribute).`);
955
+ }
956
+ const cypressHtmlforElement = cy.get(`[id="${labelElement.htmlFor}"]`);
957
+ cypressHtmlforElement.then((() => {
958
+ if (htmlforElement.classList.contains('rs-picker-toggle-textbox')) {
959
+ const rsuitePickerElement = htmlforElement.parentElement &&
960
+ htmlforElement.parentElement.parentElement &&
961
+ htmlforElement.parentElement.parentElement.parentElement
962
+ ? htmlforElement.parentElement.parentElement.parentElement.parentElement
963
+ : undefined;
964
+ if (!rsuitePickerElement) {
965
+ throw new Error('This should never happen.');
966
+ }
967
+ switch (true) {
968
+ // Select
969
+ case rsuitePickerElement.classList.contains('rs-picker-select'):
970
+ pickSelectOption(cypressHtmlforElement, value !== undefined ? String(value) : value);
971
+ break;
972
+ // Multi Select
973
+ case rsuitePickerElement.classList.contains('rs-picker-tag'):
974
+ pickMultiSelectOptions(cypressHtmlforElement, Array.isArray(value) && value.length > 0 ? value : undefined);
975
+ break;
976
+ default:
977
+ throw new Error(`\`cy.fill()\` can't handle Rsuite picker with class "${rsuitePickerElement.className}" elements.`);
978
+ }
979
+ return;
965
980
  }
966
- switch (true) {
967
- // Select
968
- case rsuitePickerElement.classList.contains('rs-picker-select'):
969
- pickSelectOption(cypressHtmlforElement, value !== undefined ? String(value) : value);
981
+ switch (htmlforElement.tagName) {
982
+ // Text/Number Input
983
+ case 'INPUT':
984
+ fillTextInput(htmlforElement, value !== undefined ? String(value) : value);
970
985
  break;
971
- // Multi Select
972
- case rsuitePickerElement.classList.contains('rs-picker-tag'):
973
- pickMultiSelectOptions(cypressHtmlforElement, Array.isArray(value) && value.length > 0 ? value : undefined);
986
+ // Textarea
987
+ case 'TEXTAREA':
988
+ fillTextarea(htmlforElement, value !== undefined ? String(value) : value);
974
989
  break;
975
990
  default:
976
- throw new Error(`\`cy.fill()\` can't handle Rsuite picker with class "${rsuitePickerElement.className}" elements.`);
991
+ throw new Error(`\`cy.fill()\` doesn't handle "${htmlforElement.tagName}" elements.`);
977
992
  }
978
- return;
979
- }
980
- switch (htmlforElement.tagName) {
981
- // Text/Number Input
982
- case 'INPUT':
983
- fillTextInput(htmlforElement, value !== undefined ? String(value) : value);
984
- break;
985
- // Textarea
986
- case 'TEXTAREA':
987
- fillTextarea(htmlforElement, value !== undefined ? String(value) : value);
988
- break;
989
- default:
990
- throw new Error(`\`cy.fill()\` doesn't handle "${htmlforElement.tagName}" elements.`);
991
- }
992
- }));
993
- return;
994
- }
995
- // -------------------------------------------------------------------------
996
- // If the label doesn't have a `for` attribute
997
- // Checkbox Input
998
- const checkboxInputElement = labelElement.querySelector('input[type="checkbox"]');
999
- if (checkboxInputElement) {
1000
- checkCheckbox(checkboxInputElement, Boolean(value));
1001
- return;
1002
- }
1003
- // Text Input
1004
- const textInputElement = labelElement.querySelector('input[type="text"]');
1005
- if (textInputElement) {
1006
- fillTextInput(textInputElement, String(value));
1007
- return;
1008
- }
1009
- // Textarea
1010
- const textareaElement = labelElement.querySelector('textarea');
1011
- if (textareaElement) {
1012
- fillTextarea(textareaElement, String(value));
1013
- return;
1014
- }
1015
- throw new Error(`Could find neither a checkbox, an input nor a textarea with the label "${label}".`);
1016
- }
1017
- // -------------------------------------------------------------------------
1018
- // If this is a `<legend />` element
1019
- const legendElement = findElementBytext('legend', label);
1020
- if (legendElement) {
1021
- const cypressLegendElement = cy.get('legend').contains(label);
1022
- cypressLegendElement.then(async () => {
1023
- await waitFor(500);
1024
- const fieldsetElement = legendElement.parentElement;
1025
- if (!fieldsetElement || fieldsetElement.tagName !== 'FIELDSET') {
1026
- throw new Error(`Could not find parent fieldset of legend element with text "${label}".`);
1027
- }
1028
- if (fieldsetElement.classList.contains('Field-DatePicker')) {
1029
- if ((!Array.isArray(value) || (value.length !== 3 && value.length !== 5) || typeof value[0] !== 'number') &&
1030
- value !== undefined) {
1031
- throw new Error('`value` should be of type `[number, number, number]`, `[number, number, number, number, number]` or `undefined`.');
1032
- }
1033
- fillDatePicker(fieldsetElement, value);
993
+ }));
1034
994
  return;
1035
995
  }
1036
- if (fieldsetElement.classList.contains('Field-DateRangePicker')) {
1037
- if ((!Array.isArray(value) ||
1038
- value.length !== 2 ||
1039
- !Array.isArray(value[0]) ||
1040
- (value[0].length !== 3 && value[0].length !== 5) ||
1041
- (value[1].length !== 3 && value[1].length !== 5)) &&
1042
- value !== undefined) {
1043
- throw new Error('`value` should be of type `[[number, number, number], [number, number, number]]` or ``[[number, number, number, number, number], [number, number, number, number, number]]`` or `undefined`.');
1044
- }
1045
- fillDateRangePicker(fieldsetElement, value);
996
+ // -------------------------------------------------------------------------
997
+ // If the label doesn't have a `for` attribute
998
+ // Checkbox Input
999
+ const checkboxInputElement = labelElement.querySelector('input[type="checkbox"]');
1000
+ if (checkboxInputElement) {
1001
+ checkCheckbox(checkboxInputElement, Boolean(value));
1046
1002
  return;
1047
1003
  }
1048
- const isMultiCheckbox = Boolean(fieldsetElement.querySelector('input[type="checkbox"]'));
1049
- const isMultiRadio = Boolean(fieldsetElement.querySelector('input[type="radio"]'));
1050
- if (isMultiCheckbox) {
1051
- checkMultiCheckboxOptions(fieldsetElement, Array.isArray(value) && value.length > 0 ? value : undefined);
1004
+ // Text Input
1005
+ const textInputElement = labelElement.querySelector('input[type="text"]');
1006
+ if (textInputElement) {
1007
+ fillTextInput(textInputElement, String(value));
1052
1008
  return;
1053
1009
  }
1054
- if (isMultiRadio) {
1055
- checkMultiRadioOption(fieldsetElement, String(value));
1010
+ // Textarea
1011
+ const textareaElement = labelElement.querySelector('textarea');
1012
+ if (textareaElement) {
1013
+ fillTextarea(textareaElement, String(value));
1056
1014
  return;
1057
1015
  }
1058
- throw new Error(`\`cy.fill()\` can't handle the field with legend "${label}".`);
1059
- });
1060
- return;
1016
+ throw new Error(`Could find neither a checkbox, an input nor a textarea with the label "${label}".`);
1017
+ }
1018
+ // -------------------------------------------------------------------------
1019
+ // If this is a `<legend />` element
1020
+ const legendElement = findElementBytext('legend', label);
1021
+ if (legendElement) {
1022
+ const cypressLegendElement = cy.get('legend').contains(label);
1023
+ cypressLegendElement.then(async () => {
1024
+ await waitFor(500);
1025
+ const fieldsetElement = legendElement.parentElement;
1026
+ if (!fieldsetElement || fieldsetElement.tagName !== 'FIELDSET') {
1027
+ throw new Error(`Could not find parent fieldset of legend element with text "${label}".`);
1028
+ }
1029
+ if (fieldsetElement.classList.contains('Field-DatePicker')) {
1030
+ if ((!Array.isArray(value) || (value.length !== 3 && value.length !== 5) || typeof value[0] !== 'number') &&
1031
+ value !== undefined) {
1032
+ throw new Error('`value` should be of type `[number, number, number]`, `[number, number, number, number, number]` or `undefined`.');
1033
+ }
1034
+ fillDatePicker(fieldsetElement, value);
1035
+ return;
1036
+ }
1037
+ if (fieldsetElement.classList.contains('Field-DateRangePicker')) {
1038
+ if ((!Array.isArray(value) ||
1039
+ value.length !== 2 ||
1040
+ !Array.isArray(value[0]) ||
1041
+ (value[0].length !== 3 && value[0].length !== 5) ||
1042
+ (value[1].length !== 3 && value[1].length !== 5)) &&
1043
+ value !== undefined) {
1044
+ throw new Error('`value` should be of type `[[number, number, number], [number, number, number]]` or ``[[number, number, number, number, number], [number, number, number, number, number]]`` or `undefined`.');
1045
+ }
1046
+ fillDateRangePicker(fieldsetElement, value);
1047
+ return;
1048
+ }
1049
+ const isMultiCheckbox = Boolean(fieldsetElement.querySelector('input[type="checkbox"]'));
1050
+ const isMultiRadio = Boolean(fieldsetElement.querySelector('input[type="radio"]'));
1051
+ if (isMultiCheckbox) {
1052
+ checkMultiCheckboxOptions(fieldsetElement, Array.isArray(value) && value.length > 0 ? value : undefined);
1053
+ return;
1054
+ }
1055
+ if (isMultiRadio) {
1056
+ checkMultiRadioOption(fieldsetElement, String(value));
1057
+ return;
1058
+ }
1059
+ throw new Error(`\`cy.fill()\` can't handle the field with legend "${label}".`);
1060
+ });
1061
+ return;
1062
+ }
1063
+ throw new Error(`Could not find label or legend element with text "${label}".`);
1061
1064
  }
1062
- if (leftRetries > 0) {
1063
- cy.wait(250).then(() => {
1064
- cy.log(`Retrying (${RETRIES - leftRetries + 1} / ${RETRIES})...`);
1065
- fill(label, value, leftRetries - 1);
1066
- });
1067
- return;
1065
+ catch (err) {
1066
+ if (leftRetries > 0) {
1067
+ cy.wait(250).then(() => {
1068
+ cy.log(`Retrying (${RETRIES - leftRetries + 1} / ${RETRIES})...`);
1069
+ fill(label, value, leftRetries - 1);
1070
+ });
1071
+ return;
1072
+ }
1073
+ throw new Error(`Could not find label or legend element with text "${label}" after ${RETRIES} attempts.`);
1068
1074
  }
1069
- throw new Error(`Could not find label or legend element with text "${label}".`);
1070
1075
  }
1071
1076
 
1072
1077
  function forceClick([subject]) {