dtable-ui-component 6.0.24-beta.5 → 6.0.24-beta1

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.
Files changed (68) hide show
  1. package/lib/BodyPortal/index.js +29 -0
  2. package/lib/DateEditor/mb-date-editor-popover/index.js +3 -3
  3. package/lib/index.js +5 -96
  4. package/lib/utils/utils.js +3 -2
  5. package/package.json +3 -11
  6. package/lib/ActionSheet/index.js +0 -194
  7. package/lib/ActionSheet/style/index.css +0 -365
  8. package/lib/ActivityIndicator/index.css +0 -108
  9. package/lib/ActivityIndicator/index.js +0 -76
  10. package/lib/Badge/index.css +0 -96
  11. package/lib/Badge/index.js +0 -65
  12. package/lib/DatePicker/index.js +0 -120
  13. package/lib/DatePicker/locale/en_US.js +0 -14
  14. package/lib/DatePicker/locale/ru_RU.js +0 -14
  15. package/lib/DatePicker/locale/sv_SE.js +0 -14
  16. package/lib/DatePicker/locale/zh_CN.js +0 -14
  17. package/lib/DatePicker/style/index.css +0 -290
  18. package/lib/DatePicker/utils.js +0 -36
  19. package/lib/Drawer/index.css +0 -142
  20. package/lib/Drawer/index.js +0 -21
  21. package/lib/Icon/index.css +0 -50
  22. package/lib/Icon/index.js +0 -34
  23. package/lib/Icon/load-sprite.js +0 -56
  24. package/lib/InputItem/custom-input.js +0 -321
  25. package/lib/InputItem/custom-keyboard.js +0 -162
  26. package/lib/InputItem/index.js +0 -388
  27. package/lib/InputItem/input.js +0 -45
  28. package/lib/InputItem/locale/en_US.js +0 -12
  29. package/lib/InputItem/locale/ru_RU.js +0 -12
  30. package/lib/InputItem/locale/sv_SE.js +0 -12
  31. package/lib/InputItem/locale/zh_CN.js +0 -12
  32. package/lib/InputItem/portal.js +0 -23
  33. package/lib/InputItem/style/index.css +0 -512
  34. package/lib/List/index.css +0 -381
  35. package/lib/List/index.js +0 -41
  36. package/lib/List/list-item.js +0 -169
  37. package/lib/Modal/alert.js +0 -82
  38. package/lib/Modal/index.js +0 -15
  39. package/lib/Modal/modal.js +0 -118
  40. package/lib/Modal/operation.js +0 -77
  41. package/lib/Modal/prompt.js +0 -207
  42. package/lib/Picker/AbstractPicker.js +0 -190
  43. package/lib/Picker/index.js +0 -28
  44. package/lib/Picker/locale/en_US.js +0 -12
  45. package/lib/Picker/locale/ru_RU.js +0 -12
  46. package/lib/Picker/locale/sv_SE.js +0 -12
  47. package/lib/Picker/locale/zh_CN.js +0 -12
  48. package/lib/Picker/popupProps.js +0 -12
  49. package/lib/Picker/style/index.css +0 -141
  50. package/lib/Popover/index.js +0 -62
  51. package/lib/Popover/item.js +0 -55
  52. package/lib/Popover/style/index.css +0 -229
  53. package/lib/Progress/index.css +0 -22
  54. package/lib/Progress/index.js +0 -65
  55. package/lib/TabBar/Tab.js +0 -76
  56. package/lib/TabBar/index.css +0 -138
  57. package/lib/TabBar/index.js +0 -128
  58. package/lib/Tabs/index.css +0 -443
  59. package/lib/Tabs/index.js +0 -38
  60. package/lib/TextareaItem/index.css +0 -231
  61. package/lib/TextareaItem/index.js +0 -231
  62. package/lib/Toast/index.css +0 -65
  63. package/lib/Toast/index.js +0 -131
  64. package/lib/_util/class.js +0 -34
  65. package/lib/_util/closest.js +0 -17
  66. package/lib/_util/exenv.js +0 -8
  67. package/lib/_util/getDataAttr.js +0 -15
  68. package/lib/_util/getLocale.js +0 -42
