UNPKG

lucid-ui

Version:

A UI component library from Xandr.

61 lines 2.46 kB
"use strict"; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.onFocusOption = exports.onFocusPrev = exports.onFocusNext = exports.onSelect = exports.onCollapse = exports.onExpand = void 0; var lodash_1 = __importDefault(require("lodash")); function onExpand(state) { var selectedIndices = state.selectedIndices; var focusedIndex = lodash_1.default.last(selectedIndices); return __assign(__assign({}, state), { isExpanded: true, focusedIndex: lodash_1.default.isNil(focusedIndex) ? null : focusedIndex }); } exports.onExpand = onExpand; function onCollapse(state) { return __assign(__assign({}, state), { isExpanded: false }); } exports.onCollapse = onCollapse; function onSelect(state, optionIndex) { return __assign(__assign({}, state), { selectedIndices: [optionIndex], isExpanded: false }); } exports.onSelect = onSelect; function onFocusNext(state) { var focusedIndex = state.focusedIndex; var nextFocusedIndex = focusedIndex; if (lodash_1.default.isNull(focusedIndex)) { nextFocusedIndex = 0; } else if (lodash_1.default.isNumber(focusedIndex)) { nextFocusedIndex = focusedIndex + 1; } return __assign(__assign({}, state), { focusedIndex: nextFocusedIndex }); } exports.onFocusNext = onFocusNext; function onFocusPrev(state) { var focusedIndex = state.focusedIndex; var nextFocusedIndex = focusedIndex; if (lodash_1.default.isNull(focusedIndex) || focusedIndex === 0) { nextFocusedIndex = null; } else if (lodash_1.default.isNumber(focusedIndex)) { nextFocusedIndex = focusedIndex - 1; } return __assign(__assign({}, state), { focusedIndex: nextFocusedIndex }); } exports.onFocusPrev = onFocusPrev; function onFocusOption(state, optionIndex) { return __assign(__assign({}, state), { focusedIndex: optionIndex }); } exports.onFocusOption = onFocusOption; //# sourceMappingURL=DropMenu.reducers.js.map