amssui 1.0.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 assui
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,7 @@
1
+ ## 轻松上手
2
+ mobile web 组件
3
+
4
+ ```bash
5
+ // 安装依赖
6
+ npm i amssui --save
7
+ ```
@@ -0,0 +1,14 @@
1
+ import * as React from 'react';
2
+ import type { ModalProps } from 'antd/lib/modal';
3
+ export interface ModalAction {
4
+ open: () => void;
5
+ close: () => void;
6
+ }
7
+ export interface ButtonModalProps extends Omit<ModalProps, 'children'> {
8
+ onClose?: () => void;
9
+ onOpen?: () => void;
10
+ trigger?: React.ReactElement;
11
+ children: ((v: ModalAction) => React.ReactElement) | React.ReactElement;
12
+ }
13
+ declare const ForwardRefButtonModal: React.ForwardRefExoticComponent<ButtonModalProps & React.RefAttributes<unknown>>;
14
+ export default ForwardRefButtonModal;
@@ -0,0 +1,131 @@
1
+ var __assign = this && this.__assign || function () {
2
+ __assign = Object.assign || function (t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+
6
+ for (var p in s) {
7
+ if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
8
+ }
9
+ }
10
+
11
+ return t;
12
+ };
13
+
14
+ return __assign.apply(this, arguments);
15
+ };
16
+
17
+ var __rest = this && this.__rest || function (s, e) {
18
+ var t = {};
19
+
20
+ for (var p in s) {
21
+ if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
22
+ }
23
+
24
+ if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
25
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
26
+ }
27
+ return t;
28
+ };
29
+
30
+ var __read = this && this.__read || function (o, n) {
31
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
32
+ if (!m) return o;
33
+ var i = m.call(o),
34
+ r,
35
+ ar = [],
36
+ e;
37
+
38
+ try {
39
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
40
+ ar.push(r.value);
41
+ }
42
+ } catch (error) {
43
+ e = {
44
+ error: error
45
+ };
46
+ } finally {
47
+ try {
48
+ if (r && !r.done && (m = i["return"])) m.call(i);
49
+ } finally {
50
+ if (e) throw e.error;
51
+ }
52
+ }
53
+
54
+ return ar;
55
+ }; // @ts-nocheck
56
+
57
+
58
+ import * as React from 'react';
59
+ import isFunction from 'lodash/isFunction';
60
+ import Modal from 'react-vant/lib/dialog';
61
+
62
+ var ButtonModal = function ButtonModal(props, ref) {
63
+ var _a = __read(React.useState(false), 2),
64
+ visible = _a[0],
65
+ setModalVisible = _a[1];
66
+
67
+ var children = props.children,
68
+ trigger = props.trigger,
69
+ onOpen = props.onOpen,
70
+ onClose = props.onClose,
71
+ onOk = props.onOk,
72
+ onCancel = props.onCancel,
73
+ restModalProps = __rest(props, ["children", "trigger", "onOpen", "onClose", "onOk", "onCancel"]);
74
+
75
+ var openModal = function openModal() {
76
+ if (onOpen) {
77
+ onOpen();
78
+ }
79
+
80
+ setModalVisible(true);
81
+ };
82
+
83
+ var closeModal = function closeModal() {
84
+ if (onClose) {
85
+ onClose();
86
+ }
87
+
88
+ setModalVisible(false);
89
+ };
90
+
91
+ var modalActionRef = React.useRef({
92
+ open: openModal,
93
+ close: closeModal
94
+ });
95
+ React.useImperativeHandle(ref, function () {
96
+ return modalActionRef.current;
97
+ });
98
+
99
+ var handleModalOk = function handleModalOk(e) {
100
+ if (onOk) {
101
+ return onOk(e);
102
+ }
103
+
104
+ closeModal();
105
+ return false;
106
+ };
107
+
108
+ var handleModalCancel = function handleModalCancel(e) {
109
+ if (onCancel) {
110
+ onCancel(e);
111
+ }
112
+
113
+ closeModal();
114
+ };
115
+
116
+ var buttonNode = trigger && /*#__PURE__*/React.cloneElement(trigger, {
117
+ onClick: openModal
118
+ });
119
+ return /*#__PURE__*/React.createElement(React.Fragment, null, buttonNode, /*#__PURE__*/React.createElement(Modal, __assign({
120
+ visible: visible,
121
+ onConfirm: handleModalOk,
122
+ onCancel: handleModalCancel,
123
+ centered: true,
124
+ maskClosable: false
125
+ }, restModalProps), isFunction(children) ? children(modalActionRef.current) : /*#__PURE__*/React.cloneElement(children, {
126
+ modalAction: modalActionRef.current
127
+ })));
128
+ };
129
+
130
+ var ForwardRefButtonModal = /*#__PURE__*/React.forwardRef(ButtonModal);
131
+ export default ForwardRefButtonModal;
@@ -0,0 +1 @@
1
+ import 'antd/lib/modal/style';
@@ -0,0 +1 @@
1
+ import 'antd/lib/modal/style';
package/es/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export type { ButtonModalProps } from './button-modal';
2
+ export { default as ButtonModal } from './button-modal';
package/es/index.js ADDED
@@ -0,0 +1 @@
1
+ export { default as ButtonModal } from './button-modal';
@@ -0,0 +1,4 @@
1
+ @labelTextLabelScale: 0.8;
2
+ @labelTextLabeltranslateY: -8px;
3
+ @pickerInputTop: 9px;
4
+ @labelFocusBorderColor: #000;
@@ -0,0 +1,14 @@
1
+ import * as React from 'react';
2
+ import type { ModalProps } from 'antd/lib/modal';
3
+ export interface ModalAction {
4
+ open: () => void;
5
+ close: () => void;
6
+ }
7
+ export interface ButtonModalProps extends Omit<ModalProps, 'children'> {
8
+ onClose?: () => void;
9
+ onOpen?: () => void;
10
+ trigger?: React.ReactElement;
11
+ children: ((v: ModalAction) => React.ReactElement) | React.ReactElement;
12
+ }
13
+ declare const ForwardRefButtonModal: React.ForwardRefExoticComponent<ButtonModalProps & React.RefAttributes<unknown>>;
14
+ export default ForwardRefButtonModal;
@@ -0,0 +1,184 @@
1
+ "use strict";
2
+
3
+ var __assign = this && this.__assign || function () {
4
+ __assign = Object.assign || function (t) {
5
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
6
+ s = arguments[i];
7
+
8
+ for (var p in s) {
9
+ if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
10
+ }
11
+ }
12
+
13
+ return t;
14
+ };
15
+
16
+ return __assign.apply(this, arguments);
17
+ };
18
+
19
+ var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
20
+ if (k2 === undefined) k2 = k;
21
+ var desc = Object.getOwnPropertyDescriptor(m, k);
22
+
23
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
24
+ desc = {
25
+ enumerable: true,
26
+ get: function get() {
27
+ return m[k];
28
+ }
29
+ };
30
+ }
31
+
32
+ Object.defineProperty(o, k2, desc);
33
+ } : function (o, m, k, k2) {
34
+ if (k2 === undefined) k2 = k;
35
+ o[k2] = m[k];
36
+ });
37
+
38
+ var __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function (o, v) {
39
+ Object.defineProperty(o, "default", {
40
+ enumerable: true,
41
+ value: v
42
+ });
43
+ } : function (o, v) {
44
+ o["default"] = v;
45
+ });
46
+
47
+ var __importStar = this && this.__importStar || function (mod) {
48
+ if (mod && mod.__esModule) return mod;
49
+ var result = {};
50
+ if (mod != null) for (var k in mod) {
51
+ if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
52
+ }
53
+
54
+ __setModuleDefault(result, mod);
55
+
56
+ return result;
57
+ };
58
+
59
+ var __rest = this && this.__rest || function (s, e) {
60
+ var t = {};
61
+
62
+ for (var p in s) {
63
+ if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
64
+ }
65
+
66
+ if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
67
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
68
+ }
69
+ return t;
70
+ };
71
+
72
+ var __read = this && this.__read || function (o, n) {
73
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
74
+ if (!m) return o;
75
+ var i = m.call(o),
76
+ r,
77
+ ar = [],
78
+ e;
79
+
80
+ try {
81
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
82
+ ar.push(r.value);
83
+ }
84
+ } catch (error) {
85
+ e = {
86
+ error: error
87
+ };
88
+ } finally {
89
+ try {
90
+ if (r && !r.done && (m = i["return"])) m.call(i);
91
+ } finally {
92
+ if (e) throw e.error;
93
+ }
94
+ }
95
+
96
+ return ar;
97
+ };
98
+
99
+ var __importDefault = this && this.__importDefault || function (mod) {
100
+ return mod && mod.__esModule ? mod : {
101
+ "default": mod
102
+ };
103
+ };
104
+
105
+ Object.defineProperty(exports, "__esModule", {
106
+ value: true
107
+ }); // @ts-nocheck
108
+
109
+ var React = __importStar(require("react"));
110
+
111
+ var isFunction_1 = __importDefault(require("lodash/isFunction"));
112
+
113
+ var dialog_1 = __importDefault(require("react-vant/lib/dialog"));
114
+
115
+ var ButtonModal = function ButtonModal(props, ref) {
116
+ var _a = __read(React.useState(false), 2),
117
+ visible = _a[0],
118
+ setModalVisible = _a[1];
119
+
120
+ var children = props.children,
121
+ trigger = props.trigger,
122
+ onOpen = props.onOpen,
123
+ onClose = props.onClose,
124
+ onOk = props.onOk,
125
+ onCancel = props.onCancel,
126
+ restModalProps = __rest(props, ["children", "trigger", "onOpen", "onClose", "onOk", "onCancel"]);
127
+
128
+ var openModal = function openModal() {
129
+ if (onOpen) {
130
+ onOpen();
131
+ }
132
+
133
+ setModalVisible(true);
134
+ };
135
+
136
+ var closeModal = function closeModal() {
137
+ if (onClose) {
138
+ onClose();
139
+ }
140
+
141
+ setModalVisible(false);
142
+ };
143
+
144
+ var modalActionRef = React.useRef({
145
+ open: openModal,
146
+ close: closeModal
147
+ });
148
+ React.useImperativeHandle(ref, function () {
149
+ return modalActionRef.current;
150
+ });
151
+
152
+ var handleModalOk = function handleModalOk(e) {
153
+ if (onOk) {
154
+ return onOk(e);
155
+ }
156
+
157
+ closeModal();
158
+ return false;
159
+ };
160
+
161
+ var handleModalCancel = function handleModalCancel(e) {
162
+ if (onCancel) {
163
+ onCancel(e);
164
+ }
165
+
166
+ closeModal();
167
+ };
168
+
169
+ var buttonNode = trigger && React.cloneElement(trigger, {
170
+ onClick: openModal
171
+ });
172
+ return React.createElement(React.Fragment, null, buttonNode, React.createElement(dialog_1["default"], __assign({
173
+ visible: visible,
174
+ onConfirm: handleModalOk,
175
+ onCancel: handleModalCancel,
176
+ centered: true,
177
+ maskClosable: false
178
+ }, restModalProps), (0, isFunction_1["default"])(children) ? children(modalActionRef.current) : React.cloneElement(children, {
179
+ modalAction: modalActionRef.current
180
+ })));
181
+ };
182
+
183
+ var ForwardRefButtonModal = React.forwardRef(ButtonModal);
184
+ exports["default"] = ForwardRefButtonModal;
@@ -0,0 +1 @@
1
+ import 'antd/lib/modal/style';
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ require("antd/lib/modal/style");
package/lib/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export type { ButtonModalProps } from './button-modal';
2
+ export { default as ButtonModal } from './button-modal';
package/lib/index.js ADDED
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ var __importDefault = this && this.__importDefault || function (mod) {
4
+ return mod && mod.__esModule ? mod : {
5
+ "default": mod
6
+ };
7
+ };
8
+
9
+ Object.defineProperty(exports, "__esModule", {
10
+ value: true
11
+ });
12
+ exports.ButtonModal = void 0;
13
+
14
+ var button_modal_1 = require("./button-modal");
15
+
16
+ Object.defineProperty(exports, "ButtonModal", {
17
+ enumerable: true,
18
+ get: function get() {
19
+ return __importDefault(button_modal_1)["default"];
20
+ }
21
+ });
@@ -0,0 +1,4 @@
1
+ @labelTextLabelScale: 0.8;
2
+ @labelTextLabeltranslateY: -8px;
3
+ @pickerInputTop: 9px;
4
+ @labelFocusBorderColor: #000;
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "amssui",
3
+ "version": "1.0.1",
4
+ "description": "react ui library",
5
+ "author": "jason <usochen@gmail.com>",
6
+ "main": "./lib/index.js",
7
+ "module": "./es/index.js",
8
+ "types": "./lib/index.d.ts",
9
+ "unpkg": "dist/assui.js",
10
+ "sideEffects": [
11
+ "dist/*",
12
+ "es/**/style/*",
13
+ "lib/**/style/*",
14
+ "*.less"
15
+ ],
16
+ "authors": {
17
+ "name": "chenjianbin",
18
+ "email": "usochen@gmail.com"
19
+ },
20
+ "repository": "https://github.com/SPOTEC-LTD/ssui",
21
+ "homepage": "https://github.com/SPOTEC-LTD/ssui",
22
+ "scripts": {
23
+ "build": "gulp"
24
+ },
25
+ "files": [
26
+ "dist",
27
+ "lib",
28
+ "es",
29
+ "package.json",
30
+ "README.md"
31
+ ],
32
+ "dependencies": {
33
+ "@ahooksjs/use-url-state": "^2.5.8",
34
+ "a-icons": "^1.0.71",
35
+ "aa-utils": "^2.0.25",
36
+ "ahooks": "^3.0.8",
37
+ "react-vant": "^2.0.0-alpha.41"
38
+ },
39
+ "peerDependencies": {
40
+ "react": "^16.8.6 || ^17.0 || ^18.0"
41
+ },
42
+ "devDependencies": {
43
+ "@types/enzyme": "^3.10.5",
44
+ "jest-websocket-mock": "^2.1.0",
45
+ "mock-socket": "^9.0.3"
46
+ },
47
+ "engines": {
48
+ "node": ">=10.0.0"
49
+ },
50
+ "license": "MIT",
51
+ "gitHead": "50e2603d97efe6f8c3eaf2852011051e1ba60b5b"
52
+ }