@mtes-mct/monitor-ui 8.7.0 → 9.0.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,18 @@
1
+ # [8.8.0](https://github.com/MTES-MCT/monitor-ui/compare/v8.7.0...v8.8.0) (2023-08-22)
2
+
3
+
4
+ ### Features
5
+
6
+ * **utils:** add pluralize() ([57663f7](https://github.com/MTES-MCT/monitor-ui/commit/57663f78110e0ea66771a74699c712eb757431d1))
7
+ * **utils:** expose cleanString() & normalizeString() ([41a6a6f](https://github.com/MTES-MCT/monitor-ui/commit/41a6a6f936e403aa66bf999664f0e5ad1f7c63fd))
8
+
9
+ # [8.7.0](https://github.com/MTES-MCT/monitor-ui/compare/v8.6.1...v8.7.0) (2023-08-22)
10
+
11
+
12
+ ### Features
13
+
14
+ * **icons:** add icons ([ace2a82](https://github.com/MTES-MCT/monitor-ui/commit/ace2a821c9baf8b78091111e4801706b37b3c2ee))
15
+
1
16
  ## [8.6.1](https://github.com/MTES-MCT/monitor-ui/compare/v8.6.0...v8.6.1) (2023-08-21)
2
17
 
3
18
 
package/README.md CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  [![License][img-license]][lnk-license] [![CI Status][img-github]][lnk-github] [![NPM Version][img-npm]][lnk-npm]
4
4
 
5
- > Common React components, hooks, utilities and CSS stylesheets for [Monitorfish][lnk-github-monitorfish] and
6
- > [Monitorenv][lnk-github-monitorenv].
5
+ > Common React components, hooks, utilities and CSS stylesheets for [MonitorFish][lnk-github-monitorfish],
6
+ > [MonitorEnv][lnk-github-monitorenv] and [RapportNav][lnk-github-rapportnav].
7
7
 
8
8
  ## Usage
9
9
 
@@ -63,6 +63,7 @@ Please read the [contributing document](CONTRIBUTING.md) for setup and contribut
63
63
  [lnk-github]: https://github.com/MTES-MCT/monitor-ui/actions?query=branch%3Amain++
64
64
  [lnk-github-monitorenv]: https://github.com/MTES-MCT/monitorenv
65
65
  [lnk-github-monitorfish]: https://github.com/MTES-MCT/monitorfish
66
+ [lnk-github-rapportnav]: https://github.com/MTES-MCT/rapportnav2
66
67
  [lnk-license]: https://github.com/MTES-MCT/monitor-ui/blob/main/LICENSE
67
68
  [lnk-npm]: https://www.npmjs.com/package/@mtes-mct/monitor-ui
68
69
  [lnk-storybook]: https://mtes-mct.github.io/monitor-ui/
package/index.js CHANGED
@@ -2350,7 +2350,7 @@ function Item({ accent, Icon, ...originalProps }) {
2350
2350
  const SecondaryDropdownItem = styled(Dropdown$1.Item) `
2351
2351
  background-color: ${p => p.theme.color.cultured};
2352
2352
  border: 1px solid ${p => p.theme.color.lightGray};
2353
- padding: 5px 7px;
2353
+ padding: 4px;
2354
2354
  :hover {
2355
2355
  background-color: ${p => p.theme.color.cultured};
2356
2356
  border: 1px solid ${p => p.theme.color.lightGray};
@@ -35985,28 +35985,44 @@ function getDMSCoordinates(transformedCoordinates) {
35985
35985
  }
35986
35986
  function getDMDFromDecimal(dd, latitudeOrLongitude) {
35987
35987
  const hemisphere = getHemisphere(dd, latitudeOrLongitude);
35988
- const absDD = Math.abs(dd);
35989
- const degrees = truncate(absDD);
35990
- const minutes = truncate((absDD - degrees) * 60);
35991
- let decimal = (absDD - degrees) * 60;
35992
- decimal -= Math.floor(decimal);
35993
- decimal = Math.round(decimal * 1000);
35988
+ // Get the decimal degrees as an absolute value
35989
+ const absoluteDecimalDegrees = Math.abs(dd);
35990
+ const degrees = truncate(absoluteDecimalDegrees);
35991
+ const [minutesInteger, minuteDecimals] = getMinutes(absoluteDecimalDegrees, degrees);
35994
35992
  const formattedDegrees = getPaddedDegrees(degrees, latitudeOrLongitude);
35995
- const formattedMinutes = minutes.toString().padStart(2, '0');
35996
- const formattedDecimal = decimal.toString().padStart(3, '0').substring(0, 3);
35993
+ const formattedMinutes = minutesInteger.padStart(2, '0');
35994
+ const formattedDecimal = minuteDecimals.padStart(3, '0').substring(0, 3);
35997
35995
  return `${formattedDegrees}° ${formattedMinutes}.${formattedDecimal}′ ${hemisphere}`;
35998
35996
  }
35999
35997
  function getDMSFromDecimal(dd, latitudeOrLongitude) {
36000
35998
  const hemisphere = getHemisphere(dd, latitudeOrLongitude);
36001
- const absDD = Math.abs(dd);
36002
- const degrees = truncate(absDD);
36003
- const minutes = truncate((absDD - degrees) * 60);
36004
- const seconds = (Math.round((((absDD - degrees) * 60 - minutes) * 60 + Number.EPSILON) * 100) / 100).toFixed(0);
35999
+ // Get the decimal degrees as an absolute value
36000
+ const absoluteDecimalDegrees = Math.abs(dd);
36001
+ const degrees = truncate(absoluteDecimalDegrees);
36002
+ const [minutesInteger, minutesDecimal] = getMinutes(absoluteDecimalDegrees, degrees);
36003
+ // Get the seconds by multiplying the decimal part by 60
36004
+ const seconds = (Number(minutesDecimal) * 1e-3 * 60).toFixed(0);
36005
36005
  const formattedDegrees = getPaddedDegrees(degrees, latitudeOrLongitude);
36006
- const formattedMinutes = minutes.toString().padStart(2, '0');
36006
+ const formattedMinutes = minutesInteger.padStart(2, '0');
36007
36007
  const formattedSeconds = seconds.toString().padStart(2, '0');
36008
36008
  return `${formattedDegrees}° ${formattedMinutes}′ ${formattedSeconds}″${hemisphere ? ` ${hemisphere}` : ''}`;
36009
36009
  }
36010
+ /**
36011
+ * Get the minutes
36012
+ * @return - the minutes as an array of [minutesInteger, minuteDecimals]
36013
+ */
36014
+ const getMinutes = (absoluteDecimalDegrees, degrees) => {
36015
+ // Get the minutes by multiplying the decimal part by 60
36016
+ let minutes = Number((absoluteDecimalDegrees - degrees) * 60).toFixed(3);
36017
+ if (minutes.split('.').length < 1) {
36018
+ minutes += '.000';
36019
+ }
36020
+ const [minutesInteger, minuteDecimals] = minutes.split('.');
36021
+ if (!minutesInteger || !minuteDecimals) {
36022
+ throw new Error('`minutesInteger` or `minuteDecimals` are undefined.');
36023
+ }
36024
+ return [minutesInteger, minuteDecimals];
36025
+ };
36010
36026
  const getHemisphere = (dd, latitudeOrLongitude) => {
36011
36027
  if (dd === 0) {
36012
36028
  return '';
@@ -36034,6 +36050,12 @@ const getPaddedDegrees = (degrees, latitudeOrLongitude) => {
36034
36050
  return '';
36035
36051
  }
36036
36052
  };
36053
+ /**
36054
+ * If n > 0
36055
+ * - Get the largest integer less than or equal to n
36056
+ * - Else, rounds n to the next largest integer.
36057
+ * @param n - number
36058
+ */
36037
36059
  function truncate(n) {
36038
36060
  return n > 0 ? Math.floor(n) : Math.ceil(n);
36039
36061
  }
@@ -36637,11 +36659,15 @@ function getOptionsFromIdAndName(collection) {
36637
36659
  }));
36638
36660
  }
36639
36661
 
36640
- function getOptionsFromLabelledEnum(labelledEnum) {
36641
- return fp.sortBy(['label'], Object.entries(labelledEnum).map(([value, label]) => ({
36662
+ function getOptionsFromLabelledEnum(labelledEnum, mustSort = false) {
36663
+ const formattedOptions = Object.entries(labelledEnum).map(([value, label]) => ({
36642
36664
  label,
36643
36665
  value
36644
- })));
36666
+ }));
36667
+ if (mustSort) {
36668
+ return fp.sortBy(['label'], formattedOptions);
36669
+ }
36670
+ return formattedOptions;
36645
36671
  }
36646
36672
 
36647
36673
  function isArray(value) {
@@ -36709,6 +36735,16 @@ function nullify(value) {
36709
36735
  return value;
36710
36736
  }
36711
36737
 
36738
+ /**
36739
+ * Pluralize a given lowercase string.
36740
+ */
36741
+ function pluralize(text, count) {
36742
+ if (!text.trim().length) {
36743
+ return '';
36744
+ }
36745
+ return text + (count > 1 ? 's' : '');
36746
+ }
36747
+
36712
36748
  /* eslint-disable no-null/no-null */
36713
36749
  const undefineArrayValues = (list) => list.map(undefine);
36714
36750
  const undefineObjectProps = (record) => pipe$1(toPairs$1, map$1(undefineObjectPropPair), fromPairs$1)(record);
@@ -36735,5 +36771,5 @@ function undefine(value) {
36735
36771
  return value;
36736
36772
  }
36737
36773
 
36738
- export { Accent, Button$1 as Button, Checkbox, CoordinatesFormat, CoordinatesInput, CustomSearch, DatePicker, DateRangePicker, Dialog, Dropdown, Field$2 as Field, FieldError, Fieldset, FormikCheckbox, FormikCoordinatesInput, FormikDatePicker, FormikDateRangePicker, FormikEffect, FormikMultiCheckbox, FormikMultiRadio, FormikMultiSelect, FormikNumberInput, FormikSearch, FormikSelect, FormikTextInput, FormikTextarea, GlobalStyle, index as Icon, IconButton, Label, Legend, MapMenuDialog, MultiCheckbox, MultiRadio, MultiSelect, MultiZoneEditor, NewWindow, NewWindowContext, NotificationEvent, Notifier, NumberInput, OPENLAYERS_PROJECTION, OnlyFontGlobalStyle, Search, Select, SideMenu, SimpleTable, SingleTag, Size, THEME, TableWithSelectableRows, Tag, TagBullet, TagGroup, TextInput, Textarea, ThemeProvider, WSG84_PROJECTION, coordinatesAreDistinct, customDayjs, getCoordinates, getLocalizedDayjs, getOptionsFromIdAndName, getOptionsFromLabelledEnum, getPseudoRandomString, getUtcizedDayjs, isArray, isDefined, isNumeric, isObject, logSoftError, nullify, stopMouseEventPropagation, undefine, useClickOutsideEffect, useFieldControl, useForceUpdate, useKey, useNewWindow, usePrevious };
36774
+ export { Accent, Button$1 as Button, Checkbox, CoordinatesFormat, CoordinatesInput, CustomSearch, DatePicker, DateRangePicker, Dialog, Dropdown, Field$2 as Field, FieldError, Fieldset, FormikCheckbox, FormikCoordinatesInput, FormikDatePicker, FormikDateRangePicker, FormikEffect, FormikMultiCheckbox, FormikMultiRadio, FormikMultiSelect, FormikNumberInput, FormikSearch, FormikSelect, FormikTextInput, FormikTextarea, GlobalStyle, index as Icon, IconButton, Label, Legend, MapMenuDialog, MultiCheckbox, MultiRadio, MultiSelect, MultiZoneEditor, NewWindow, NewWindowContext, NotificationEvent, Notifier, NumberInput, OPENLAYERS_PROJECTION, OnlyFontGlobalStyle, Search, Select, SideMenu, SimpleTable, SingleTag, Size, THEME, TableWithSelectableRows, Tag, TagBullet, TagGroup, TextInput, Textarea, ThemeProvider, WSG84_PROJECTION, cleanString, coordinatesAreDistinct, customDayjs, getCoordinates, getLocalizedDayjs, getOptionsFromIdAndName, getOptionsFromLabelledEnum, getPseudoRandomString, getUtcizedDayjs, isArray, isDefined, isNumeric, isObject, logSoftError, normalizeString, nullify, pluralize, stopMouseEventPropagation, undefine, useClickOutsideEffect, useFieldControl, useForceUpdate, useKey, useNewWindow, usePrevious };
36739
36775
  //# sourceMappingURL=index.js.map