@kdcloudjs/kdesign 1.7.68-stable.8 → 1.7.68-stable.9

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 (47) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/dist/kdesign-complete.less +110 -0
  3. package/dist/kdesign.css +365 -1
  4. package/dist/kdesign.css.map +1 -1
  5. package/dist/kdesign.js +3876 -167
  6. package/dist/kdesign.js.map +1 -1
  7. package/dist/kdesign.min.css +3 -3
  8. package/dist/kdesign.min.js +12 -12
  9. package/dist/kdesign.min.js.map +1 -1
  10. package/es/_utils/useId.d.ts +2 -0
  11. package/es/_utils/useId.js +30 -0
  12. package/es/city-picker/city-picker.js +16 -28
  13. package/es/city-picker/option.js +1 -5
  14. package/es/city-picker/style/index.css +8 -0
  15. package/es/city-picker/style/index.less +10 -0
  16. package/es/config-provider/compDefaultProps.d.ts +0 -1
  17. package/es/config-provider/compDefaultProps.js +0 -1
  18. package/es/locale/locale.d.ts +1 -0
  19. package/es/locale/zh-CN.d.ts +1 -0
  20. package/es/locale/zh-CN.js +1 -0
  21. package/es/popper/index.d.ts +61 -0
  22. package/es/popper/index.js +550 -0
  23. package/es/popper/style/css.js +2 -0
  24. package/es/popper/style/index.css +355 -0
  25. package/es/popper/style/index.d.ts +2 -0
  26. package/es/popper/style/index.js +2 -0
  27. package/es/popper/style/index.less +99 -0
  28. package/lib/_utils/useId.d.ts +2 -0
  29. package/lib/_utils/useId.js +43 -0
  30. package/lib/city-picker/city-picker.js +16 -28
  31. package/lib/city-picker/option.js +1 -5
  32. package/lib/city-picker/style/index.css +8 -0
  33. package/lib/city-picker/style/index.less +10 -0
  34. package/lib/config-provider/compDefaultProps.d.ts +0 -1
  35. package/lib/config-provider/compDefaultProps.js +0 -1
  36. package/lib/locale/locale.d.ts +1 -0
  37. package/lib/locale/zh-CN.d.ts +1 -0
  38. package/lib/locale/zh-CN.js +1 -0
  39. package/lib/popper/index.d.ts +61 -0
  40. package/lib/popper/index.js +567 -0
  41. package/lib/popper/style/css.js +4 -0
  42. package/lib/popper/style/index.css +355 -0
  43. package/lib/popper/style/index.d.ts +2 -0
  44. package/lib/popper/style/index.js +4 -0
  45. package/lib/popper/style/index.less +99 -0
  46. package/lib/style/components.less +1 -0
  47. package/package.json +1 -1
@@ -0,0 +1,2 @@
1
+ declare const _default: (id?: string | undefined) => any;
2
+ export default _default;
@@ -0,0 +1,30 @@
1
+ import _slicedToArray from "@babel/runtime-corejs3/helpers/slicedToArray";
2
+ import _extends from "@babel/runtime-corejs3/helpers/extends";
3
+ import * as React from 'react';
4
+ function getUseId() {
5
+ var fullClone = _extends({}, React);
6
+ return fullClone === null || fullClone === void 0 ? void 0 : fullClone.useId;
7
+ }
8
+ var uuid = 0;
9
+ var useOriginId = getUseId();
10
+ export default useOriginId ? function useId(id) {
11
+ var reactId = useOriginId();
12
+ if (id) {
13
+ return id;
14
+ }
15
+ return reactId;
16
+ } : function useCompatId(id) {
17
+ var _React$useState = React.useState('ssr-id'),
18
+ _React$useState2 = _slicedToArray(_React$useState, 2),
19
+ innerId = _React$useState2[0],
20
+ setInnerId = _React$useState2[1];
21
+ React.useEffect(function () {
22
+ var nextId = uuid;
23
+ uuid += 1;
24
+ setInnerId("kd_unique_".concat(nextId));
25
+ }, []);
26
+ if (id) {
27
+ return id;
28
+ }
29
+ return innerId;
30
+ };
@@ -6,13 +6,14 @@ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/insta
6
6
  import _findInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/find";
7
7
  import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
8
8
  import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
9
+ import _findIndexInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/find-index";
9
10
  import React, { useContext, useRef, useEffect, useState, useCallback, useMemo } from 'react';
10
11
  import { useMergedState } from '../_utils/hooks';
11
12
  import classNames from 'classnames';
