@nutui/nutui-react 0.1.0-beta.1 → 0.1.2

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 (167) hide show
  1. package/README.md +50 -135
  2. package/dist/esm/ActionSheet/style/index.js +1 -0
  3. package/dist/esm/Address/style/index.js +1 -0
  4. package/dist/esm/AnimatingNumbers/style/index.js +1 -0
  5. package/dist/esm/Avatar/style/index.js +1 -0
  6. package/dist/esm/BackTop/style/index.js +1 -0
  7. package/dist/esm/BackTop.js +1 -3
  8. package/dist/esm/Badge/style/index.js +1 -0
  9. package/dist/esm/Barrage/style/index.js +1 -0
  10. package/dist/esm/Button/style/index.js +1 -0
  11. package/dist/esm/Button.js +110 -4
  12. package/dist/esm/Calendar/style/index.js +1 -0
  13. package/dist/esm/Calendar.js +86 -0
  14. package/dist/esm/CalendarItem/style/index.js +1 -0
  15. package/dist/esm/CalendarItem.js +554 -0
  16. package/dist/esm/Cell/style/index.js +1 -0
  17. package/dist/esm/Cell.js +1 -1
  18. package/dist/esm/CellGroup/style/index.js +1 -0
  19. package/dist/esm/CellGroup.js +33 -0
  20. package/dist/esm/Checkbox/style/index.js +1 -0
  21. package/dist/esm/Checkbox.js +1 -1
  22. package/dist/esm/CheckboxGroup/style/index.js +1 -0
  23. package/dist/esm/CircleProgress/style/index.js +1 -0
  24. package/dist/esm/Col/style/index.js +1 -0
  25. package/dist/esm/Col.js +60 -0
  26. package/dist/esm/Collapse/style/index.js +1 -0
  27. package/dist/esm/CollapseItem/style/index.js +1 -0
  28. package/dist/esm/CollapseItem.js +142 -0
  29. package/dist/esm/Dialog/style/index.js +1 -0
  30. package/dist/esm/Dialog.js +327 -0
  31. package/dist/esm/Divider/style/index.js +1 -0
  32. package/dist/esm/Drag/style/index.js +1 -0
  33. package/dist/esm/Drag.js +83 -140
  34. package/dist/esm/Elevator/style/index.js +1 -0
  35. package/dist/esm/Elevator.js +3 -6
  36. package/dist/esm/FixedNav/style/index.js +1 -0
  37. package/dist/esm/FixedNav.js +2 -2
  38. package/dist/esm/Icon/style/index.js +1 -0
  39. package/dist/esm/Icon.js +70 -4
  40. package/dist/esm/Infiniteloading/style/index.js +1 -0
  41. package/dist/esm/Input/style/index.js +1 -0
  42. package/dist/esm/Input.js +1 -1
  43. package/dist/esm/InputNumber/style/index.js +1 -0
  44. package/dist/esm/Layout/style/index.js +1 -0
  45. package/dist/esm/NavBar/style/index.js +1 -0
  46. package/dist/esm/NavBar.js +1 -1
  47. package/dist/esm/NoticeBar/style/index.js +1 -0
  48. package/dist/esm/NoticeBar.js +1 -1
  49. package/dist/esm/Notify/style/index.js +1 -0
  50. package/dist/esm/Overlay/style/index.js +1 -0
  51. package/dist/esm/Pagination/style/index.js +1 -0
  52. package/dist/esm/Picker/style/index.js +1 -0
  53. package/dist/esm/Picker.js +397 -0
  54. package/dist/esm/Popover/style/index.js +1 -0
  55. package/dist/esm/Popover.js +299 -0
  56. package/dist/esm/Popup/style/index.js +1 -0
  57. package/dist/esm/Popup.js +0 -3
  58. package/dist/esm/Price/style/index.js +1 -0
  59. package/dist/esm/Radio/style/index.js +1 -0
  60. package/dist/esm/Radio.js +2 -3
  61. package/dist/esm/RadioGroup/style/index.js +1 -0
  62. package/dist/esm/Range/style/index.js +1 -0
  63. package/dist/esm/Range.js +1 -4
  64. package/dist/esm/Rate/style/index.js +1 -0
  65. package/dist/esm/Rate.js +1 -1
  66. package/dist/esm/Row/style/index.js +1 -0
  67. package/dist/esm/Row.js +48 -0
  68. package/dist/esm/ShortPassword/style/index.js +1 -0
  69. package/dist/esm/ShortPassword.js +203 -0
  70. package/dist/esm/Signature/style/index.js +1 -0
  71. package/dist/esm/Signature.js +1 -2
  72. package/dist/esm/Step/style/index.js +1 -0
  73. package/dist/esm/Steps/style/index.js +1 -0
  74. package/dist/esm/Swiper/style/index.js +1 -0
  75. package/dist/esm/Swiper.js +517 -0
  76. package/dist/esm/SwiperItem/style/index.js +1 -0
  77. package/dist/esm/SwiperItem.js +64 -0
  78. package/dist/esm/Switch/style/index.js +1 -0
  79. package/dist/esm/Switch.js +85 -0
  80. package/dist/esm/Tabbar/style/index.js +1 -0
  81. package/dist/esm/Tabbar.js +1 -4
  82. package/dist/esm/TabbarItem/style/index.js +1 -0
  83. package/dist/esm/TabbarItem.js +1 -1
  84. package/dist/esm/Tag/style/index.js +1 -0
  85. package/dist/esm/TextArea/style/index.js +1 -0
  86. package/dist/esm/Toast/style/index.js +1 -0
  87. package/dist/esm/Toast.js +294 -7
  88. package/dist/esm/Uploader/style/index.js +1 -0
  89. package/dist/esm/UserContext-b4181162.js +3 -0
  90. package/dist/esm/UserContext-be8097d2.js +3 -0
  91. package/dist/esm/date-649fe493.js +112 -0
  92. package/dist/esm/nutui-react.es.js +28 -15
  93. package/dist/esm/types/src/packages/calendar/calendar.d.ts +14 -0
  94. package/dist/esm/types/src/packages/calendar/index.d.ts +2 -0
  95. package/dist/esm/types/src/packages/calendaritem/calendaritem.d.ts +17 -0
  96. package/dist/esm/types/src/packages/calendaritem/index.d.ts +2 -0
  97. package/dist/esm/types/src/packages/dialog/Confirm.d.ts +7 -0
  98. package/dist/esm/types/src/packages/dialog/Content.d.ts +10 -0
  99. package/dist/esm/types/src/packages/dialog/DialogWrap.d.ts +11 -0
  100. package/dist/esm/types/src/packages/dialog/DialogWrapper.d.ts +8 -0
  101. package/dist/esm/types/src/packages/dialog/Mask.d.ts +3 -0
  102. package/dist/esm/types/src/packages/dialog/config.d.ts +46 -0
  103. package/dist/esm/types/src/packages/dialog/dialog.d.ts +2 -0
  104. package/dist/esm/types/src/packages/dialog/index.d.ts +2 -0
  105. package/dist/esm/types/src/packages/drag/drag.d.ts +1 -1
  106. package/dist/esm/types/src/packages/nutui.react.build.d.ts +29 -16
  107. package/dist/esm/types/src/packages/nutui.react.d.ts +29 -16
  108. package/dist/esm/types/src/packages/picker/index.d.ts +2 -0
  109. package/dist/esm/types/src/packages/picker/picker.d.ts +19 -0
  110. package/dist/esm/types/src/packages/picker/pickerSlot.d.ts +10 -0
  111. package/dist/esm/types/src/packages/popover/Trigger.d.ts +21 -0
  112. package/dist/esm/types/src/packages/popover/index.d.ts +2 -0
  113. package/dist/esm/types/src/packages/popover/popover.d.ts +13 -0
  114. package/dist/esm/types/src/packages/row/UserContext.d.ts +1 -0
  115. package/dist/esm/types/src/packages/shortpassword/index.d.ts +2 -0
  116. package/dist/esm/types/src/packages/shortpassword/shortpassword.d.ts +21 -0
  117. package/dist/esm/types/src/packages/steps/UserContext.d.ts +1 -0
  118. package/dist/esm/types/src/packages/swiper/UserContext.d.ts +2 -0
  119. package/dist/esm/types/src/packages/swiper/index.d.ts +2 -0
  120. package/dist/esm/types/src/packages/swiper/swiper.d.ts +26 -0
  121. package/dist/esm/types/src/packages/swiperitem/index.d.ts +2 -0
  122. package/dist/esm/types/src/packages/swiperitem/swiperitem.d.ts +7 -0
  123. package/dist/nutui.react.es.js +10683 -4344
  124. package/dist/nutui.react.umd.js +26 -17
  125. package/dist/packages/actionsheet/actionsheet.scss +1 -0
  126. package/dist/packages/address/address.scss +3 -0
  127. package/dist/packages/animatingnumbers/animatingnumbers.scss +1 -1
  128. package/dist/packages/backtop/backtop.scss +1 -0
  129. package/dist/packages/button/button.scss +1 -1
  130. package/dist/packages/calendar/calendar.scss +200 -0
  131. package/dist/packages/calendaritem/calendaritem.scss +191 -0
  132. package/dist/packages/cell/cell.scss +2 -0
  133. package/dist/packages/checkbox/checkbox.scss +1 -1
  134. package/dist/packages/collapse/collapse.scss +1 -1
  135. package/dist/packages/collapseitem/collapseitem.scss +2 -0
  136. package/dist/packages/dialog/dialog.scss +129 -0
  137. package/dist/packages/drag/drag.scss +2 -1
  138. package/dist/packages/fixednav/fixednav.scss +5 -0
  139. package/dist/packages/icon/icon.scss +1 -1
  140. package/dist/packages/infiniteloading/infiniteloading.scss +1 -0
  141. package/dist/packages/input/input.scss +1 -0
  142. package/dist/packages/inputnumber/inputnumber.scss +1 -0
  143. package/dist/packages/navbar/navbar.scss +2 -0
  144. package/dist/packages/noticebar/noticebar.scss +2 -0
  145. package/dist/packages/picker/picker.scss +104 -0
  146. package/dist/packages/popover/popover.scss +142 -0
  147. package/dist/packages/popup/popup.scss +2 -0
  148. package/dist/packages/radio/radio.scss +2 -0
  149. package/dist/packages/range/range.scss +1 -0
  150. package/dist/packages/rate/rate.scss +2 -0
  151. package/dist/packages/shortpassword/shortpassword.scss +115 -0
  152. package/dist/packages/signature/signature.scss +1 -0
  153. package/dist/packages/step/step.scss +1 -0
  154. package/dist/packages/swiper/swiper.scss +45 -0
  155. package/dist/packages/swiperitem/swiperitem.scss +3 -0
  156. package/dist/packages/tabbaritem/{tabbarItem.scss → tabbaritem.scss} +2 -0
  157. package/dist/packages/tag/tag.scss +1 -0
  158. package/dist/packages/toast/toast.scss +2 -0
  159. package/dist/packages/uploader/uploader.scss +2 -0
  160. package/dist/style.css +1 -1
  161. package/dist/style.es.js +1 -1
  162. package/dist/styles/themes/default.scss +26 -16
  163. package/dist/styles/variables.scss +25 -0
  164. package/package.json +16 -5
  165. package/dist/esm/button-345fb015.js +0 -110
  166. package/dist/esm/icon-63c0d58f.js +0 -70
  167. package/dist/esm/toast-420b65b7.js +0 -294
