init
This commit is contained in:
235
unpackage/dist/dev/mp-weixin/uni_modules/nutui-uni/components/cascader/cascader.js
vendored
Normal file
235
unpackage/dist/dev/mp-weixin/uni_modules/nutui-uni/components/cascader/cascader.js
vendored
Normal file
@@ -0,0 +1,235 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../../../common/vendor.js");
|
||||
const uni_modules_nutuiUni_components__constants_event = require("../_constants/event.js");
|
||||
const uni_modules_nutuiUni_components__constants_prefix = require("../_constants/prefix.js");
|
||||
require("../_utils/env.js");
|
||||
const uni_modules_nutuiUni_components__utils_style = require("../_utils/style.js");
|
||||
const uni_modules_nutuiUni_components__utils_props = require("../_utils/props.js");
|
||||
const popup = require("../../../../popup.js");
|
||||
const cascaderProps = {
|
||||
...popup.popupProps,
|
||||
...uni_modules_nutuiUni_components__utils_props.commonProps,
|
||||
/**
|
||||
* @description 选中值,双向绑定
|
||||
*/
|
||||
modelValue: Array,
|
||||
/**
|
||||
* @description 显示选择层
|
||||
*/
|
||||
visible: Boolean,
|
||||
/**
|
||||
* @description 级联数据
|
||||
*/
|
||||
options: uni_modules_nutuiUni_components__utils_props.makeArrayProp([]),
|
||||
/**
|
||||
* @description 是否开启动态加载
|
||||
*/
|
||||
lazy: Boolean,
|
||||
/**
|
||||
* @description 动态加载回调,开启动态加载时生效
|
||||
*/
|
||||
lazyLoad: Function,
|
||||
/**
|
||||
* @description 自定义 `options` 结构中 `value` 的字段
|
||||
*/
|
||||
valueKey: uni_modules_nutuiUni_components__utils_props.makeStringProp("value"),
|
||||
/**
|
||||
* @description 自定义 `options` 结构中 `text` 的字段
|
||||
*/
|
||||
textKey: uni_modules_nutuiUni_components__utils_props.makeStringProp("text"),
|
||||
/**
|
||||
* @description 自定义 `options` 结构中 `children` 的字段
|
||||
*/
|
||||
childrenKey: uni_modules_nutuiUni_components__utils_props.makeStringProp("children"),
|
||||
/**
|
||||
* @description 当 `options` 为可转换为树形结构的扁平结构时,配置转换规则
|
||||
*/
|
||||
convertConfig: Object,
|
||||
/**
|
||||
* @description 是否需要弹层展示(设置为 `false` 后,`title` 失效)
|
||||
*/
|
||||
poppable: uni_modules_nutuiUni_components__utils_props.truthProp,
|
||||
/**
|
||||
* @description 标题
|
||||
*/
|
||||
title: String,
|
||||
/**
|
||||
* @description 选中底部展示样式 可选值: 'line', 'smile'
|
||||
*/
|
||||
titleType: uni_modules_nutuiUni_components__utils_props.makeStringProp("line"),
|
||||
/**
|
||||
* @description 标签栏字体尺寸大小 可选值: 'large', 'normal', 'small'
|
||||
*/
|
||||
titleSize: uni_modules_nutuiUni_components__utils_props.makeStringProp("normal"),
|
||||
/**
|
||||
* @description 标签间隙
|
||||
*/
|
||||
titleGutter: uni_modules_nutuiUni_components__utils_props.makeNumericProp(0),
|
||||
/**
|
||||
* @description 是否省略过长的标题文字
|
||||
*/
|
||||
titleEllipsis: uni_modules_nutuiUni_components__utils_props.truthProp,
|
||||
/**
|
||||
* @description 自定义弹窗样式
|
||||
*/
|
||||
popStyle: {
|
||||
type: [String, Object, Array],
|
||||
default: ""
|
||||
},
|
||||
/**
|
||||
* @description 遮罩显示时的背景是否锁定
|
||||
*/
|
||||
lockScroll: uni_modules_nutuiUni_components__utils_props.truthProp
|
||||
};
|
||||
const cascaderEmits = {
|
||||
[uni_modules_nutuiUni_components__constants_event.UPDATE_MODEL_EVENT]: (value) => true,
|
||||
[uni_modules_nutuiUni_components__constants_event.UPDATE_VISIBLE_EVENT]: (value) => true,
|
||||
[uni_modules_nutuiUni_components__constants_event.CHANGE_EVENT]: (value, nodes) => true,
|
||||
pathChange: (nodes) => true,
|
||||
[uni_modules_nutuiUni_components__constants_event.OPEN_EVENT]: () => true,
|
||||
[uni_modules_nutuiUni_components__constants_event.OPENED_EVENT]: () => true,
|
||||
[uni_modules_nutuiUni_components__constants_event.CLOSE_EVENT]: () => true,
|
||||
[uni_modules_nutuiUni_components__constants_event.CLOSED_EVENT]: () => true
|
||||
};
|
||||
if (!Math) {
|
||||
(NutCascaderItem + NutPopup)();
|
||||
}
|
||||
const NutCascaderItem = () => "../cascaderitem/cascaderitem.js";
|
||||
const NutPopup = () => "../popup/popup.js";
|
||||
const componentName = `${uni_modules_nutuiUni_components__constants_prefix.PREFIX}-cascader`;
|
||||
const __default__ = common_vendor.defineComponent({
|
||||
name: componentName,
|
||||
options: {
|
||||
virtualHost: true,
|
||||
addGlobalClass: true,
|
||||
styleIsolation: "shared"
|
||||
}
|
||||
});
|
||||
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
|
||||
...__default__,
|
||||
props: cascaderProps,
|
||||
emits: cascaderEmits,
|
||||
setup(__props, { emit: __emit }) {
|
||||
const props = __props;
|
||||
const emit = __emit;
|
||||
const slots = common_vendor.useSlots();
|
||||
const innerValue = common_vendor.ref(props.modelValue);
|
||||
const innerVisible = common_vendor.computed({
|
||||
get() {
|
||||
return props.visible;
|
||||
},
|
||||
set(value) {
|
||||
emit(uni_modules_nutuiUni_components__constants_event.UPDATE_VISIBLE_EVENT, value);
|
||||
}
|
||||
});
|
||||
const classes = common_vendor.computed(() => {
|
||||
return uni_modules_nutuiUni_components__utils_style.getMainClass(props, componentName);
|
||||
});
|
||||
const popClasses = common_vendor.computed(() => {
|
||||
return `${componentName}__popup ${props.popClass}`;
|
||||
});
|
||||
const overlayClasses = common_vendor.computed(() => {
|
||||
return `${componentName}__overlay ${props.overlayClass}`;
|
||||
});
|
||||
function handleChange(value, pathNodes) {
|
||||
innerValue.value = value;
|
||||
innerVisible.value = false;
|
||||
emit(uni_modules_nutuiUni_components__constants_event.UPDATE_MODEL_EVENT, value);
|
||||
emit(uni_modules_nutuiUni_components__constants_event.CHANGE_EVENT, value, pathNodes);
|
||||
}
|
||||
function handlePathChange(pathNodes) {
|
||||
emit("pathChange", pathNodes);
|
||||
}
|
||||
function handleOpen() {
|
||||
emit(uni_modules_nutuiUni_components__constants_event.OPEN_EVENT);
|
||||
}
|
||||
function handleOpened() {
|
||||
emit(uni_modules_nutuiUni_components__constants_event.OPENED_EVENT);
|
||||
}
|
||||
function handleClose() {
|
||||
emit(uni_modules_nutuiUni_components__constants_event.CLOSE_EVENT);
|
||||
}
|
||||
function handleClosed() {
|
||||
emit(uni_modules_nutuiUni_components__constants_event.CLOSED_EVENT);
|
||||
}
|
||||
common_vendor.watch(() => props.modelValue, (value) => {
|
||||
if (value !== innerValue.value) {
|
||||
innerValue.value = value;
|
||||
}
|
||||
});
|
||||
return (_ctx, _cache) => {
|
||||
return common_vendor.e({
|
||||
a: props.poppable
|
||||
}, props.poppable ? common_vendor.e({
|
||||
b: common_vendor.unref(slots).title
|
||||
}, common_vendor.unref(slots).title ? {} : common_vendor.e({
|
||||
c: props.title
|
||||
}, props.title ? {
|
||||
d: props.title
|
||||
} : {}), {
|
||||
e: common_vendor.o(handleChange),
|
||||
f: common_vendor.o(handlePathChange),
|
||||
g: common_vendor.p({
|
||||
["model-value"]: innerValue.value,
|
||||
visible: innerVisible.value,
|
||||
options: props.options,
|
||||
lazy: props.lazy,
|
||||
["lazy-load"]: props.lazyLoad,
|
||||
["value-key"]: props.valueKey,
|
||||
["text-key"]: props.textKey,
|
||||
["children-key"]: props.childrenKey,
|
||||
["convert-config"]: props.convertConfig,
|
||||
["title-type"]: props.titleType,
|
||||
["title-size"]: props.titleSize,
|
||||
["title-gutter"]: props.titleGutter,
|
||||
["title-ellipsis"]: props.titleEllipsis
|
||||
}),
|
||||
h: common_vendor.o(handleOpen),
|
||||
i: common_vendor.o(handleOpened),
|
||||
j: common_vendor.o(handleClose),
|
||||
k: common_vendor.o(handleClosed),
|
||||
l: common_vendor.o(($event) => innerVisible.value = $event),
|
||||
m: common_vendor.p({
|
||||
["custom-class"]: popClasses.value,
|
||||
["custom-style"]: props.popStyle,
|
||||
["overlay-class"]: overlayClasses.value,
|
||||
["overlay-style"]: props.overlayStyle,
|
||||
position: "bottom",
|
||||
round: true,
|
||||
closeable: props.closeable,
|
||||
["close-icon"]: props.closeIcon,
|
||||
["close-icon-position"]: props.closeIconPosition,
|
||||
["z-index"]: props.zIndex,
|
||||
["lock-scroll"]: props.lockScroll,
|
||||
overlay: props.overlay,
|
||||
["close-on-click-overlay"]: props.closeOnClickOverlay,
|
||||
["destroy-on-close"]: false,
|
||||
visible: innerVisible.value
|
||||
})
|
||||
}) : {
|
||||
n: common_vendor.o(handleChange),
|
||||
o: common_vendor.o(handlePathChange),
|
||||
p: common_vendor.p({
|
||||
["model-value"]: innerValue.value,
|
||||
visible: innerVisible.value,
|
||||
options: props.options,
|
||||
lazy: props.lazy,
|
||||
["lazy-load"]: props.lazyLoad,
|
||||
["value-key"]: props.valueKey,
|
||||
["text-key"]: props.textKey,
|
||||
["children-key"]: props.childrenKey,
|
||||
["convert-config"]: props.convertConfig,
|
||||
["title-type"]: props.titleType,
|
||||
["title-size"]: props.titleSize,
|
||||
["title-gutter"]: props.titleGutter,
|
||||
["title-ellipsis"]: props.titleEllipsis
|
||||
})
|
||||
}, {
|
||||
q: common_vendor.n(classes.value),
|
||||
r: common_vendor.s(props.customStyle)
|
||||
});
|
||||
};
|
||||
}
|
||||
});
|
||||
wx.createComponent(_sfc_main);
|
||||
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/nutui-uni/components/cascader/cascader.js.map
|
||||
7
unpackage/dist/dev/mp-weixin/uni_modules/nutui-uni/components/cascader/cascader.json
vendored
Normal file
7
unpackage/dist/dev/mp-weixin/uni_modules/nutui-uni/components/cascader/cascader.json
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"nut-cascader-item": "../cascaderitem/cascaderitem",
|
||||
"nut-popup": "../popup/popup"
|
||||
}
|
||||
}
|
||||
1
unpackage/dist/dev/mp-weixin/uni_modules/nutui-uni/components/cascader/cascader.wxml
vendored
Normal file
1
unpackage/dist/dev/mp-weixin/uni_modules/nutui-uni/components/cascader/cascader.wxml
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<view class="{{q}}" style="{{r}}"><block wx:if="{{a}}"><nut-popup wx:if="{{m}}" u-s="{{['d']}}" bindopen="{{h}}" bindopened="{{i}}" bindclose="{{j}}" bindclosed="{{k}}" u-i="36fa809a-0" bind:__l="__l" bindupdateVisible="{{l}}" u-p="{{m}}"><slot wx:if="{{b}}" name="title"/><block wx:else><rich-text wx:if="{{c}}" class="nut-cascader__bar" nodes="{{d}}"/></block><nut-cascader-item wx:if="{{g}}" bindchange="{{e}}" bindpathChange="{{f}}" u-i="36fa809a-1,36fa809a-0" bind:__l="__l" u-p="{{g}}"/></nut-popup></block><block wx:else><nut-cascader-item wx:if="{{p}}" bindchange="{{n}}" bindpathChange="{{o}}" u-i="36fa809a-2" bind:__l="__l" u-p="{{p}}"/></block></view>
|
||||
247
unpackage/dist/dev/mp-weixin/uni_modules/nutui-uni/components/cascader/cascader.wxss
vendored
Normal file
247
unpackage/dist/dev/mp-weixin/uni_modules/nutui-uni/components/cascader/cascader.wxss
vendored
Normal file
@@ -0,0 +1,247 @@
|
||||
/**
|
||||
* 这里是uni-app内置的常用样式变量
|
||||
*
|
||||
* uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量
|
||||
* 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能
|
||||
*
|
||||
* 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
|
||||
*/
|
||||
/* 颜色变量 */
|
||||
/* 行为相关颜色 */
|
||||
/* 文字基本颜色 */
|
||||
/* 背景颜色 */
|
||||
/* 边框颜色 */
|
||||
/* 尺寸变量 */
|
||||
/* 文字尺寸 */
|
||||
/* 图片尺寸 */
|
||||
/* Border Radius */
|
||||
/* 水平间距 */
|
||||
/* 垂直间距 */
|
||||
/* 透明度 */
|
||||
/* 文章场景相关 */
|
||||
/**
|
||||
* 这里是uni-app内置的常用样式变量
|
||||
*
|
||||
* uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量
|
||||
* 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能
|
||||
*
|
||||
* 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
|
||||
*/
|
||||
/* 颜色变量 */
|
||||
/* 行为相关颜色 */
|
||||
/* 文字基本颜色 */
|
||||
/* 背景颜色 */
|
||||
/* 边框颜色 */
|
||||
/* 尺寸变量 */
|
||||
/* 文字尺寸 */
|
||||
/* 图片尺寸 */
|
||||
/* Border Radius */
|
||||
/* 水平间距 */
|
||||
/* 垂直间距 */
|
||||
/* 透明度 */
|
||||
/* 文章场景相关 */
|
||||
.nut-theme-dark .nut-cascader .nut-tabs__titles {
|
||||
background: var(--nut-dark-background3, #141414) !important;
|
||||
}
|
||||
.nut-theme-dark .nut-cascader__bar {
|
||||
color: var(--nut-dark-color, var(--nut-white, #fff));
|
||||
background: var(--nut-dark-background2, #1b1b1b);
|
||||
}
|
||||
.nut-theme-dark .nut-cascader-item__inner {
|
||||
color: var(--nut-dark-color-gray, var(--nut-text-color, #808080));
|
||||
}
|
||||
.nut-cascader .nut-tab-pane {
|
||||
padding: 0;
|
||||
}
|
||||
.nut-cascader .nut-tabs__titles {
|
||||
padding: var(--nut-cascader-tabs-item-padding, 0 10px);
|
||||
background: #fff;
|
||||
}
|
||||
.nut-cascader-item {
|
||||
width: 100%;
|
||||
font-size: var(--nut-cascader-font-size, var(--nut-font-size-2, 14px));
|
||||
line-height: var(--nut-cascader-line-height, 22px);
|
||||
}
|
||||
.nut-cascader-item.nut-tabs.horizontal .nut-tabs__titles .nut-tabs__titles-item {
|
||||
flex: initial;
|
||||
padding: var(--nut-cascader-tabs-item-padding, 0 10px);
|
||||
white-space: nowrap;
|
||||
}
|
||||
.nut-cascader-item__inner {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: var(--nut-cascader-item-padding, 10px 20px);
|
||||
margin: 0;
|
||||
font-size: var(--nut-cascader-item-font-size, var(--nut-font-size-2, 14px));
|
||||
color: var(--nut-cascader-item-color, var(--nut-title-color, #1a1a1a));
|
||||
cursor: pointer;
|
||||
}
|
||||
.nut-cascader-item__title {
|
||||
flex: 1;
|
||||
}
|
||||
.nut-cascader-item__icon-check {
|
||||
margin-left: 10px;
|
||||
visibility: hidden;
|
||||
}
|
||||
.nut-cascader-item__icon-loading {
|
||||
margin-left: 10px;
|
||||
}
|
||||
.nut-cascader-item.active:not(.disabled) {
|
||||
color: var(--nut-cascader-item-active-color, var(--nut-primary-color, #fa2c19));
|
||||
}
|
||||
.nut-cascader-item.active .nut-cascader-item__icon-check {
|
||||
color: var(--nut-cascader-item-active-color, var(--nut-primary-color, #fa2c19));
|
||||
visibility: visible;
|
||||
}
|
||||
.nut-cascader-item.disabled {
|
||||
cursor: not-allowed;
|
||||
opacity: 0.6;
|
||||
}
|
||||
.nut-cascader__bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: var(--nut-cascader-bar-padding, 24px 20px 17px);
|
||||
font-size: var(--nut-cascader-bar-font-size, var(--nut-font-size-4, 18px));
|
||||
font-weight: bold;
|
||||
line-height: var(--nut-cascader-bar-line-height, 20px);
|
||||
color: var(--nut-cascader-bar-color, var(--nut-title-color, #1a1a1a));
|
||||
text-align: center;
|
||||
}
|
||||
.nut-cascader-pane {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 342px;
|
||||
padding: 10px 0 0;
|
||||
margin: 0;
|
||||
overflow-y: auto;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
.nut-overlay {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: var(--nut-overlay-bg-color, rgba(0, 0, 0, 0.7));
|
||||
}
|
||||
.nut-overflow-hidden {
|
||||
overflow: hidden !important;
|
||||
}
|
||||
.nut-theme-dark .nut-popup {
|
||||
background: var(--nut-dark-background2, #1b1b1b);
|
||||
}
|
||||
.nut-theme-dark .nut-popup__close-icon {
|
||||
color: var(--nut-dark-color, var(--nut-white, #fff));
|
||||
}
|
||||
.nut-popup-slide-center-enter-active, .nut-popup-slide-center-leave-active {
|
||||
transition-timing-function: ease;
|
||||
transition-property: opacity;
|
||||
}
|
||||
.nut-popup-slide-center-enter-from, .nut-popup-slide-center-leave-to {
|
||||
opacity: 0;
|
||||
}
|
||||
.nut-popup-slide-top-enter-from, .nut-popup-slide-top-leave-active {
|
||||
transform: translate(0, -100%);
|
||||
}
|
||||
.nut-popup-slide-right-enter-from, .nut-popup-slide-right-leave-active {
|
||||
transform: translate(100%, 0);
|
||||
}
|
||||
.nut-popup-slide-bottom-enter-from, .nut-popup-slide-bottom-leave-active {
|
||||
transform: translate(0, 100%);
|
||||
}
|
||||
.nut-popup-slide-left-enter-from, .nut-popup-slide-left-leave-active {
|
||||
transform: translate(-100%, 0);
|
||||
}
|
||||
.nut-popup--center {
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
.nut-popup--center.round {
|
||||
border-radius: var(--nut-popup-border-radius, 20px);
|
||||
}
|
||||
.nut-popup--bottom {
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
}
|
||||
.nut-popup--bottom.round {
|
||||
border-radius: var(--nut-popup-border-radius, 20px) var(--nut-popup-border-radius, 20px) 0 0;
|
||||
}
|
||||
.nut-popup--bottom--safebottom {
|
||||
padding-bottom: constant(safe-area-inset-bottom);
|
||||
padding-bottom: env(safe-area-inset-bottom);
|
||||
}
|
||||
.nut-popup--right {
|
||||
top: 0;
|
||||
right: 0;
|
||||
}
|
||||
.nut-popup--right.round {
|
||||
border-radius: var(--nut-popup-border-radius, 20px) 0 0 var(--nut-popup-border-radius, 20px);
|
||||
}
|
||||
.nut-popup--left {
|
||||
top: 0;
|
||||
left: 0;
|
||||
}
|
||||
.nut-popup--left.round {
|
||||
border-radius: 0 var(--nut-popup-border-radius, 20px) var(--nut-popup-border-radius, 20px) 0;
|
||||
}
|
||||
.nut-popup--top {
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
}
|
||||
.nut-popup--top.round {
|
||||
border-radius: 0 0 var(--nut-popup-border-radius, 20px) var(--nut-popup-border-radius, 20px);
|
||||
}
|
||||
.nut-popup--top--safetop {
|
||||
padding-top: var(--status-bar-height);
|
||||
padding-top: constant(safe-area-inset-top);
|
||||
padding-top: env(safe-area-inset-top);
|
||||
}
|
||||
.nut-popup {
|
||||
position: fixed;
|
||||
max-height: 100%;
|
||||
overflow-y: auto;
|
||||
background-color: var(--nut-white, #fff);
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
.nut-popup__close-icon {
|
||||
position: absolute !important;
|
||||
z-index: 1;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
font-size: 18px;
|
||||
line-height: 30px;
|
||||
color: #969799;
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
}
|
||||
.nut-popup__close-icon:active {
|
||||
opacity: 0.7;
|
||||
}
|
||||
.nut-popup__close-icon--top-left {
|
||||
top: var(--nut-popup-close-icon-margin, 16px);
|
||||
left: var(--nut-popup-close-icon-margin, 16px);
|
||||
}
|
||||
.nut-popup__close-icon--top-right {
|
||||
top: var(--nut-popup-close-icon-margin, 16px);
|
||||
right: var(--nut-popup-close-icon-margin, 16px);
|
||||
}
|
||||
.nut-popup__close-icon--bottom-left {
|
||||
bottom: var(--nut-popup-close-icon-margin, 16px);
|
||||
left: var(--nut-popup-close-icon-margin, 16px);
|
||||
}
|
||||
.nut-popup__close-icon--bottom-right {
|
||||
right: var(--nut-popup-close-icon-margin, 16px);
|
||||
bottom: var(--nut-popup-close-icon-margin, 16px);
|
||||
}
|
||||
65
unpackage/dist/dev/mp-weixin/uni_modules/nutui-uni/components/cascader/helper.js
vendored
Normal file
65
unpackage/dist/dev/mp-weixin/uni_modules/nutui-uni/components/cascader/helper.js
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
"use strict";
|
||||
function formatTree(tree, parent, config) {
|
||||
return tree.map((node) => {
|
||||
const { value: valueKey = "value", text: textKey = "text", children: childrenKey = "children" } = config;
|
||||
const { [valueKey]: value, [textKey]: text, [childrenKey]: children, ...others } = node;
|
||||
const newNode = {
|
||||
loading: false,
|
||||
...others,
|
||||
level: parent ? (parent && parent.level || 0) + 1 : 0,
|
||||
value,
|
||||
text,
|
||||
children,
|
||||
_parent: parent
|
||||
};
|
||||
if (newNode.children && newNode.children.length)
|
||||
newNode.children = formatTree(newNode.children, newNode, config);
|
||||
return newNode;
|
||||
});
|
||||
}
|
||||
function eachTree(tree, cb) {
|
||||
let i = 0;
|
||||
let node;
|
||||
while (node = tree[i++]) {
|
||||
if (cb(node) === true)
|
||||
break;
|
||||
if (node.children && node.children.length)
|
||||
eachTree(node.children, cb);
|
||||
}
|
||||
}
|
||||
const defaultConvertConfig = {
|
||||
topId: null,
|
||||
idKey: "id",
|
||||
pidKey: "pid",
|
||||
sortKey: ""
|
||||
};
|
||||
function convertListToOptions(list, options) {
|
||||
const mergedOptions = {
|
||||
...defaultConvertConfig,
|
||||
...options || {}
|
||||
};
|
||||
const { topId, idKey, pidKey, sortKey } = mergedOptions;
|
||||
let result = [];
|
||||
let map = {};
|
||||
list.forEach((node) => {
|
||||
node = { ...node };
|
||||
const { [idKey]: id, [pidKey]: pid } = node;
|
||||
const children = map[pid] = map[pid] || [];
|
||||
if (!result.length && pid === topId)
|
||||
result = children;
|
||||
children.push(node);
|
||||
node.children = map[id] || (map[id] = []);
|
||||
});
|
||||
if (sortKey) {
|
||||
Object.keys(map).forEach((i) => {
|
||||
if (map[i].length > 1)
|
||||
map[i].sort((a, b) => a[sortKey] - b[sortKey]);
|
||||
});
|
||||
}
|
||||
map = null;
|
||||
return result;
|
||||
}
|
||||
exports.convertListToOptions = convertListToOptions;
|
||||
exports.eachTree = eachTree;
|
||||
exports.formatTree = formatTree;
|
||||
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/nutui-uni/components/cascader/helper.js.map
|
||||
56
unpackage/dist/dev/mp-weixin/uni_modules/nutui-uni/components/cascader/tree.js
vendored
Normal file
56
unpackage/dist/dev/mp-weixin/uni_modules/nutui-uni/components/cascader/tree.js
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
"use strict";
|
||||
const uni_modules_nutuiUni_components_cascader_helper = require("./helper.js");
|
||||
class Tree {
|
||||
constructor(nodes, config) {
|
||||
this.config = {
|
||||
value: "value",
|
||||
text: "text",
|
||||
children: "children",
|
||||
...config || {}
|
||||
};
|
||||
this.nodes = uni_modules_nutuiUni_components_cascader_helper.formatTree(nodes, null, this.config);
|
||||
}
|
||||
updateChildren(nodes, parent) {
|
||||
if (!parent)
|
||||
this.nodes = uni_modules_nutuiUni_components_cascader_helper.formatTree(nodes, null, this.config);
|
||||
else
|
||||
parent.children = uni_modules_nutuiUni_components_cascader_helper.formatTree(nodes, parent, this.config);
|
||||
}
|
||||
// for test
|
||||
getNodeByValue(value) {
|
||||
let foundNode;
|
||||
uni_modules_nutuiUni_components_cascader_helper.eachTree(this.nodes, (node) => {
|
||||
if (node.value === value) {
|
||||
foundNode = node;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
return foundNode;
|
||||
}
|
||||
getPathNodesByValue(value) {
|
||||
if (!value.length)
|
||||
return [];
|
||||
const pathNodes = [];
|
||||
let currentNodes = this.nodes;
|
||||
while (currentNodes && currentNodes.length) {
|
||||
const foundNode = currentNodes.find((node) => node.value === value[node.level]);
|
||||
if (!foundNode)
|
||||
break;
|
||||
pathNodes.push(foundNode);
|
||||
currentNodes = foundNode.children;
|
||||
}
|
||||
return pathNodes;
|
||||
}
|
||||
isLeaf(node, lazy) {
|
||||
const { leaf, children } = node;
|
||||
const hasChildren = Array.isArray(children) && Boolean(children.length);
|
||||
return leaf == null ? !hasChildren && !lazy : leaf;
|
||||
}
|
||||
hasChildren(node, lazy) {
|
||||
if (lazy)
|
||||
return Array.isArray(node.children) && Boolean(node.children.length);
|
||||
return !this.isLeaf(node, lazy);
|
||||
}
|
||||
}
|
||||
exports.Tree = Tree;
|
||||
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/nutui-uni/components/cascader/tree.js.map
|
||||
Reference in New Issue
Block a user