@trionesdev/antd-taro-react 0.0.2-beta.2 → 0.0.2-beta.20

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 (179) hide show
  1. package/LICENSE +21 -21
  2. package/dist/ActionSheet/ActionSheet.d.ts +25 -0
  3. package/dist/ActionSheet/ActionSheet.js +77 -0
  4. package/dist/ActionSheet/index.d.ts +1 -1
  5. package/dist/ActionSheet/index.js +1 -1
  6. package/dist/ActionSheet/style.scss +52 -0
  7. package/dist/Button/button.d.ts +2 -1
  8. package/dist/Button/button.js +2 -3
  9. package/dist/Button/style.scss +246 -231
  10. package/dist/Calendar/calendar-grid.d.ts +10 -9
  11. package/dist/Calendar/calendar-grid.js +37 -62
  12. package/dist/Calendar/calendar-header.d.ts +3 -2
  13. package/dist/Calendar/calendar-header.js +9 -6
  14. package/dist/Calendar/calendar-range.d.ts +4 -3
  15. package/dist/Calendar/calendar-range.js +22 -18
  16. package/dist/Calendar/calendar.d.ts +5 -4
  17. package/dist/Calendar/calendar.js +30 -17
  18. package/dist/Calendar/style.scss +88 -85
  19. package/dist/Calendar/touchable-calendar-grid.d.ts +6 -5
  20. package/dist/Calendar/touchable-calendar-grid.js +96 -95
  21. package/dist/CalendarDatetimePicker/CalendarDatetimePicker.d.ts +3 -2
  22. package/dist/CalendarDatetimePicker/CalendarDatetimePicker.js +40 -57
  23. package/dist/CalendarDatetimePicker/DateTimeSwitch.d.ts +3 -2
  24. package/dist/CalendarDatetimePicker/DateTimeSwitch.js +2 -2
  25. package/dist/CalendarDatetimePicker/style.scss +62 -54
  26. package/dist/CalendarDatetimePickerCell/CalendarDatetimePickerCell.d.ts +9 -0
  27. package/dist/CalendarDatetimePickerCell/CalendarDatetimePickerCell.js +60 -0
  28. package/dist/CalendarDatetimePickerCell/index.d.ts +3 -0
  29. package/dist/CalendarDatetimePickerCell/index.js +2 -0
  30. package/dist/CalendarPicker/{calendar-picker.js → CalendarPicker.js} +10 -6
  31. package/dist/CalendarPicker/{calendar-range-picker.js → CalendarRangePicker.js} +8 -6
  32. package/dist/CalendarPicker/index.d.ts +3 -4
  33. package/dist/CalendarPicker/index.js +2 -2
  34. package/dist/CalendarPicker/style.scss +32 -31
  35. package/dist/CalendarPicker/types.d.ts +8 -6
  36. package/dist/CalendarPicker/types.js +1 -1
  37. package/dist/CalendarPickerCell/CalendarPickerCell.d.ts +11 -0
  38. package/dist/CalendarPickerCell/CalendarPickerCell.js +54 -0
  39. package/dist/CalendarPickerCell/CalendarRangePickerCell.d.ts +11 -0
  40. package/dist/CalendarPickerCell/CalendarRangePickerCell.js +56 -0
  41. package/dist/CalendarPickerCell/index.d.ts +8 -0
  42. package/dist/CalendarPickerCell/index.js +5 -0
  43. package/dist/CascaderPicker/cascader-picker.d.ts +27 -0
  44. package/dist/CascaderPicker/cascader-picker.js +90 -0
  45. package/dist/CascaderPicker/index.d.ts +1 -1
  46. package/dist/CascaderPicker/index.js +1 -1
  47. package/dist/CascaderPicker/style.scss +45 -0
  48. package/dist/CascaderPickerCell/CascaderPickerCell.d.ts +20 -0
  49. package/dist/CascaderPickerCell/CascaderPickerCell.js +70 -0
  50. package/dist/CascaderPickerCell/index.d.ts +3 -0
  51. package/dist/CascaderPickerCell/index.js +2 -0
  52. package/dist/DatePicker/DatePicker.d.ts +18 -0
  53. package/dist/DatePicker/DatePicker.js +310 -0
  54. package/dist/DatePicker/index.d.ts +4 -0
  55. package/dist/DatePicker/index.js +3 -0
  56. package/dist/DatePicker/style.scss +41 -0
  57. package/dist/DatePicker/types.d.ts +1 -0
  58. package/dist/DatePicker/types.js +1 -0
  59. package/dist/DatePickerCell/DatePickerCell.d.ts +16 -0
  60. package/dist/DatePickerCell/DatePickerCell.js +78 -0
  61. package/dist/DatePickerCell/index.d.ts +3 -0
  62. package/dist/DatePickerCell/index.js +2 -0
  63. package/dist/FetchPicker/FetchPicker.d.ts +78 -0
  64. package/dist/FetchPicker/FetchPicker.js +310 -0
  65. package/dist/FetchPicker/index.d.ts +4 -0
  66. package/dist/FetchPicker/index.js +3 -0
  67. package/dist/FetchPicker/styles.scss +130 -0
  68. package/dist/FloatButton/FloatButton.d.ts +19 -0
  69. package/dist/FloatButton/FloatButton.js +60 -0
  70. package/dist/FloatButton/FloatButtonGroup.d.ts +21 -0
  71. package/dist/FloatButton/FloatButtonGroup.js +141 -0
  72. package/dist/FloatButton/context.d.ts +10 -0
  73. package/dist/FloatButton/context.js +2 -0
  74. package/dist/FloatButton/index.d.ts +10 -0
  75. package/dist/FloatButton/index.js +5 -0
  76. package/dist/FloatButton/style.scss +126 -0
  77. package/dist/Form/FormItem/form-item-content.d.ts +17 -0
  78. package/dist/Form/FormItem/form-item-content.js +39 -0
  79. package/dist/Form/FormItem/form-item-label.d.ts +13 -0
  80. package/dist/Form/FormItem/form-item-label.js +29 -0
  81. package/dist/Form/FormItem/form-item.d.ts +23 -0
  82. package/dist/Form/FormItem/form-item.js +77 -0
  83. package/dist/Form/FormItem/index.d.ts +5 -0
  84. package/dist/Form/FormItem/index.js +3 -0
  85. package/dist/Form/index.d.ts +9 -2
  86. package/dist/Form/index.js +5 -1
  87. package/dist/Form/style.scss +100 -0
  88. package/dist/FormCell/index.d.ts +3 -0
  89. package/dist/FormCell/index.js +2 -0
  90. package/dist/ImagesPreview/ImagesPreview.js +4 -3
  91. package/dist/ImagesPreview/style.scss +34 -34
  92. package/dist/ImagesWall/ImagesWall.js +1 -1
  93. package/dist/ImagesWall/style.scss +70 -70
  94. package/dist/Input/index.d.ts +17 -2
  95. package/dist/Input/index.js +13 -1
  96. package/dist/Input/index.scss +282 -0
  97. package/dist/Input/input-affix-wrapper.d.ts +13 -0
  98. package/dist/Input/input-affix-wrapper.js +37 -0
  99. package/dist/Input/input-digit.d.ts +7 -0
  100. package/dist/Input/input-digit.js +53 -0
  101. package/dist/Input/input-number.d.ts +7 -0
  102. package/dist/Input/input-number.js +50 -0
  103. package/dist/Input/input-opt.d.ts +16 -0
  104. package/dist/Input/input-opt.js +87 -0
  105. package/dist/Input/input-password.d.ts +8 -0
  106. package/dist/Input/input-password.js +49 -0
  107. package/dist/Input/input.d.ts +3 -0
  108. package/dist/Input/input.js +7 -0
  109. package/dist/Input/taro-input.d.ts +8 -0
  110. package/dist/Input/taro-input.js +70 -0
  111. package/dist/Input/textarea.d.ts +15 -0
  112. package/dist/Input/textarea.js +52 -0
  113. package/dist/Input/types.d.ts +20 -0
  114. package/dist/Input/types.js +2 -0
  115. package/dist/Loading/index.d.ts +4 -0
  116. package/dist/Loading/index.js +3 -0
  117. package/dist/Overlay/Overlay.d.ts +17 -0
  118. package/dist/Overlay/Overlay.js +100 -0
  119. package/dist/Overlay/index.d.ts +4 -0
  120. package/dist/Overlay/index.js +3 -0
  121. package/dist/Overlay/style.scss +20 -0
  122. package/dist/Picker/Picker.d.ts +27 -0
  123. package/dist/Picker/Picker.js +100 -0
  124. package/dist/Picker/index.d.ts +1 -1
  125. package/dist/Picker/index.js +1 -1
  126. package/dist/Picker/style.scss +41 -0
  127. package/dist/PickerView/PickerView.d.ts +4 -0
  128. package/dist/PickerView/PickerView.js +71 -0
  129. package/dist/PickerView/index.d.ts +2 -2
  130. package/dist/PickerView/index.js +1 -1
  131. package/dist/PickerView/style.scss +13 -0
  132. package/dist/PickerView/types.d.ts +15 -0
  133. package/dist/PickerView/types.js +1 -0
  134. package/dist/Popup/Popup.d.ts +48 -0
  135. package/dist/Popup/Popup.js +135 -0
  136. package/dist/Popup/index.d.ts +2 -1
  137. package/dist/Popup/index.js +2 -1
  138. package/dist/Popup/style.scss +126 -0
  139. package/dist/Progress/index.d.ts +1 -1
  140. package/dist/Progress/index.js +1 -1
  141. package/dist/Segmented/index.d.ts +3 -0
  142. package/dist/Segmented/index.js +2 -0
  143. package/dist/SideBar/side-bar.js +9 -8
  144. package/dist/SideBar/style.scss +85 -85
  145. package/dist/Stepper/index.d.ts +3 -0
  146. package/dist/Stepper/index.js +2 -0
  147. package/dist/Toast/Toast.d.ts +18 -0
  148. package/dist/Toast/Toast.js +112 -0
  149. package/dist/Toast/index.d.ts +1 -1
  150. package/dist/Toast/index.js +1 -1
  151. package/dist/Toast/style.scss +63 -0
  152. package/dist/VerificationCodeInput/index.d.ts +2 -2
  153. package/dist/VerificationCodeInput/index.js +1 -1
  154. package/dist/VerificationCodeInput/style.scss +20 -0
  155. package/dist/VerificationCodeInput/verification-code-input.d.ts +24 -0
  156. package/dist/VerificationCodeInput/verification-code-input.js +99 -0
  157. package/dist/index.d.ts +28 -7
  158. package/dist/index.js +12 -2
  159. package/dist/style/variable.scss +34 -1
  160. package/dist/types.d.ts +0 -1
  161. package/dist/utils/dayjs.d.ts +4 -0
  162. package/dist/utils/dayjs.js +42 -0
  163. package/package.json +25 -30
  164. package/readme.md +23 -23
  165. package/dist/Mask/index.d.ts +0 -3
  166. package/dist/Mask/index.js +0 -2
  167. package/dist/Progress/Progress.d.ts +0 -38
  168. package/dist/Progress/Progress.js +0 -53
  169. package/dist/Progress/ProgressCircle.d.ts +0 -16
  170. package/dist/Progress/ProgressCircle.js +0 -147
  171. package/dist/Progress/ProgressLine.d.ts +0 -15
  172. package/dist/Progress/ProgressLine.js +0 -87
  173. package/dist/Progress/style.scss +0 -33
  174. package/dist/Progress/types.d.ts +0 -4
  175. package/dist/Progress/types.js +0 -2
  176. package/dist/SpinLoading/index.d.ts +0 -3
  177. package/dist/SpinLoading/index.js +0 -2
  178. /package/dist/CalendarPicker/{calendar-picker.d.ts → CalendarPicker.d.ts} +0 -0
  179. /package/dist/CalendarPicker/{calendar-range-picker.d.ts → CalendarRangePicker.d.ts} +0 -0