package/dist/style.es.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @nutui/nutui-react v0.1.0-beta.0 Fri Dec 24 2021 15:38:32 GMT+0800 (China Standard Time)
2
+ * @nutui/nutui-react v0.1.2 Thu Jan 06 2022 17:37:34 GMT+0800 (China Standard Time)
3
3
  * (c) 2021 @jdf2e.
4
4
  * Released under the MIT License.
5
5
  */
@@ -2,6 +2,7 @@
2
2
  @import '../../packages/avatar/avatar.scss';
3
3
  @import '../../packages/button/button.scss';
4
4
  @import '../../packages/cell/cell.scss';
5
+ @import '../../packages/cellgroup/cellgroup.scss';
5
6
  @import '../../packages/icon/icon.scss';
6
7
  @import '../../packages/price/price.scss';
7
8
  @import '../../packages/overlay/overlay.scss';
@@ -9,38 +10,47 @@
9
10
  @import '../../packages/layout/layout.scss';
10
11
  @import '../../packages/row/row.scss';
11
12
  @import '../../packages/col/col.scss';
12
- @import '../../packages/drag/drag.scss';
13
- @import '../../packages/collapse/collapse.scss';
14
13
  @import '../../packages/toast/toast.scss';
15
- @import '../../packages/backtop/backtop.scss';
16
- @import '../../packages/range/range.scss';
17
- @import '../../packages/infiniteloading/infiniteloading.scss';
18
- @import '../../packages/steps/steps.scss';
19
- @import '../../packages/step/step.scss';
20
- @import '../../packages/circleprogress/circleprogress.scss';
14
+ @import '../../packages/dialog/dialog.scss';
21
15
  @import '../../packages/popup/popup.scss';
