@synerise/ds-format-picker 0.6.2 → 0.6.3

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
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [0.6.3](https://github.com/Synerise/synerise-design/compare/@synerise/ds-format-picker@0.6.2...@synerise/ds-format-picker@0.6.3) (2024-11-28)
7
+
8
+ **Note:** Version bump only for package @synerise/ds-format-picker
9
+
10
+
11
+
12
+
13
+
6
14
  ## [0.6.2](https://github.com/Synerise/synerise-design/compare/@synerise/ds-format-picker@0.6.1...@synerise/ds-format-picker@0.6.2) (2024-11-21)
7
15
 
8
16
 
@@ -1,13 +1,8 @@
1
1
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
-
3
2
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
-
5
3
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
-
7
4
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
8
-
9
5
  function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
10
-
11
6
  import React, { useCallback, useEffect, useMemo } from 'react';
12
7
  import { useIntl } from 'react-intl';
13
8
  import Button from '@synerise/ds-button';
@@ -15,28 +10,25 @@ import Dropdown from '@synerise/ds-dropdown';
15
10
  import Icon, { HashM } from '@synerise/ds-icon';
16
11
  import { useDataFormat } from '@synerise/ds-data-format';
17
12
  import FormatSettings from './FormatSettings/FormatSettings';
18
-
19
13
  var FormatPicker = function FormatPicker(_ref) {
20
14
  var onUseSeparatorChange = _ref.onUseSeparatorChange,
21
- onFixedLengthChange = _ref.onFixedLengthChange,
22
- onDataFormatChange = _ref.onDataFormatChange,
23
- onCurrencyChange = _ref.onCurrencyChange,
24
- onCompactNumbersChange = _ref.onCompactNumbersChange,
25
- onSetDefault = _ref.onSetDefault,
26
- onFormattedValueChange = _ref.onFormattedValueChange,
27
- value = _ref.value,
28
- format = _ref.format,
29
- text = _ref.text,
30
- currenciesConfig = _ref.currenciesConfig,
31
- _ref$buttonType = _ref.buttonType,
32
- buttonType = _ref$buttonType === void 0 ? 'tertiary' : _ref$buttonType,
33
- disabled = _ref.disabled,
34
- maxFixedLength = _ref.maxFixedLength;
15
+ onFixedLengthChange = _ref.onFixedLengthChange,
16
+ onDataFormatChange = _ref.onDataFormatChange,
17
+ onCurrencyChange = _ref.onCurrencyChange,
18
+ onCompactNumbersChange = _ref.onCompactNumbersChange,
19
+ onSetDefault = _ref.onSetDefault,
20
+ onFormattedValueChange = _ref.onFormattedValueChange,
21
+ value = _ref.value,
22
+ format = _ref.format,
23
+ text = _ref.text,
24
+ currenciesConfig = _ref.currenciesConfig,
25
+ _ref$buttonType = _ref.buttonType,
26
+ buttonType = _ref$buttonType === void 0 ? 'tertiary' : _ref$buttonType,
27
+ disabled = _ref.disabled,
28
+ maxFixedLength = _ref.maxFixedLength;
35
29
  var intl = useIntl();
36
-
37
30
  var _useDataFormat = useDataFormat(),
38
- formatValue = _useDataFormat.formatValue;
39
-
31
+ formatValue = _useDataFormat.formatValue;
40
32
  var texts = useMemo(function () {
41
33
  return _objectSpread({
42
34
  header: intl.formatMessage({
@@ -79,40 +71,35 @@ var FormatPicker = function FormatPicker(_ref) {
79
71
  }, [text, intl]);
80
72
  var getFormattedValue = useCallback(function (overrideOptions) {
81
73
  var useSeparator = format.useSeparator,
82
- compactNumbers = format.compactNumbers,
83
- currency = format.currency,
84
- dataFormat = format.dataFormat,
85
- fixedLength = format.fixedLength;
74
+ compactNumbers = format.compactNumbers,
75
+ currency = format.currency,
76
+ dataFormat = format.dataFormat,
77
+ fixedLength = format.fixedLength;
86
78
  var options = {
87
79
  useGrouping: useSeparator
88
80
  };
89
-
90
81
  if (compactNumbers) {
91
82
  options = {
92
83
  notation: 'compact'
93
84
  };
94
85
  }
95
-
96
86
  if (dataFormat === 'cash' && currency) {
97
87
  options = _objectSpread({}, options, {
98
88
  currency: currency,
99
89
  style: 'currency'
100
90
  });
101
91
  }
102
-
103
92
  if (dataFormat === 'percent') {
104
93
  options = _objectSpread({}, options, {
105
94
  suffix: compactNumbers ? ' %' : '%'
106
95
  });
107
96
  }
108
-
109
97
  if (typeof fixedLength === 'number') {
110
98
  options = _objectSpread({}, options, {
111
99
  minimumFractionDigits: fixedLength,
112
100
  maximumFractionDigits: fixedLength
113
101
  }, overrideOptions);
114
102
  }
115
-
116
103
  return formatValue(value, options);
117
104
  }, [value, format, formatValue]);
118
105
  useEffect(function () {
@@ -144,5 +131,4 @@ var FormatPicker = function FormatPicker(_ref) {
144
131
  component: /*#__PURE__*/React.createElement(HashM, null)
145
132
  }), texts.format + " " + getFormattedValue()));
146
133
  };
147
-
148
134
  export default FormatPicker;
@@ -22,7 +22,6 @@ var DEFAULT_CURRENCIES_CONFIG = [{
22
22
  currency: 'JPY',
23
23
  label: 'Yen (JP)'
24
24
  }];
25
-
26
25
  var getFormattingTypes = function getFormattingTypes(intl, text) {
27
26
  return [{
28
27
  format: 'numeric',
@@ -38,21 +37,20 @@ var getFormattingTypes = function getFormattingTypes(intl, text) {
38
37
  tooltip: text.cash
39
38
  }];
40
39
  };
41
-
42
40
  var FormatSettings = function FormatSettings(_ref) {
43
41
  var onCompactNumbersChange = _ref.onCompactNumbersChange,
44
- onCurrencyChange = _ref.onCurrencyChange,
45
- onDataFormatChange = _ref.onDataFormatChange,
46
- onFixedLengthChange = _ref.onFixedLengthChange,
47
- onUseSeparatorChange = _ref.onUseSeparatorChange,
48
- onSetDefault = _ref.onSetDefault,
49
- getFormattedValue = _ref.getFormattedValue,
50
- format = _ref.format,
51
- text = _ref.text,
52
- _ref$currenciesConfig = _ref.currenciesConfig,
53
- currenciesConfig = _ref$currenciesConfig === void 0 ? DEFAULT_CURRENCIES_CONFIG : _ref$currenciesConfig,
54
- disabled = _ref.disabled,
55
- maxFixedLength = _ref.maxFixedLength;
42
+ onCurrencyChange = _ref.onCurrencyChange,
43
+ onDataFormatChange = _ref.onDataFormatChange,
44
+ onFixedLengthChange = _ref.onFixedLengthChange,
45
+ onUseSeparatorChange = _ref.onUseSeparatorChange,
46
+ onSetDefault = _ref.onSetDefault,
47
+ getFormattedValue = _ref.getFormattedValue,
48
+ format = _ref.format,
49
+ text = _ref.text,
50
+ _ref$currenciesConfig = _ref.currenciesConfig,
51
+ currenciesConfig = _ref$currenciesConfig === void 0 ? DEFAULT_CURRENCIES_CONFIG : _ref$currenciesConfig,
52
+ disabled = _ref.disabled,
53
+ maxFixedLength = _ref.maxFixedLength;
56
54
  var intl = useIntl();
57
55
  var handleDecreaseFixedLength = useCallback(function () {
58
56
  if (format.fixedLength > 0) {
@@ -117,7 +115,7 @@ var FormatSettings = function FormatSettings(_ref) {
117
115
  disabled: disabled,
118
116
  overlay: /*#__PURE__*/React.createElement(S.DropdownWrapper, null, currenciesConfig.map(function (_ref2) {
119
117
  var currency = _ref2.currency,
120
- label = _ref2.label;
118
+ label = _ref2.label;
121
119
  return /*#__PURE__*/React.createElement(S.ListItem, {
122
120
  key: currency,
123
121
  suffixel: text.currencyMenuItemPrefix + " " + getFormattedValue({
@@ -150,5 +148,4 @@ var FormatSettings = function FormatSettings(_ref) {
150
148
  disabled: disabled
151
149
  }, text.setDefault)));
152
150
  };
153
-
154
151
  export default FormatSettings;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-format-picker",
3
- "version": "0.6.2",
3
+ "version": "0.6.3",
4
4
  "description": "FormatPicker UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "Synerise/synerise-design",
@@ -34,16 +34,16 @@
34
34
  ],
35
35
  "types": "dist/index.d.ts",
36
36
  "dependencies": {
37
- "@synerise/ds-button": "^0.21.19",
38
- "@synerise/ds-button-group": "^0.7.23",
39
- "@synerise/ds-checkbox": "^0.12.17",
37
+ "@synerise/ds-button": "^0.21.20",
38
+ "@synerise/ds-button-group": "^0.7.24",
39
+ "@synerise/ds-checkbox": "^0.12.18",
40
40
  "@synerise/ds-data-format": "^0.6.1",
41
- "@synerise/ds-dropdown": "^0.18.24",
42
- "@synerise/ds-icon": "^0.67.0",
43
- "@synerise/ds-list-item": "^0.4.19",
44
- "@synerise/ds-radio": "^0.12.13",
45
- "@synerise/ds-tooltip": "^0.14.49",
46
- "@synerise/ds-typography": "^0.16.6",
41
+ "@synerise/ds-dropdown": "^0.18.25",
42
+ "@synerise/ds-icon": "^0.67.1",
43
+ "@synerise/ds-list-item": "^0.5.0",
44
+ "@synerise/ds-radio": "^0.12.14",
45
+ "@synerise/ds-tooltip": "^0.14.50",
46
+ "@synerise/ds-typography": "^0.16.7",
47
47
  "@synerise/ds-utils": "^0.31.2"
48
48
  },
49
49
  "peerDependencies": {
@@ -52,5 +52,5 @@
52
52
  "react-intl": ">=3.12.0 <= 6.8",
53
53
  "styled-components": "5.0.1"
54
54
  },
55
- "gitHead": "05f083c767e2cec3c2f91c9475aee89852a77d6c"
55
+ "gitHead": "4a56ee7ef816c22341ce704154dc7aa65b7d1dcc"
56
56
  }