@@ -0,0 +1,90 @@
1
+ import classNames from 'classnames';
2
+ import { isEqual } from 'lodash-es';
3
+ import React, { useEffect, useRef } from 'react';
4
+ import CascaderView from "../CascaderView";
5
+ import ConfigProvider from "../ConfigProvider";
6
+ import Popup from "../Popup";
7
+ import "./style.scss";
8
+ var cascaderPickerCls = 'triones-antm-cascader-picker';
9
+ export var CascaderPicker = /*#__PURE__*/React.memo(function (_ref) {
10
+ var className = _ref.className,
11
+ style = _ref.style,
12
+ _ref$open = _ref.open,
13
+ open = _ref$open === void 0 ? false : _ref$open,
14
+ afterOpenChange = _ref.afterOpenChange,
15
+ title = _ref.title,
16
+ options = _ref.options,
17
+ _ref$labelInValue = _ref.labelInValue,
18
+ labelInValue = _ref$labelInValue === void 0 ? false : _ref$labelInValue,
19
+ fieldNames = _ref.fieldNames,
20
+ columnsCount = _ref.columnsCount,
21
+ value = _ref.value,
22
+ onOk = _ref.onOk,
23
+ onCancel = _ref.onCancel,
24
+ onClose = _ref.onClose,
25
+ asyncRequest = _ref.asyncRequest;
26
+ var _ConfigProvider$useCo = ConfigProvider.useConfig(),
27
+ locale = _ConfigProvider$useCo.locale;
28
+ var internalValueRf = useRef(value);
29
+ var handleClose = function handleClose() {
30
+ onClose === null || onClose === void 0 || onClose();
31
+ };
32
+ var handleOk = function handleOk() {
33
+ onOk === null || onOk === void 0 || onOk(internalValueRf.current);
34
+ };
35
+ var handelCancel = function handelCancel() {
36
+ onCancel === null || onCancel === void 0 || onCancel();
37
+ handleClose();
38
+ };
39
+ useEffect(function () {
40
+ if (value === undefined) {
41
+ return;
42
+ }
43
+ if (isEqual(value, internalValueRf.current)) {
44
+ return;
45
+ }
46
+ internalValueRf.current = value;
47
+ }, [value]);
48
+ return /*#__PURE__*/React.createElement(Popup, {
49
+ open: open,
50
+ round: true,
51
+ onClose: handleClose,
52
+ overlayClosable: true,
53
+ styles: {
54
+ body: {
55
+ borderTopLeftRadius: 6,
56
+ borderTopRightRadius: 6
57
+ }
58
+ }
59
+ }, /*#__PURE__*/React.createElement("div", {
60
+ className: classNames(cascaderPickerCls, className),
61
+ style: style
62
+ }, /*#__PURE__*/React.createElement("div", {
63
+ className: classNames("".concat(cascaderPickerCls, "-header"))
64
+ }, /*#__PURE__*/React.createElement("a", {
65
+ className: classNames("".concat(cascaderPickerCls, "-header-button"), "".concat(cascaderPickerCls, "-header-button-cancel")),
66
+ onClick: handelCancel
67
+ }, locale.common.cancel), title && /*#__PURE__*/React.createElement("div", {
68
+ className: classNames("".concat(cascaderPickerCls, "-header-title"))
69
+ }, title), /*#__PURE__*/React.createElement("a", {
70
+ className: classNames("".concat(cascaderPickerCls, "-header-button"), "".concat(cascaderPickerCls, "-header-button-ok")),
71
+ onClick: handleOk
72
+ }, locale.common.confirm)), /*#__PURE__*/React.createElement("div", {
73
+ className: classNames("".concat(cascaderPickerCls, "-body"))
74
+ }, /*#__PURE__*/React.createElement(CascaderView
75
+ // open={ open}
76
+ , {
77
+ fieldNames: fieldNames,
78
+ options: options,
79
+ labelInValue: labelInValue,
80
+ columnsCount: columnsCount,
81
+ value: value,
82
+ onChange: function onChange(newVal) {
83
+ internalValueRf.current = newVal;
84
+ },
85
+ asyncRequest: asyncRequest,
86
+ style: {
87
+ height: '100%'
88
+ }
89
+ }))));
90
+ });
@@ -1,3 +1,3 @@
1
- import { CascaderPicker, CascaderPickerProps } from "@trionesdev/antd-mobile-base-react";
1
+ import { CascaderPicker, CascaderPickerProps } from "./cascader-picker";
2
2
  export type { CascaderPickerProps };