22
16
  @import '../../packages/actionsheet/actionsheet.scss';
17
+ @import '../../packages/picker/picker.scss';
18
+ @import '../../packages/infiniteloading/infiniteloading.scss';
19
+ @import '../../packages/popover/popover.scss';
20
+ @import '../../packages/collapse/collapse.scss';
21
+ @import '../../packages/collapseitem/collapseitem.scss';
22
+ @import '../../packages/range/range.scss';
23
+ @import '../../packages/circleprogress/circleprogress.scss';
23
24
  @import '../../packages/noticebar/noticebar.scss';
24
25
  @import '../../packages/notify/notify.scss';
25
- @import '../../packages/collapseitem/collapseitem.scss';
26
+ @import '../../packages/switch/switch.scss';
26
27
  @import '../../packages/navbar/navbar.scss';
27
28
  @import '../../packages/tabbar/tabbar.scss';
28
29
  @import '../../packages/tabbaritem/tabbaritem.scss';
29
- @import '../../packages/inputnumber/inputnumber.scss';
30
30
  @import '../../packages/elevator/elevator.scss';
31
31
  @import '../../packages/fixednav/fixednav.scss';
32
32
  @import '../../packages/pagination/pagination.scss';
33
+ @import '../../packages/steps/steps.scss';
34
+ @import '../../packages/step/step.scss';
35
+ @import '../../packages/swiper/swiper.scss';
36
+ @import '../../packages/swiperitem/swiperitem.scss';
37
+ @import '../../packages/backtop/backtop.scss';
33
38
  @import '../../packages/rate/rate.scss';