12
13
  import ConfigContext from '../config-provider/ConfigContext';
13
14
  import { getCompProps } from '../_utils';
14
15
  import { Icon, Tabs, Spin } from '../index';
15
- import usePopper from '../_utils/usePopper';
16
+ import Popper from '../popper';
16
17
  import Option from './option';
17
18
  import escapeRegExp from 'lodash/escapeRegExp';
18
19
  import KeyCode from '../_utils/KeyCode';
@@ -59,7 +60,8 @@ var InternalSelect = function InternalSelect(props, ref) {
59
60
  clearIcon = selectProps.clearIcon,
60
61
  loading = selectProps.loading,
61
62
  showDescription = selectProps.showDescription,
62
- description = selectProps.description,
63
+ _selectProps$descript = selectProps.description,
64
+ description = _selectProps$descript === void 0 ? cityPickerLangMsg.title : _selectProps$descript,
63
65
  optionHighlightProps = selectProps.optionHighlightProps,
64
66
  _selectProps$popperSt = selectProps.popperStyle,
65
67
  popperStyle = _selectProps$popperSt === void 0 ? {} : _selectProps$popperSt,
@@ -152,15 +154,6 @@ var InternalSelect = function InternalSelect(props, ref) {
152
154
  setAfterChangeFocus(false);
153
155
  onBlur && onBlur(e);
154
156
  }, [onBlur]);
155
- useEffect(function () {
156
- selectionRef.current.addEventListener('mouseup', function (e) {
157
- var _a;
158
- var isCloseBtn = ((_a = e === null || e === void 0 ? void 0 : e.target) === null || _a === void 0 ? void 0 : _a.className.indexOf('kd-tag-close-icon')) > -1;
159
- if (isCloseBtn) {
160
- e.stopPropagation();
161
- }
162
- });
163
- }, []);
164
157
  // 输入框变化搜索内容
165
158
  var handleSearchChange = useCallback(function (event) {
166
159
  var val = event.currentTarget.value;
@@ -365,14 +358,7 @@ var InternalSelect = function InternalSelect(props, ref) {
365
358
  }, [optionShow]);
366
359
  useEffect(function () {
367
360
  var _a;
368
- var fn = function fn(e) {
369
- e.stopPropagation();
370
- };
371
- (_a = clearRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener('mouseup', fn);
372
- return function () {
373
- var _a;
374
- (_a = clearRef.current) === null || _a === void 0 ? void 0 : _a.removeEventListener('mouseup', fn);
375
- };
361
+ (_a = clearRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener('click', handleReset);
376
362
  }, [initValue]);
377
363
  // keyboard
378
364
  var curkeyboardList = useMemo(function () {
@@ -402,15 +388,17 @@ var InternalSelect = function InternalSelect(props, ref) {
402
388
  setActiveIndex(index === undefined ? getActiveIndex(0) : index);
403
389
  };
404
390
  useEffect(function () {
405
- initActiveIndex(searchValue ? undefined : -1);
406
- }, [searchValue, tabsValue, curkeyboardList]);
391
+ var index = _findIndexInstanceProperty(curkeyboardList).call(curkeyboardList, function (item) {
392
+ return item.id === initValue;
393
+ });
394
+ initActiveIndex(index >= 0 ? index : undefined);
395
+ }, [curkeyboardList, initValue]);
407
396
  var onInternalKeyDown = function onInternalKeyDown(e) {
408
397
  var _a, _b, _c;
409
398
  var which = e.which;
410
399
  // open
411
400
  if (which === KeyCode.ENTER || which === KeyCode.UP || which === KeyCode.DOWN) {
412
401
  e.preventDefault();
413
- setOptionShow(true);
414
402
  }
415
403
  // up、down、enter、esc
416
404
  if (optionShow) {
@@ -431,6 +419,8 @@ var InternalSelect = function InternalSelect(props, ref) {
431
419
  break;
432
420
  }
433
421
  case KeyCode.ESC:
422
+ e.stopPropagation();
423
+ e.nativeEvent.stopImmediatePropagation();
434
424
  handleVisibleChange(false);
435
425
  break;
436
426
  default:
@@ -476,15 +466,11 @@ var InternalSelect = function InternalSelect(props, ref) {
476
466
  minWidth: width,
477
467
  maxWidth: 600
478
468
  }, dropdownStyle), {
479
- width: (dropdownStyle === null || dropdownStyle === void 0 ? void 0 : dropdownStyle.width) || 'auto',
480
- zIndex: 1050
469
+ width: (dropdownStyle === null || dropdownStyle === void 0 ? void 0 : dropdownStyle.width) || 'auto'
481
470
  }), popperStyle);
482
471
  }
483
472
  };
