@kne/react-form-antd 4.1.1 → 4.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/index.js +475 -44
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +478 -66
- package/dist/index.modern.js.map +1 -1
- package/package.json +2 -2
package/dist/index.modern.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import React__default, { forwardRef, useCallback, createContext, useContext, useEffect, useState, useRef, useMemo } from 'react';
|
|
2
3
|
import classnames from 'classnames';
|
|
3
4
|
import ReactForm__default, { preset as preset$2, useReset, useSubmit } from '@kne/react-form';
|
|
4
5
|
export * from '@kne/react-form';
|
|
@@ -6,19 +7,18 @@ import { preset as preset$1, widget, hooks, hoc } from '@kne/react-form-helper';
|
|
|
6
7
|
export { hoc, hooks, utils, widget } from '@kne/react-form-helper';
|
|
7
8
|
import merge from 'lodash/merge';
|
|
8
9
|
import { TreeSelect, TimePicker, Input, Switch as Switch$1, Select, Radio, InputNumber, Button, DatePicker, Checkbox as Checkbox$1, Cascader as Cascader$1, Rate as Rate$1, Slider as Slider$1 } from 'antd';
|
|
9
|
-
import {
|
|
10
|
-
import { CloseCircleFilled, CalendarOutlined } from '@ant-design/icons';
|
|
10
|
+
import { createWithIntlProvider, useIntl } from '@kne/react-intl';
|
|
11
11
|
import dayjs from 'dayjs';
|
|
12
12
|
import useControlValue from '@kne/use-control-value';
|
|
13
13
|
|
|
14
|
-
function _extends() {
|
|
15
|
-
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
14
|
+
function _extends$3() {
|
|
15
|
+
return _extends$3 = Object.assign ? Object.assign.bind() : function (n) {
|
|
16
16
|
for (var e = 1; e < arguments.length; e++) {
|
|
17
17
|
var t = arguments[e];
|
|
18
18
|
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
19
19
|
}
|
|
20
20
|
return n;
|
|
21
|
-
}, _extends.apply(null, arguments);
|
|
21
|
+
}, _extends$3.apply(null, arguments);
|
|
22
22
|
}
|
|
23
23
|
function _objectWithoutPropertiesLoose(r, e) {
|
|
24
24
|
if (null == r) return {};
|
|
@@ -52,7 +52,7 @@ var preset = props => {
|
|
|
52
52
|
preset$2(globalParams.rules);
|
|
53
53
|
};
|
|
54
54
|
|
|
55
|
-
const _excluded$
|
|
55
|
+
const _excluded$4 = ["className", "cache", "enterSubmit", "scrollToError", "scrollProps", "type", "size", "children"];
|
|
56
56
|
const {
|
|
57
57
|
ScrollToError,
|
|
58
58
|
EnterSubmit,
|
|
@@ -71,7 +71,7 @@ const Form = forwardRef((originProps, ref) => {
|
|
|
71
71
|
},
|
|
72
72
|
children
|
|
73
73
|
} = originProps,
|
|
74
|
-
props = _objectWithoutPropertiesLoose(originProps, _excluded$
|
|
74
|
+
props = _objectWithoutPropertiesLoose(originProps, _excluded$4);
|
|
75
75
|
const baseClass = 'react-form';
|
|
76
76
|
let computedClass = baseClass;
|
|
77
77
|
const {
|
|
@@ -87,24 +87,24 @@ const Form = forwardRef((originProps, ref) => {
|
|
|
87
87
|
if (size !== 'middle') {
|
|
88
88
|
computedClass += `--${size}`;
|
|
89
89
|
}
|
|
90
|
-
const maxLabel = /*#__PURE__*/
|
|
91
|
-
return /*#__PURE__*/
|
|
90
|
+
const maxLabel = /*#__PURE__*/React__default.createElement(MaxLabelProvider, null, children);
|
|
91
|
+
return /*#__PURE__*/React__default.createElement("form", {
|
|
92
92
|
className: classnames(baseClass, computedClass, className),
|
|
93
93
|
onSubmit: e => {
|
|
94
94
|
e.preventDefault();
|
|
95
95
|
e.stopPropagation();
|
|
96
96
|
}
|
|
97
|
-
}, /*#__PURE__*/
|
|
97
|
+
}, /*#__PURE__*/React__default.createElement(SizeProvider, {
|
|
98
98
|
value: {
|
|
99
99
|
size
|
|
100
100
|
}
|
|
101
|
-
}, /*#__PURE__*/
|
|
101
|
+
}, /*#__PURE__*/React__default.createElement(ReactForm__default, _extends$3({}, props, {
|
|
102
102
|
ref: ref
|
|
103
|
-
}), cache ? /*#__PURE__*/
|
|
103
|
+
}), cache ? /*#__PURE__*/React__default.createElement(FormStore, {
|
|
104
104
|
cache: cache
|
|
105
|
-
}) : null, scrollToError ? /*#__PURE__*/
|
|
105
|
+
}) : null, scrollToError ? /*#__PURE__*/React__default.createElement(ScrollToError, {
|
|
106
106
|
scrollProps: scrollProps
|
|
107
|
-
}) : null, enterSubmit ? /*#__PURE__*/
|
|
107
|
+
}) : null, enterSubmit ? /*#__PURE__*/React__default.createElement(EnterSubmit, null, maxLabel) : maxLabel)));
|
|
108
108
|
});
|
|
109
109
|
|
|
110
110
|
const locale$1 = {
|
|
@@ -127,26 +127,14 @@ const locale = {
|
|
|
127
127
|
SoFar: 'Present'
|
|
128
128
|
};
|
|
129
129
|
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
locale = 'zh-CN'
|
|
139
|
-
} = _ref,
|
|
140
|
-
props = _objectWithoutPropertiesLoose(_ref, _excluded$4);
|
|
141
|
-
const messages = localeMap[locale] || locale$1;
|
|
142
|
-
return /*#__PURE__*/React.createElement(IntlProvider, {
|
|
143
|
-
locale: locale,
|
|
144
|
-
messages: messages
|
|
145
|
-
}, /*#__PURE__*/React.createElement(WrappedComponent, props));
|
|
146
|
-
};
|
|
147
|
-
WithLocaleComponent.displayName = `withLocale(${WrappedComponent.displayName || WrappedComponent.name || 'Component'})`;
|
|
148
|
-
return WithLocaleComponent;
|
|
149
|
-
};
|
|
130
|
+
const withLocale = createWithIntlProvider({
|
|
131
|
+
defaultLocale: 'zh-CN',
|
|
132
|
+
messages: {
|
|
133
|
+
'zh-CN': locale$1,
|
|
134
|
+
'en-US': locale
|
|
135
|
+
},
|
|
136
|
+
namespace: 'react-form-antd'
|
|
137
|
+
});
|
|
150
138
|
|
|
151
139
|
const {
|
|
152
140
|
useOnChange: useOnChange$b
|
|
@@ -293,7 +281,7 @@ const RadioGroup = _ref => {
|
|
|
293
281
|
const handler = useCallback(e => {
|
|
294
282
|
onChange && onChange(e.target.value);
|
|
295
283
|
}, [onChange]);
|
|
296
|
-
return /*#__PURE__*/
|
|
284
|
+
return /*#__PURE__*/React__default.createElement(Radio.Group, _extends$3({}, props, {
|
|
297
285
|
onChange: handler
|
|
298
286
|
}));
|
|
299
287
|
};
|
|
@@ -369,7 +357,409 @@ PasswordInner.Field = Input.Password;
|
|
|
369
357
|
const InputField = withLocale(InputFieldInner);
|
|
370
358
|
InputField.Password = withLocale(PasswordInner);
|
|
371
359
|
|
|
372
|
-
const
|
|
360
|
+
const IconContext = /*#__PURE__*/createContext({});
|
|
361
|
+
var Context = IconContext;
|
|
362
|
+
|
|
363
|
+
function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}
|
|
364
|
+
|
|
365
|
+
const APPEND_ORDER = 'data-rc-order';
|
|
366
|
+
const APPEND_PRIORITY = 'data-rc-priority';
|
|
367
|
+
const MARK_KEY = 'rc-util-key';
|
|
368
|
+
const containerCache = new Map();
|
|
369
|
+
function canUseDom() {
|
|
370
|
+
return !!(typeof window !== 'undefined' && window.document && window.document.createElement);
|
|
371
|
+
}
|
|
372
|
+
function contains(root, node) {
|
|
373
|
+
if (!root || !node) {
|
|
374
|
+
return false;
|
|
375
|
+
}
|
|
376
|
+
if (root.contains) {
|
|
377
|
+
return root.contains(node);
|
|
378
|
+
}
|
|
379
|
+
let current = node;
|
|
380
|
+
while (current) {
|
|
381
|
+
if (current === root) {
|
|
382
|
+
return true;
|
|
383
|
+
}
|
|
384
|
+
current = current.parentNode;
|
|
385
|
+
}
|
|
386
|
+
return false;
|
|
387
|
+
}
|
|
388
|
+
function getMark({
|
|
389
|
+
mark
|
|
390
|
+
} = {}) {
|
|
391
|
+
if (mark) {
|
|
392
|
+
return mark.startsWith('data-') ? mark : `data-${mark}`;
|
|
393
|
+
}
|
|
394
|
+
return MARK_KEY;
|
|
395
|
+
}
|
|
396
|
+
function getContainer(option) {
|
|
397
|
+
if (option.attachTo) {
|
|
398
|
+
return option.attachTo;
|
|
399
|
+
}
|
|
400
|
+
const head = document.querySelector('head');
|
|
401
|
+
return head || document.body;
|
|
402
|
+
}
|
|
403
|
+
function getOrder(prepend) {
|
|
404
|
+
if (prepend === 'queue') {
|
|
405
|
+
return 'prependQueue';
|
|
406
|
+
}
|
|
407
|
+
return prepend ? 'prepend' : 'append';
|
|
408
|
+
}
|
|
409
|
+
function findStyles(container) {
|
|
410
|
+
return Array.from((containerCache.get(container) || container).children).filter(node => node.tagName === 'STYLE');
|
|
411
|
+
}
|
|
412
|
+
function injectCSS(css, option = {}) {
|
|
413
|
+
if (!canUseDom()) {
|
|
414
|
+
return null;
|
|
415
|
+
}
|
|
416
|
+
const {
|
|
417
|
+
csp,
|
|
418
|
+
prepend,
|
|
419
|
+
priority = 0
|
|
420
|
+
} = option;
|
|
421
|
+
const mergedOrder = getOrder(prepend);
|
|
422
|
+
const isPrependQueue = mergedOrder === 'prependQueue';
|
|
423
|
+
const styleNode = document.createElement('style');
|
|
424
|
+
styleNode.setAttribute(APPEND_ORDER, mergedOrder);
|
|
425
|
+
if (isPrependQueue && priority) {
|
|
426
|
+
styleNode.setAttribute(APPEND_PRIORITY, `${priority}`);
|
|
427
|
+
}
|
|
428
|
+
if (csp?.nonce) {
|
|
429
|
+
styleNode.nonce = csp.nonce;
|
|
430
|
+
}
|
|
431
|
+
styleNode.innerHTML = css;
|
|
432
|
+
const container = getContainer(option);
|
|
433
|
+
const {
|
|
434
|
+
firstChild
|
|
435
|
+
} = container;
|
|
436
|
+
if (prepend) {
|
|
437
|
+
if (isPrependQueue) {
|
|
438
|
+
const existStyle = (option.styles || findStyles(container)).filter(node => {
|
|
439
|
+
if (!['prepend', 'prependQueue'].includes(node.getAttribute(APPEND_ORDER))) {
|
|
440
|
+
return false;
|
|
441
|
+
}
|
|
442
|
+
const nodePriority = Number(node.getAttribute(APPEND_PRIORITY) || 0);
|
|
443
|
+
return priority >= nodePriority;
|
|
444
|
+
});
|
|
445
|
+
if (existStyle.length) {
|
|
446
|
+
container.insertBefore(styleNode, existStyle[existStyle.length - 1].nextSibling);
|
|
447
|
+
return styleNode;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
container.insertBefore(styleNode, firstChild);
|
|
451
|
+
} else {
|
|
452
|
+
container.appendChild(styleNode);
|
|
453
|
+
}
|
|
454
|
+
return styleNode;
|
|
455
|
+
}
|
|
456
|
+
function findExistNode(key, option = {}) {
|
|
457
|
+
let {
|
|
458
|
+
styles
|
|
459
|
+
} = option;
|
|
460
|
+
styles ||= findStyles(getContainer(option));
|
|
461
|
+
return styles.find(node => node.getAttribute(getMark(option)) === key);
|
|
462
|
+
}
|
|
463
|
+
function syncRealContainer(container, option) {
|
|
464
|
+
const cachedRealContainer = containerCache.get(container);
|
|
465
|
+
if (!cachedRealContainer || !contains(document, cachedRealContainer)) {
|
|
466
|
+
const placeholderStyle = injectCSS('', option);
|
|
467
|
+
if (!placeholderStyle) {
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
470
|
+
const {
|
|
471
|
+
parentNode
|
|
472
|
+
} = placeholderStyle;
|
|
473
|
+
containerCache.set(container, parentNode);
|
|
474
|
+
container.removeChild(placeholderStyle);
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
function updateCSS(css, key, originOption = {}) {
|
|
478
|
+
if (!canUseDom()) {
|
|
479
|
+
return null;
|
|
480
|
+
}
|
|
481
|
+
const container = getContainer(originOption);
|
|
482
|
+
const styles = findStyles(container);
|
|
483
|
+
const option = {
|
|
484
|
+
...originOption,
|
|
485
|
+
styles
|
|
486
|
+
};
|
|
487
|
+
syncRealContainer(container, option);
|
|
488
|
+
const existNode = findExistNode(key, option);
|
|
489
|
+
if (existNode) {
|
|
490
|
+
if (option.csp?.nonce && existNode.nonce !== option.csp.nonce) {
|
|
491
|
+
existNode.nonce = option.csp.nonce;
|
|
492
|
+
}
|
|
493
|
+
if (existNode.innerHTML !== css) {
|
|
494
|
+
existNode.innerHTML = css;
|
|
495
|
+
}
|
|
496
|
+
return existNode;
|
|
497
|
+
}
|
|
498
|
+
const newNode = injectCSS(css, option);
|
|
499
|
+
newNode?.setAttribute(getMark(option), key);
|
|
500
|
+
return newNode;
|
|
501
|
+
}
|
|
502
|
+
function getRoot(ele) {
|
|
503
|
+
return ele?.getRootNode?.();
|
|
504
|
+
}
|
|
505
|
+
function getShadowRoot(ele) {
|
|
506
|
+
const root = getRoot(ele);
|
|
507
|
+
return typeof ShadowRoot !== 'undefined' && root instanceof ShadowRoot ? root : null;
|
|
508
|
+
}
|
|
509
|
+
const warned = {};
|
|
510
|
+
function warningOnce(valid, message) {
|
|
511
|
+
if (valid || warned[message]) {
|
|
512
|
+
return;
|
|
513
|
+
}
|
|
514
|
+
if (process.env.NODE_ENV !== 'production' && typeof console !== 'undefined') {
|
|
515
|
+
console.error(`Warning: ${message}`);
|
|
516
|
+
}
|
|
517
|
+
warned[message] = true;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
function camelCase(input) {
|
|
521
|
+
return input.replace(/-(.)/g, (match, g) => g.toUpperCase());
|
|
522
|
+
}
|
|
523
|
+
function warning(valid, message) {
|
|
524
|
+
warningOnce(valid, `[@ant-design/icons] ${message}`);
|
|
525
|
+
}
|
|
526
|
+
function isIconDefinition(target) {
|
|
527
|
+
return typeof target === 'object' && typeof target.name === 'string' && typeof target.theme === 'string' && (typeof target.icon === 'object' || typeof target.icon === 'function');
|
|
528
|
+
}
|
|
529
|
+
function normalizeAttrs(attrs = {}) {
|
|
530
|
+
return Object.keys(attrs).reduce((acc, key) => {
|
|
531
|
+
const val = attrs[key];
|
|
532
|
+
switch (key) {
|
|
533
|
+
case 'class':
|
|
534
|
+
acc.className = val;
|
|
535
|
+
delete acc.class;
|
|
536
|
+
break;
|
|
537
|
+
default:
|
|
538
|
+
delete acc[key];
|
|
539
|
+
acc[camelCase(key)] = val;
|
|
540
|
+
}
|
|
541
|
+
return acc;
|
|
542
|
+
}, {});
|
|
543
|
+
}
|
|
544
|
+
function generate(node, key, rootProps) {
|
|
545
|
+
if (!rootProps) {
|
|
546
|
+
return /*#__PURE__*/React__default.createElement(node.tag, {
|
|
547
|
+
key,
|
|
548
|
+
...normalizeAttrs(node.attrs)
|
|
549
|
+
}, (node.children || []).map((child, index) => generate(child, `${key}-${node.tag}-${index}`)));
|
|
550
|
+
}
|
|
551
|
+
return /*#__PURE__*/React__default.createElement(node.tag, {
|
|
552
|
+
key,
|
|
553
|
+
...normalizeAttrs(node.attrs),
|
|
554
|
+
...rootProps
|
|
555
|
+
}, (node.children || []).map((child, index) => generate(child, `${key}-${node.tag}-${index}`)));
|
|
556
|
+
}
|
|
557
|
+
const iconStyles = `
|
|
558
|
+
.anticon {
|
|
559
|
+
display: inline-flex;
|
|
560
|
+
align-items: center;
|
|
561
|
+
color: inherit;
|
|
562
|
+
font-style: normal;
|
|
563
|
+
line-height: 0;
|
|
564
|
+
text-align: center;
|
|
565
|
+
text-transform: none;
|
|
566
|
+
vertical-align: -0.125em;
|
|
567
|
+
text-rendering: optimizeLegibility;
|
|
568
|
+
-webkit-font-smoothing: antialiased;
|
|
569
|
+
-moz-osx-font-smoothing: grayscale;
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
.anticon > * {
|
|
573
|
+
line-height: 1;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
.anticon svg {
|
|
577
|
+
display: inline-block;
|
|
578
|
+
vertical-align: inherit;
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
.anticon::before {
|
|
582
|
+
display: none;
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
.anticon .anticon-icon {
|
|
586
|
+
display: block;
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
.anticon[tabindex] {
|
|
590
|
+
cursor: pointer;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
.anticon-spin {
|
|
594
|
+
-webkit-animation: loadingCircle 1s infinite linear;
|
|
595
|
+
animation: loadingCircle 1s infinite linear;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
@-webkit-keyframes loadingCircle {
|
|
599
|
+
100% {
|
|
600
|
+
-webkit-transform: rotate(360deg);
|
|
601
|
+
transform: rotate(360deg);
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
@keyframes loadingCircle {
|
|
606
|
+
100% {
|
|
607
|
+
-webkit-transform: rotate(360deg);
|
|
608
|
+
transform: rotate(360deg);
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
`;
|
|
612
|
+
const useInsertStyles = eleRef => {
|
|
613
|
+
const {
|
|
614
|
+
csp,
|
|
615
|
+
prefixCls,
|
|
616
|
+
layer,
|
|
617
|
+
zeroRuntime
|
|
618
|
+
} = useContext(Context);
|
|
619
|
+
let mergedStyleStr = iconStyles;
|
|
620
|
+
if (prefixCls) {
|
|
621
|
+
mergedStyleStr = mergedStyleStr.replace(/anticon/g, prefixCls);
|
|
622
|
+
}
|
|
623
|
+
if (layer) {
|
|
624
|
+
mergedStyleStr = `@layer ${layer} {\n${mergedStyleStr}\n}`;
|
|
625
|
+
}
|
|
626
|
+
useEffect(() => {
|
|
627
|
+
if (zeroRuntime) {
|
|
628
|
+
return;
|
|
629
|
+
}
|
|
630
|
+
const ele = eleRef.current;
|
|
631
|
+
const shadowRoot = getShadowRoot(ele);
|
|
632
|
+
updateCSS(mergedStyleStr, '@ant-design-icons', {
|
|
633
|
+
prepend: !layer,
|
|
634
|
+
csp,
|
|
635
|
+
attachTo: shadowRoot
|
|
636
|
+
});
|
|
637
|
+
}, []);
|
|
638
|
+
};
|
|
639
|
+
|
|
640
|
+
const IconBase = props => {
|
|
641
|
+
const {
|
|
642
|
+
icon,
|
|
643
|
+
className,
|
|
644
|
+
onClick,
|
|
645
|
+
style,
|
|
646
|
+
primaryColor: _primaryColor,
|
|
647
|
+
secondaryColor: _secondaryColor,
|
|
648
|
+
...restProps
|
|
649
|
+
} = props;
|
|
650
|
+
const svgRef = React.useRef(null);
|
|
651
|
+
useInsertStyles(svgRef);
|
|
652
|
+
warning(isIconDefinition(icon), `icon should be icon definiton, but got ${icon}`);
|
|
653
|
+
if (!isIconDefinition(icon)) {
|
|
654
|
+
return null;
|
|
655
|
+
}
|
|
656
|
+
const target = icon;
|
|
657
|
+
return generate(target.icon, `svg-${target.name}`, {
|
|
658
|
+
className,
|
|
659
|
+
onClick,
|
|
660
|
+
style,
|
|
661
|
+
'data-icon': target.name,
|
|
662
|
+
width: '1em',
|
|
663
|
+
height: '1em',
|
|
664
|
+
fill: 'currentColor',
|
|
665
|
+
'aria-hidden': 'true',
|
|
666
|
+
...restProps,
|
|
667
|
+
ref: svgRef
|
|
668
|
+
});
|
|
669
|
+
};
|
|
670
|
+
IconBase.displayName = 'IconReact';
|
|
671
|
+
var ReactIcon = IconBase;
|
|
672
|
+
|
|
673
|
+
function _extends$2() { _extends$2 = 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$2.apply(this, arguments); }
|
|
674
|
+
const Icon = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
675
|
+
const {
|
|
676
|
+
// affect outter <i>...</i>
|
|
677
|
+
className,
|
|
678
|
+
// affect inner <svg>...</svg>
|
|
679
|
+
icon,
|
|
680
|
+
spin,
|
|
681
|
+
rotate,
|
|
682
|
+
tabIndex,
|
|
683
|
+
onClick,
|
|
684
|
+
twoToneColor: _twoToneColor,
|
|
685
|
+
// other
|
|
686
|
+
...restProps
|
|
687
|
+
} = props;
|
|
688
|
+
const {
|
|
689
|
+
prefixCls = 'anticon',
|
|
690
|
+
rootClassName
|
|
691
|
+
} = React.useContext(Context);
|
|
692
|
+
const classString = clsx(rootClassName, prefixCls, {
|
|
693
|
+
[`${prefixCls}-${icon.name}`]: !!icon.name,
|
|
694
|
+
[`${prefixCls}-spin`]: !!spin || icon.name === 'loading'
|
|
695
|
+
}, className);
|
|
696
|
+
let iconTabIndex = tabIndex;
|
|
697
|
+
if (iconTabIndex === undefined && onClick) {
|
|
698
|
+
iconTabIndex = -1;
|
|
699
|
+
}
|
|
700
|
+
const svgStyle = rotate ? {
|
|
701
|
+
msTransform: `rotate(${rotate}deg)`,
|
|
702
|
+
transform: `rotate(${rotate}deg)`
|
|
703
|
+
} : undefined;
|
|
704
|
+
return /*#__PURE__*/React.createElement("span", _extends$2({
|
|
705
|
+
role: "img",
|
|
706
|
+
"aria-label": icon.name
|
|
707
|
+
}, restProps, {
|
|
708
|
+
ref: ref,
|
|
709
|
+
tabIndex: iconTabIndex,
|
|
710
|
+
onClick: onClick,
|
|
711
|
+
className: classString
|
|
712
|
+
}), /*#__PURE__*/React.createElement(ReactIcon, {
|
|
713
|
+
icon: icon,
|
|
714
|
+
style: svgStyle
|
|
715
|
+
}));
|
|
716
|
+
});
|
|
717
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
718
|
+
Icon.displayName = 'AntdIcon';
|
|
719
|
+
}
|
|
720
|
+
var AntdIcon = Icon;
|
|
721
|
+
|
|
722
|
+
// This icon file is generated automatically.
|
|
723
|
+
|
|
724
|
+
var CalendarOutlined$2 = { "icon": { "tag": "svg", "attrs": { "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M880 184H712v-64c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v64H384v-64c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v64H144c-17.7 0-32 14.3-32 32v664c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V216c0-17.7-14.3-32-32-32zm-40 656H184V460h656v380zM184 392V256h128v48c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8v-48h256v48c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8v-48h128v136H184z" } }] }, "name": "calendar", "theme": "outlined" };
|
|
725
|
+
var _default$1 = CalendarOutlined$2;
|
|
726
|
+
|
|
727
|
+
var CalendarOutlinedSvg = _default$1;
|
|
728
|
+
|
|
729
|
+
function _extends$1() { _extends$1 = 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$1.apply(this, arguments); }
|
|
730
|
+
const CalendarOutlined = (props, ref) => /*#__PURE__*/React.createElement(AntdIcon, _extends$1({}, props, {
|
|
731
|
+
ref: ref,
|
|
732
|
+
icon: CalendarOutlinedSvg
|
|
733
|
+
}));
|
|
734
|
+
|
|
735
|
+
/** */
|
|
736
|
+
const RefIcon$1 = /*#__PURE__*/React.forwardRef(CalendarOutlined);
|
|
737
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
738
|
+
RefIcon$1.displayName = 'CalendarOutlined';
|
|
739
|
+
}
|
|
740
|
+
var CalendarOutlined$1 = RefIcon$1;
|
|
741
|
+
|
|
742
|
+
// This icon file is generated automatically.
|
|
743
|
+
|
|
744
|
+
var CloseCircleFilled$2 = { "icon": { "tag": "svg", "attrs": { "fill-rule": "evenodd", "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M512 64c247.4 0 448 200.6 448 448S759.4 960 512 960 64 759.4 64 512 264.6 64 512 64zm127.98 274.82h-.04l-.08.06L512 466.75 384.14 338.88c-.04-.05-.06-.06-.08-.06a.12.12 0 00-.07 0c-.03 0-.05.01-.09.05l-45.02 45.02a.2.2 0 00-.05.09.12.12 0 000 .07v.02a.27.27 0 00.06.06L466.75 512 338.88 639.86c-.05.04-.06.06-.06.08a.12.12 0 000 .07c0 .03.01.05.05.09l45.02 45.02a.2.2 0 00.09.05.12.12 0 00.07 0c.02 0 .04-.01.08-.05L512 557.25l127.86 127.87c.04.04.06.05.08.05a.12.12 0 00.07 0c.03 0 .05-.01.09-.05l45.02-45.02a.2.2 0 00.05-.09.12.12 0 000-.07v-.02a.27.27 0 00-.05-.06L557.25 512l127.87-127.86c.04-.04.05-.06.05-.08a.12.12 0 000-.07c0-.03-.01-.05-.05-.09l-45.02-45.02a.2.2 0 00-.09-.05.12.12 0 00-.07 0z" } }] }, "name": "close-circle", "theme": "filled" };
|
|
745
|
+
var _default = CloseCircleFilled$2;
|
|
746
|
+
|
|
747
|
+
var CloseCircleFilledSvg = _default;
|
|
748
|
+
|
|
749
|
+
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); }
|
|
750
|
+
const CloseCircleFilled = (props, ref) => /*#__PURE__*/React.createElement(AntdIcon, _extends({}, props, {
|
|
751
|
+
ref: ref,
|
|
752
|
+
icon: CloseCircleFilledSvg
|
|
753
|
+
}));
|
|
754
|
+
|
|
755
|
+
/** */
|
|
756
|
+
const RefIcon = /*#__PURE__*/React.forwardRef(CloseCircleFilled);
|
|
757
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
758
|
+
RefIcon.displayName = 'CloseCircleFilled';
|
|
759
|
+
}
|
|
760
|
+
var CloseCircleFilled$1 = RefIcon;
|
|
761
|
+
|
|
762
|
+
const _excluded$2 = ["soFarText", "soFarValue", "picker", "placeholder"];
|
|
373
763
|
const {
|
|
374
764
|
useOnChange: useOnChange$6
|
|
375
765
|
} = hooks;
|
|
@@ -377,7 +767,8 @@ const PickerTodayInner = _ref => {
|
|
|
377
767
|
let {
|
|
378
768
|
soFarText,
|
|
379
769
|
soFarValue = 'soFar',
|
|
380
|
-
picker = 'date'
|
|
770
|
+
picker = 'date',
|
|
771
|
+
placeholder
|
|
381
772
|
} = _ref,
|
|
382
773
|
props = _objectWithoutPropertiesLoose(_ref, _excluded$2);
|
|
383
774
|
const {
|
|
@@ -395,6 +786,24 @@ const PickerTodayInner = _ref => {
|
|
|
395
786
|
const soFarLabel = soFarText || formatMessage({
|
|
396
787
|
id: 'SoFar'
|
|
397
788
|
});
|
|
789
|
+
const placeholderList = Array.isArray(placeholder) ? placeholder : [];
|
|
790
|
+
const startPlaceholder = placeholderList[0] || formatMessage({
|
|
791
|
+
id: 'StartDate'
|
|
792
|
+
});
|
|
793
|
+
const endPlaceholder = placeholderList[1] || formatMessage({
|
|
794
|
+
id: 'EndDate'
|
|
795
|
+
});
|
|
796
|
+
|
|
797
|
+
// 根据 picker 类型获取格式化字符串
|
|
798
|
+
const formatPattern = useMemo(() => {
|
|
799
|
+
const patterns = {
|
|
800
|
+
date: 'YYYY-MM-DD',
|
|
801
|
+
week: 'YYYY-wo',
|
|
802
|
+
month: 'YYYY-MM',
|
|
803
|
+
year: 'YYYY'
|
|
804
|
+
};
|
|
805
|
+
return patterns[picker] || 'YYYY-MM-DD';
|
|
806
|
+
}, [picker]);
|
|
398
807
|
|
|
399
808
|
// 判断是否有值
|
|
400
809
|
const hasValue = useMemo(() => {
|
|
@@ -420,15 +829,15 @@ const PickerTodayInner = _ref => {
|
|
|
420
829
|
// 显示文本 - 弹窗打开时显示临时值,关闭后显示实际值
|
|
421
830
|
const displayText = useMemo(() => {
|
|
422
831
|
// 开始时间:有临时值时显示临时值
|
|
423
|
-
const startText = tempStart ? tempStart.format(
|
|
832
|
+
const startText = tempStart ? tempStart.format(formatPattern) : parsedValue.start ? parsedValue.start.format(formatPattern) : '';
|
|
424
833
|
|
|
425
834
|
// 结束时间:有临时值时显示临时值
|
|
426
|
-
const endText = tempEnd ? tempEnd.format(
|
|
835
|
+
const endText = tempEnd ? tempEnd.format(formatPattern) : isSoFar ? soFarLabel : parsedValue.end ? parsedValue.end.format(formatPattern) : '';
|
|
427
836
|
return {
|
|
428
837
|
start: startText,
|
|
429
838
|
end: endText
|
|
430
839
|
};
|
|
431
|
-
}, [parsedValue, isSoFar, soFarLabel, tempStart, tempEnd]);
|
|
840
|
+
}, [parsedValue, isSoFar, soFarLabel, tempStart, tempEnd, formatPattern]);
|
|
432
841
|
|
|
433
842
|
// 点击整个Input框时,先弹出开始时间选择
|
|
434
843
|
const handleInputClick = useCallback(() => {
|
|
@@ -510,7 +919,7 @@ const PickerTodayInner = _ref => {
|
|
|
510
919
|
}, []);
|
|
511
920
|
|
|
512
921
|
// 空的 footer(用于开始时间,保持高度一致)
|
|
513
|
-
const renderEmptyFooter = useCallback(() => /*#__PURE__*/
|
|
922
|
+
const renderEmptyFooter = useCallback(() => /*#__PURE__*/React__default.createElement("div", {
|
|
514
923
|
style: {
|
|
515
924
|
height: 40
|
|
516
925
|
}
|
|
@@ -519,11 +928,11 @@ const PickerTodayInner = _ref => {
|
|
|
519
928
|
// 带至今按钮的 footer
|
|
520
929
|
const renderExtraFooter = useCallback(() => {
|
|
521
930
|
const isCurrentSoFar = !tempStart && isSoFar;
|
|
522
|
-
return /*#__PURE__*/
|
|
931
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
523
932
|
style: {
|
|
524
933
|
textAlign: 'right'
|
|
525
934
|
}
|
|
526
|
-
}, /*#__PURE__*/
|
|
935
|
+
}, /*#__PURE__*/React__default.createElement(Button, {
|
|
527
936
|
type: isCurrentSoFar ? 'primary' : 'default',
|
|
528
937
|
onClick: handleSoFarClick
|
|
529
938
|
}, soFarLabel));
|
|
@@ -532,42 +941,45 @@ const PickerTodayInner = _ref => {
|
|
|
532
941
|
// 结束时间的可选日期(不能早于开始时间)
|
|
533
942
|
const endDisabledDate = useCallback(current => {
|
|
534
943
|
if (!tempStart) return false;
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
944
|
+
const startOfMap = {
|
|
945
|
+
date: 'day',
|
|
946
|
+
week: 'week',
|
|
947
|
+
month: 'month',
|
|
948
|
+
year: 'year'
|
|
949
|
+
};
|
|
950
|
+
const unit = startOfMap[picker] || 'day';
|
|
951
|
+
return current && current < tempStart.startOf(unit);
|
|
952
|
+
}, [tempStart, picker]);
|
|
953
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
538
954
|
className: "date-picker-today-container",
|
|
539
955
|
ref: containerRef
|
|
540
|
-
}, /*#__PURE__*/
|
|
956
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
541
957
|
className: "date-picker-today-inputs",
|
|
542
958
|
onClick: handleInputClick,
|
|
543
959
|
onMouseEnter: () => setHovering(true),
|
|
544
960
|
onMouseLeave: () => setHovering(false)
|
|
545
|
-
}, /*#__PURE__*/
|
|
961
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
546
962
|
className: "date-picker-today-start"
|
|
547
|
-
}, /*#__PURE__*/
|
|
963
|
+
}, /*#__PURE__*/React__default.createElement("input", {
|
|
548
964
|
readOnly: true,
|
|
549
|
-
placeholder:
|
|
550
|
-
id: 'StartDate'
|
|
551
|
-
}),
|
|
965
|
+
placeholder: startPlaceholder,
|
|
552
966
|
value: displayText.start,
|
|
553
967
|
className: "ant-input"
|
|
554
|
-
})), /*#__PURE__*/
|
|
968
|
+
})), /*#__PURE__*/React__default.createElement("span", {
|
|
555
969
|
className: "date-picker-today-separator"
|
|
556
|
-
}, "~"), /*#__PURE__*/
|
|
970
|
+
}, "~"), /*#__PURE__*/React__default.createElement("div", {
|
|
557
971
|
className: "date-picker-today-end"
|
|
558
|
-
}, /*#__PURE__*/
|
|
972
|
+
}, /*#__PURE__*/React__default.createElement("input", {
|
|
559
973
|
readOnly: true,
|
|
560
|
-
placeholder:
|
|
561
|
-
id: 'EndDate'
|
|
562
|
-
}),
|
|
974
|
+
placeholder: endPlaceholder,
|
|
563
975
|
value: displayText.end,
|
|
564
976
|
className: `ant-input ${isSoFar ? 'so-far-active' : ''}`
|
|
565
|
-
})), /*#__PURE__*/
|
|
977
|
+
})), /*#__PURE__*/React__default.createElement("span", {
|
|
566
978
|
className: "date-picker-today-suffix"
|
|
567
|
-
}, hasValue && hovering ? /*#__PURE__*/
|
|
979
|
+
}, hasValue && hovering ? /*#__PURE__*/React__default.createElement(CloseCircleFilled$1, {
|
|
568
980
|
className: "date-picker-today-clear",
|
|
569
981
|
onClick: handleClear
|
|
570
|
-
}) : /*#__PURE__*/
|
|
982
|
+
}) : /*#__PURE__*/React__default.createElement(CalendarOutlined$1, null))), /*#__PURE__*/React__default.createElement(DatePicker, {
|
|
571
983
|
picker: picker,
|
|
572
984
|
open: openStart,
|
|
573
985
|
onOpenChange: handleStartOpenChange,
|
|
@@ -583,7 +995,7 @@ const PickerTodayInner = _ref => {
|
|
|
583
995
|
position: 'absolute'
|
|
584
996
|
},
|
|
585
997
|
placement: "bottomLeft"
|
|
586
|
-
}), /*#__PURE__*/
|
|
998
|
+
}), /*#__PURE__*/React__default.createElement(DatePicker, {
|
|
587
999
|
picker: picker,
|
|
588
1000
|
open: openEnd,
|
|
589
1001
|
onOpenChange: handleEndOpenChange,
|
|
@@ -769,7 +1181,7 @@ Slider.Field = Slider$1;
|
|
|
769
1181
|
|
|
770
1182
|
const ResetButton = props => {
|
|
771
1183
|
const resetProps = useReset();
|
|
772
|
-
return /*#__PURE__*/
|
|
1184
|
+
return /*#__PURE__*/React__default.createElement(Button, _extends$3({}, resetProps, props));
|
|
773
1185
|
};
|
|
774
1186
|
|
|
775
1187
|
const _excluded$1 = ["type", "realtime", "disabled"],
|
|
@@ -787,7 +1199,7 @@ const SubmitButton = _ref => {
|
|
|
787
1199
|
isLoading
|
|
788
1200
|
} = _useSubmit,
|
|
789
1201
|
submitProps = _objectWithoutPropertiesLoose(_useSubmit, _excluded2);
|
|
790
|
-
return /*#__PURE__*/
|
|
1202
|
+
return /*#__PURE__*/React__default.createElement(Button, _extends$3({
|
|
791
1203
|
type: type,
|
|
792
1204
|
loading: isLoading,
|
|
793
1205
|
disabled: disabled || (realtime ? !isPass : false)
|
|
@@ -804,7 +1216,7 @@ const CancelButton = _ref => {
|
|
|
804
1216
|
} = _ref,
|
|
805
1217
|
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
806
1218
|
const remove = useCacheRemove();
|
|
807
|
-
return /*#__PURE__*/
|
|
1219
|
+
return /*#__PURE__*/React__default.createElement(Button, _extends$3({}, props, {
|
|
808
1220
|
onClick: (...args) => {
|
|
809
1221
|
remove();
|
|
810
1222
|
onClick && onClick(...args);
|