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.17.0 to 3.18.0

assets/panel.less

2

es/Cascader.d.ts

@@ -5,2 +5,3 @@ import type { BuildInPlacements } from '@rc-component/trigger/lib/interface';

import * as React from 'react';
import Panel from './Panel';
import { SHOW_CHILD, SHOW_PARENT } from './utils/commonUtil';

@@ -92,3 +93,4 @@ export interface ShowSearchType<OptionType extends BaseOptionType = DefaultOptionType> {

SHOW_CHILD: typeof SHOW_CHILD;
Panel: typeof Panel;
};
export default Cascader;

119

es/Cascader.js

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

import useId from "rc-select/es/hooks/useId";
import { conductCheck } from "rc-tree/es/utils/conductUtil";
import useEvent from "rc-util/es/hooks/useEvent";

@@ -15,24 +14,13 @@ import useMergedState from "rc-util/es/hooks/useMergedState";

import useDisplayValues from "./hooks/useDisplayValues";
import useEntities from "./hooks/useEntities";
import useMissingValues from "./hooks/useMissingValues";
import useOptions from "./hooks/useOptions";
import useSearchConfig from "./hooks/useSearchConfig";
import useSearchOptions from "./hooks/useSearchOptions";
import useSelect from "./hooks/useSelect";
import useValues from "./hooks/useValues";
import OptionList from "./OptionList";
import { fillFieldNames, SHOW_CHILD, SHOW_PARENT, toPathKey, toPathKeys } from "./utils/commonUtil";
import Panel from "./Panel";
import { fillFieldNames, SHOW_CHILD, SHOW_PARENT, toPathKeys, toRawValues } from "./utils/commonUtil";
import { formatStrategyValues, toPathOptions } from "./utils/treeUtil";
import warningProps, { warningNullOptions } from "./utils/warningPropsUtil";
function isMultipleValue(value) {
return Array.isArray(value) && Array.isArray(value[0]);
}
function toRawValues(value) {
if (!value) {
return [];
}
if (isMultipleValue(value)) {
return value;
}
return (value.length === 0 ? [] : [value]).map(function (val) {
return Array.isArray(val) ? val : [val];
});
}
var Cascader = /*#__PURE__*/React.forwardRef(function (props, ref) {

@@ -96,20 +84,8 @@ var id = props.id,

// =========================== Option ===========================
var mergedOptions = React.useMemo(function () {
return options || [];
}, [options]);
var _useOptions = useOptions(mergedFieldNames, options),
_useOptions2 = _slicedToArray(_useOptions, 3),
mergedOptions = _useOptions2[0],
getPathKeyEntities = _useOptions2[1],
getValueByKeyPath = _useOptions2[2];
// Only used in multiple mode, this fn will not call in single mode
var getPathKeyEntities = useEntities(mergedOptions, mergedFieldNames);
/** Convert path key back to value format */
var getValueByKeyPath = React.useCallback(function (pathKeys) {
var keyPathEntities = getPathKeyEntities();
return pathKeys.map(function (pathKey) {
var nodes = keyPathEntities[pathKey].nodes;
return nodes.map(function (node) {
return node[mergedFieldNames.value];
});
});
}, [getPathKeyEntities, mergedFieldNames]);
// =========================== Search ===========================

@@ -141,23 +117,7 @@ var _useMergedState3 = useMergedState('', {

// Fill `rawValues` with checked conduction values
var _React$useMemo = React.useMemo(function () {
var _getMissingValues = getMissingValues(rawValues),
_getMissingValues2 = _slicedToArray(_getMissingValues, 2),
existValues = _getMissingValues2[0],
missingValues = _getMissingValues2[1];
if (!multiple || !rawValues.length) {
return [existValues, [], missingValues];
}
var keyPathValues = toPathKeys(existValues);
var keyPathEntities = getPathKeyEntities();
var _conductCheck = conductCheck(keyPathValues, true, keyPathEntities),
checkedKeys = _conductCheck.checkedKeys,
halfCheckedKeys = _conductCheck.halfCheckedKeys;
// Convert key back to value cells
return [getValueByKeyPath(checkedKeys), getValueByKeyPath(halfCheckedKeys), missingValues];
}, [multiple, rawValues, getPathKeyEntities, getValueByKeyPath, getMissingValues]),
_React$useMemo2 = _slicedToArray(_React$useMemo, 3),
checkedValues = _React$useMemo2[0],
halfCheckedValues = _React$useMemo2[1],
missingCheckedValues = _React$useMemo2[2];
var _useValues = useValues(multiple, rawValues, getPathKeyEntities, getValueByKeyPath, getMissingValues),
_useValues2 = _slicedToArray(_useValues, 3),
checkedValues = _useValues2[0],
halfCheckedValues = _useValues2[1],
missingCheckedValues = _useValues2[2];
var deDuplicatedValues = React.useMemo(function () {

@@ -189,2 +149,3 @@ var checkedKeys = toPathKeys(checkedValues);

// =========================== Select ===========================
var handleSelection = useSelect(multiple, triggerChange, checkedValues, halfCheckedValues, missingCheckedValues, getPathKeyEntities, getValueByKeyPath, showCheckedStrategy);
var onInternalSelect = useEvent(function (valuePath) {

@@ -194,48 +155,3 @@ if (!multiple || autoClearSearchValue) {

}
if (!multiple) {
triggerChange(valuePath);
} else {
// Prepare conduct required info
var pathKey = toPathKey(valuePath);
var checkedPathKeys = toPathKeys(checkedValues);
var halfCheckedPathKeys = toPathKeys(halfCheckedValues);
var existInChecked = checkedPathKeys.includes(pathKey);
var existInMissing = missingCheckedValues.some(function (valueCells) {
return toPathKey(valueCells) === pathKey;
});
// Do update
var nextCheckedValues = checkedValues;
var nextMissingValues = missingCheckedValues;
if (existInMissing && !existInChecked) {
// Missing value only do filter
nextMissingValues = missingCheckedValues.filter(function (valueCells) {
return toPathKey(valueCells) !== pathKey;
});
} else {
// Update checked key first
var nextRawCheckedKeys = existInChecked ? checkedPathKeys.filter(function (key) {
return key !== pathKey;
}) : [].concat(_toConsumableArray(checkedPathKeys), [pathKey]);
var pathKeyEntities = getPathKeyEntities();
// Conduction by selected or not
var checkedKeys;
if (existInChecked) {
var _conductCheck2 = conductCheck(nextRawCheckedKeys, {
checked: false,
halfCheckedKeys: halfCheckedPathKeys
}, pathKeyEntities);
checkedKeys = _conductCheck2.checkedKeys;
} else {
var _conductCheck3 = conductCheck(nextRawCheckedKeys, true, pathKeyEntities);
checkedKeys = _conductCheck3.checkedKeys;
}
// Roll up to parent level keys
var deDuplicatedKeys = formatStrategyValues(checkedKeys, getPathKeyEntities, showCheckedStrategy);
nextCheckedValues = getValueByKeyPath(deDuplicatedKeys);
}
triggerChange([].concat(_toConsumableArray(nextMissingValues), _toConsumableArray(nextCheckedValues)));
}
handleSelection(valuePath);
});

@@ -344,2 +260,3 @@

Cascader.SHOW_CHILD = SHOW_CHILD;
Cascader.Panel = Panel;
export default Cascader;

@@ -1,3 +0,3 @@

import type { SingleValueType, DefaultOptionType, InternalFieldNames } from '../Cascader';
declare const _default: (options: DefaultOptionType[], fieldNames: InternalFieldNames) => (rawValues: SingleValueType[]) => [SingleValueType[], SingleValueType[]];
export default _default;
import type { DefaultOptionType, InternalFieldNames, SingleValueType } from '../Cascader';
export type GetMissValues = ReturnType<typeof useMissingValues>;
export default function useMissingValues(options: DefaultOptionType[], fieldNames: InternalFieldNames): (rawValues: SingleValueType[]) => [SingleValueType[], SingleValueType[]];
import * as React from 'react';
import { toPathOptions } from "../utils/treeUtil";
export default (function (options, fieldNames) {
export default function useMissingValues(options, fieldNames) {
return React.useCallback(function (rawValues) {

@@ -19,2 +19,2 @@ var missingValues = [];

}, [options, fieldNames]);
});
}
import Cascader from './Cascader';
export type { CascaderProps, FieldNames, ShowSearchType, DefaultOptionType, BaseOptionType, SingleCascaderProps, MultipleCascaderProps, } from './Cascader';
import Panel from './Panel';
export type { BaseOptionType, CascaderProps, DefaultOptionType, FieldNames, MultipleCascaderProps, ShowSearchType, SingleCascaderProps, } from './Cascader';
export { Panel };
export default Cascader;
import Cascader from "./Cascader";
import Panel from "./Panel";
export { Panel };
export default Cascader;
import _extends from "@babel/runtime/helpers/esm/extends";
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
/* eslint-disable default-case */
import classNames from 'classnames';
import { useBaseProps } from 'rc-select';
import * as React from 'react';
import CascaderContext from "../context";
import { getFullPathKeys, isLeaf, scrollIntoParentView, toPathKey, toPathKeys, toPathValueStr } from "../utils/commonUtil";
import { toPathOptions } from "../utils/treeUtil";
import CacheContent from "./CacheContent";
import Column, { FIX_LABEL } from "./Column";
import useActive from "./useActive";
import useKeyboard from "./useKeyboard";
import RawOptionList from "./List";
var RefOptionList = /*#__PURE__*/React.forwardRef(function (props, ref) {
var _optionColumns$, _optionColumns$$optio, _ref3, _classNames;
var _useBaseProps = useBaseProps(),
prefixCls = _useBaseProps.prefixCls,
multiple = _useBaseProps.multiple,
searchValue = _useBaseProps.searchValue,
toggleOpen = _useBaseProps.toggleOpen,
notFoundContent = _useBaseProps.notFoundContent,
direction = _useBaseProps.direction,
open = _useBaseProps.open;
var containerRef = React.useRef();
var rtl = direction === 'rtl';
var _React$useContext = React.useContext(CascaderContext),
options = _React$useContext.options,
values = _React$useContext.values,
halfValues = _React$useContext.halfValues,
fieldNames = _React$useContext.fieldNames,
changeOnSelect = _React$useContext.changeOnSelect,
onSelect = _React$useContext.onSelect,
searchOptions = _React$useContext.searchOptions,
dropdownPrefixCls = _React$useContext.dropdownPrefixCls,
loadData = _React$useContext.loadData,
expandTrigger = _React$useContext.expandTrigger;
var mergedPrefixCls = dropdownPrefixCls || prefixCls;
var baseProps = useBaseProps();
// ========================= loadData =========================
var _React$useState = React.useState([]),
_React$useState2 = _slicedToArray(_React$useState, 2),
loadingKeys = _React$useState2[0],
setLoadingKeys = _React$useState2[1];
var internalLoadData = function internalLoadData(valueCells) {
// Do not load when search
if (!loadData || searchValue) {
return;
}
var optionList = toPathOptions(valueCells, options, fieldNames);
var rawOptions = optionList.map(function (_ref) {
var option = _ref.option;
return option;
});
var lastOption = rawOptions[rawOptions.length - 1];
if (lastOption && !isLeaf(lastOption, fieldNames)) {
var pathKey = toPathKey(valueCells);
setLoadingKeys(function (keys) {
return [].concat(_toConsumableArray(keys), [pathKey]);
});
loadData(rawOptions);
}
};
// zombieJ: This is bad. We should make this same as `rc-tree` to use Promise instead.
React.useEffect(function () {
if (loadingKeys.length) {
loadingKeys.forEach(function (loadingKey) {
var valueStrCells = toPathValueStr(loadingKey);
var optionList = toPathOptions(valueStrCells, options, fieldNames, true).map(function (_ref2) {
var option = _ref2.option;
return option;
});
var lastOption = optionList[optionList.length - 1];
if (!lastOption || lastOption[fieldNames.children] || isLeaf(lastOption, fieldNames)) {
setLoadingKeys(function (keys) {
return keys.filter(function (key) {
return key !== loadingKey;
});
});
}
});
}
}, [options, loadingKeys, fieldNames]);
// ========================== Values ==========================
var checkedSet = React.useMemo(function () {
return new Set(toPathKeys(values));
}, [values]);
var halfCheckedSet = React.useMemo(function () {
return new Set(toPathKeys(halfValues));
}, [halfValues]);
// ====================== Accessibility =======================
var _useActive = useActive(),
_useActive2 = _slicedToArray(_useActive, 2),
activeValueCells = _useActive2[0],
setActiveValueCells = _useActive2[1];
// =========================== Path ===========================
var onPathOpen = function onPathOpen(nextValueCells) {
setActiveValueCells(nextValueCells);
// Trigger loadData
internalLoadData(nextValueCells);
};
var isSelectable = function isSelectable(option) {
var disabled = option.disabled;
var isMergedLeaf = isLeaf(option, fieldNames);
return !disabled && (isMergedLeaf || changeOnSelect || multiple);
};
var onPathSelect = function onPathSelect(valuePath, leaf) {
var fromKeyboard = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
onSelect(valuePath);
if (!multiple && (leaf || changeOnSelect && (expandTrigger === 'hover' || fromKeyboard))) {
toggleOpen(false);
}
};
// ========================== Option ==========================
var mergedOptions = React.useMemo(function () {
if (searchValue) {
return searchOptions;
}
return options;
}, [searchValue, searchOptions, options]);
// ========================== Column ==========================
var optionColumns = React.useMemo(function () {
var optionList = [{
options: mergedOptions
}];
var currentList = mergedOptions;
var fullPathKeys = getFullPathKeys(currentList, fieldNames);
var _loop = function _loop() {
var activeValueCell = activeValueCells[i];
var currentOption = currentList.find(function (option, index) {
return (fullPathKeys[index] ? toPathKey(fullPathKeys[index]) : option[fieldNames.value]) === activeValueCell;
});
var subOptions = currentOption === null || currentOption === void 0 ? void 0 : currentOption[fieldNames.children];
if (!(subOptions !== null && subOptions !== void 0 && subOptions.length)) {
return "break";
}
currentList = subOptions;
optionList.push({
options: subOptions
});
};
for (var i = 0; i < activeValueCells.length; i += 1) {
var _ret = _loop();
if (_ret === "break") break;
}
return optionList;
}, [mergedOptions, activeValueCells, fieldNames]);
// ========================= Keyboard =========================
var onKeyboardSelect = function onKeyboardSelect(selectValueCells, option) {
if (isSelectable(option)) {
onPathSelect(selectValueCells, isLeaf(option, fieldNames), true);
}
};
useKeyboard(ref, mergedOptions, fieldNames, activeValueCells, onPathOpen, onKeyboardSelect);
// >>>>> Active Scroll
React.useEffect(function () {
for (var i = 0; i < activeValueCells.length; i += 1) {
var _containerRef$current;
var cellPath = activeValueCells.slice(0, i + 1);
var cellKeyPath = toPathKey(cellPath);
var ele = (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.querySelector("li[data-path-key=\"".concat(cellKeyPath.replace(/\\{0,2}"/g, '\\"'), "\"]") // matches unescaped double quotes
);
if (ele) {
scrollIntoParentView(ele);
}
}
}, [activeValueCells]);
// ========================== Render ==========================
// >>>>> Empty
var isEmpty = !((_optionColumns$ = optionColumns[0]) !== null && _optionColumns$ !== void 0 && (_optionColumns$$optio = _optionColumns$.options) !== null && _optionColumns$$optio !== void 0 && _optionColumns$$optio.length);
var emptyList = [(_ref3 = {}, _defineProperty(_ref3, fieldNames.value, '__EMPTY__'), _defineProperty(_ref3, FIX_LABEL, notFoundContent), _defineProperty(_ref3, "disabled", true), _ref3)];
var columnProps = _objectSpread(_objectSpread({}, props), {}, {
multiple: !isEmpty && multiple,
onSelect: onPathSelect,
onActive: onPathOpen,
onToggleOpen: toggleOpen,
checkedSet: checkedSet,
halfCheckedSet: halfCheckedSet,
loadingKeys: loadingKeys,
isSelectable: isSelectable
});
// >>>>> Columns
var mergedOptionColumns = isEmpty ? [{
options: emptyList
}] : optionColumns;
var columnNodes = mergedOptionColumns.map(function (col, index) {
var prevValuePath = activeValueCells.slice(0, index);
var activeValue = activeValueCells[index];
return /*#__PURE__*/React.createElement(Column, _extends({
key: index
}, columnProps, {
searchValue: searchValue,
prefixCls: mergedPrefixCls,
options: col.options,
prevValuePath: prevValuePath,
activeValue: activeValue
}));
});
// >>>>> Render
return /*#__PURE__*/React.createElement(CacheContent, {
open: open
}, /*#__PURE__*/React.createElement("div", {
className: classNames("".concat(mergedPrefixCls, "-menus"), (_classNames = {}, _defineProperty(_classNames, "".concat(mergedPrefixCls, "-menu-empty"), isEmpty), _defineProperty(_classNames, "".concat(mergedPrefixCls, "-rtl"), rtl), _classNames)),
ref: containerRef
}, columnNodes));
return /*#__PURE__*/React.createElement(RawOptionList, _extends({}, props, baseProps, {
ref: ref
}));
});
export default RefOptionList;

@@ -5,3 +5,3 @@ import * as React from 'react';

*/
declare const _default: () => [React.Key[], (activeValueCells: React.Key[]) => void];
declare const _default: (multiple: boolean, open: boolean) => [React.Key[], (activeValueCells: React.Key[]) => void];
export default _default;
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
import * as React from 'react';
import CascaderContext from "../context";
import { useBaseProps } from 'rc-select';

@@ -9,6 +8,3 @@ /**

*/
export default (function () {
var _useBaseProps = useBaseProps(),
multiple = _useBaseProps.multiple,
open = _useBaseProps.open;
export default (function (multiple, open) {
var _React$useContext = React.useContext(CascaderContext),

@@ -15,0 +11,0 @@ values = _React$useContext.values;

import type { RefOptionListProps } from 'rc-select/lib/OptionList';
import * as React from 'react';
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;
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, contextProps: {
direction: 'ltr' | 'rtl';
searchValue: string;
toggleOpen: (open?: boolean) => void;
open: boolean;
}) => void;
export default _default;
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
import { useBaseProps } from 'rc-select';
import KeyCode from "rc-util/es/KeyCode";

@@ -8,8 +7,7 @@ import * as React from 'react';

import { getFullPathKeys, toPathKey } from "../utils/commonUtil";
export default (function (ref, options, fieldNames, activeValueCells, setActiveValueCells, onKeyBoardSelect) {
var _useBaseProps = useBaseProps(),
direction = _useBaseProps.direction,
searchValue = _useBaseProps.searchValue,
toggleOpen = _useBaseProps.toggleOpen,
open = _useBaseProps.open;
export default (function (ref, options, fieldNames, activeValueCells, setActiveValueCells, onKeyBoardSelect, contextProps) {
var direction = contextProps.direction,
searchValue = contextProps.searchValue,
toggleOpen = contextProps.toggleOpen,
open = contextProps.open;
var rtl = direction === 'rtl';

@@ -16,0 +14,0 @@ var _React$useMemo = React.useMemo(function () {

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

import type { DefaultOptionType, FieldNames, InternalFieldNames, SingleValueType } from '../Cascader';
import type { DefaultOptionType, FieldNames, InternalFieldNames, SingleValueType, ValueType } from '../Cascader';
export declare const VALUE_SPLIT = "__RC_CASCADER_SPLIT__";

@@ -18,1 +18,2 @@ export declare const SHOW_PARENT = "SHOW_PARENT";

export declare function getFullPathKeys(options: DefaultOptionType[], fieldNames: FieldNames): any[];
export declare function toRawValues(value: ValueType): SingleValueType[];

@@ -62,2 +62,16 @@ import { SEARCH_MARK } from "../hooks/useSearchOptions";

});
}
function isMultipleValue(value) {
return Array.isArray(value) && Array.isArray(value[0]);
}
export function toRawValues(value) {
if (!value) {
return [];
}
if (isMultipleValue(value)) {
return value;
}
return (value.length === 0 ? [] : [value]).map(function (val) {
return Array.isArray(val) ? val : [val];
});
}

@@ -5,2 +5,3 @@ import type { BuildInPlacements } from '@rc-component/trigger/lib/interface';

import * as React from 'react';
import Panel from './Panel';
import { SHOW_CHILD, SHOW_PARENT } from './utils/commonUtil';

@@ -92,3 +93,4 @@ export interface ShowSearchType<OptionType extends BaseOptionType = DefaultOptionType> {

SHOW_CHILD: typeof SHOW_CHILD;
Panel: typeof Panel;
};
export default Cascader;

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

var _useId = _interopRequireDefault(require("rc-select/lib/hooks/useId"));
var _conductUtil = require("rc-tree/lib/utils/conductUtil");
var _useEvent = _interopRequireDefault(require("rc-util/lib/hooks/useEvent"));

@@ -22,7 +21,10 @@ var _useMergedState5 = _interopRequireDefault(require("rc-util/lib/hooks/useMergedState"));

var _useDisplayValues = _interopRequireDefault(require("./hooks/useDisplayValues"));
var _useEntities = _interopRequireDefault(require("./hooks/useEntities"));
var _useMissingValues = _interopRequireDefault(require("./hooks/useMissingValues"));
var _useOptions3 = _interopRequireDefault(require("./hooks/useOptions"));
var _useSearchConfig3 = _interopRequireDefault(require("./hooks/useSearchConfig"));
var _useSearchOptions = _interopRequireDefault(require("./hooks/useSearchOptions"));
var _useSelect = _interopRequireDefault(require("./hooks/useSelect"));
var _useValues3 = _interopRequireDefault(require("./hooks/useValues"));
var _OptionList = _interopRequireDefault(require("./OptionList"));
var _Panel = _interopRequireDefault(require("./Panel"));
var _commonUtil = require("./utils/commonUtil");

@@ -34,16 +36,2 @@ var _treeUtil = require("./utils/treeUtil");

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; }
function isMultipleValue(value) {
return Array.isArray(value) && Array.isArray(value[0]);
}
function toRawValues(value) {
if (!value) {
return [];
}
if (isMultipleValue(value)) {
return value;
}
return (value.length === 0 ? [] : [value]).map(function (val) {
return Array.isArray(val) ? val : [val];
});
}
var Cascader = /*#__PURE__*/React.forwardRef(function (props, ref) {

@@ -93,3 +81,3 @@ var id = props.id,

value: value,
postState: toRawValues
postState: _commonUtil.toRawValues
}),

@@ -108,20 +96,8 @@ _useMergedState2 = (0, _slicedToArray2.default)(_useMergedState, 2),

// =========================== Option ===========================
var mergedOptions = React.useMemo(function () {
return options || [];
}, [options]);
var _useOptions = (0, _useOptions3.default)(mergedFieldNames, options),
_useOptions2 = (0, _slicedToArray2.default)(_useOptions, 3),
mergedOptions = _useOptions2[0],
getPathKeyEntities = _useOptions2[1],
getValueByKeyPath = _useOptions2[2];
// Only used in multiple mode, this fn will not call in single mode
var getPathKeyEntities = (0, _useEntities.default)(mergedOptions, mergedFieldNames);
/** Convert path key back to value format */
var getValueByKeyPath = React.useCallback(function (pathKeys) {
var keyPathEntities = getPathKeyEntities();
return pathKeys.map(function (pathKey) {
var nodes = keyPathEntities[pathKey].nodes;
return nodes.map(function (node) {
return node[mergedFieldNames.value];
});
});
}, [getPathKeyEntities, mergedFieldNames]);
// =========================== Search ===========================

@@ -153,23 +129,7 @@ var _useMergedState3 = (0, _useMergedState5.default)('', {

// Fill `rawValues` with checked conduction values
var _React$useMemo = React.useMemo(function () {
var _getMissingValues = getMissingValues(rawValues),
_getMissingValues2 = (0, _slicedToArray2.default)(_getMissingValues, 2),
existValues = _getMissingValues2[0],
missingValues = _getMissingValues2[1];
if (!multiple || !rawValues.length) {
return [existValues, [], missingValues];
}
var keyPathValues = (0, _commonUtil.toPathKeys)(existValues);
var keyPathEntities = getPathKeyEntities();
var _conductCheck = (0, _conductUtil.conductCheck)(keyPathValues, true, keyPathEntities),
checkedKeys = _conductCheck.checkedKeys,
halfCheckedKeys = _conductCheck.halfCheckedKeys;
// Convert key back to value cells
return [getValueByKeyPath(checkedKeys), getValueByKeyPath(halfCheckedKeys), missingValues];
}, [multiple, rawValues, getPathKeyEntities, getValueByKeyPath, getMissingValues]),
_React$useMemo2 = (0, _slicedToArray2.default)(_React$useMemo, 3),
checkedValues = _React$useMemo2[0],
halfCheckedValues = _React$useMemo2[1],
missingCheckedValues = _React$useMemo2[2];
var _useValues = (0, _useValues3.default)(multiple, rawValues, getPathKeyEntities, getValueByKeyPath, getMissingValues),
_useValues2 = (0, _slicedToArray2.default)(_useValues, 3),
checkedValues = _useValues2[0],
halfCheckedValues = _useValues2[1],
missingCheckedValues = _useValues2[2];
var deDuplicatedValues = React.useMemo(function () {

@@ -188,3 +148,3 @@ var checkedKeys = (0, _commonUtil.toPathKeys)(checkedValues);

if (onChange) {
var nextRawValues = toRawValues(nextValues);
var nextRawValues = (0, _commonUtil.toRawValues)(nextValues);
var valueOptions = nextRawValues.map(function (valueCells) {

@@ -202,2 +162,3 @@ return (0, _treeUtil.toPathOptions)(valueCells, mergedOptions, mergedFieldNames).map(function (valueOpt) {

// =========================== Select ===========================
var handleSelection = (0, _useSelect.default)(multiple, triggerChange, checkedValues, halfCheckedValues, missingCheckedValues, getPathKeyEntities, getValueByKeyPath, showCheckedStrategy);
var onInternalSelect = (0, _useEvent.default)(function (valuePath) {

@@ -207,48 +168,3 @@ if (!multiple || autoClearSearchValue) {

}
if (!multiple) {
triggerChange(valuePath);
} else {
// Prepare conduct required info
var pathKey = (0, _commonUtil.toPathKey)(valuePath);
var checkedPathKeys = (0, _commonUtil.toPathKeys)(checkedValues);
var halfCheckedPathKeys = (0, _commonUtil.toPathKeys)(halfCheckedValues);
var existInChecked = checkedPathKeys.includes(pathKey);
var existInMissing = missingCheckedValues.some(function (valueCells) {
return (0, _commonUtil.toPathKey)(valueCells) === pathKey;
});
// Do update
var nextCheckedValues = checkedValues;
var nextMissingValues = missingCheckedValues;
if (existInMissing && !existInChecked) {
// Missing value only do filter
nextMissingValues = missingCheckedValues.filter(function (valueCells) {
return (0, _commonUtil.toPathKey)(valueCells) !== pathKey;
});
} else {
// Update checked key first
var nextRawCheckedKeys = existInChecked ? checkedPathKeys.filter(function (key) {
return key !== pathKey;
}) : [].concat((0, _toConsumableArray2.default)(checkedPathKeys), [pathKey]);
var pathKeyEntities = getPathKeyEntities();
// Conduction by selected or not
var checkedKeys;
if (existInChecked) {
var _conductCheck2 = (0, _conductUtil.conductCheck)(nextRawCheckedKeys, {
checked: false,
halfCheckedKeys: halfCheckedPathKeys
}, pathKeyEntities);
checkedKeys = _conductCheck2.checkedKeys;
} else {
var _conductCheck3 = (0, _conductUtil.conductCheck)(nextRawCheckedKeys, true, pathKeyEntities);
checkedKeys = _conductCheck3.checkedKeys;
}
// Roll up to parent level keys
var deDuplicatedKeys = (0, _treeUtil.formatStrategyValues)(checkedKeys, getPathKeyEntities, showCheckedStrategy);
nextCheckedValues = getValueByKeyPath(deDuplicatedKeys);
}
triggerChange([].concat((0, _toConsumableArray2.default)(nextMissingValues), (0, _toConsumableArray2.default)(nextCheckedValues)));
}
handleSelection(valuePath);
});

@@ -357,3 +273,4 @@

Cascader.SHOW_CHILD = _commonUtil.SHOW_CHILD;
Cascader.Panel = _Panel.default;
var _default = Cascader;
exports.default = _default;

@@ -1,3 +0,3 @@

import type { SingleValueType, DefaultOptionType, InternalFieldNames } from '../Cascader';
declare const _default: (options: DefaultOptionType[], fieldNames: InternalFieldNames) => (rawValues: SingleValueType[]) => [SingleValueType[], SingleValueType[]];
export default _default;
import type { DefaultOptionType, InternalFieldNames, SingleValueType } from '../Cascader';
export type GetMissValues = ReturnType<typeof useMissingValues>;
export default function useMissingValues(options: DefaultOptionType[], fieldNames: InternalFieldNames): (rawValues: SingleValueType[]) => [SingleValueType[], SingleValueType[]];

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

});
exports.default = void 0;
exports.default = useMissingValues;
var React = _interopRequireWildcard(require("react"));

@@ -13,3 +13,3 @@ var _treeUtil = require("../utils/treeUtil");

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 _default = function _default(options, fieldNames) {
function useMissingValues(options, fieldNames) {
return React.useCallback(function (rawValues) {

@@ -30,3 +30,2 @@ var missingValues = [];

}, [options, fieldNames]);
};
exports.default = _default;
}
import Cascader from './Cascader';
export type { CascaderProps, FieldNames, ShowSearchType, DefaultOptionType, BaseOptionType, SingleCascaderProps, MultipleCascaderProps, } from './Cascader';
import Panel from './Panel';
export type { BaseOptionType, CascaderProps, DefaultOptionType, FieldNames, MultipleCascaderProps, ShowSearchType, SingleCascaderProps, } from './Cascader';
export { Panel };
export default Cascader;

@@ -7,5 +7,12 @@ "use strict";

});
Object.defineProperty(exports, "Panel", {
enumerable: true,
get: function get() {
return _Panel.default;
}
});
exports.default = void 0;
var _Cascader = _interopRequireDefault(require("./Cascader"));
var _Panel = _interopRequireDefault(require("./Panel"));
var _default = _Cascader.default;
exports.default = _default;

@@ -10,16 +10,5 @@ "use strict";

var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
var _classnames = _interopRequireDefault(require("classnames"));
var _rcSelect = require("rc-select");
var React = _interopRequireWildcard(require("react"));
var _context = _interopRequireDefault(require("../context"));
var _commonUtil = require("../utils/commonUtil");
var _treeUtil = require("../utils/treeUtil");
var _CacheContent = _interopRequireDefault(require("./CacheContent"));
var _Column = _interopRequireWildcard(require("./Column"));
var _useActive3 = _interopRequireDefault(require("./useActive"));
var _useKeyboard = _interopRequireDefault(require("./useKeyboard"));
var _List = _interopRequireDefault(require("./List"));
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); }

@@ -30,206 +19,10 @@ 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 RefOptionList = /*#__PURE__*/React.forwardRef(function (props, ref) {
var _optionColumns$, _optionColumns$$optio, _ref3, _classNames;
var _useBaseProps = (0, _rcSelect.useBaseProps)(),
prefixCls = _useBaseProps.prefixCls,
multiple = _useBaseProps.multiple,
searchValue = _useBaseProps.searchValue,
toggleOpen = _useBaseProps.toggleOpen,
notFoundContent = _useBaseProps.notFoundContent,
direction = _useBaseProps.direction,
open = _useBaseProps.open;
var containerRef = React.useRef();
var rtl = direction === 'rtl';
var _React$useContext = React.useContext(_context.default),
options = _React$useContext.options,
values = _React$useContext.values,
halfValues = _React$useContext.halfValues,
fieldNames = _React$useContext.fieldNames,
changeOnSelect = _React$useContext.changeOnSelect,
onSelect = _React$useContext.onSelect,
searchOptions = _React$useContext.searchOptions,
dropdownPrefixCls = _React$useContext.dropdownPrefixCls,
loadData = _React$useContext.loadData,
expandTrigger = _React$useContext.expandTrigger;
var mergedPrefixCls = dropdownPrefixCls || prefixCls;
var baseProps = (0, _rcSelect.useBaseProps)();
// ========================= loadData =========================
var _React$useState = React.useState([]),
_React$useState2 = (0, _slicedToArray2.default)(_React$useState, 2),
loadingKeys = _React$useState2[0],
setLoadingKeys = _React$useState2[1];
var internalLoadData = function internalLoadData(valueCells) {
// Do not load when search
if (!loadData || searchValue) {
return;
}
var optionList = (0, _treeUtil.toPathOptions)(valueCells, options, fieldNames);
var rawOptions = optionList.map(function (_ref) {
var option = _ref.option;
return option;
});
var lastOption = rawOptions[rawOptions.length - 1];
if (lastOption && !(0, _commonUtil.isLeaf)(lastOption, fieldNames)) {
var pathKey = (0, _commonUtil.toPathKey)(valueCells);
setLoadingKeys(function (keys) {
return [].concat((0, _toConsumableArray2.default)(keys), [pathKey]);
});
loadData(rawOptions);
}
};
// zombieJ: This is bad. We should make this same as `rc-tree` to use Promise instead.
React.useEffect(function () {
if (loadingKeys.length) {
loadingKeys.forEach(function (loadingKey) {
var valueStrCells = (0, _commonUtil.toPathValueStr)(loadingKey);
var optionList = (0, _treeUtil.toPathOptions)(valueStrCells, options, fieldNames, true).map(function (_ref2) {
var option = _ref2.option;
return option;
});
var lastOption = optionList[optionList.length - 1];
if (!lastOption || lastOption[fieldNames.children] || (0, _commonUtil.isLeaf)(lastOption, fieldNames)) {
setLoadingKeys(function (keys) {
return keys.filter(function (key) {
return key !== loadingKey;
});
});
}
});
}
}, [options, loadingKeys, fieldNames]);
// ========================== Values ==========================
var checkedSet = React.useMemo(function () {
return new Set((0, _commonUtil.toPathKeys)(values));
}, [values]);
var halfCheckedSet = React.useMemo(function () {
return new Set((0, _commonUtil.toPathKeys)(halfValues));
}, [halfValues]);
// ====================== Accessibility =======================
var _useActive = (0, _useActive3.default)(),
_useActive2 = (0, _slicedToArray2.default)(_useActive, 2),
activeValueCells = _useActive2[0],
setActiveValueCells = _useActive2[1];
// =========================== Path ===========================
var onPathOpen = function onPathOpen(nextValueCells) {
setActiveValueCells(nextValueCells);
// Trigger loadData
internalLoadData(nextValueCells);
};
var isSelectable = function isSelectable(option) {
var disabled = option.disabled;
var isMergedLeaf = (0, _commonUtil.isLeaf)(option, fieldNames);
return !disabled && (isMergedLeaf || changeOnSelect || multiple);
};
var onPathSelect = function onPathSelect(valuePath, leaf) {
var fromKeyboard = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
onSelect(valuePath);
if (!multiple && (leaf || changeOnSelect && (expandTrigger === 'hover' || fromKeyboard))) {
toggleOpen(false);
}
};
// ========================== Option ==========================
var mergedOptions = React.useMemo(function () {
if (searchValue) {
return searchOptions;
}
return options;
}, [searchValue, searchOptions, options]);
// ========================== Column ==========================
var optionColumns = React.useMemo(function () {
var optionList = [{
options: mergedOptions
}];
var currentList = mergedOptions;
var fullPathKeys = (0, _commonUtil.getFullPathKeys)(currentList, fieldNames);
var _loop = function _loop() {
var activeValueCell = activeValueCells[i];
var currentOption = currentList.find(function (option, index) {
return (fullPathKeys[index] ? (0, _commonUtil.toPathKey)(fullPathKeys[index]) : option[fieldNames.value]) === activeValueCell;
});
var subOptions = currentOption === null || currentOption === void 0 ? void 0 : currentOption[fieldNames.children];
if (!(subOptions !== null && subOptions !== void 0 && subOptions.length)) {
return "break";
}
currentList = subOptions;
optionList.push({
options: subOptions
});
};
for (var i = 0; i < activeValueCells.length; i += 1) {
var _ret = _loop();
if (_ret === "break") break;
}
return optionList;
}, [mergedOptions, activeValueCells, fieldNames]);
// ========================= Keyboard =========================
var onKeyboardSelect = function onKeyboardSelect(selectValueCells, option) {
if (isSelectable(option)) {
onPathSelect(selectValueCells, (0, _commonUtil.isLeaf)(option, fieldNames), true);
}
};
(0, _useKeyboard.default)(ref, mergedOptions, fieldNames, activeValueCells, onPathOpen, onKeyboardSelect);
// >>>>> Active Scroll
React.useEffect(function () {
for (var i = 0; i < activeValueCells.length; i += 1) {
var _containerRef$current;
var cellPath = activeValueCells.slice(0, i + 1);
var cellKeyPath = (0, _commonUtil.toPathKey)(cellPath);
var ele = (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.querySelector("li[data-path-key=\"".concat(cellKeyPath.replace(/\\{0,2}"/g, '\\"'), "\"]") // matches unescaped double quotes
);
if (ele) {
(0, _commonUtil.scrollIntoParentView)(ele);
}
}
}, [activeValueCells]);
// ========================== Render ==========================
// >>>>> Empty
var isEmpty = !((_optionColumns$ = optionColumns[0]) !== null && _optionColumns$ !== void 0 && (_optionColumns$$optio = _optionColumns$.options) !== null && _optionColumns$$optio !== void 0 && _optionColumns$$optio.length);
var emptyList = [(_ref3 = {}, (0, _defineProperty2.default)(_ref3, fieldNames.value, '__EMPTY__'), (0, _defineProperty2.default)(_ref3, _Column.FIX_LABEL, notFoundContent), (0, _defineProperty2.default)(_ref3, "disabled", true), _ref3)];
var columnProps = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, props), {}, {
multiple: !isEmpty && multiple,
onSelect: onPathSelect,
onActive: onPathOpen,
onToggleOpen: toggleOpen,
checkedSet: checkedSet,
halfCheckedSet: halfCheckedSet,
loadingKeys: loadingKeys,
isSelectable: isSelectable
});
// >>>>> Columns
var mergedOptionColumns = isEmpty ? [{
options: emptyList
}] : optionColumns;
var columnNodes = mergedOptionColumns.map(function (col, index) {
var prevValuePath = activeValueCells.slice(0, index);
var activeValue = activeValueCells[index];
return /*#__PURE__*/React.createElement(_Column.default, (0, _extends2.default)({
key: index
}, columnProps, {
searchValue: searchValue,
prefixCls: mergedPrefixCls,
options: col.options,
prevValuePath: prevValuePath,
activeValue: activeValue
}));
});
// >>>>> Render
return /*#__PURE__*/React.createElement(_CacheContent.default, {
open: open
}, /*#__PURE__*/React.createElement("div", {
className: (0, _classnames.default)("".concat(mergedPrefixCls, "-menus"), (_classNames = {}, (0, _defineProperty2.default)(_classNames, "".concat(mergedPrefixCls, "-menu-empty"), isEmpty), (0, _defineProperty2.default)(_classNames, "".concat(mergedPrefixCls, "-rtl"), rtl), _classNames)),
ref: containerRef
}, columnNodes));
return /*#__PURE__*/React.createElement(_List.default, (0, _extends2.default)({}, props, baseProps, {
ref: ref
}));
});
var _default = RefOptionList;
exports.default = _default;

@@ -5,3 +5,3 @@ import * as React from 'react';

*/
declare const _default: () => [React.Key[], (activeValueCells: React.Key[]) => void];
declare const _default: (multiple: boolean, open: boolean) => [React.Key[], (activeValueCells: React.Key[]) => void];
export default _default;

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

var _context = _interopRequireDefault(require("../context"));
var _rcSelect = require("rc-select");
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); }

@@ -19,6 +18,3 @@ 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 _default = function _default() {
var _useBaseProps = (0, _rcSelect.useBaseProps)(),
multiple = _useBaseProps.multiple,
open = _useBaseProps.open;
var _default = function _default(multiple, open) {
var _React$useContext = React.useContext(_context.default),

@@ -25,0 +21,0 @@ values = _React$useContext.values;

import type { RefOptionListProps } from 'rc-select/lib/OptionList';
import * as React from 'react';
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;
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, contextProps: {
direction: 'ltr' | 'rtl';
searchValue: string;
toggleOpen: (open?: boolean) => void;
open: boolean;
}) => void;
export default _default;

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

var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
var _rcSelect = require("rc-select");
var _KeyCode = _interopRequireDefault(require("rc-util/lib/KeyCode"));

@@ -19,8 +18,7 @@ var React = _interopRequireWildcard(require("react"));

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 _default = function _default(ref, options, fieldNames, activeValueCells, setActiveValueCells, onKeyBoardSelect) {
var _useBaseProps = (0, _rcSelect.useBaseProps)(),
direction = _useBaseProps.direction,
searchValue = _useBaseProps.searchValue,
toggleOpen = _useBaseProps.toggleOpen,
open = _useBaseProps.open;
var _default = function _default(ref, options, fieldNames, activeValueCells, setActiveValueCells, onKeyBoardSelect, contextProps) {
var direction = contextProps.direction,
searchValue = contextProps.searchValue,
toggleOpen = contextProps.toggleOpen,
open = contextProps.open;
var rtl = direction === 'rtl';

@@ -27,0 +25,0 @@ var _React$useMemo = React.useMemo(function () {

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

import type { DefaultOptionType, FieldNames, InternalFieldNames, SingleValueType } from '../Cascader';
import type { DefaultOptionType, FieldNames, InternalFieldNames, SingleValueType, ValueType } from '../Cascader';
export declare const VALUE_SPLIT = "__RC_CASCADER_SPLIT__";

@@ -18,1 +18,2 @@ export declare const SHOW_PARENT = "SHOW_PARENT";

export declare function getFullPathKeys(options: DefaultOptionType[], fieldNames: FieldNames): any[];
export declare function toRawValues(value: ValueType): SingleValueType[];

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

exports.toPathValueStr = toPathValueStr;
exports.toRawValues = toRawValues;
var _useSearchOptions = require("../hooks/useSearchOptions");

@@ -79,2 +80,16 @@ var VALUE_SPLIT = '__RC_CASCADER_SPLIT__';

});
}
function isMultipleValue(value) {
return Array.isArray(value) && Array.isArray(value[0]);
}
function toRawValues(value) {
if (!value) {
return [];
}
if (isMultipleValue(value)) {
return value;
}
return (value.length === 0 ? [] : [value]).map(function (val) {
return Array.isArray(val) ? val : [val];
});
}
{
"name": "rc-cascader",
"version": "3.17.0",
"version": "3.18.0",
"description": "cascade select ui component for react",

@@ -5,0 +5,0 @@ "keywords": [

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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