484
473
  var handleVisibleChange = function handleVisibleChange(visible) {
485
- if (!visible) {
486
- initActiveIndex(-1);
487
- }
488
474
  if (visible !== optionShow) {
489
475
  props.visible === undefined && setOptionShow(visible);
490
476
  onVisibleChange && onVisibleChange(visible);
@@ -504,7 +490,9 @@ var InternalSelect = function InternalSelect(props, ref) {
504
490
  }
505
491
  }
506
492
  });
507
- return usePopper(renderCityPicker(), renderContent(), popperProps);
493
+ return /*#__PURE__*/React.createElement(Popper, _extends({
494
+ tip: renderContent()
495
+ }, popperProps), renderCityPicker());
508
496
  };
509
497
  var Select = /*#__PURE__*/React.forwardRef(InternalSelect);
510
498
  Select.displayName = 'CityPicker';
@@ -33,16 +33,12 @@ var InternalOption = function InternalOption(props, ref) {
33
33
  var handleOnMouseEnter = function handleOnMouseEnter() {
34
34
  onChangeActiveIndex && onChangeActiveIndex(index);
35
35
  };
36
- var handleOnMouseLeave = function handleOnMouseLeave() {
37
- onChangeActiveIndex && onChangeActiveIndex(-1);
38
- };
39
36
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
40
37
  ref: optionRef,
41
38
  className: optionCls,
42
39
  title: name,
43
40
  onClick: handleClick,
44
- onMouseEnter: handleOnMouseEnter,
45
- onMouseLeave: handleOnMouseLeave
41
+ onMouseEnter: handleOnMouseEnter
46
42
  }, typeof itemRender === 'function' ? itemRender(city) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
47
43
  className: "".concat(selectOptionPrefixCls, "-content")