3
3
  export default CascaderPicker;
@@ -1,2 +1,2 @@
1
- import { CascaderPicker } from "@trionesdev/antd-mobile-base-react";
1
+ import { CascaderPicker } from "./cascader-picker";
2
2
  export default CascaderPicker;
@@ -0,0 +1,45 @@
1
+ @use "../style/variable" as variable;
2
+ $cascaderPickerCls: 'triones-antm-cascader-picker';
3
+
4
+ .#{$cascaderPickerCls} {
5
+ width: 100%;
6
+ height: 300Px;
7
+ overflow: hidden;
8
+ position: relative;
9
+ display: flex;
10
+ flex-direction: column;
11
+
12
+ &-header {
13
+ display: flex;
14
+ justify-content: space-between;
15
+ align-items: center;
16
+ border-bottom: 1Px solid variable.$trionesBorderColor;
17
+ padding: 4Px;
18
+
19
+ &-button {
20
+
21
+ padding: 8Px;
22
+ font-size: 12Px;
23
+ &-cancel{
24
+ color: variable.$trionesColorTextSecondary;
25
+ }
26
+ &-ok{
27
+ color: variable.$trionesColorPrimary;
28
+ }
29
+ }
30
+
31
+ &-title {
32
+ }
33
+ }
34
+
35
+ &-body {
36
+ flex: 1 1;
37
+ width: 100%;
38
+ pointer-events: unset;
39
+ overflow: hidden;
40
+ }
41
+ &-view{
42
+ --height: 100%;
43
+ }
44
+
45
+ }
@@ -0,0 +1,20 @@
1
+ import { FC } from "react";
2
+ import { FormCellProps } from "../FormCell";
3
+ export type CascaderPickerCellProps = Omit<FormCellProps, 'value'> & {
4
+ onChange?: (value: any[]) => void;
5
+ options?: any[];
6
+ /**
7
+ * @description 是否把每个选项的 label 包装到 value 中,会把 Select 的 value 类型从 string 变为 { value: string, label: ReactNode } 的格式
8
+ * @default false
9
+ */
10
+ labelInValue?: boolean;
11
+ fieldNames?: {
12
+ value?: string;
13
+ label?: string;
14
+ children?: string;
15
+ };
16
+ columnsCount?: number;
17
+ value?: any[];
18
+ asyncRequest?: (parentValue?: any) => Promise<any>;
19
+ };
20
+ export declare const CascaderPickerCell: FC<CascaderPickerCellProps>;
@@ -0,0 +1,70 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ var _excluded = ["placeholder", "onChange", "value", "labelInValue"];
3
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
4
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
5
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
6
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
7
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
8
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
9
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
10
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
11
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
12
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
13
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
14
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
15
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
16
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
17
+ import React, { useEffect, useState } from "react";
18
+ import CascaderPopup from "../CascaderPicker";
19
+ import FormCell from "../FormCell";
20
+ export var CascaderPickerCell = function CascaderPickerCell(_ref) {
21
+ var _ref$placeholder = _ref.placeholder,
22
+ placeholder = _ref$placeholder === void 0 ? '请选择' : _ref$placeholder,
23
+ onChange = _ref.onChange,
24
+ value = _ref.value,
25
+ _ref$labelInValue = _ref.labelInValue,
26
+ labelInValue = _ref$labelInValue === void 0 ? true : _ref$labelInValue,
27
+ rest = _objectWithoutProperties(_ref, _excluded);
28
+ var mergedFieldNames = _objectSpread({
29
+ value: 'value',
30
+ label: 'label',
31
+ children: 'children'
32
+ }, rest.fieldNames);
33
+ var _useState = useState(false),
34
+ _useState2 = _slicedToArray(_useState, 2),
35
+ open = _useState2[0],
36
+ setOpen = _useState2[1];
37
+ var _useState3 = useState(value || []),
38
+ _useState4 = _slicedToArray(_useState3, 2),
39
+ internalValue = _useState4[0],
40
+ setInternalValue = _useState4[1];
41
+ useEffect(function () {
42
+ if ((value || []) !== (internalValue || [])) {
43
+ setInternalValue(value || []);
44
+ }
45
+ }, [value]);
46
+ var valueText = function valueText() {
47
+ if (labelInValue) {
48
+ return internalValue === null || internalValue === void 0 ? void 0 : internalValue.map(function (item) {
49
+ return item[mergedFieldNames.label];
50
+ }).join('/');
51
+ }
52
+ };
53
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CascaderPopup, _extends({}, rest, {
54
+ open: open,
55
+ value: internalValue,
56
+ labelInValue: labelInValue,
57
+ onCancel: function onCancel() {
58
+ setOpen(false);
59
+ },
60
+ onOk: function onOk(value) {
61
+ setInternalValue(value || []);
62
+ setOpen(false);
63
+ onChange === null || onChange === void 0 || onChange(value || []);
64
+ }
65
+ })), /*#__PURE__*/React.createElement(FormCell, _extends({}, rest, {
66
+ onClick: function onClick() {
67
+ setOpen(true);
68
+ }
69
+ }), valueText()));
70
+ };
@@ -0,0 +1,3 @@
1
+ import { CascaderPickerCell, CascaderPickerCellProps } from "./CascaderPickerCell";
2
+ export type { CascaderPickerCellProps };
3
+ export default CascaderPickerCell;
@@ -0,0 +1,2 @@
1
+ import { CascaderPickerCell } from "./CascaderPickerCell";
2
+ export default CascaderPickerCell;
@@ -0,0 +1,18 @@
1
+ import { FC } from "react";
2
+ import React from "react";
3
+ import { Mode } from "./types";
4
+ import dayjs from "dayjs";
5
+ export type DatePickerPops = {
6
+ open?: boolean;
7
+ onClose?: () => void;
8
+ title?: React.ReactNode;
9
+ mode?: Mode;
10
+ showTime?: boolean | {
11
+ format?: string;
12
+ };
13
+ value?: dayjs.Dayjs;
14
+ onOk?: (value: dayjs.Dayjs) => void;
15
+ minDate?: dayjs.Dayjs;
16
+ maxDate?: dayjs.Dayjs;
17
+ };
18
+ export declare const DatePicker: FC<DatePickerPops>;
@@ -0,0 +1,310 @@
1
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
2
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
3
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
5
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
6
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
7
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
8
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
9
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
10
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
11
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
13
+ import { useEffect, useMemo, useState } from "react";
14
+ import Popup from "../Popup";
15
+ import PickerView from "../PickerView";
16
+ import React from "react";
17
+ import classNames from "classnames";
18
+ import ConfigProvider from "../ConfigProvider";
19
+ import { isEqual } from "lodash-es";
20
+ import dayjs from "dayjs";
21
+ var cls = 'triones-antm-date-picker';
22
+ export var DatePicker = function DatePicker(_ref) {
23
+ var open = _ref.open,
24
+ onClose = _ref.onClose,
25
+ title = _ref.title,
26
+ _ref$mode = _ref.mode,
27
+ mode = _ref$mode === void 0 ? 'date' : _ref$mode,
28
+ showTime = _ref.showTime,
29
+ value = _ref.value,
30
+ onOk = _ref.onOk,
31
+ minDate = _ref.minDate,
32
+ maxDate = _ref.maxDate;
33
+ var cleanTimeFormat = useMemo(function () {
34
+ if (_typeof(showTime) === 'object' && showTime !== null && showTime !== void 0 && showTime.format) {
35
+ return showTime.format.replace(/\[([^\]]+)\]/g, '');
36
+ }
37
+ return '';
38
+ }, [showTime]);
39
+ var hasHour = cleanTimeFormat === null || cleanTimeFormat === void 0 ? void 0 : cleanTimeFormat.includes('H');
40
+ var hasMinute = cleanTimeFormat === null || cleanTimeFormat === void 0 ? void 0 : cleanTimeFormat.includes('m');
41
+ var hasSecond = cleanTimeFormat === null || cleanTimeFormat === void 0 ? void 0 : cleanTimeFormat.includes('s');
42
+ var _ConfigProvider$useCo = ConfigProvider.useConfig(),
43
+ locale = _ConfigProvider$useCo.locale;
44
+ var _useState = useState({
45
+ year: (value === null || value === void 0 ? void 0 : value.year()) || dayjs().year(),
46
+ mouth: ((value === null || value === void 0 ? void 0 : value.month()) || dayjs().month()) + 1,
47
+ date: (value === null || value === void 0 ? void 0 : value.date()) || dayjs().date(),
48
+ hour: (value === null || value === void 0 ? void 0 : value.hour()) || dayjs().hour(),
49
+ minute: (value === null || value === void 0 ? void 0 : value.minute()) || dayjs().minute(),
50
+ second: (value === null || value === void 0 ? void 0 : value.second()) || dayjs().second()
51
+ }),
52
+ _useState2 = _slicedToArray(_useState, 2),
53
+ internalValue = _useState2[0],
54
+ setInternalValue = _useState2[1];
55
+ var years = useMemo(function () {
56
+ var startYear = dayjs().year() - 50;
57
+ var endYear = dayjs().year() + 50;
58
+ if (minDate && maxDate) {
59
+ startYear = minDate.year();
60
+ endYear = maxDate.year();
61
+ }
62
+ if (minDate) {
63
+ startYear = minDate.year();
64
+ }
65
+ if (maxDate) {
66
+ endYear = maxDate.year();
67
+ }
68
+ return Array.from({
69
+ length: endYear - startYear + 1
70
+ }, function (_, i) {
71
+ return startYear + i;
72
+ });
73
+ }, [internalValue.year, minDate, maxDate]);
74
+ var mouths = useMemo(function () {
75
+ var start = 0;
76
+ var end = 11;
77
+ if (minDate && minDate.year() === internalValue.year) {
78
+ start = minDate.month();
79
+ }
80
+ if (maxDate && maxDate.year() === internalValue.year) {
81
+ end = maxDate.month();
82
+ }
83
+ return Array.from({
84
+ length: end - start
85
+ }, function (_, i) {
86
+ return start + i + 1;
87
+ });
88
+ }, [internalValue.year, minDate, maxDate]);
89
+ var days = useMemo(function () {
90
+ var start = 1;
91
+ var end = dayjs().year(internalValue.year || dayjs().year()).month((internalValue.mouth || 1) - 1).daysInMonth();
92
+ if (minDate && minDate.year() === internalValue.year && minDate.month() + 1 === internalValue.mouth) {
93
+ start = minDate.date();
94
+ }
95
+ if (maxDate && maxDate.year() === internalValue.year && maxDate.month() + 1 === internalValue.mouth) {
96
+ end = maxDate.date();
97
+ }
98
+ return Array.from({
99
+ length: end - start + 1
100
+ }, function (_, i) {
101
+ return start + i;
102
+ });
103
+ }, [internalValue.year, internalValue.mouth, minDate, maxDate]);
104
+ var hours = Array.from({
105
+ length: 24
106
+ }, function (_, i) {
107
+ return i;
108
+ });
109
+ var minutes = Array.from({
110
+ length: 60
111
+ }, function (_, i) {
112
+ return i;
113
+ });
114
+ var seconds = Array.from({
115
+ length: 60
116
+ }, function (_, i) {
117
+ return i;
118
+ });
119
+ var columns = useMemo(function () {
120
+ if (mode === 'date') {
121
+ var dateColumns = [];
122
+ dateColumns.push(years.map(function (v) {
123
+ return {
124
+ label: "".concat(v, "\u5E74"),
125
+ value: v
126
+ };
127
+ }), mouths.map(function (v) {
128
+ return {
129
+ label: "".concat(v, "\u6708"),
130
+ value: v
131
+ };
132
+ }), days.map(function (v) {
133
+ return {
134
+ label: "".concat(v, "\u65E5"),
135
+ value: v
136
+ };
137
+ }));
138
+ if (Boolean(showTime)) {
139
+ if (cleanTimeFormat) {
140
+ if (hasHour) {
141
+ dateColumns.push(hours.map(function (v) {
142
+ return {
143
+ label: "".concat(v, "\u65F6"),
144
+ value: v
145
+ };
146
+ }));
147
+ }
148
+ if (hasMinute) {
149
+ dateColumns.push(minutes.map(function (v) {
150
+ return {
151
+ label: "".concat(v, "\u5206"),
152
+ value: v
153
+ };
154
+ }));
155
+ }
156
+ if (hasSecond) {
157
+ dateColumns.push(seconds.map(function (v) {
158
+ return {
159
+ label: "".concat(v, "\u79D2"),
160
+ value: v
161
+ };
162
+ }));
163
+ }
164
+ } else {
165
+ dateColumns.push(hours.map(function (v) {
166
+ return {
167
+ label: "".concat(v, "\u65F6"),
168
+ value: v
169
+ };
170
+ }), minutes.map(function (v) {
171
+ return {
172
+ label: "".concat(v, "\u5206"),
173
+ value: v
174
+ };
175
+ }), seconds.map(function (v) {
176
+ return {
177
+ label: "".concat(v, "\u79D2"),
178
+ value: v
179
+ };
180
+ }));
181
+ }
182
+ }
183
+ return dateColumns;
184
+ } else if (mode === 'time') {
185
+ var timeColumns = [];
186
+ if (cleanTimeFormat) {
187
+ if (hasHour) {
188
+ timeColumns.push(hours.map(function (v) {
189
+ return {
190
+ label: "".concat(v, "\u65F6"),
191
+ value: v
192
+ };
193
+ }));
194
+ }
195
+ if (hasMinute) {
196
+ timeColumns.push(minutes.map(function (v) {
197
+ return {
198
+ label: "".concat(v, "\u5206"),
199
+ value: v
200
+ };
201
+ }));
202
+ }
203
+ if (hasSecond) {
204
+ timeColumns.push(seconds.map(function (v) {
205
+ return {
206
+ label: "".concat(v, "\u79D2"),
207
+ value: v
208
+ };
209
+ }));
210
+ }
211
+ } else {
212
+ timeColumns.push(hours.map(function (v) {
213
+ return {
214
+ label: "".concat(v, "\u65F6"),
215
+ value: v
216
+ };
217
+ }), minutes.map(function (v) {
218
+ return {
219
+ label: "".concat(v, "\u5206"),
220
+ value: v
221
+ };
222
+ }), seconds.map(function (v) {
223
+ return {
224
+ label: "".concat(v, "\u79D2"),
225
+ value: v
226
+ };
227
+ }));
228
+ }
229
+ return timeColumns;
230
+ }
231
+ return [];
232
+ }, [mode, showTime, years, days]);
233
+ var handleOk = function handleOk() {
234
+ var now = dayjs();
235
+ onOk === null || onOk === void 0 || onOk(dayjs(new Date(internalValue.year || now.year(), (internalValue.mouth || now.month()) - 1, internalValue.date || now.date(), internalValue.hour || now.hour(), internalValue.minute || now.minute())));
236
+ onClose === null || onClose === void 0 || onClose();
237
+ };
238
+ var handelCancel = function handelCancel() {
239
+ onClose === null || onClose === void 0 || onClose();
240
+ };
241
+ var handleValueChange = function handleValueChange(value) {
242
+ var changedValue = _objectSpread({}, internalValue);
243
+ if (mode === 'date') {
244
+ changedValue.year = value[0];
245
+ changedValue.mouth = value[1];
246
+ changedValue.date = value[2];
247
+ if (showTime) {
248
+ changedValue.hour = value[3];
249
+ changedValue.minute = value[4];
250
+ }
251
+ } else if (mode === 'time') {
252
+ changedValue.hour = value[0];
253
+ changedValue.minute = value[1];
254
+ }
255
+ if (!isEqual(internalValue, changedValue)) {
256
+ setInternalValue(changedValue);
257
+ }
258
+ };
259
+ useEffect(function () {
260
+ if (value === undefined) {
261
+ return;
262
+ }
263
+ if (value.year() !== internalValue.year || value.month() + 1 !== internalValue.mouth || value.date() !== internalValue.date || value.hour() !== internalValue.hour || value.minute() !== internalValue.minute || value.second() !== internalValue.second) {
264
+ setInternalValue({
265
+ year: value.year(),
266
+ mouth: value.month() + 1,
267
+ date: value.date(),
268
+ hour: value.hour(),
269
+ minute: value.minute(),
270
+ second: value.second()
271
+ });
272
+ }
273
+ }, [value]);
274
+ var pickerValue = useMemo(function () {
275
+ if (mode === 'time') {
276
+ return [internalValue.hour, internalValue.minute, internalValue.second];
277
+ } else if (mode === 'date') {
278
+ if (showTime) {
279
+ return [internalValue.year, internalValue.mouth, internalValue.date, internalValue.hour, internalValue.minute, internalValue.second];
280
+ } else {
281
+ return [internalValue.year, internalValue.mouth, internalValue.date];
282
+ }
283
+ }
284
+ }, [internalValue]);
285
+ return /*#__PURE__*/React.createElement(Popup, {
286
+ open: open,
287
+ onClose: onClose,
288
+ round: true
289
+ }, /*#__PURE__*/React.createElement("div", {
290
+ className: classNames("".concat(cls))
291
+ }, /*#__PURE__*/React.createElement("div", {
292
+ className: classNames("".concat(cls, "-header"))
293
+ }, /*#__PURE__*/React.createElement("a", {
294
+ className: classNames("".concat(cls, "-header-button"), "".concat(cls, "-header-button-cancel")),
295
+ onClick: handelCancel
296
+ }, locale.common.cancel), title && /*#__PURE__*/React.createElement("div", {
297
+ className: classNames("".concat(cls, "-header-title"))
298
+ }, title), /*#__PURE__*/React.createElement("a", {
299
+ className: classNames("".concat(cls, "-header-button"), "".concat(cls, "-header-button-ok")),
300
+ onClick: handleOk
301
+ }, locale.common.confirm)), /*#__PURE__*/React.createElement("div", {
302
+ className: classNames("".concat(cls, "-body"))
303
+ }, /*#__PURE__*/React.createElement(PickerView, {
304
+ columns: columns,
305
+ value: pickerValue,
306
+ onChange: function onChange(v) {
307
+ handleValueChange(v);
308
+ }
309
+ }))));
310
+ };
@@ -0,0 +1,4 @@
1
+ import { DatePicker, DatePickerPops } from "./DatePicker";
2
+ import "./style.scss";
3
+ export type { DatePickerPops };
4
+ export default DatePicker;
@@ -0,0 +1,3 @@
1
+ import { DatePicker } from "./DatePicker";
2
+ import "./style.scss";
3
+ export default DatePicker;
@@ -0,0 +1,41 @@
1
+ @use "../style/variable" as variable;
2
+
3
+ $datePickerCls: 'triones-antm-date-picker';
4
+
5
+ .#{$datePickerCls} {
6
+ border-top-left-radius: variable.$trionesBorderRadius;
7
+ border-top-right-radius: variable.$trionesBorderRadius;
8
+
9
+ &-header {
10
+ display: flex;
11
+ justify-content: space-between;
12
+ align-items: center;
13
+ padding: 4Px;
14
+ border-bottom: 1Px solid variable.$trionesBorderColor;
15
+ &-title {
16
+ font-size: 16Px;
17
+ padding: 8Px;
18
+ text-align: center;
19
+ }
20
+
21
+ &-button {
22
+ padding: 8Px 12Px;
23
+ cursor: pointer;
24
+ &-cancel{
25
+ color: variable.$trionesColorTextSecondary;
26
+ }
27
+ }
28
+ }
29
+
30
+ &-body {
31
+ .time-picker {
32
+ .time-item {
33
+ flex-shrink: 0;
34
+ display: flex;
35
+ align-items: center;
36
+ justify-content: center;
37
+ height: 32Px;
38
+ }
39
+ }
40
+ }
41
+ }
@@ -0,0 +1 @@
1
+ export type Mode = 'date' | 'time';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,16 @@
1
+ import { FC } from "react";
2
+ import dayjs from "dayjs";
3
+ import { Mode } from "../DatePicker/types";
4
+ import { CellProps } from "../Cell";
5
+ export type DatePickerCellPops = Omit<CellProps, 'value'> & {
6
+ value?: dayjs.Dayjs;
7
+ format?: string;
8
+ onChange?: (value?: dayjs.Dayjs) => void;
9
+ mode?: Mode;
10
+ showTime?: boolean | {
11
+ format?: string;
12
+ };
13
+ minDate?: dayjs.Dayjs;
14
+ maxDate?: dayjs.Dayjs;
15
+ };
16
+ export declare const DatePickerCell: FC<DatePickerCellPops>;