Socket
Socket
Sign inDemoInstall

rc-cascader

Package Overview
Dependencies
Maintainers
5
Versions
166
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rc-cascader - npm Package Compare versions

Comparing version 3.8.0 to 3.8.1

2

es/Cascader.d.ts
import type { BaseSelectPropsWithoutPrivate, BaseSelectRef } from 'rc-select';
import type { Placement } from 'rc-select/lib/BaseSelect';
import type { BuildInPlacements } from 'rc-trigger/lib/interface';
import * as React from 'react';

@@ -60,2 +61,3 @@ import { SHOW_CHILD, SHOW_PARENT } from './utils/commonUtil';

placement?: Placement;
builtinPlacements?: BuildInPlacements;
/** @deprecated Use `onDropdownVisibleChange` instead */

@@ -62,0 +64,0 @@ onPopupVisibleChange?: (open: boolean) => void;

2

es/OptionList/Column.js

@@ -104,3 +104,3 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";

key: fullPathKey,
className: classNames(menuItemPrefixCls, (_classNames = {}, _defineProperty(_classNames, "".concat(menuItemPrefixCls, "-expand"), !isMergedLeaf), _defineProperty(_classNames, "".concat(menuItemPrefixCls, "-active"), activeValue === value), _defineProperty(_classNames, "".concat(menuItemPrefixCls, "-disabled"), disabled), _defineProperty(_classNames, "".concat(menuItemPrefixCls, "-loading"), isLoading), _classNames)),
className: classNames(menuItemPrefixCls, (_classNames = {}, _defineProperty(_classNames, "".concat(menuItemPrefixCls, "-expand"), !isMergedLeaf), _defineProperty(_classNames, "".concat(menuItemPrefixCls, "-active"), activeValue === value || activeValue === fullPathKey), _defineProperty(_classNames, "".concat(menuItemPrefixCls, "-disabled"), disabled), _defineProperty(_classNames, "".concat(menuItemPrefixCls, "-loading"), isLoading), _classNames)),
style: dropdownMenuColumnStyle,

@@ -107,0 +107,0 @@ role: "menuitemcheckbox",

@@ -11,3 +11,3 @@ import _extends from "@babel/runtime/helpers/esm/extends";

import CascaderContext from '../context';
import { isLeaf, scrollIntoParentView, toPathKey, toPathKeys, toPathValueStr } from '../utils/commonUtil';
import { getFullPathKeys, isLeaf, scrollIntoParentView, toPathKey, toPathKeys, toPathValueStr } from '../utils/commonUtil';
import { toPathOptions } from '../utils/treeUtil';

@@ -127,6 +127,7 @@ import Column, { FIX_LABEL } from './Column';