48
44
  }, children), /*#__PURE__*/React.createElement("span", {
@@ -270,6 +270,14 @@
270
270
  -webkit-box-shadow: 0 4px 10px 0 rgba(0, 0, 0, 0.2);
271
271
  box-shadow: 0 4px 10px 0 rgba(0, 0, 0, 0.2);
272
272
  }
273
+ .kd-city-picker-dropdown.kd-popper-bottom-start-in {
274
+ -webkit-animation-name: kdSlideUpIn;
275
+ animation-name: kdSlideUpIn;
276
+ }
277
+ .kd-city-picker-dropdown.kd-popper-bottom-start-out {
278
+ -webkit-animation-name: kdSlideUpOut;
279
+ animation-name: kdSlideUpOut;
280
+ }
273
281
  .kd-city-picker-dropdown .kd-tabs-tab-list {
274
282
  width: 100%;
275
283
  }
@@ -4,6 +4,7 @@
4
4
 
5
5
  @city-picker-prefix-cls: ~'@{kd-prefix}-city-picker';
6
6
  @tabs-prefix-cls: ~'@{kd-prefix}-tabs';
7
+ @popper-prefix-cls: ~'@{kd-prefix}-popper';
7
8
 
8
9
  .@{city-picker-prefix-cls} {
9
10
  position: relative;
@@ -156,6 +157,15 @@
156
157
  outline: none;
157
158
  box-shadow: 0 4px 10px 0 rgba(0, 0, 0, 0.2);
158
159
 
160
+ &.@{popper-prefix-cls}-bottom-start {
161
+ &-in {
162
+ animation-name: kdSlideUpIn;
163
+ }
164
+
165
+ &-out {
166
+ animation-name: kdSlideUpOut;
167
+ }
168
+ }
159
169
  // 调整tabs样式
160
170
  .@{tabs-prefix-cls}-tab-list {
161
171
  width: 100%;
@@ -470,7 +470,6 @@ declare const compDefaultProps: {
470
470
  defaultOpen: boolean;
471
471
  showArrow: boolean;
472
472
  placeholder: string;
473
- description: string;
474
473
  showDescription: boolean;
475
474
  optionHighlightProps: string;
476
475
  allowClear: boolean;
@@ -488,7 +488,6 @@ var compDefaultProps = {
488
488
  defaultOpen: false,
489
489
  showArrow: true,
490
490
  placeholder: '',
491
- description: '城市',
492
491
  showDescription: true,
493
492
  optionHighlightProps: 'highlightText',
494
493
  allowClear: true
@@ -69,6 +69,7 @@ declare class LocaleCache {
69
69
  'CityPicker.commonEmptyText': string;
70
70
  'CityPicker.tabsDomestic': string;
71
71
  'CityPicker.tabsInternation': string;
72
+ 'CityPicker.title': string;
72
73
  'ColorPicker.followFunctionalColor': string;
73
74
  'Search.placeholder': string;
74
75
  'Search.desc': string[];
@@ -41,6 +41,7 @@ declare const locale: {
41
41
  'CityPicker.commonEmptyText': string;
42
42
  'CityPicker.tabsDomestic': string;
43
43
  'CityPicker.tabsInternation': string;
44
+ 'CityPicker.title': string;
44
45
  'ColorPicker.followFunctionalColor': string;
45
46
  'Search.placeholder': string;
46
47
  'Search.desc': string[];
@@ -45,6 +45,7 @@ var locale = _extends(_extends({
45
45
  'CityPicker.commonEmptyText': '无常用城市',
46
46
  'CityPicker.tabsDomestic': '国内',
47
47
  'CityPicker.tabsInternation': '国际/中国港澳台',
48
+ 'CityPicker.title': '城市',
48
49
  'ColorPicker.followFunctionalColor': '跟随功能色',
49
50
  'Search.placeholder': '请输入需要搜索的内容',
50
51
  'Search.desc': ['空格代表"或",回车代表"且"'],
@@ -0,0 +1,61 @@
1
+ import React from 'react';
2
+ import { Modifier, Placement } from '@popperjs/core';
3
+ export declare const Placements: ["top", "left", "right", "bottom", "topLeft", "topRight", "bottomLeft", "bottomRight", "leftTop", "leftBottom", "rightTop", "rightBottom"];
4
+ export declare type PlacementType = typeof Placements[number];
5
+ export declare const Triggers: ["hover", "focus", "click", "contextMenu"];
6
+ export declare type TriggerType = typeof Triggers[number];
7
+ export declare type Reason = TriggerType | 'scroll' | 'clickOutside' | 'clickToClose' | 'parentHidden' | 'unknown';
8
+ export declare type RenderFunction = () => React.ReactNode;
9
+ export declare type PopperProps = {
10
+ gap?: number;
11
+ arrow?: boolean;
12
+ visible?: boolean;
13
+ prefixCls?: string;
14
+ arrowSize?: number;
15
+ disabled?: boolean;
16
+ arrowOffset?: number;
17
+ scrollHidden?: boolean;
18
+ mouseEnterDelay?: number;
19
+ mouseLeaveDelay?: number;
20
+ defaultVisible?: boolean;
21
+ autoPlacement?: boolean;
22
+ autoPlacementList?: Placement[];
23
+ className?: string;
24
+ style?: React.CSSProperties;
25
+ popperClassName?: string;
26
+ popperStyle?: React.CSSProperties;
27
+ popperOuterClassName?: string;
28
+ popperOuterStyle?: React.CSSProperties;
29
+ placement?: PlacementType;
30
+ tip?: any;
31
+ trigger?: TriggerType | Array<TriggerType>;
32
+ strategy?: 'fixed' | 'absolute';
33
+ clickToClose?: boolean;
34
+ onTrigger?: (trigger: TriggerType) => void;
35
+ onVisibleChange?: (visible: boolean, reason?: Reason) => void;
36
+ getTriggerElement?: (locatorNode: HTMLElement) => HTMLElement;
37
+ getPopupContainer?: (locatorNode: HTMLElement) => HTMLElement;
38
+ onTransitionEnd?: (e: React.TransitionEvent) => void;
39
+ onAnimationEnd?: (e: React.AnimationEvent) => void;
40
+ children?: React.ReactNode;
41
+ customerModifiers?: (modifiers: Partial<Modifier<any, any>>[]) => Partial<Modifier<any, any>>[];
42
+ };
43
+ export interface TriggerContextProps {
44
+ registerSubPopup: (id: string, node: any) => void;
45
+ }
46
+ export declare const popperPlacementMap: {
47
+ top: string;
48
+ left: string;
49
+ right: string;
50
+ bottom: string;
51
+ topLeft: string;
52
+ topRight: string;
53
+ bottomLeft: string;
54
+ bottomRight: string;
55
+ leftTop: string;
56
+ leftBottom: string;
57
+ rightTop: string;
58
+ rightBottom: string;
59
+ };
60
+ export declare const Popper: React.ForwardRefExoticComponent<PopperProps & React.RefAttributes<unknown>>;
61
+ export default Popper;