@elliemae/ds-zoom 2.0.0-alpha.1 → 2.0.0-alpha.13
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/cjs/DSZoom.js +21 -13
- package/cjs/components/utils.js +1 -1
- package/cjs/index.js +1 -1
- package/esm/DSZoom.js +17 -8
- package/esm/components/utils.js +1 -1
- package/package.json +8 -5
- package/types/DSZoom.d.ts +55 -7
- package/cjs/package.json +0 -7
- package/esm/package.json +0 -7
package/cjs/DSZoom.js
CHANGED
|
@@ -5,10 +5,18 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
6
6
|
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
7
7
|
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
|
8
|
+
require('core-js/modules/esnext.async-iterator.find.js');
|
|
9
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
10
|
+
require('core-js/modules/esnext.iterator.find.js');
|
|
11
|
+
require('core-js/modules/web.dom-collections.iterator.js');
|
|
12
|
+
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
13
|
+
require('core-js/modules/esnext.iterator.filter.js');
|
|
14
|
+
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
15
|
+
require('core-js/modules/esnext.iterator.for-each.js');
|
|
8
16
|
var react = require('react');
|
|
9
17
|
var reactDesc = require('react-desc');
|
|
10
18
|
var dsClassnames = require('@elliemae/ds-classnames');
|
|
11
|
-
var
|
|
19
|
+
var dsForm = require('@elliemae/ds-form');
|
|
12
20
|
var zoomOptions = require('./components/zoomOptions.js');
|
|
13
21
|
var utils = require('./components/utils.js');
|
|
14
22
|
var jsxRuntime = require('react/jsx-runtime');
|
|
@@ -18,13 +26,12 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
18
26
|
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
19
27
|
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
20
28
|
var _objectWithoutProperties__default = /*#__PURE__*/_interopDefaultLegacy(_objectWithoutProperties);
|
|
21
|
-
var DSComboBox__default = /*#__PURE__*/_interopDefaultLegacy(DSComboBox);
|
|
22
29
|
|
|
23
30
|
const _excluded = ["className", "disabled", "value", "onChange", "containerProps", "zoomOptions"];
|
|
24
31
|
|
|
25
32
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
26
33
|
|
|
27
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty__default[
|
|
34
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
28
35
|
|
|
29
36
|
const DSZoom = _ref => {
|
|
30
37
|
let {
|
|
@@ -35,7 +42,7 @@ const DSZoom = _ref => {
|
|
|
35
42
|
containerProps = {},
|
|
36
43
|
zoomOptions: zoomOptions$1 = zoomOptions
|
|
37
44
|
} = _ref,
|
|
38
|
-
otherProps = _objectWithoutProperties__default[
|
|
45
|
+
otherProps = _objectWithoutProperties__default["default"](_ref, _excluded);
|
|
39
46
|
|
|
40
47
|
const {
|
|
41
48
|
cssClassName
|
|
@@ -46,22 +53,23 @@ const DSZoom = _ref => {
|
|
|
46
53
|
const [menuIsOpen, setMenuIsOpen] = react.useState(false);
|
|
47
54
|
const [selectedOption, setSelectedOption] = react.useState(defaultOption);
|
|
48
55
|
const [custom, setCustom] = react.useState(!value ? defaultOption : {
|
|
49
|
-
label:
|
|
56
|
+
label: "".concat(utils.clean(value), "%"),
|
|
50
57
|
value: utils.clean(value),
|
|
51
58
|
id: 'custom'
|
|
52
59
|
});
|
|
53
60
|
const options = [custom, ...zoomOptions$1.filter(option => !option.default)];
|
|
54
61
|
const currentValue = value || (selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.value) || (custom === null || custom === void 0 ? void 0 : custom.value) || (defaultOption === null || defaultOption === void 0 ? void 0 : defaultOption.value);
|
|
55
62
|
return /*#__PURE__*/jsxRuntime.jsx("div", _objectSpread(_objectSpread(_objectSpread({
|
|
56
|
-
className:
|
|
63
|
+
className: "".concat(cssClassName)
|
|
57
64
|
}, containerProps), otherProps), {}, {
|
|
58
|
-
children: /*#__PURE__*/_jsx__default[
|
|
65
|
+
children: /*#__PURE__*/_jsx__default["default"](dsForm.DSComboBox, {
|
|
59
66
|
searchable: true,
|
|
60
67
|
disabled: disabled,
|
|
61
68
|
menuIsOpen: menuIsOpen,
|
|
62
|
-
onChange: (valueChange, {
|
|
63
|
-
|
|
64
|
-
|
|
69
|
+
onChange: (valueChange, _ref2) => {
|
|
70
|
+
let {
|
|
71
|
+
action
|
|
72
|
+
} = _ref2;
|
|
65
73
|
const op = options.find(option => option.value === valueChange);
|
|
66
74
|
setSelectedOption(op);
|
|
67
75
|
onChange(op);
|
|
@@ -80,8 +88,8 @@ const DSZoom = _ref => {
|
|
|
80
88
|
} else if (!Number.isNaN(parseInt(valueInput, 10))) {
|
|
81
89
|
const cleanValue = parseInt(valueInput, 10);
|
|
82
90
|
const newOption = {
|
|
83
|
-
label:
|
|
84
|
-
value:
|
|
91
|
+
label: "".concat(cleanValue, "%"),
|
|
92
|
+
value: "".concat(cleanValue, "%"),
|
|
85
93
|
id: 'custom'
|
|
86
94
|
};
|
|
87
95
|
setCustom(newOption);
|
|
@@ -114,4 +122,4 @@ ZoomWithSchema.propTypes = zoomProps;
|
|
|
114
122
|
|
|
115
123
|
exports.DSZoom = DSZoom;
|
|
116
124
|
exports.ZoomWithSchema = ZoomWithSchema;
|
|
117
|
-
exports[
|
|
125
|
+
exports["default"] = DSZoom;
|
package/cjs/components/utils.js
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
require('core-js/modules/es.string.replace.js');
|
|
6
6
|
|
|
7
7
|
const getCurrentFont = () => Number(window.getComputedStyle(document.querySelector(':root')).getPropertyValue('font-size').match(/\d+/)[0]);
|
|
8
|
-
const setSize = size => document.querySelector(':root').setAttribute('style',
|
|
8
|
+
const setSize = size => document.querySelector(':root').setAttribute('style', "font-size: ".concat(size, "px"));
|
|
9
9
|
const getFactor = value => value / 100;
|
|
10
10
|
const clean = value => value.replace(/\D/g, '').substring(0, 3);
|
|
11
11
|
|
package/cjs/index.js
CHANGED
package/esm/DSZoom.js
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
2
2
|
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
3
3
|
import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
|
|
4
|
+
import 'core-js/modules/esnext.async-iterator.find.js';
|
|
5
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
6
|
+
import 'core-js/modules/esnext.iterator.find.js';
|
|
7
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
8
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
9
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
10
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
11
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
4
12
|
import { useState } from 'react';
|
|
5
13
|
import { PropTypes, describe } from 'react-desc';
|
|
6
14
|
import { convertPropToCssClassName } from '@elliemae/ds-classnames';
|
|
7
|
-
import DSComboBox from '@elliemae/ds-form
|
|
15
|
+
import { DSComboBox } from '@elliemae/ds-form';
|
|
8
16
|
import zoomDefaultOptions from './components/zoomOptions.js';
|
|
9
17
|
import { clean } from './components/utils.js';
|
|
10
18
|
import { jsx } from 'react/jsx-runtime';
|
|
@@ -35,22 +43,23 @@ const DSZoom = _ref => {
|
|
|
35
43
|
const [menuIsOpen, setMenuIsOpen] = useState(false);
|
|
36
44
|
const [selectedOption, setSelectedOption] = useState(defaultOption);
|
|
37
45
|
const [custom, setCustom] = useState(!value ? defaultOption : {
|
|
38
|
-
label:
|
|
46
|
+
label: "".concat(clean(value), "%"),
|
|
39
47
|
value: clean(value),
|
|
40
48
|
id: 'custom'
|
|
41
49
|
});
|
|
42
50
|
const options = [custom, ...zoomOptions.filter(option => !option.default)];
|
|
43
51
|
const currentValue = value || (selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.value) || (custom === null || custom === void 0 ? void 0 : custom.value) || (defaultOption === null || defaultOption === void 0 ? void 0 : defaultOption.value);
|
|
44
52
|
return /*#__PURE__*/jsx("div", _objectSpread(_objectSpread(_objectSpread({
|
|
45
|
-
className:
|
|
53
|
+
className: "".concat(cssClassName)
|
|
46
54
|
}, containerProps), otherProps), {}, {
|
|
47
55
|
children: /*#__PURE__*/_jsx(DSComboBox, {
|
|
48
56
|
searchable: true,
|
|
49
57
|
disabled: disabled,
|
|
50
58
|
menuIsOpen: menuIsOpen,
|
|
51
|
-
onChange: (valueChange, {
|
|
52
|
-
|
|
53
|
-
|
|
59
|
+
onChange: (valueChange, _ref2) => {
|
|
60
|
+
let {
|
|
61
|
+
action
|
|
62
|
+
} = _ref2;
|
|
54
63
|
const op = options.find(option => option.value === valueChange);
|
|
55
64
|
setSelectedOption(op);
|
|
56
65
|
onChange(op);
|
|
@@ -69,8 +78,8 @@ const DSZoom = _ref => {
|
|
|
69
78
|
} else if (!Number.isNaN(parseInt(valueInput, 10))) {
|
|
70
79
|
const cleanValue = parseInt(valueInput, 10);
|
|
71
80
|
const newOption = {
|
|
72
|
-
label:
|
|
73
|
-
value:
|
|
81
|
+
label: "".concat(cleanValue, "%"),
|
|
82
|
+
value: "".concat(cleanValue, "%"),
|
|
74
83
|
id: 'custom'
|
|
75
84
|
};
|
|
76
85
|
setCustom(newOption);
|
package/esm/components/utils.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import 'core-js/modules/es.string.replace.js';
|
|
2
2
|
|
|
3
3
|
const getCurrentFont = () => Number(window.getComputedStyle(document.querySelector(':root')).getPropertyValue('font-size').match(/\d+/)[0]);
|
|
4
|
-
const setSize = size => document.querySelector(':root').setAttribute('style',
|
|
4
|
+
const setSize = size => document.querySelector(':root').setAttribute('style', "font-size: ".concat(size, "px"));
|
|
5
5
|
const getFactor = value => value / 100;
|
|
6
6
|
const clean = value => value.replace(/\D/g, '').substring(0, 3);
|
|
7
7
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-zoom",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.13",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Zoom",
|
|
6
6
|
"module": "./esm/index.js",
|
|
@@ -44,10 +44,13 @@
|
|
|
44
44
|
"build": "node ../../scripts/build/build.js"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@elliemae/ds-classnames": "2.0.0-alpha.
|
|
48
|
-
"@elliemae/ds-
|
|
49
|
-
"
|
|
50
|
-
|
|
47
|
+
"@elliemae/ds-classnames": "2.0.0-alpha.13",
|
|
48
|
+
"@elliemae/ds-form": "2.0.0-alpha.13",
|
|
49
|
+
"react-desc": "~4.1.3"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@testing-library/jest-dom": "~5.15.0",
|
|
53
|
+
"@testing-library/react": "~12.1.2"
|
|
51
54
|
},
|
|
52
55
|
"peerDependencies": {
|
|
53
56
|
"react": "^17.0.2",
|
package/types/DSZoom.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference path="../../../../shared/typings/react-desc.d.ts" />
|
|
1
2
|
/// <reference types="react" />
|
|
2
3
|
declare const DSZoom: {
|
|
3
4
|
({ className, disabled, value, onChange, containerProps, zoomOptions, ...otherProps }: {
|
|
@@ -18,14 +19,61 @@ declare const DSZoom: {
|
|
|
18
19
|
})[] | undefined;
|
|
19
20
|
}): JSX.Element;
|
|
20
21
|
propTypes: {
|
|
21
|
-
className:
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
className: {
|
|
23
|
+
defaultValue<T = unknown>(arg: T): {
|
|
24
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
25
|
+
};
|
|
26
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
27
|
+
};
|
|
28
|
+
containerProps: {
|
|
29
|
+
defaultValue<T = unknown>(arg: T): {
|
|
30
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
31
|
+
};
|
|
32
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
33
|
+
};
|
|
34
|
+
disabled: {
|
|
35
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
36
|
+
};
|
|
37
|
+
value: {
|
|
38
|
+
defaultValue<T = unknown>(arg: T): {
|
|
39
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
40
|
+
};
|
|
41
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
42
|
+
};
|
|
43
|
+
onChange: {
|
|
44
|
+
defaultValue<T = unknown>(arg: T): {
|
|
45
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
46
|
+
};
|
|
47
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
48
|
+
};
|
|
49
|
+
zoomOptions: {
|
|
50
|
+
defaultValue<T = unknown>(arg: T): {
|
|
51
|
+
deprecated: import("react-desc").PropTypesDescValidator;
|
|
52
|
+
};
|
|
53
|
+
isRequired: import("react-desc").PropTypesDescValidator;
|
|
54
|
+
};
|
|
27
55
|
};
|
|
28
56
|
};
|
|
29
|
-
declare const ZoomWithSchema:
|
|
57
|
+
declare const ZoomWithSchema: {
|
|
58
|
+
(props?: {
|
|
59
|
+
[x: string]: any;
|
|
60
|
+
className?: string | undefined;
|
|
61
|
+
disabled?: boolean | undefined;
|
|
62
|
+
value?: undefined;
|
|
63
|
+
onChange?: (() => null) | undefined;
|
|
64
|
+
containerProps?: {} | undefined;
|
|
65
|
+
zoomOptions?: ({
|
|
66
|
+
label: string;
|
|
67
|
+
value: string;
|
|
68
|
+
default?: undefined;
|
|
69
|
+
} | {
|
|
70
|
+
label: string;
|
|
71
|
+
value: string;
|
|
72
|
+
default: boolean;
|
|
73
|
+
})[] | undefined;
|
|
74
|
+
} | undefined): JSX.Element;
|
|
75
|
+
propTypes: unknown;
|
|
76
|
+
toTypescript: () => import("react-desc").TypescriptSchema;
|
|
77
|
+
};
|
|
30
78
|
export { DSZoom, ZoomWithSchema };
|
|
31
79
|
export default DSZoom;
|
package/cjs/package.json
DELETED