var currentList = mergedOptions;
var _loop = function _loop(i) {
var fullPathKeys = getFullPathKeys(currentList, fieldNames);
var _loop = function _loop() {
var activeValueCell = activeValueCells[i];
var currentOption = currentList.find(function (option) {
return option[fieldNames.value] === activeValueCell;
var currentOption = currentList.find(function (option, index) {
return (fullPathKeys[index] ? toPathKey(fullPathKeys[index]) : option[fieldNames.value]) === activeValueCell;
});

@@ -143,3 +144,3 @@ var subOptions = currentOption === null || currentOption === void 0 ? void 0 : currentOption[fieldNames.children];

for (var i = 0; i < activeValueCells.length; i += 1) {
var _ret = _loop(i);
var _ret = _loop();
if (_ret === "break") break;

@@ -146,0 +147,0 @@ }

@@ -0,5 +1,5 @@

import type { RefOptionListProps } from 'rc-select/lib/OptionList';
import * as React from 'react';
import type { RefOptionListProps } from 'rc-select/lib/OptionList';
import type { DefaultOptionType, InternalFieldNames, SingleValueType } from '../Cascader';
declare const _default: (ref: React.Ref<RefOptionListProps>, options: DefaultOptionType[], fieldNames: InternalFieldNames, activeValueCells: React.Key[], setActiveValueCells: (activeValueCells: React.Key[]) => void, onKeyBoardSelect: (valueCells: SingleValueType, option: DefaultOptionType) => void) => void;
export default _default;
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
import * as React from 'react';
import { useBaseProps } from 'rc-select';
import KeyCode from "rc-util/es/KeyCode";
import * as React from 'react';
import { SEARCH_MARK } from '../hooks/useSearchOptions';
import { getFullPathKeys, toPathKey } from '../utils/commonUtil';
export default (function (ref, options, fieldNames, activeValueCells, setActiveValueCells, onKeyBoardSelect) {

@@ -20,7 +21,8 @@ var _useBaseProps = useBaseProps(),

var len = activeValueCells.length;
var pathKeys = getFullPathKeys(options, fieldNames);
// Fill validate active value cells and index
var _loop = function _loop(i) {
// Mark the active index for current options
var nextActiveIndex = currentOptions.findIndex(function (option) {
return option[fieldNames.value] === activeValueCells[i];
var nextActiveIndex = currentOptions.findIndex(function (option, index) {
return (pathKeys[index] ? toPathKey(pathKeys[index]) : option[fieldNames.value]) === activeValueCells[i];
});

@@ -44,8 +46,9 @@ if (nextActiveIndex === -1) {

}
return [mergedActiveValueCells, activeIndex, activeOptions];
return [mergedActiveValueCells, activeIndex, activeOptions, pathKeys];
}, [activeValueCells, fieldNames, options]),
_React$useMemo2 = _slicedToArray(_React$useMemo, 3),
_React$useMemo2 = _slicedToArray(_React$useMemo, 4),
validActiveValueCells = _React$useMemo2[0],
lastActiveIndex = _React$useMemo2[1],
lastActiveOptions = _React$useMemo2[2];
lastActiveOptions = _React$useMemo2[2],
fullPathKeys = _React$useMemo2[3];
// Update active value cells and scroll to target element

@@ -66,4 +69,3 @@ var internalSetActiveValueCells = function internalSetActiveValueCells(next) {

if (option && !option.disabled) {
var value = option[fieldNames.value];
var nextActiveCells = validActiveValueCells.slice(0, -1).concat(value);
var nextActiveCells = validActiveValueCells.slice(0, -1).concat(fullPathKeys[currentIndex] ? toPathKey(fullPathKeys[currentIndex]) : option[fieldNames.value]);
internalSetActiveValueCells(nextActiveCells);

@@ -70,0 +72,0 @@ return;

@@ -11,1 +11,2 @@ import type { DefaultOptionType, FieldNames, InternalFieldNames, SingleValueType } from '../Cascader';

export declare function scrollIntoParentView(element: HTMLElement): void;
export declare function getFullPathKeys(options: DefaultOptionType[], fieldNames: FieldNames): any[];

@@ -0,1 +1,2 @@

import { SEARCH_MARK } from '../hooks/useSearchOptions';
export var VALUE_SPLIT = '__RC_CASCADER_SPLIT__';

@@ -45,2 +46,10 @@ export var SHOW_PARENT = 'SHOW_PARENT';

}
}
export function getFullPathKeys(options, fieldNames) {
return options.map(function (item) {
var _item$SEARCH_MARK;
return (_item$SEARCH_MARK = item[SEARCH_MARK]) === null || _item$SEARCH_MARK === void 0 ? void 0 : _item$SEARCH_MARK.map(function (opt) {
return opt[fieldNames.value];
});
});
}

@@ -18,3 +18,3 @@ import { SHOW_CHILD } from './commonUtil';

var valueOptions = [];
var _loop = function _loop(i) {
var _loop = function _loop() {
var _currentList, _currentList2, _foundOption$fieldNam;

@@ -35,5 +35,5 @@ var valueCell = valueCells[i];

for (var i = 0; i < valueCells.length; i += 1) {
_loop(i);
_loop();
}
return valueOptions;
}
import type { BaseSelectPropsWithoutPrivate, BaseSelectRef } from 'rc-select';
import type { Placement } from 'rc-select/lib/BaseSelect';
import type { BuildInPlacements } from 'rc-trigger/lib/interface';
import * as React from 'react';

@@ -60,2 +61,3 @@ import { SHOW_CHILD, SHOW_PARENT } from './utils/commonUtil';

placement?: Placement;
builtinPlacements?: BuildInPlacements;
/** @deprecated Use `onDropdownVisibleChange` instead */

@@ -62,0 +64,0 @@ onPopupVisibleChange?: (open: boolean) => void;

@@ -116,3 +116,3 @@ "use strict";

key: fullPathKey,
className: (0, _classnames.default)(menuItemPrefixCls, (_classNames = {}, (0, _defineProperty2.default)(_classNames, "".concat(menuItemPrefixCls, "-expand"), !isMergedLeaf), (0, _defineProperty2.default)(_classNames, "".concat(menuItemPrefixCls, "-active"), activeValue === value), (0, _defineProperty2.default)(_classNames, "".concat(menuItemPrefixCls, "-disabled"), disabled), (0, _defineProperty2.default)(_classNames, "".concat(menuItemPrefixCls, "-loading"), isLoading), _classNames)),
className: (0, _classnames.default)(menuItemPrefixCls, (_classNames = {}, (0, _defineProperty2.default)(_classNames, "".concat(menuItemPrefixCls, "-expand"), !isMergedLeaf), (0, _defineProperty2.default)(_classNames, "".concat(menuItemPrefixCls, "-active"), activeValue === value || activeValue === fullPathKey), (0, _defineProperty2.default)(_classNames, "".concat(menuItemPrefixCls, "-disabled"), disabled), (0, _defineProperty2.default)(_classNames, "".concat(menuItemPrefixCls, "-loading"), isLoading), _classNames)),
style: dropdownMenuColumnStyle,

@@ -119,0 +119,0 @@ role: "menuitemcheckbox",

@@ -137,6 +137,7 @@ "use strict";

var currentList = mergedOptions;
var _loop = function _loop(i) {
var fullPathKeys = (0, _commonUtil.getFullPathKeys)(currentList, fieldNames);
var _loop = function _loop() {
var activeValueCell = activeValueCells[i];
var currentOption = currentList.find(function (option) {
return option[fieldNames.value] === activeValueCell;
var currentOption = currentList.find(function (option, index) {
return (fullPathKeys[index] ? (0, _commonUtil.toPathKey)(fullPathKeys[index]) : option[fieldNames.value]) === activeValueCell;
});

@@ -153,3 +154,3 @@ var subOptions = currentOption === null || currentOption === void 0 ? void 0 : currentOption[fieldNames.children];

for (var i = 0; i < activeValueCells.length; i += 1) {
var _ret = _loop(i);
var _ret = _loop();
if (_ret === "break") break;

@@ -156,0 +157,0 @@ }

@@ -0,5 +1,5 @@

import type { RefOptionListProps } from 'rc-select/lib/OptionList';
import * as React from 'react';
import type { RefOptionListProps } from 'rc-select/lib/OptionList';
import type { DefaultOptionType, InternalFieldNames, SingleValueType } from '../Cascader';
declare const _default: (ref: React.Ref<RefOptionListProps>, options: DefaultOptionType[], fieldNames: InternalFieldNames, activeValueCells: React.Key[], setActiveValueCells: (activeValueCells: React.Key[]) => void, onKeyBoardSelect: (valueCells: SingleValueType, option: DefaultOptionType) => void) => void;
export default _default;

@@ -11,6 +11,7 @@ "use strict";

var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
var React = _interopRequireWildcard(require("react"));
var _rcSelect = require("rc-select");
var _KeyCode = _interopRequireDefault(require("rc-util/lib/KeyCode"));
var React = _interopRequireWildcard(require("react"));
var _useSearchOptions = require("../hooks/useSearchOptions");
var _commonUtil = require("../utils/commonUtil");
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

@@ -31,7 +32,8 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

var len = activeValueCells.length;
var pathKeys = (0, _commonUtil.getFullPathKeys)(options, fieldNames);
// Fill validate active value cells and index
var _loop = function _loop(i) {
// Mark the active index for current options
var nextActiveIndex = currentOptions.findIndex(function (option) {
return option[fieldNames.value] === activeValueCells[i];
var nextActiveIndex = currentOptions.findIndex(function (option, index) {
return (pathKeys[index] ? (0, _commonUtil.toPathKey)(pathKeys[index]) : option[fieldNames.value]) === activeValueCells[i];
});

@@ -55,8 +57,9 @@ if (nextActiveIndex === -1) {

}
return [mergedActiveValueCells, activeIndex, activeOptions];
return [mergedActiveValueCells, activeIndex, activeOptions, pathKeys];
}, [activeValueCells, fieldNames, options]),
_React$useMemo2 = (0, _slicedToArray2.default)(_React$useMemo, 3),
_React$useMemo2 = (0, _slicedToArray2.default)(_React$useMemo, 4),
validActiveValueCells = _React$useMemo2[0],
lastActiveIndex = _React$useMemo2[1],
lastActiveOptions = _React$useMemo2[2];
lastActiveOptions = _React$useMemo2[2],
fullPathKeys = _React$useMemo2[3];
// Update active value cells and scroll to target element

@@ -77,4 +80,3 @@ var internalSetActiveValueCells = function internalSetActiveValueCells(next) {

if (option && !option.disabled) {
var value = option[fieldNames.value];
var nextActiveCells = validActiveValueCells.slice(0, -1).concat(value);
var nextActiveCells = validActiveValueCells.slice(0, -1).concat(fullPathKeys[currentIndex] ? (0, _commonUtil.toPathKey)(fullPathKeys[currentIndex]) : option[fieldNames.value]);
internalSetActiveValueCells(nextActiveCells);

@@ -81,0 +83,0 @@ return;

@@ -11,1 +11,2 @@ import type { DefaultOptionType, FieldNames, InternalFieldNames, SingleValueType } from '../Cascader';

export declare function scrollIntoParentView(element: HTMLElement): void;
export declare function getFullPathKeys(options: DefaultOptionType[], fieldNames: FieldNames): any[];

@@ -8,2 +8,3 @@ "use strict";

exports.fillFieldNames = fillFieldNames;
exports.getFullPathKeys = getFullPathKeys;
exports.isLeaf = isLeaf;

@@ -14,2 +15,3 @@ exports.scrollIntoParentView = scrollIntoParentView;

exports.toPathValueStr = toPathValueStr;
var _useSearchOptions = require("../hooks/useSearchOptions");
var VALUE_SPLIT = '__RC_CASCADER_SPLIT__';

@@ -62,2 +64,10 @@ exports.VALUE_SPLIT = VALUE_SPLIT;

}
}
function getFullPathKeys(options, fieldNames) {
return options.map(function (item) {
var _item$SEARCH_MARK;
return (_item$SEARCH_MARK = item[_useSearchOptions.SEARCH_MARK]) === null || _item$SEARCH_MARK === void 0 ? void 0 : _item$SEARCH_MARK.map(function (opt) {
return opt[fieldNames.value];
});
});
}

@@ -25,3 +25,3 @@ "use strict";

var valueOptions = [];
var _loop = function _loop(i) {
var _loop = function _loop() {
var _currentList, _currentList2, _foundOption$fieldNam;

@@ -42,5 +42,5 @@ var valueCell = valueCells[i];

for (var i = 0; i < valueCells.length; i += 1) {
_loop(i);
_loop();
}
return valueOptions;
}
{
"name": "rc-cascader",
"version": "3.8.0",
"version": "3.8.1",
"description": "cascade select ui component for react",

@@ -51,3 +51,3 @@ "keywords": [

"cross-env": "^7.0.0",
"dumi": "^1.1.12",
"dumi": "^2.1.10",
"enzyme": "^3.3.0",

@@ -65,3 +65,4 @@ "enzyme-adapter-react-16": "^1.0.2",

"react-dom": "^16.0.0",
"typescript": "^4.4.2"
"typescript": "^4.4.2",
"less": "^3.13.1"
},

@@ -68,0 +69,0 @@ "dependencies": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc