@elliemae/ds-zoom 3.4.2 → 3.4.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/dist/cjs/DSZoom.js +50 -43
- package/dist/cjs/DSZoom.js.map +2 -2
- package/dist/cjs/components/utils.js +7 -2
- package/dist/cjs/components/utils.js.map +1 -1
- package/dist/cjs/components/zoomOptions.js +4 -1
- package/dist/cjs/components/zoomOptions.js.map +1 -1
- package/dist/cjs/index.js +4 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/DSZoom.js +46 -42
- package/dist/esm/DSZoom.js.map +1 -1
- package/dist/esm/components/utils.js +3 -1
- package/dist/esm/components/utils.js.map +1 -1
- package/dist/esm/components/zoomOptions.js.map +1 -1
- package/dist/esm/index.js.map +2 -2
- package/package.json +4 -4
package/dist/cjs/DSZoom.js
CHANGED
|
@@ -17,7 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
}
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
21
24
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
25
|
var DSZoom_exports = {};
|
|
23
26
|
__export(DSZoom_exports, {
|
|
@@ -27,7 +30,8 @@ __export(DSZoom_exports, {
|
|
|
27
30
|
});
|
|
28
31
|
module.exports = __toCommonJS(DSZoom_exports);
|
|
29
32
|
var React = __toESM(require("react"));
|
|
30
|
-
var
|
|
33
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
34
|
+
var import_react = require("react");
|
|
31
35
|
var import_ds_utilities = require("@elliemae/ds-utilities");
|
|
32
36
|
var import_ds_classnames = require("@elliemae/ds-classnames");
|
|
33
37
|
var import_ds_form = require("@elliemae/ds-form");
|
|
@@ -48,52 +52,55 @@ const DSZoom = ({
|
|
|
48
52
|
const defaultOption = zoomOptions.find((option) => option.default);
|
|
49
53
|
const [menuIsOpen, setMenuIsOpen] = (0, import_react.useState)(false);
|
|
50
54
|
const [selectedOption, setSelectedOption] = (0, import_react.useState)(defaultOption);
|
|
51
|
-
const [custom, setCustom] = (0, import_react.useState)(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
const [custom, setCustom] = (0, import_react.useState)(
|
|
56
|
+
!value ? defaultOption : {
|
|
57
|
+
label: `${(0, import_utils.clean)(value)}%`,
|
|
58
|
+
value: (0, import_utils.clean)(value),
|
|
59
|
+
id: "custom"
|
|
60
|
+
}
|
|
61
|
+
);
|
|
56
62
|
const options = [custom, ...zoomOptions.filter((option) => !option.default)];
|
|
57
63
|
const currentValue = value || selectedOption?.value || custom?.value || defaultOption?.value;
|
|
58
|
-
return /* @__PURE__ */
|
|
64
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
59
65
|
className: `${cssClassName}`,
|
|
60
66
|
...containerProps,
|
|
61
|
-
...otherProps
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
67
|
+
...otherProps,
|
|
68
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ds_form.DSComboBox, {
|
|
69
|
+
searchable: true,
|
|
70
|
+
disabled,
|
|
71
|
+
menuIsOpen,
|
|
72
|
+
onChange: (valueChange, { action }) => {
|
|
73
|
+
const op = options.find((option) => option.value === valueChange);
|
|
74
|
+
setSelectedOption(op);
|
|
75
|
+
onChange(op);
|
|
76
|
+
setMenuIsOpen(false);
|
|
77
|
+
if (action === "select-option") {
|
|
78
|
+
document.activeElement.blur();
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
onClickDropdownIndicator: () => setMenuIsOpen(!menuIsOpen),
|
|
82
|
+
onInputChange: (valueInput, action) => {
|
|
83
|
+
if (valueInput || action.action === "input-change") {
|
|
84
|
+
if (!valueInput) {
|
|
85
|
+
setCustom(defaultOption);
|
|
86
|
+
onChange(defaultOption);
|
|
87
|
+
} else if (!Number.isNaN(parseInt(valueInput, 10))) {
|
|
88
|
+
const cleanValue = parseInt(valueInput, 10);
|
|
89
|
+
const newOption = {
|
|
90
|
+
label: `${cleanValue}%`,
|
|
91
|
+
value: `${cleanValue}%`,
|
|
92
|
+
id: "custom"
|
|
93
|
+
};
|
|
94
|
+
setCustom(newOption);
|
|
95
|
+
onChange(newOption);
|
|
96
|
+
}
|
|
90
97
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
})
|
|
98
|
+
setMenuIsOpen(false);
|
|
99
|
+
},
|
|
100
|
+
options,
|
|
101
|
+
value: currentValue
|
|
102
|
+
})
|
|
103
|
+
});
|
|
97
104
|
};
|
|
98
105
|
const zoomProps = {
|
|
99
106
|
className: import_ds_utilities.PropTypes.string.description("html class attribute"),
|
package/dist/cjs/DSZoom.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/DSZoom.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
4
|
"sourcesContent": ["/* eslint-disable indent */\nimport React, { useState } from 'react';\nimport { describe, PropTypes } from '@elliemae/ds-utilities';\nimport { convertPropToCssClassName } from '@elliemae/ds-classnames';\nimport { DSComboBox } from '@elliemae/ds-form';\nimport zoomDefaultOptions from './components/zoomOptions';\nimport { clean } from './components/utils';\n\nconst DSZoom = ({\n className = '',\n disabled = false,\n value = undefined,\n onChange = () => null,\n containerProps = {},\n zoomOptions = zoomDefaultOptions,\n ...otherProps\n}) => {\n const { cssClassName } = convertPropToCssClassName('zoom-resize', className, {\n disabled,\n });\n const defaultOption = zoomOptions.find((option) => option.default);\n const [menuIsOpen, setMenuIsOpen] = useState(false);\n const [selectedOption, setSelectedOption] = useState(defaultOption);\n const [custom, setCustom] = useState(\n !value\n ? defaultOption\n : {\n label: `${clean(value)}%`,\n value: clean(value),\n id: 'custom',\n },\n );\n const options = [custom, ...zoomOptions.filter((option) => !option.default)];\n\n const currentValue = value || selectedOption?.value || custom?.value || defaultOption?.value;\n\n return (\n <div className={`${cssClassName}`} {...containerProps} {...otherProps}>\n <DSComboBox\n searchable\n disabled={disabled}\n menuIsOpen={menuIsOpen}\n onChange={(valueChange, { action }) => {\n const op = options.find((option) => option.value === valueChange);\n setSelectedOption(op);\n onChange(op);\n setMenuIsOpen(false);\n if (action === 'select-option') {\n document.activeElement.blur();\n }\n }}\n onClickDropdownIndicator={() => setMenuIsOpen(!menuIsOpen)}\n onInputChange={(valueInput, action) => {\n if (valueInput || action.action === 'input-change') {\n if (!valueInput) {\n setCustom(defaultOption);\n onChange(defaultOption);\n } else if (!Number.isNaN(parseInt(valueInput, 10))) {\n const cleanValue = parseInt(valueInput, 10);\n const newOption = {\n label: `${cleanValue}%`,\n value: `${cleanValue}%`,\n id: 'custom',\n };\n setCustom(newOption);\n onChange(newOption);\n }\n }\n setMenuIsOpen(false);\n }}\n options={options}\n value={currentValue}\n />\n </div>\n );\n};\n\nconst zoomProps = {\n className: PropTypes.string.description('html class attribute'),\n containerProps: PropTypes.object.description('Set of Properties attached to the main container'),\n disabled: PropTypes.bool.description('disable component').defaultValue(false),\n value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.object]).description('current value'),\n onChange: PropTypes.func.description('function called when a new value is selected'),\n zoomOptions: PropTypes.shape({\n label: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n default: PropTypes.bool,\n }).description('list of options to display in the select menu'),\n};\n\nDSZoom.propTypes = zoomProps;\nDSZoom.displayName = 'DSZoom';\nconst ZoomWithSchema = describe(DSZoom);\nZoomWithSchema.propTypes = zoomProps;\n\nexport { DSZoom, ZoomWithSchema };\nexport default DSZoom;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": []
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB;AACA,mBAAgC;AAChC,0BAAoC;AACpC,2BAA0C;AAC1C,qBAA2B;AAC3B,yBAA+B;AAC/B,mBAAsB;AAEtB,MAAM,SAAS,CAAC;AAAA,EACd,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,WAAW,MAAM;AAAA,EACjB,iBAAiB,CAAC;AAAA,EAClB,cAAc,mBAAAA;AAAA,KACX;AACL,MAAM;AACJ,QAAM,EAAE,aAAa,QAAI,gDAA0B,eAAe,WAAW;AAAA,IAC3E;AAAA,EACF,CAAC;AACD,QAAM,gBAAgB,YAAY,KAAK,CAAC,WAAW,OAAO,OAAO;AACjE,QAAM,CAAC,YAAY,aAAa,QAAI,uBAAS,KAAK;AAClD,QAAM,CAAC,gBAAgB,iBAAiB,QAAI,uBAAS,aAAa;AAClE,QAAM,CAAC,QAAQ,SAAS,QAAI;AAAA,IAC1B,CAAC,QACG,gBACA;AAAA,MACE,OAAO,OAAG,oBAAM,KAAK;AAAA,MACrB,WAAO,oBAAM,KAAK;AAAA,MAClB,IAAI;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EAAE,aAAa,KAAK;AAAA,EAC5E,OAAO,8BAAU,UAAU,CAAC,8BAAU,QAAQ,8BAAU,QAAQ,8BAAU,MAAM,CAAC,EAAE,YAAY,eAAe;AAAA,EAC9G,UAAU,8BAAU,KAAK,YAAY,8CAA8C;AAAA,EACnF,aAAa,8BAAU,MAAM;AAAA,IAC3B,OAAO,8BAAU,UAAU,CAAC,8BAAU,QAAQ,8BAAU,MAAM,CAAC;AAAA,IAC/D,OAAO,8BAAU,UAAU,CAAC,8BAAU,QAAQ,8BAAU,MAAM,CAAC;AAAA,IAC/D,SAAS,8BAAU;AAAA,EACrB,CAAC,EAAE,YAAY,+CAA+C;AAChE;AAEA,OAAO,YAAY;AACnB,OAAO,cAAc;AACrB,MAAM,qBAAiB,8BAAS,MAAM;AACtC,eAAe,YAAY;AAG3B,IAAO,iBAAQ;",
|
|
6
|
+
"names": ["zoomDefaultOptions"]
|
|
7
7
|
}
|
|
@@ -17,7 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
}
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
21
24
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
25
|
var utils_exports = {};
|
|
23
26
|
__export(utils_exports, {
|
|
@@ -28,7 +31,9 @@ __export(utils_exports, {
|
|
|
28
31
|
});
|
|
29
32
|
module.exports = __toCommonJS(utils_exports);
|
|
30
33
|
var React = __toESM(require("react"));
|
|
31
|
-
const getCurrentFont = () => Number(
|
|
34
|
+
const getCurrentFont = () => Number(
|
|
35
|
+
window.getComputedStyle(document.querySelector(":root")).getPropertyValue("font-size").match(/\d+/)[0]
|
|
36
|
+
);
|
|
32
37
|
const setSize = (size) => document.querySelector(":root").setAttribute("style", `font-size: ${size}px`);
|
|
33
38
|
const getFactor = (value) => value / 100;
|
|
34
39
|
const clean = (value) => value.replace(/\D/g, "").substring(0, 3);
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/utils.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
4
|
"sourcesContent": ["export const getCurrentFont = () =>\n Number(\n window\n .getComputedStyle(document.querySelector(':root'))\n .getPropertyValue('font-size')\n .match(/\\d+/)[0],\n );\nexport const setSize = (size) =>\n document.querySelector(':root').setAttribute('style', `font-size: ${size}px`);\n\nexport const getFactor = (value) => value / 100;\n\nexport const clean = (value) => value.replace(/\\D/g, '').substring(0, 3);\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAhB,MAAM,iBAAiB,MAC5B;AAAA,EACE,OACG,iBAAiB,SAAS,cAAc,OAAO,CAAC,EAChD,iBAAiB,WAAW,EAC5B,MAAM,KAAK,EAAE;AAClB;AACK,MAAM,UAAU,CAAC,SACtB,SAAS,cAAc,OAAO,EAAE,aAAa,SAAS,cAAc,QAAQ;AAEvE,MAAM,YAAY,CAAC,UAAU,QAAQ;AAErC,MAAM,QAAQ,CAAC,UAAU,MAAM,QAAQ,OAAO,EAAE,EAAE,UAAU,GAAG,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -17,7 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
}
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
21
24
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
25
|
var zoomOptions_exports = {};
|
|
23
26
|
__export(zoomOptions_exports, {
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/zoomOptions.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
4
|
"sourcesContent": ["export default [\n {\n label: '25%',\n value: '25',\n },\n {\n label: '50%',\n value: '50',\n },\n {\n label: '75%',\n value: '75',\n },\n {\n label: '100%',\n value: '100',\n default: true,\n },\n {\n label: '125%',\n value: '125',\n },\n {\n label: '150%',\n value: '150',\n },\n {\n label: '175%',\n value: '175',\n },\n {\n label: '200%',\n value: '200',\n },\n];\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,IAAO,sBAAQ;AAAA,EACb;AAAA,IACE,OAAO;AAAA,IACP,OAAO;AAAA,EACT;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,OAAO;AAAA,EACT;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,OAAO;AAAA,EACT;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,OAAO;AAAA,IACP,SAAS;AAAA,EACX;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,OAAO;AAAA,EACT;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,OAAO;AAAA,EACT;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,OAAO;AAAA,EACT;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,OAAO;AAAA,EACT;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -18,7 +18,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
20
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
23
|
+
mod
|
|
24
|
+
));
|
|
22
25
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
26
|
var src_exports = {};
|
|
24
27
|
__export(src_exports, {
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
4
|
"sourcesContent": ["export * from './DSZoom';\nexport { default } from './DSZoom';\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,wBAAc,qBAAd;AACA,oBAAwB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/DSZoom.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from "react";
|
|
3
4
|
import { describe, PropTypes } from "@elliemae/ds-utilities";
|
|
4
5
|
import { convertPropToCssClassName } from "@elliemae/ds-classnames";
|
|
5
6
|
import { DSComboBox } from "@elliemae/ds-form";
|
|
@@ -20,52 +21,55 @@ const DSZoom = ({
|
|
|
20
21
|
const defaultOption = zoomOptions.find((option) => option.default);
|
|
21
22
|
const [menuIsOpen, setMenuIsOpen] = useState(false);
|
|
22
23
|
const [selectedOption, setSelectedOption] = useState(defaultOption);
|
|
23
|
-
const [custom, setCustom] = useState(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
const [custom, setCustom] = useState(
|
|
25
|
+
!value ? defaultOption : {
|
|
26
|
+
label: `${clean(value)}%`,
|
|
27
|
+
value: clean(value),
|
|
28
|
+
id: "custom"
|
|
29
|
+
}
|
|
30
|
+
);
|
|
28
31
|
const options = [custom, ...zoomOptions.filter((option) => !option.default)];
|
|
29
32
|
const currentValue = value || selectedOption?.value || custom?.value || defaultOption?.value;
|
|
30
|
-
return /* @__PURE__ */
|
|
33
|
+
return /* @__PURE__ */ jsx("div", {
|
|
31
34
|
className: `${cssClassName}`,
|
|
32
35
|
...containerProps,
|
|
33
|
-
...otherProps
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
36
|
+
...otherProps,
|
|
37
|
+
children: /* @__PURE__ */ jsx(DSComboBox, {
|
|
38
|
+
searchable: true,
|
|
39
|
+
disabled,
|
|
40
|
+
menuIsOpen,
|
|
41
|
+
onChange: (valueChange, { action }) => {
|
|
42
|
+
const op = options.find((option) => option.value === valueChange);
|
|
43
|
+
setSelectedOption(op);
|
|
44
|
+
onChange(op);
|
|
45
|
+
setMenuIsOpen(false);
|
|
46
|
+
if (action === "select-option") {
|
|
47
|
+
document.activeElement.blur();
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
onClickDropdownIndicator: () => setMenuIsOpen(!menuIsOpen),
|
|
51
|
+
onInputChange: (valueInput, action) => {
|
|
52
|
+
if (valueInput || action.action === "input-change") {
|
|
53
|
+
if (!valueInput) {
|
|
54
|
+
setCustom(defaultOption);
|
|
55
|
+
onChange(defaultOption);
|
|
56
|
+
} else if (!Number.isNaN(parseInt(valueInput, 10))) {
|
|
57
|
+
const cleanValue = parseInt(valueInput, 10);
|
|
58
|
+
const newOption = {
|
|
59
|
+
label: `${cleanValue}%`,
|
|
60
|
+
value: `${cleanValue}%`,
|
|
61
|
+
id: "custom"
|
|
62
|
+
};
|
|
63
|
+
setCustom(newOption);
|
|
64
|
+
onChange(newOption);
|
|
65
|
+
}
|
|
62
66
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
})
|
|
67
|
+
setMenuIsOpen(false);
|
|
68
|
+
},
|
|
69
|
+
options,
|
|
70
|
+
value: currentValue
|
|
71
|
+
})
|
|
72
|
+
});
|
|
69
73
|
};
|
|
70
74
|
const zoomProps = {
|
|
71
75
|
className: PropTypes.string.description("html class attribute"),
|
package/dist/esm/DSZoom.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/DSZoom.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable indent */\nimport React, { useState } from 'react';\nimport { describe, PropTypes } from '@elliemae/ds-utilities';\nimport { convertPropToCssClassName } from '@elliemae/ds-classnames';\nimport { DSComboBox } from '@elliemae/ds-form';\nimport zoomDefaultOptions from './components/zoomOptions';\nimport { clean } from './components/utils';\n\nconst DSZoom = ({\n className = '',\n disabled = false,\n value = undefined,\n onChange = () => null,\n containerProps = {},\n zoomOptions = zoomDefaultOptions,\n ...otherProps\n}) => {\n const { cssClassName } = convertPropToCssClassName('zoom-resize', className, {\n disabled,\n });\n const defaultOption = zoomOptions.find((option) => option.default);\n const [menuIsOpen, setMenuIsOpen] = useState(false);\n const [selectedOption, setSelectedOption] = useState(defaultOption);\n const [custom, setCustom] = useState(\n !value\n ? defaultOption\n : {\n label: `${clean(value)}%`,\n value: clean(value),\n id: 'custom',\n },\n );\n const options = [custom, ...zoomOptions.filter((option) => !option.default)];\n\n const currentValue = value || selectedOption?.value || custom?.value || defaultOption?.value;\n\n return (\n <div className={`${cssClassName}`} {...containerProps} {...otherProps}>\n <DSComboBox\n searchable\n disabled={disabled}\n menuIsOpen={menuIsOpen}\n onChange={(valueChange, { action }) => {\n const op = options.find((option) => option.value === valueChange);\n setSelectedOption(op);\n onChange(op);\n setMenuIsOpen(false);\n if (action === 'select-option') {\n document.activeElement.blur();\n }\n }}\n onClickDropdownIndicator={() => setMenuIsOpen(!menuIsOpen)}\n onInputChange={(valueInput, action) => {\n if (valueInput || action.action === 'input-change') {\n if (!valueInput) {\n setCustom(defaultOption);\n onChange(defaultOption);\n } else if (!Number.isNaN(parseInt(valueInput, 10))) {\n const cleanValue = parseInt(valueInput, 10);\n const newOption = {\n label: `${cleanValue}%`,\n value: `${cleanValue}%`,\n id: 'custom',\n };\n setCustom(newOption);\n onChange(newOption);\n }\n }\n setMenuIsOpen(false);\n }}\n options={options}\n value={currentValue}\n />\n </div>\n );\n};\n\nconst zoomProps = {\n className: PropTypes.string.description('html class attribute'),\n containerProps: PropTypes.object.description('Set of Properties attached to the main container'),\n disabled: PropTypes.bool.description('disable component').defaultValue(false),\n value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.object]).description('current value'),\n onChange: PropTypes.func.description('function called when a new value is selected'),\n zoomOptions: PropTypes.shape({\n label: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n default: PropTypes.bool,\n }).description('list of options to display in the select menu'),\n};\n\nDSZoom.propTypes = zoomProps;\nDSZoom.displayName = 'DSZoom';\nconst ZoomWithSchema = describe(DSZoom);\nZoomWithSchema.propTypes = zoomProps;\n\nexport { DSZoom, ZoomWithSchema };\nexport default DSZoom;\n"],
|
|
5
|
-
"mappings": "AAAA;
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB;AACA,SAAgB,gBAAgB;AAChC,SAAS,UAAU,iBAAiB;AACpC,SAAS,iCAAiC;AAC1C,SAAS,kBAAkB;AAC3B,OAAO,wBAAwB;AAC/B,SAAS,aAAa;AAEtB,MAAM,SAAS,CAAC;AAAA,EACd,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,WAAW,MAAM;AAAA,EACjB,iBAAiB,CAAC;AAAA,EAClB,cAAc;AAAA,KACX;AACL,MAAM;AACJ,QAAM,EAAE,aAAa,IAAI,0BAA0B,eAAe,WAAW;AAAA,IAC3E;AAAA,EACF,CAAC;AACD,QAAM,gBAAgB,YAAY,KAAK,CAAC,WAAW,OAAO,OAAO;AACjE,QAAM,CAAC,YAAY,aAAa,IAAI,SAAS,KAAK;AAClD,QAAM,CAAC,gBAAgB,iBAAiB,IAAI,SAAS,aAAa;AAClE,QAAM,CAAC,QAAQ,SAAS,IAAI;AAAA,IAC1B,CAAC,QACG,gBACA;AAAA,MACE,OAAO,GAAG,MAAM,KAAK;AAAA,MACrB,OAAO,MAAM,KAAK;AAAA,MAClB,IAAI;AAAA,IACN;AAAA,EACN;AACA,QAAM,UAAU,CAAC,QAAQ,GAAG,YAAY,OAAO,CAAC,WAAW,CAAC,OAAO,OAAO,CAAC;AAE3E,QAAM,eAAe,SAAS,gBAAgB,SAAS,QAAQ,SAAS,e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AAAA,EACnF,aAAa,UAAU,MAAM;AAAA,IAC3B,OAAO,UAAU,UAAU,CAAC,UAAU,QAAQ,UAAU,MAAM,CAAC;AAAA,IAC/D,OAAO,UAAU,UAAU,CAAC,UAAU,QAAQ,UAAU,MAAM,CAAC;AAAA,IAC/D,SAAS,UAAU;AAAA,EACrB,CAAC,EAAE,YAAY,+CAA+C;AAChE;AAEA,OAAO,YAAY;AACnB,OAAO,cAAc;AACrB,MAAM,iBAAiB,SAAS,MAAM;AACtC,eAAe,YAAY;AAG3B,IAAO,iBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
const getCurrentFont = () => Number(
|
|
2
|
+
const getCurrentFont = () => Number(
|
|
3
|
+
window.getComputedStyle(document.querySelector(":root")).getPropertyValue("font-size").match(/\d+/)[0]
|
|
4
|
+
);
|
|
3
5
|
const setSize = (size) => document.querySelector(":root").setAttribute("style", `font-size: ${size}px`);
|
|
4
6
|
const getFactor = (value) => value / 100;
|
|
5
7
|
const clean = (value) => value.replace(/\D/g, "").substring(0, 3);
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/components/utils.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export const getCurrentFont = () =>\n Number(\n window\n .getComputedStyle(document.querySelector(':root'))\n .getPropertyValue('font-size')\n .match(/\\d+/)[0],\n );\nexport const setSize = (size) =>\n document.querySelector(':root').setAttribute('style', `font-size: ${size}px`);\n\nexport const getFactor = (value) => value / 100;\n\nexport const clean = (value) => value.replace(/\\D/g, '').substring(0, 3);\n"],
|
|
5
|
-
"mappings": "AAAA;
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAhB,MAAM,iBAAiB,MAC5B;AAAA,EACE,OACG,iBAAiB,SAAS,cAAc,OAAO,CAAC,EAChD,iBAAiB,WAAW,EAC5B,MAAM,KAAK,EAAE;AAClB;AACK,MAAM,UAAU,CAAC,SACtB,SAAS,cAAc,OAAO,EAAE,aAAa,SAAS,cAAc,QAAQ;AAEvE,MAAM,YAAY,CAAC,UAAU,QAAQ;AAErC,MAAM,QAAQ,CAAC,UAAU,MAAM,QAAQ,OAAO,EAAE,EAAE,UAAU,GAAG,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/components/zoomOptions.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export default [\n {\n label: '25%',\n value: '25',\n },\n {\n label: '50%',\n value: '50',\n },\n {\n label: '75%',\n value: '75',\n },\n {\n label: '100%',\n value: '100',\n default: true,\n },\n {\n label: '125%',\n value: '125',\n },\n {\n label: '150%',\n value: '150',\n },\n {\n label: '175%',\n value: '175',\n },\n {\n label: '200%',\n value: '200',\n },\n];\n"],
|
|
5
|
-
"mappings": "AAAA;
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,IAAO,sBAAQ;AAAA,EACb;AAAA,IACE,OAAO;AAAA,IACP,OAAO;AAAA,EACT;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,OAAO;AAAA,EACT;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,OAAO;AAAA,EACT;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,OAAO;AAAA,IACP,SAAS;AAAA,EACX;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,OAAO;AAAA,EACT;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,OAAO;AAAA,EACT;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,OAAO;AAAA,EACT;AAAA,EACA;AAAA,IACE,OAAO;AAAA,IACP,OAAO;AAAA,EACT;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/index.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/index.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export * from './DSZoom';\nexport { default } from './DSZoom';\n"],
|
|
5
|
-
"mappings": "AAAA;
|
|
6
|
-
"names": []
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,cAAc;AACd,SAAS,WAAAA,gBAAe;",
|
|
6
|
+
"names": ["default"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-zoom",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Zoom",
|
|
6
6
|
"files": [
|
|
@@ -47,9 +47,9 @@
|
|
|
47
47
|
"indent": 4
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@elliemae/ds-classnames": "3.4.
|
|
51
|
-
"@elliemae/ds-form": "3.4.
|
|
52
|
-
"@elliemae/ds-utilities": "3.4.
|
|
50
|
+
"@elliemae/ds-classnames": "3.4.3",
|
|
51
|
+
"@elliemae/ds-form": "3.4.3",
|
|
52
|
+
"@elliemae/ds-utilities": "3.4.3"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@testing-library/jest-dom": "~5.16.4",
|