@@ -1,50 +0,0 @@
1
- .am-icon {
2
- fill: currentColor;
3
- background-size: cover;
4
- width: 22px;
5
- height: 22px;
6
- }
7
-
8
- .am-icon-xxs {
9
- width: 15px;
10
- height: 15px;
11
- }
12
-
13
- .am-icon-xs {
14
- width: 18px;
15
- height: 18px;
16
- }
17
-
18
- .am-icon-sm {
19
- width: 21px;
20
- height: 21px;
21
- }
22
-
23
- .am-icon-md {
24
- width: 22px;
25
- height: 22px;
26
- }
27
-
28
- .am-icon-lg {
29
- width: 36px;
30
- height: 36px;
31
- }
32
-
33
- .am-icon-loading {
34
- -webkit-animation: cirle-anim 1s linear infinite;
35
- animation: cirle-anim 1s linear infinite;
36
- }
37
-
38
- @-webkit-keyframes cirle-anim {
39
- 100% {
40
- -webkit-transform: rotate(360deg);
41
- transform: rotate(360deg);
42
- }
43
- }
44
-
45
- @keyframes cirle-anim {
46
- 100% {
47
- -webkit-transform: rotate(360deg);
48
- transform: rotate(360deg);
49
- }
50
- }
package/lib/Icon/index.js DELETED
@@ -1,34 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = void 0;
9
- var _classnames = _interopRequireDefault(require("classnames"));
10
- var React = _interopRequireWildcard(require("react"));
11
- var _loadSprite = _interopRequireDefault(require("./load-sprite"));
12
- class Icon extends React.Component {
13
- componentDidMount() {
14
- (0, _loadSprite.default)();
15
- }
16
- render() {
17
- const {
18
- type,
19
- className,
20
- size,
21
- ...restProps
22
- } = this.props;
23
- const cls = (0, _classnames.default)(className, 'am-icon', "am-icon-".concat(type), "am-icon-".concat(size));
24
- return /*#__PURE__*/React.createElement("svg", Object.assign({
25
- className: cls
26
- }, restProps), /*#__PURE__*/React.createElement("use", {
27
- xlinkHref: "#".concat(type)
28
- }));
29
- }
30
- }
31
- exports.default = Icon;
32
- Icon.defaultProps = {
33
- size: 'md'
34
- };
@@ -1,56 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- /* tslint:disable:max-line-length */
8
- // inspried by https://github.com/kisenka/svg-sprite-loader/blob/master/runtime/browser-sprite.js
9
- // Much simplified, do make sure run this after document ready
10
- const svgSprite = contents => "\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n id=\"__ANTD_MOBILE_SVG_SPRITE_NODE__\"\n style=\"display:none;overflow:hidden;width:0;height:0\"\n >\n <defs>\n ".concat(contents, "\n </defs>\n </svg>\n");
11
-
12
- // both minified by https://github.com/svg/svgo
13
- const icons = {
14
- check: '<svg viewBox="0 0 44 44"><path fill-rule="evenodd" d="M34.538 8L38 11.518 17.808 32 8 22.033l3.462-3.518 6.346 6.45z"/></svg>',
15
- 'check-circle': '<svg viewBox="0 0 48 48"><path d="M24 48c13.255 0 24-10.745 24-24S37.255 0 24 0 0 10.745 0 24s10.745 24 24 24zM13.1 23.2l-2.2 2.1 10 9.9L38.1 15l-2.2-2-15.2 17.8-7.6-7.6z" fill-rule="evenodd"/></svg>',
16
- 'check-circle-o': '<svg viewBox="0 0 48 48"><g fill-rule="evenodd"><path d="M24 48c13.255 0 24-10.745 24-24S37.255 0 24 0 0 10.745 0 24s10.745 24 24 24zm0-3c11.598 0 21-9.402 21-21S35.598 3 24 3 3 12.402 3 24s9.402 21 21 21z"/><path d="M12.2 23.2L10 25.3l10 9.9L37.2 15 35 13 19.8 30.8z"/></g></svg>',
17
- cross: '<svg viewBox="0 0 44 44"><path fill-rule="evenodd" d="M24.008 21.852l8.97-8.968L31.092 11l-8.97 8.968L13.157 11l-1.884 1.884 8.968 8.968-9.24 9.24 1.884 1.885 9.24-9.24 9.24 9.24 1.885-1.884-9.24-9.24z"/></svg>',
18
- 'cross-circle': '<svg viewBox="0 0 48 48"><g fill-rule="evenodd"><path d="M24 48c13.255 0 24-10.745 24-24S37.255 0 24 0 0 10.745 0 24s10.745 24 24 24zm0-3c11.598 0 21-9.402 21-21S35.598 3 24 3 3 12.402 3 24s9.402 21 21 21z"/><path d="M24.34 22.22l-7.775-7.775a1.5 1.5 0 1 0-2.12 2.12l7.773 7.775-7.774 7.775a1.5 1.5 0 1 0 2.12 2.12l7.775-7.773 7.774 7.774a1.5 1.5 0 1 0 2.12-2.12L26.46 24.34l7.774-7.774a1.5 1.5 0 1 0-2.12-2.12l-7.776 7.773z"/></g></svg>',
19
- 'cross-circle-o': '<svg viewBox="0 0 48 48"><path d="M24 48c13.255 0 24-10.745 24-24S37.255 0 24 0 0 10.745 0 24s10.745 24 24 24zm.353-25.77l-7.593-7.593c-.797-.8-1.538-.822-2.263-.207-.724.614-.56 1.617-.124 2.067l7.852 7.847-7.72 7.723c-.727.728-.56 1.646-.066 2.177.493.532 1.553.683 2.31-.174l7.588-7.584 7.644 7.623c.796.798 1.608.724 2.21.145.605-.58.72-1.442-.074-2.24l-7.657-7.67 7.545-7.52c.81-.697.9-1.76.297-2.34-.92-.885-1.85-.338-2.264.078l-7.685 7.667z" fill-rule="evenodd"/></svg>',
20
- // Todo: simplify direction to 2, use css transform
21
- left: '<svg viewBox="0 0 44 44"><defs><path id="a" d="M-129-845h24v24h-24z"/></defs><clipPath id="b"><use xlink:href="#a" overflow="visible"/></clipPath><g clip-path="url(#b)"><defs><path id="c" d="M-903-949H947V996H-903z"/></defs></g><path d="M16.247 21.4L28.48 9.165l2.12 2.12-10.117 10.12L30.6 31.524l-2.12 2.12-12.233-12.232.007-.006z"/></svg>',
22
- right: '<svg viewBox="0 0 44 44"><defs><path id="a" d="M-129-845h24v24h-24z"/></defs><clipPath id="b"><use xlink:href="#a" overflow="visible"/></clipPath><g clip-path="url(#b)"><defs><path id="c" d="M-903-949H947V996H-903z"/></defs></g><path d="M30.6 21.4L18.37 9.165l-2.12 2.12 10.117 10.12-10.118 10.118 2.12 2.12 12.234-12.232-.005-.006z"/></svg>',
23
- down: '<svg viewBox="0 0 44 44"><path d="M22.355 28.237l-11.483-10.9c-.607-.576-1.714-.396-2.48.41l.674-.71c-.763.802-.73 2.07-.282 2.496l11.37 10.793-.04.04 2.088 2.195L23.3 31.52l12.308-11.682c.447-.425.48-1.694-.282-2.496l.674.71c-.766-.806-1.873-.986-2.48-.41L22.355 28.237z" fill-rule="evenodd"/></svg>',
24
- up: '<svg viewBox="0 0 44 44"><path fill="none" d="M-1-1h46v46H-1z"/><defs><path id="a" d="M-129-845h24v24h-24z"/></defs><clipPath id="b"><use xlink:href="#a"/></clipPath><g clip-path="url(#b)"><defs><path id="c" d="M-903-949H947V996H-903z"/></defs></g><path d="M23.417 14.23L11.184 26.46l2.12 2.12 10.12-10.117 10.118 10.118 2.12-2.12L23.43 14.228l-.006.005z"/></svg>',
25
- loading: '<svg viewBox="0 -2 59.75 60.25"><path fill="#ccc" d="M29.69-.527C14.044-.527 1.36 12.158 1.36 27.806S14.043 56.14 29.69 56.14c15.65 0 28.334-12.686 28.334-28.334S45.34-.527 29.69-.527zm.185 53.75c-14.037 0-25.417-11.38-25.417-25.417S15.838 2.39 29.875 2.39s25.417 11.38 25.417 25.417-11.38 25.416-25.417 25.416z"/><path fill="none" stroke="#108ee9" stroke-width="3" stroke-linecap="round" stroke-miterlimit="10" d="M56.587 29.766c.37-7.438-1.658-14.7-6.393-19.552"/></svg>',
26
- search: '<svg viewBox="0 0 44 44"><path d="M32.98 29.255l8.915 8.293L39.603 40l-8.86-8.242a15.952 15.952 0 0 1-10.753 4.147C11.16 35.905 4 28.763 4 19.952 4 11.142 11.16 4 19.99 4s15.99 7.142 15.99 15.952c0 3.472-1.112 6.685-3 9.303zm.05-9.21c0 7.123-5.7 12.918-12.88 12.918-7.176 0-13.015-5.795-13.015-12.918 0-7.12 5.84-12.917 13.017-12.917 7.178 0 12.88 5.797 12.88 12.917z" fill-rule="evenodd"/></svg>',
27
- ellipsis: '<svg viewBox="0 0 44 44"><circle cx="21.888" cy="22" r="4.045"/><circle cx="5.913" cy="22" r="4.045"/><circle cx="37.863" cy="22" r="4.045"/></svg>',
28
- 'ellipsis-circle': '<svg viewBox="0 0 44 44"><g fill-rule="evenodd"><path d="M22.13.11C10.05.11.255 9.902.255 21.983S10.05 43.86 22.13 43.86s21.875-9.795 21.875-21.876S34.21.11 22.13.11zm0 40.7c-10.396 0-18.825-8.43-18.825-18.826S11.735 3.16 22.13 3.16c10.396 0 18.825 8.428 18.825 18.824S32.525 40.81 22.13 40.81z"/><circle cx="21.888" cy="22.701" r="2.445"/><circle cx="12.23" cy="22.701" r="2.445"/><circle cx="31.546" cy="22.701" r="2.445"/></g></svg>',
29
- 'exclamation-circle': '<svg viewBox="0 0 64 64"><path d="M59.58 40.89L41.193 9.11C39.135 5.382 35.723 3 31.387 3c-3.11 0-6.52 2.382-8.58 6.11L4.42 40.89c-2.788 4.635-3.126 8.81-1.225 12.22C5.015 56.208 7.572 58 13 58h36.773c5.428 0 9.21-1.792 11.03-4.89 1.9-3.41 1.565-7.583-1.224-12.22zm-2.452 11c-.635 1.694-3.802 2.443-7.354 2.443H13c-3.59 0-5.493-.75-6.13-2.444-1.71-2.41-1.374-5.263 0-8.557l18.387-31.777c2.116-3.168 4.394-4.89 6.13-4.89 2.96 0 5.238 1.722 7.354 4.89l18.387 31.777c1.374 3.294 1.713 6.146 0 8.556zm-25.74-33c-.405 0-1.227.835-1.227 2.443v15.89c0 1.608.823 2.444 1.227 2.444 1.628 0 2.452-.836 2.452-2.445v-15.89c0-1.607-.825-2.443-2.453-2.443zm0 23.22c-.405 0-1.227.79-1.227 1.223v2.445c0 .434.823 1.222 1.227 1.222 1.628 0 2.452-.788 2.452-1.222v-2.445c0-.434-.825-1.222-2.453-1.222z" fill-rule="evenodd"/></svg>',
30
- 'info-circle': '<svg viewBox="0 0 44 44"><circle cx="13.828" cy="19.63" r="1.938"/><circle cx="21.767" cy="19.63" r="1.938"/><circle cx="29.767" cy="19.63" r="1.938"/><path d="M22.102 4.16c-9.918 0-17.958 7.147-17.958 15.962 0 4.935 2.522 9.345 6.48 12.273v5.667l.04.012a2.627 2.627 0 1 0 4.5 1.455h.002l5.026-3.54c.628.06 1.265.094 1.91.094 9.92 0 17.96-7.146 17.96-15.96C40.06 11.306 32.02 4.16 22.1 4.16zm-.04 29.902c-.902 0-1.78-.08-2.642-.207l-5.882 4.234c-.024.024-.055.04-.083.06l-.008.005a.51.51 0 0 1-.284.095.525.525 0 0 1-.525-.525l.005-6.375c-3.91-2.516-6.456-6.544-6.456-11.1 0-7.628 7.107-13.812 15.875-13.812s15.875 6.184 15.875 13.812-7.107 13.812-15.875 13.812z"/></svg>',
31
- 'question-circle': '<svg viewBox="0 0 44 44"><g fill-rule="evenodd"><path d="M21.186 3c-10.853 0-19.36 8.506-19.36 19.358C1.827 32.494 10.334 41 21.187 41c10.133 0 18.64-8.506 18.64-18.642C39.827 11.506 31.32 3 21.187 3m15.64 19c0 8.823-7.178 16-16 16s-16-7.177-16-16 7.178-16 16-16 16 7.177 16 16z"/><path d="M22.827 31.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0m4-15.48c0 .957-.203 1.822-.61 2.593-.427.792-1.117 1.612-2.073 2.457-.867.734-1.453 1.435-1.754 2.096-.302.7-.453 1.693-.453 2.98a.828.828 0 0 1-.823.854.828.828 0 0 1-.584-.22.877.877 0 0 1-.24-.635c0-1.305.168-2.38.506-3.227.336-.883.93-1.682 1.78-2.4 1.01-.883 1.71-1.692 2.1-2.428.336-.645.503-1.38.503-2.21-.02-.935-.3-1.7-.85-2.288-.655-.717-1.62-1.075-2.897-1.075-1.506 0-2.596.535-3.27 1.6-.46.754-.688 1.645-.688 2.677a.92.92 0 0 1-.266.66.747.747 0 0 1-.56.25.73.73 0 0 1-.584-.194c-.16-.164-.24-.393-.24-.69 0-1.82.585-3.272 1.755-4.357C18.645 11.486 19.928 11 21.434 11h.293c1.452 0 2.638.414 3.56 1.24 1.028.903 1.54 2.163 1.54 3.78z"/></g></svg>',
32
- voice: '<svg viewBox="0 0 38 33"><g fill-rule="evenodd"><path d="M17.838 28.8c-.564-.468-1.192-.983-1.836-1.496-4.244-3.385-5.294-3.67-6.006-3.67-.014 0-.027.005-.04.005-.015 0-.028-.006-.042-.006H3.562c-.734 0-.903-.203-.903-.928v-12.62c0-.49.057-.8.66-.8H9.1c.694 0 1.76-.28 6.4-3.63.83-.596 1.638-1.196 2.337-1.722V28.8zM19.682.19c-.463-.22-1.014-.158-1.417.157-.02.016-1.983 1.552-4.152 3.125C10.34 6.21 9.243 6.664 9.02 6.737H3.676c-.027 0-.053.003-.08.004H1.183c-.608 0-1.1.487-1.1 1.086V25.14c0 .598.492 1.084 1.1 1.084h8.71c.22.08 1.257.55 4.605 3.24 1.947 1.562 3.694 3.088 3.712 3.103.25.22.568.333.89.333.186 0 .373-.038.55-.116.48-.213.79-.684.79-1.204V1.38c0-.506-.294-.968-.758-1.19z" mask="url(#mask-2)"/><path d="M31.42 16.475c0-3.363-1.854-6.297-4.606-7.876-.125-.067-.42-.193-.625-.193-.613 0-1.11.488-1.11 1.09 0 .404.22.764.55.952 2.13 1.19 3.566 3.44 3.566 6.024 0 2.627-1.486 4.913-3.677 6.087-.32.19-.53.54-.53.935 0 .602.495 1.09 1.106 1.09.26.002.568-.15.568-.15 2.835-1.556 4.754-4.538 4.754-7.96" mask="url(#mask-4)"/><path d="M30.14 3.057c-.205-.122-.41-.22-.658-.22-.608 0-1.1.485-1.1 1.084 0 .434.26.78.627.978 4.042 2.323 6.76 6.636 6.76 11.578 0 4.938-2.715 9.248-6.754 11.572-.354.19-.66.55-.66.993 0 .6.494 1.085 1.102 1.085.243 0 .438-.092.65-.213 4.692-2.695 7.848-7.7 7.848-13.435 0-5.723-3.142-10.718-7.817-13.418" mask="url(#mask-6)"/></g></svg>',
33
- plus: '<svg viewBox="0 0 30 30"><path d="M14 14H0v2h14v14h2V16h14v-2H16V0h-2v14z" fill-rule="evenodd"/></svg>',
34
- minus: '<svg viewBox="0 0 30 2"><path d="M0 0h30v2H0z" fill-rule="evenodd"/></svg>',
35
- dislike: '<svg viewBox="0 0 72 72"><g fill="none" fill-rule="evenodd"><path d="M36 72c19.882 0 36-16.118 36-36S55.882 0 36 0 0 16.118 0 36s16.118 36 36 36zm0-2c18.778 0 34-15.222 34-34S54.778 2 36 2 2 17.222 2 36s15.222 34 34 34z" fill="#FFF"/><path fill="#FFF" d="M47 22h2v6h-2zm-24 0h2v6h-2z"/><path d="M21 51s4.6-7 15-7 15 7 15 7" stroke="#FFF" stroke-width="2"/></g></svg>',
36
- fail: '<svg viewBox="0 0 72 72"><g fill="none" fill-rule="evenodd"><path d="M36 72c19.882 0 36-16.118 36-36S55.882 0 36 0 0 16.118 0 36s16.118 36 36 36zm0-2c18.778 0 34-15.222 34-34S54.778 2 36 2 2 17.222 2 36s15.222 34 34 34z" fill="#FFF"/><path d="M22 22l28.304 28.304m-28.304 0L50.304 22" stroke="#FFF" stroke-width="2"/></g></svg>',
37
- success: '<svg viewBox="0 0 72 72"><g fill="none" fill-rule="evenodd"><path d="M36 72c19.882 0 36-16.118 36-36S55.882 0 36 0 0 16.118 0 36s16.118 36 36 36zm0-2c18.778 0 34-15.222 34-34S54.778 2 36 2 2 17.222 2 36s15.222 34 34 34z" fill="#FFF"/><path stroke="#FFF" stroke-width="2" d="M19 34.54l11.545 11.923L52.815 24"/></g></svg>'
38
- };
39
- const renderSvgSprite = () => {
40
- const symbols = Object.keys(icons).map(iconName => {
41
- const svgContent = icons[iconName].split('svg')[1];
42
- return "<symbol id=".concat(iconName).concat(svgContent, "symbol>");
43
- }).join('');
44
- return svgSprite(symbols);
45
- };
46
- const loadSprite = () => {
47
- if (!document) {
48
- return;
49
- }
50
- const existing = document.getElementById('__ANTD_MOBILE_SVG_SPRITE_NODE__');
51
- const mountNode = document.body;
52
- if (!existing) {
53
- mountNode.insertAdjacentHTML('afterbegin', renderSvgSprite());
54
- }
55
- };
56
- var _default = exports.default = loadSprite;
@@ -1,321 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = void 0;
9
- var _classnames = _interopRequireDefault(require("classnames"));
10
- var React = _interopRequireWildcard(require("react"));
11
- var ReactDOM = _interopRequireWildcard(require("react-dom"));
12
- var _class = require("../_util/class");
13
- var _exenv = require("../_util/exenv");
14
- var _customKeyboard = _interopRequireDefault(require("./custom-keyboard"));
15
- var _portal = _interopRequireDefault(require("./portal"));
16
- let customNumberKeyboard = null;
17
- const IS_REACT_16 = !!ReactDOM.createPortal;
18
- function getBodyScrollTop() {
19
- const el = document.scrollingElement || document.documentElement;
20
- return el && el.scrollTop || 0;
21
- }
22
- function setBodyScrollTop(scrollTop) {
23
- const el = document.scrollingElement || document.documentElement;
24
- el.scrollTop = scrollTop;
25
- }
26
- class NumberInput extends React.Component {
27
- constructor(props) {
28
- super(props);
29
- this.onChange = value => {
30
- if (!('value' in this.props)) {
31
- this.setState({
32
- value: value.target.value
33
- });
34
- }
35
- this.props.onChange(value);
36
- };
37
- this.onConfirm = value => {
38
- this.props.onVirtualKeyboardConfirm(value);
39
- };
40
- this.addBlurListener = () => {
41
- document.addEventListener('touchend', this.doBlur, false);
42
- };
43
- this.removeBlurListener = () => {
44
- document.removeEventListener('touchend', this.doBlur, false);
45
- };
46
- this.saveRef = el => {
47
- if (IS_REACT_16 && el) {
48
- customNumberKeyboard = el;
49
- }
50
- };
51
- this.doBlur = ev => {
52
- const {
53
- value
54
- } = this.state;
55
- if (ev.target !== this.inputRef) {
56
- this.onInputBlur(value);
57
- }
58
- };
59
- this.unLinkInput = () => {
60
- if (customNumberKeyboard && customNumberKeyboard.antmKeyboard && customNumberKeyboard.linkedInput && customNumberKeyboard.linkedInput === this) {
61
- customNumberKeyboard.linkedInput = null;
62
- if (this.props.autoAdjustHeight) {
63
- this.getContainer().style.height = '0';
64
- }
65
- (0, _class.addClass)(customNumberKeyboard.antmKeyboard, "".concat(this.props.keyboardPrefixCls, "-wrapper-hide"));
66
- }
67
- // for unmount
68
- this.removeBlurListener();
69
- };
70
- this.onInputBlur = value => {
71
- if (IS_REACT_16) {
72
- this.keyBoard = null;
73
- }
74
- const {
75
- focus
76
- } = this.state;
77
- if (focus) {
78
- this.setState({
79
- focus: false
80
- });
81
- this.props.onBlur(value);
82
- setTimeout(() => {
83
- this.unLinkInput();
84
- }, 50);
85
- }
86
- };
87
- this.onInputFocus = () => {
88
- const {
89
- value
90
- } = this.state;
91
- this.props.onFocus(value);
92
- this.setState({
93
- focus: true
94
- }, () => {
95
- if (customNumberKeyboard) {
96
- customNumberKeyboard.linkedInput = this;
97
- if (customNumberKeyboard.antmKeyboard) {
98
- if (this.props.autoAdjustHeight) {
99
- const keyBoardHeight = customNumberKeyboard.antmKeyboard.offsetHeight;
100
- this.getContainer().style.height = "".concat(keyBoardHeight, "px");
101
- if (this.inputRef) {
102
- const {
103
- bottom
104
- } = this.inputRef.getBoundingClientRect();
105
- const clientHeight = window.innerHeight;
106
- // 计算输入框距离视窗的底部距离
107
- const distance = clientHeight - bottom;
108
- if (distance < keyBoardHeight) {
109
- setBodyScrollTop(getBodyScrollTop() + keyBoardHeight - distance);
110
- }
111
- }
112
- }
113
- (0, _class.removeClass)(customNumberKeyboard.antmKeyboard, "".concat(this.props.keyboardPrefixCls, "-wrapper-hide"));
114
- }
115
- customNumberKeyboard.confirmDisabled = value === '';
116
- if (customNumberKeyboard.confirmKeyboardItem) {
117
- if (value === '') {
118
- (0, _class.addClass)(customNumberKeyboard.confirmKeyboardItem, "".concat(this.props.keyboardPrefixCls, "-item-disabled"));
119
- } else {
120
- (0, _class.removeClass)(customNumberKeyboard.confirmKeyboardItem, "".concat(this.props.keyboardPrefixCls, "-item-disabled"));
121
- }
122
- }
123
- }
124
- });
125
- };
126
- this.onKeyboardClick = KeyboardItemValue => {
127
- const {
128
- maxLength
129
- } = this.props;
130
- const {
131
- value
132
- } = this.state;
133
- // tslint:disable-next-line:no-this-assignment
134
- const {
135
- onChange
136
- } = this;
137
- let valueAfterChange;
138
- // 删除键
139
- if (KeyboardItemValue === 'delete') {
140
- valueAfterChange = value.substring(0, value.length - 1);
141
- onChange({
142
- target: {
143
- value: valueAfterChange
144
- }
145
- });
146
- // 确认键
147
- } else if (KeyboardItemValue === 'confirm') {
148
- valueAfterChange = value;
149
- onChange({
150
- target: {
151
- value: valueAfterChange
152
- }
153
- });
154
- this.onInputBlur(value);
155
- this.onConfirm(value);
156
- // 收起键
157
- } else if (KeyboardItemValue === 'hide') {
158
- valueAfterChange = value;
159
- this.onInputBlur(valueAfterChange);
160
- } else {
161
- if (maxLength !== undefined && +maxLength >= 0 && (value + KeyboardItemValue).length > maxLength) {
162
- valueAfterChange = (value + KeyboardItemValue).substr(0, maxLength);
163
- onChange({
164
- target: {
165
- value: valueAfterChange
166
- }
167
- });
168
- } else {
169
- valueAfterChange = value + KeyboardItemValue;
170
- onChange({
171
- target: {
172
- value: valueAfterChange
173
- }
174
- });
175
- }
176
- }
177
- if (customNumberKeyboard) {
178
- customNumberKeyboard.confirmDisabled = valueAfterChange === '';
179
- if (customNumberKeyboard.confirmKeyboardItem) {
180
- if (valueAfterChange === '') {
181
- (0, _class.addClass)(customNumberKeyboard.confirmKeyboardItem, "".concat(this.props.keyboardPrefixCls, "-item-disabled"));
182
- } else {
183
- (0, _class.removeClass)(customNumberKeyboard.confirmKeyboardItem, "".concat(this.props.keyboardPrefixCls, "-item-disabled"));
184
- }
185
- }
186
- }
187
- };
188
- this.onFakeInputClick = () => {
189
- this.focus();
190
- };
191
- this.focus = () => {
192
- // this focus may invocked by users page button click, so this click may trigger blurEventListener at the same time
193
- this.renderCustomKeyboard();
194
- this.removeBlurListener();
195
- const {
196
- focus
197
- } = this.state;
198
- if (!focus) {
199
- this.onInputFocus();
200
- }
201
- setTimeout(() => {
202
- this.addBlurListener();
203
- }, 50);
204
- };
205
- this.state = {
206
- focus: false,
207
- value: props.value || ''
208
- };
209
- }
210
- componentWillReceiveProps(nextProps) {
211
- if ('value' in nextProps) {
212
- this.setState({
213
- value: nextProps.value
214
- });
215
- }
216
- }
217
- componentWillUnmount() {
218
- // focus:true unmount 不能触发 blur
219
- if (this.state.focus) {
220
- this.props.onBlur(this.state.value);
221
- }
222
- this.unLinkInput();
223
- }
224
- getComponent() {
225
- const {
226
- confirmLabel,
227
- backspaceLabel,
228
- cancelKeyboardLabel,
229
- keyboardPrefixCls,
230
- moneyKeyboardWrapProps,
231
- moneyKeyboardHeader,
232
- disabledKeys
233
- } = this.props;
234
- return /*#__PURE__*/React.createElement(_customKeyboard.default, {
235
- ref: this.saveRef,
236
- onClick: this.onKeyboardClick,
237
- prefixCls: keyboardPrefixCls,
238
- confirmLabel: confirmLabel,
239
- backspaceLabel: backspaceLabel,
240
- cancelKeyboardLabel: cancelKeyboardLabel,
241
- wrapProps: moneyKeyboardWrapProps,
242
- header: moneyKeyboardHeader,
243
- disabledKeys: disabledKeys
244
- });
245
- }
246
- getContainer() {
247
- const {
248
- keyboardPrefixCls
249
- } = this.props;
250
- let container = document.querySelector("#".concat(keyboardPrefixCls, "-container"));
251
- if (!container) {
252
- container = document.createElement('div');
253
- container.setAttribute('id', "".concat(keyboardPrefixCls, "-container"));
254
- document.body.appendChild(container);
255
- }
256
- this.container = container;
257
- return this.container;
258
- }
259
- renderCustomKeyboard() {
260
- if (IS_REACT_16) {
261
- this.keyBoard = /*#__PURE__*/React.createElement(_portal.default, {
262
- getContainer: () => this.getContainer()
263
- }, this.getComponent());
264
- } else {
265
- customNumberKeyboard = ReactDOM.unstable_renderSubtreeIntoContainer(this, this.getComponent(), this.getContainer());
266
- }
267
- }
268
- renderPortal() {
269
- if (!IS_REACT_16 || !_exenv.canUseDOM) {
270
- return null;
271
- }
272
- return this.keyBoard;
273
- }
274
- render() {
275
- const {
276
- placeholder,
277
- disabled,
278
- editable,
279
- moneyKeyboardAlign
280
- } = this.props;
281
- const {
282
- focus,
283
- value
284
- } = this.state;
285
- const preventKeyboard = disabled || !editable;
286
- const fakeInputCls = (0, _classnames.default)('fake-input', {
287
- focus,
288
- 'fake-input-disabled': disabled
289
- });
290
- const fakeInputContainerCls = (0, _classnames.default)('fake-input-container', {
291
- 'fake-input-container-left': moneyKeyboardAlign === 'left'
292
- });
293
- return /*#__PURE__*/React.createElement("div", {
294
- className: fakeInputContainerCls
295
- }, value === '' &&
296
- /*#__PURE__*/
297
- // tslint:disable-next-line:jsx-no-multiline-js
298
- React.createElement("div", {
299
- className: "fake-input-placeholder"
300
- }, placeholder), /*#__PURE__*/React.createElement("div", {
301
- role: "textbox",
302
- "aria-label": value || placeholder,
303
- className: fakeInputCls,
304
- ref: el => this.inputRef = el,
305
- onClick: preventKeyboard ? () => {} : this.onFakeInputClick
306
- }, value), this.renderPortal());
307
- }
308
- }
309
- NumberInput.defaultProps = {
310
- onChange: () => {},
311
- onFocus: () => {},
312
- onBlur: () => {},
313
- onVirtualKeyboardConfirm: () => {},
314
- placeholder: '',
315
- disabled: false,
316
- editable: true,
317
- prefixCls: 'am-input',
318
- keyboardPrefixCls: 'am-number-keyboard',
319
- autoAdjustHeight: false
320
- };
321
- var _default = exports.default = NumberInput;
@@ -1,162 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = exports.KeyboardItem = void 0;
9
- var _classnames = _interopRequireDefault(require("classnames"));
10
- var React = _interopRequireWildcard(require("react"));
11
- var _rmcFeedback = _interopRequireDefault(require("rmc-feedback"));
12
- var _exenv = require("../_util/exenv");
13
- /**
14
- * determines whether an array includes a certain value among its entries, returning true or false as appropriate.
15
- * @param {array} arr The array to search in
16
- * @param {any} item The value to search for
17
- */
18
- function includes(arr, item) {
19
- if (!arr || !arr.length || !item) {
20
- return false;
21
- }
22
- for (let i = 0, len = arr.length; i < len; i++) {
23
- if (arr[i] === item) {
24
- return true;
25
- }
26
- }
27
- return false;
28
- }
29
- class KeyboardItem extends React.Component {
30
- render() {
31
- const {
32
- prefixCls,
33
- onClick,
34
- className,
35
- disabled,
36
- children,
37
- tdRef,
38
- label,
39
- iconOnly,
40
- ...restProps
41
- } = this.props;
42
- let value = children;
43
- if (className === 'keyboard-delete') {
44
- value = 'delete';
45
- } else if (className === 'keyboard-hide') {
46
- value = 'hide';
47
- } else if (className === 'keyboard-confirm') {
48
- value = 'confirm';
49
- }
50
- const extraCls = {
51
- ["".concat(prefixCls, "-item-disabled")]: disabled
52
- };
53
- const wrapCls = (0, _classnames.default)("".concat(prefixCls, "-item"), className, extraCls);
54
- return /*#__PURE__*/React.createElement(_rmcFeedback.default, {
55
- disabled: disabled,
56
- activeClassName: "".concat(prefixCls, "-item-active")
57
- }, /*#__PURE__*/React.createElement("td", Object.assign({
58
- ref: tdRef
59
- // tslint:disable-next-line:jsx-no-multiline-js
60
- ,
61
- onTouchEnd: e => {
62
- onClick(e, value);
63
- },
64
- className: wrapCls
65
- }, restProps), children, iconOnly && /*#__PURE__*/React.createElement("i", {
66
- className: "sr-only"
67
- }, label)));
68
- }
69
- }
70
- exports.KeyboardItem = KeyboardItem;
71
- KeyboardItem.defaultProps = {
72
- prefixCls: 'am-number-keyboard',
73
- onClick: () => {},
74
- disabled: false
75
- };
76
- class CustomKeyboard extends React.Component {
77
- constructor() {
78
- var _this;
79
- super(...arguments);
80
- _this = this;
81
- this.onKeyboardClick = function (e) {
82
- let value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
83
- e.nativeEvent.stopImmediatePropagation();
84
- if (_this.props.disabledKeys && includes(_this.props.disabledKeys, value)) {
85
- return null;
86
- }
87
- if (value === 'confirm' && _this.confirmDisabled) {
88
- return null;
89
- } else {
90
- if (_this.linkedInput) {
91
- _this.linkedInput.onKeyboardClick(value);
92
- }
93
- }
94
- };
95
- this.renderKeyboardItem = (item, index) => {
96
- let disabled = false;
97
- if (this.props.disabledKeys && includes(this.props.disabledKeys, item)) {
98
- disabled = true;
99
- }
100
- return /*#__PURE__*/React.createElement(KeyboardItem, {
101
- onClick: this.onKeyboardClick,
102
- key: "item-".concat(item, "-").concat(index),
103
- disabled: disabled
104
- }, item);
105
- };
106
- }
107
- render() {
108
- const {
109
- prefixCls,
110
- confirmLabel,
111
- backspaceLabel,
112
- cancelKeyboardLabel,
113
- wrapProps,
114
- header
115
- } = this.props;
116
- const wrapperCls = (0, _classnames.default)("".concat(prefixCls, "-wrapper"), "".concat(prefixCls, "-wrapper-hide"));
117
- return /*#__PURE__*/React.createElement("div", Object.assign({
118
- className: wrapperCls,
119
- ref: el => this.antmKeyboard = el
120
- }, wrapProps), header && /*#__PURE__*/React.cloneElement(header, {
121
- onClick: this.onKeyboardClick
122
- }), /*#__PURE__*/React.createElement("table", null, /*#__PURE__*/React.createElement("tbody", null, /*#__PURE__*/React.createElement("tr", null, ['1', '2', '3'].map((item, index) =>
123
- // tslint:disable-next-line:jsx-no-multiline-js
124
- this.renderKeyboardItem(item, index)), /*#__PURE__*/React.createElement(KeyboardItem, Object.assign({
125
- className: "keyboard-delete",
126
- rowSpan: 2,
127
- onClick: this.onKeyboardClick
128
- }, this.getAriaAttr(backspaceLabel)))), /*#__PURE__*/React.createElement("tr", null, ['4', '5', '6'].map((item, index) =>
129
- // tslint:disable-next-line:jsx-no-multiline-js
130
- this.renderKeyboardItem(item, index))), /*#__PURE__*/React.createElement("tr", null, ['7', '8', '9'].map((item, index) =>
131
- // tslint:disable-next-line:jsx-no-multiline-js
132
- this.renderKeyboardItem(item, index)), /*#__PURE__*/React.createElement(KeyboardItem, {
133
- className: "keyboard-confirm",
134
- rowSpan: 2,
135
- onClick: this.onKeyboardClick,
136
- tdRef: el => this.confirmKeyboardItem = el
137
- }, confirmLabel)), /*#__PURE__*/React.createElement("tr", null, ['.', '0'].map((item, index) =>
138
- // tslint:disable-next-line:jsx-no-multiline-js
139
- this.renderKeyboardItem(item, index)), /*#__PURE__*/React.createElement(KeyboardItem, Object.assign({
140
- className: "keyboard-hide",
141
- onClick: this.onKeyboardClick
142
- }, this.getAriaAttr(cancelKeyboardLabel)))))));
143
- }
144
- getAriaAttr(label) {
145
- if (_exenv.IS_IOS) {
146
- return {
147
- label,
148
- iconOnly: true
149
- };
150
- } else {
151
- return {
152
- role: 'button',
153
- 'aria-label': label
154
- };
155
- }
156
- }
157
- }
158
- CustomKeyboard.defaultProps = {
159
- prefixCls: 'am-number-keyboard',
160
- disabledKeys: null
161
- };
162
- var _default = exports.default = CustomKeyboard;