34
- @import '../../packages/uploader/uploader.scss';
35
39
  @import '../../packages/input/input.scss';
36
40
  @import '../../packages/textarea/textarea.scss';
41
+ @import '../../packages/inputnumber/inputnumber.scss';
42
+ @import '../../packages/shortpassword/shortpassword.scss';
43
+ @import '../../packages/radio/radio.scss';
44
+ @import '../../packages/radiogroup/radiogroup.scss';
37
45
  @import '../../packages/checkbox/checkbox.scss';
38
46
  @import '../../packages/checkboxgroup/checkboxgroup.scss';
39
47
  @import '../../packages/tag/tag.scss';
40
48
  @import '../../packages/badge/badge.scss';
41
- @import '../../packages/animatingnumbers/animatingnumbers.scss';
42
- @import '../../packages/radio/radio.scss';
43
- @import '../../packages/radiogroup/radiogroup.scss';
44
- @import '../../packages/signature/signature.scss';
45
- @import '../../packages/barrage/barrage.scss';
49
+ @import '../../packages/uploader/uploader.scss';
50
+ @import '../../packages/calendar/calendar.scss';
51
+ @import '../../packages/calendaritem/calendaritem.scss';
46
52
  @import '../../packages/address/address.scss';
53
+ @import '../../packages/barrage/barrage.scss';
54
+ @import '../../packages/signature/signature.scss';
55
+ @import '../../packages/drag/drag.scss';
56
+ @import '../../packages/animatingnumbers/animatingnumbers.scss';
@@ -306,6 +306,13 @@ $badge-background-color: linear-gradient(
306
306
  $badge-font-size: $font-size-1 !default;
307
307
  $badge-default-background-color: rgba(255, 255, 255, 1) !default;
308
308
 
309
+ //popover
310
+ $popover-white-background-color: rgba(255, 255, 255, 1) !default;
311
+ $popover-dark-background-color: rgba(75, 76, 77, 1) !default;
312
+ $popover-border-bottom-color: rgba(229, 229, 229, 1) !default;
313
+ $popover-primary-text-color: rgba(51, 51, 51, 1) !default;
314
+ $popover-disable-color: rgba(154, 155, 157, 1) !default;
315
+
309
316
  //pagination
310
317
  $pagination-color: $primary-color !default;
311
318
  $pagination-font-size: $font-size-2 !default;
@@ -322,5 +329,23 @@ $pagination-disable-background-color: #f7f8fa !default;
322
329
  $pagination-item-border-width: 1px !default;
323
330
  $pagination-item-border-radius: 2px !default;
324
331
  $pagination-prev-next-padding: 0 11px !default;
332
+
333
+ // dialog
334
+ $dialog-min-height: 156px !default;
335
+ $dialog-padding: 28px 24px 16px 24px !default;
336
+ $dialog-header-height: 20px !default;
337
+ $dialog-header-color: rgba(38, 38, 38, 1) !default;
338
+ $dialog-content-margin: 20px 0 !default;
339
+ $dialog-content-max-height: 268px !default;
340
+ $dialog-content-line-height: 16px !default;
341
+ $dialog-mask-z-index: 1050 !default;
342
+ $dialog-mask-background-color: rgba($black, 0.7) !default;
343
+ $dialog-outer-z-index: 2000 !default;
344
+ $dialog-outer-bordder-radius: 20px !default;
345
+ $dialog-vertical-footer-ok-margin-top: 10px !default;
346
+ $dialog-footer-button-min-width: 100px !default;
347
+ $dialog-footer-cancel-margin-right: 20px !default;
348
+ $dialog-footer-ok-max-width: 128px !default;
349
+
325
350
  @import './mixins/index';
326
351
  @import './animation/index';
package/package.json CHANGED
@@ -1,14 +1,16 @@
1
1
  {
2
2
  "name": "@nutui/nutui-react",
3
- "version": "0.1.0-beta.1",
3
+ "version": "0.1.2",
4
4
  "style": "dist/style.css",
5
5
  "main": "dist/nutui.react.umd.js",
6
6
  "module": "dist/esm/nutui-react.es.js",
7
7
  "typings": "dist/esm/types/src/packages/nutui.react.d.ts",
8
8
  "sideEffects": [
9
9
  "*.scss",
10
+ "dist/esm/**/style/*",
10
11
  "dist/style.css"
11
12
  ],
13
+ "description": "京东风格的轻量级移动端 React 组件库",
12
14
  "keywords": [
13
15
  "nutui",
14
16
  "nutui2",
@@ -37,6 +39,7 @@
37
39
  "add": "node scripts/createComponentMode.js",
38
40
  "generate:types": "tsc && npm run replace:types",
39
41
  "generate:file": "node scripts/generate-nutui.js",
42
+ "generate:loader-style": "node scripts/generate-loader-style.js",
40
43
  "replace:scss": "node scripts/replace-scss.js",
41
44
  "replace:types": "node scripts/replace-types.js",
42
45
  "generate:themes": "node scripts/generate-themes.js",
@@ -45,9 +48,9 @@
45
48
  "build:css": "npm run generate:themes && vite build --config vite.config.build.css.ts && npm run build:replace",
46
49
  "build:replace": "npm run replace:scss",
47
50
  "build:esm": "npx rollup -c rollup.config.es.js",
48
- "build": "npm run checked && vite build --config vite.config.build.ts && npm run build:esm && npm run build:css && npm run generate:types ",
51
+ "build": "npm run checked && vite build --config vite.config.build.ts && npm run build:esm && npm run build:css && npm run generate:types && npm run generate:loader-style",
49
52
  "build:site": "npm run checked && vite build --config vite.config.build.site.ts",
50
- "publish:beta": "npm publish --tag=beta",
53
+ "publish:beta": "npm publish --tag beta",
51
54
  "prepare": "husky install"
52
55
  },
53
56
  "lint-staged": {
@@ -59,6 +62,8 @@
59
62
  "dependencies": {
60
63
  "@babel/runtime": "^7.16.5",
61
64
  "@bem-react/classname": "^1.5.10",
65
+ "@react-spring/web": "^9.3.2",
66
+ "@use-gesture/react": "^10.2.4",
62
67
  "classnames": "^2.3.1",
63
68
  "react-router-dom": "^5.2.0",
64
69
  "react-transition-group": "^4.4.2"
@@ -83,6 +88,7 @@
83
88
  "@types/react": "^17.0.0",
84
89
  "@types/react-dom": "^17.0.0",
85
90
  "@types/react-router-dom": "^5.1.7",
91
+ "@types/react-syntax-highlighter": "^13.5.2",
86
92
  "@types/react-transition-group": "^4.4.4",
87
93
  "@typescript-eslint/eslint-plugin": "^4.24.0",
88
94
  "@typescript-eslint/parser": "^4.24.0",
@@ -103,6 +109,7 @@
103
109
  "husky": "^6.0.0",
104
110
  "inquirer": "^8.0.0",
105
111
  "lint-staged": "^11.0.0",
112
+ "lzutf8": "^0.6.0",
106
113
  "map-stream": "0.0.7",
107
114
  "marked": "^2.0.3",
108
115
  "postcss-import": "^14.0.2",
@@ -110,11 +117,15 @@
110
117
  "prettier": "2.3.0",
111
118
  "react": "^17.0.0",
112
119
  "react-dom": "^17.0.0",
120
+ "react-markdown": "^7.1.2",
121
+ "react-syntax-highlighter": "^15.4.5",
122
+ "remark-directive": "^2.0.1",
123
+ "remark-gfm": "^3.0.1",
113
124
  "sass": "^1.45.0",
114
125
  "shelljs": "^0.8.4",
115
126
  "typescript": "^4.1.2",
127
+ "unist-util-visit": "^4.1.0",
116
128
  "vinyl-fs": "^3.0.3",
117
- "vite": "^2.1.5",
118
- "vite-plugin-markdown": "^2.0.2"
129
+ "vite": "^2.1.5"
119
130
  }
120
131
  }
@@ -1,110 +0,0 @@
1
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
- import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
- var _excluded = ["color", "shape", "plain", "loading", "disabled", "type", "size", "block", "icon", "children", "onClick", "className", "style"];
5
-
6
- 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; }
7
-
8
- 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; }
9
-
10
- import React__default, { useState, useEffect } from 'react';
11
- import Icon from './Icon.js';
12
- var defaultProps = {
13
- className: '',
14
- color: '',
15
- shape: 'round',
16
- plain: false,
17
- loading: false,
18
- disabled: false,
19
- type: 'default',
20
- size: 'normal',
21
- block: false,
22
- icon: '',
23
- style: {},
24
- children: undefined,
25
- onClick: function onClick(e) {}
26
- };
27
-
28
- var Button = function Button(props) {
29
- var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
30
- color = _defaultProps$props.color,
31
- shape = _defaultProps$props.shape,
32
- plain = _defaultProps$props.plain,
33
- loading = _defaultProps$props.loading,
34
- disabled = _defaultProps$props.disabled,
35
- type = _defaultProps$props.type,
36
- size = _defaultProps$props.size,
37
- block = _defaultProps$props.block,
38
- icon = _defaultProps$props.icon,
39
- children = _defaultProps$props.children,
40
- onClick = _defaultProps$props.onClick,
41
- className = _defaultProps$props.className,
42
- style = _defaultProps$props.style,
43
- rest = _objectWithoutProperties(_defaultProps$props, _excluded);
44
-
45
- var _useState = useState(''),
46
- _useState2 = _slicedToArray(_useState, 2),
47
- btnName = _useState2[0],
48
- setBtnName = _useState2[1];
49
-
50
- var _useState3 = useState({}),
51
- _useState4 = _slicedToArray(_useState3, 2),
52
- btnStyle = _useState4[0],
53
- setBtnStyle = _useState4[1];
54
-
55
- useEffect(function () {
56
- setBtnName(classes());
57
- setBtnStyle(getStyle());
58
- }, [className, color, shape, plain, loading, disabled, style, type, size, block, icon, children, onClick]);
59
-
60
- var classes = function classes() {
61
- var prefixCls = 'nut-button';
62
- return "".concat(prefixCls, " ").concat(type ? "".concat(prefixCls, "--").concat(type) : '', "\n ").concat(size ? "".concat(prefixCls, "--").concat(size) : '', "\n ").concat(shape ? "".concat(prefixCls, "--").concat(shape) : '', "\n ").concat(plain ? "".concat(prefixCls, "--plain") : '', "\n ").concat(block ? "".concat(prefixCls, "--block") : '', "\n ").concat(disabled ? "".concat(prefixCls, "--disabled") : '', "\n ").concat(loading ? "".concat(prefixCls, "--loading") : '');
63
- };
64
-
65
- var handleClick = function handleClick(e) {
66
- if (!loading && !disabled && onClick) {
67
- onClick(e);
68
- }
69
- };
70
-
71
- var getStyle = function getStyle() {
72
- var style = {};
73
-
74
- if (color) {
75
- if (plain) {
76
- style.color = color;
77
- style.background = '#fff';
78
-
79
- if (!(color !== null && color !== void 0 && color.includes('gradient'))) {
80
- style.borderColor = color;
81
- }
82
- } else {
83
- style.color = '#fff';
84
- style.background = color;
85
- }
86
- }
87
-
88
- return style;
89
- };
90
-
91
- return React__default.createElement("div", _objectSpread(_objectSpread({
92
- className: "".concat(btnName, " ").concat(className),
93
- style: _objectSpread(_objectSpread({}, btnStyle), style)
94
- }, rest), {}, {
95
- onClick: function onClick(e) {
96
- return handleClick(e);
97
- }
98
- }), React__default.createElement("div", {
99
- className: "nut-button__warp",
100
- style: getStyle()
101
- }, loading && React__default.createElement(Icon, {
102
- name: "loading"
103
- }), !loading && icon ? React__default.createElement(Icon, {
104
- name: icon
105
- }) : '', children));
106
- };
107
-
108
- Button.defaultProps = defaultProps;
109
- Button.displayName = 'NutButton';
110
- export { Button as B };
@@ -1,70 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["name", "size", "classPrefix", "color", "tag", "children", "className", "style", "click"];
4
-
5
- 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; }
6
-
7
- 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; }
8
-
9
- import React__default from 'react';
10
- import { c as cn } from './bem-893ad28d.js';
11
- var defaultProps = {
12
- name: '',
13
- size: '',
14
- classPrefix: 'nutui-iconfont',
15
- color: '',
16
- tag: 'i',
17
- click: function click(e) {},
18
- className: ''
19
- };
20
-
21
- function pxCheck(value) {
22
- return Number.isNaN(Number(value)) ? String(value) : "".concat(value, "px");
23
- }
24
-
25
- var Icon = function Icon(props) {
26
- var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
27
- name = _defaultProps$props.name,
28
- size = _defaultProps$props.size,
29
- classPrefix = _defaultProps$props.classPrefix,
30
- color = _defaultProps$props.color,
31
- tag = _defaultProps$props.tag,
32
- children = _defaultProps$props.children,
33
- className = _defaultProps$props.className,
34
- style = _defaultProps$props.style,
35
- click = _defaultProps$props.click,
36
- rest = _objectWithoutProperties(_defaultProps$props, _excluded);
37
-
38
- var isImage = name ? name.indexOf('/') !== -1 : false;
39
- var type = isImage ? 'img' : tag;
40
- var b = cn('icon');
41
-
42
- var handleClick = function handleClick(e) {
43
- if (props.click) {
44
- props.click(e);
45
- }
46
- };
47
-
48
- var hasSrc = function hasSrc() {
49
- if (isImage) return {
50
- src: name
51
- };
52
- return {};
53
- };
54
-
55
- return React__default.createElement(type, _objectSpread(_objectSpread({
56
- className: isImage ? "".concat(className || '', " ").concat(b('img')) : "".concat(className || '', " ").concat(b(null, [classPrefix]), " nut-icon-").concat(name, " "),
57
- style: _objectSpread({
58
- color: color,
59
- fontSize: pxCheck(size),
60
- width: pxCheck(size),
61
- height: pxCheck(size)
62
- }, style)
63
- }, rest), {}, {
64
- onClick: handleClick
65
- }, hasSrc()), children);
66
- };
67
-
68
- Icon.defaultProps = defaultProps;
69
- Icon.displayName = 'NutIcon';
70
- export { Icon as I };
@@ -1,294 +0,0 @@
1
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/createClass";
3
- import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
4
- import _inherits from "@babel/runtime/helpers/inherits";
5
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
-
9
- 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; }
10
-
11
- 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; }
12
-
13
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
14
-
15
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
16
-
17
- import * as React from 'react';
18
- import * as ReactDOM from 'react-dom';
19
- import { c as cn } from './bem-893ad28d.js';
20
- import { I as Icon } from './icon-63c0d58f.js';
21
- import classNames from 'classnames';
22
-
23
- var Notification = /*#__PURE__*/function (_React$PureComponent) {
24
- _inherits(Notification, _React$PureComponent);
25
-
26
- var _super = _createSuper(Notification);
27
-
28
- function Notification(props) {
29
- var _this;
30
-
31
- _classCallCheck(this, Notification);
32
-
33
- _this = _super.call(this, props);
34
-
35
- _defineProperty(_assertThisInitialized(_this), "closeTimer", void 0);
36
-
37
- _this.close = _this.close.bind(_assertThisInitialized(_this));
38
- _this.startCloseTimer = _this.startCloseTimer.bind(_assertThisInitialized(_this));
39
- _this.clearCloseTimer = _this.clearCloseTimer.bind(_assertThisInitialized(_this));
40
- _this.close = _this.close.bind(_assertThisInitialized(_this));
41
- _this.clickCover = _this.clickCover.bind(_assertThisInitialized(_this));
42
- _this.state = {
43
- show: true
44
- };
45
- return _this;
46
- }
47
-
48
- _createClass(Notification, [{
49
- key: "close",
50
- value: function close() {
51
- this.setState({
52
- show: false
53
- });
54
- this.clearCloseTimer();
55
- this.props.onClose();
56
- }
57
- }, {
58
- key: "startCloseTimer",
59
- value: function startCloseTimer() {
60
- var _this2 = this;
61
-
62
- var duration = this.props.duration;
63
-
64
- if (duration) {
65
- this.closeTimer = window.setTimeout(function () {
66
- _this2.close();
67
- }, duration * 1000);
68
- }
69
- }
70
- }, {
71
- key: "clearCloseTimer",
72
- value: function clearCloseTimer() {
73
- if (this.closeTimer) {
74
- clearTimeout(this.closeTimer);
75
- this.closeTimer = -1;
76
- }
77
- }
78
- }, {
79
- key: "clickCover",
80
- value: function clickCover() {
81
- var closeOnClickOverlay = this.props.closeOnClickOverlay;
82
-
83
- if (closeOnClickOverlay) {
84
- this.close();
85
- }
86
- }
87
- }, {
88
- key: "componentDidMount",
89
- value: function componentDidMount() {
90
- this.startCloseTimer();
91
- }
92
- }, {
93
- key: "componentWillUnmount",
94
- value: function componentWillUnmount() {
95
- this.clearCloseTimer();
96
- }
97
- }, {
98
- key: "render",
99
- value: function render() {
100
- var _classNames,
101
- _this3 = this;
102
-
103
- var _this$props = this.props,
104
- style = _this$props.style,
105
- icon = _this$props.icon,
106
- msg = _this$props.msg,
107
- bottom = _this$props.bottom,
108
- center = _this$props.center,
109
- bgColor = _this$props.bgColor,
110
- coverColor = _this$props.coverColor,
111
- textAlignCenter = _this$props.textAlignCenter,
112
- size = _this$props.size,
113
- customClass = _this$props.customClass,
114
- cover = _this$props.cover,
115
- type = _this$props.type;
116
- this.state;
117
- var toastBem = cn('toast');
118
- var classes = classNames((_classNames = {}, _defineProperty(_classNames, 'nut-toast-center', center), _defineProperty(_classNames, 'nut-toast-has-icon', icon), _defineProperty(_classNames, 'nut-toast-cover', cover), _defineProperty(_classNames, 'nut-toast-loading', type === 'loading'), _defineProperty(_classNames, "customClass", customClass), _defineProperty(_classNames, 'nut-toast-' + size, true), _classNames));
119
- return React.createElement(React.Fragment, null, React.createElement("div", {
120
- className: "".concat(toastBem(), " ").concat(classes),
121
- style: {
122
- bottom: center ? 'auto' : bottom + 'px',
123
- backgroundColor: cover ? coverColor : ''
124
- },
125
- onClick: function onClick() {
126
- _this3.clickCover();
127
- }
128
- }, React.createElement("div", {
129
- className: toastBem('inner'),
130
- style: {
131
- textAlign: textAlignCenter ? 'center' : 'left',
132
- backgroundColor: bgColor
133
- }
134
- }, icon ? React.createElement("p", {
135
- className: toastBem('icon-wrapper')
136
- }, React.createElement(Icon, {
137
- name: icon ? icon : '',
138
- size: "20"
139
- })) : null, React.createElement("span", {
140
- className: toastBem('text')
141
- }, msg))));
142
- }
143
- }]);
144
-
145
- return Notification;
146
- }(React.PureComponent);
147
-
148
- _defineProperty(Notification, "newInstance", void 0);
149
-
150
- Notification.newInstance = function (properties, callback) {
151
- var element = document.createElement('div');
152
-
153
- if (properties.id) {
154
- element.setAttribute('id', "".concat(properties.id));
155
- }
156
-
157
- document.body.appendChild(element);
158
- var called = false;
159
-
160
- function ref(instance) {
161
- if (called) {
162
- return;
163
- }
164
-
165
- called = true;
166
- callback({
167
- component: instance,
168
- destroy: function destroy() {
169
- ReactDOM.unmountComponentAtNode(element);
170
- element && element.parentNode && element.parentNode.removeChild(element);
171
- }
172
- });
173
- }
174
-
175
- ReactDOM.render(React.createElement(Notification, _objectSpread(_objectSpread({}, properties), {}, {
176
- ref: ref
177
- })), element);
178
- };
179
-
180
- var messageInstance = null;
181
- var options = {
182
- msg: '',
183
- id: '',
184
- duration: 1.5,
185
- center: true,
186
- type: 'text',
187
- customClass: '',
188
- bottom: 30,
189
- size: 'base',
190
- icon: '',
191
- textAlignCenter: true,
192
- loadingRotate: true,
193
- bgColor: 'rgba(0, 0, 0, .8)',
194
- onClose: function onClose() {},
195
- cover: false,
196
- coverColor: 'rgba(0, 0, 0, 0)',
197
- closeOnClickOverlay: false // 是否点击遮罩可关闭
198
-
199
- };
200
-
201
- function getInstance(props, callback) {
202
- if (messageInstance) {
203
- messageInstance.destroy();
204
- messageInstance = null;
205
- }
206
-
207
- Notification.newInstance(props, function (notification) {
208
- return callback && callback(notification);
209
- });
210
- }
211
-
212
- function notice(opts) {
213
- function close() {
214
- if (messageInstance) {
215
- messageInstance.destroy();
216
- messageInstance = null;
217
- }
218
- }
219
-
220
- opts = _objectSpread(_objectSpread(_objectSpread({}, options), opts), {}, {
221
- onClose: close
222
- });
223
- getInstance(opts, function (notification) {
224
- messageInstance = notification;
225
- });
226
- }
227
-
228
- var errorMsg = function errorMsg(msg) {
229
- if (!msg) {
230
- console.warn('[NutUI Toast]: msg不能为空');
231
- return;
232
- }
233
- };
234
-
235
- var Toast = {
236
- text: function text(msg) {
237
- var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
238
- errorMsg(msg);
239
- return notice(_objectSpread({
240
- msg: msg,
241
- type: 'text'
242
- }, option));
243
- },
244
- success: function success(msg) {
245
- var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
246
- errorMsg(msg);
247
- return notice(_objectSpread({
248
- msg: msg,
249
- icon: 'success',
250
- type: 'success'
251
- }, option));
252
- },
253
- fail: function fail(msg) {
254
- var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
255
- errorMsg(msg);
256
- return notice(_objectSpread({
257
- msg: msg,
258
- icon: 'failure',
259
- type: 'fail'
260
- }, option));
261
- },
262
- loading: function loading(msg) {
263
- var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
264
- errorMsg(msg);
265
- return notice(_objectSpread({
266
- msg: msg,
267
- icon: 'loading',
268
- type: 'loading'
269
- }, option));
270
- },
271
- warn: function warn(msg) {
272
- var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
273
- errorMsg(msg);
274
- return notice(_objectSpread({
275
- msg: msg,
276
- icon: 'tips',
277
- type: 'warn'
278
- }, option));
279
- },
280
- customIcon: function customIcon(msg) {
281
- var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
282
- errorMsg(msg);
283
- return notice(_objectSpread({
284
- msg: msg
285
- }, option));
286
- },
287
- hide: function hide() {
288
- if (messageInstance) {
289
- messageInstance.destroy();
290
- messageInstance = null;
291
- }
292
- }
293
- };
294
- export { Toast as T };