init
This commit is contained in:
116
unpackage/dist/dev/mp-weixin/uni_modules/nutui-uni/components/menu/menu.js
vendored
Normal file
116
unpackage/dist/dev/mp-weixin/uni_modules/nutui-uni/components/menu/menu.js
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../../../common/vendor.js");
|
||||
const uni_modules_nutuiUni_components__constants_prefix = require("../_constants/prefix.js");
|
||||
const uni_modules_nutuiUni_components__hooks_useProvide = require("../_hooks/useProvide.js");
|
||||
const uni_modules_nutuiUni_components__hooks_useRect = require("../_hooks/useRect.js");
|
||||
const uni_modules_nutuiUni_components__utils_common = require("../_utils/common.js");
|
||||
require("../_utils/env.js");
|
||||
const uni_modules_nutuiUni_components__utils_style = require("../_utils/style.js");
|
||||
const menu = require("../../../../menu.js");
|
||||
const Icon = () => "../icon/icon.js";
|
||||
const componentName = `${uni_modules_nutuiUni_components__constants_prefix.PREFIX}-menu`;
|
||||
const _sfc_main = common_vendor.defineComponent({
|
||||
name: componentName,
|
||||
components: { Icon },
|
||||
props: menu.menuProps,
|
||||
options: {
|
||||
virtualHost: true,
|
||||
addGlobalClass: true,
|
||||
styleIsolation: "shared"
|
||||
},
|
||||
setup(props) {
|
||||
const barId = `nut-menu__bar${uni_modules_nutuiUni_components__utils_common.getRandomId()}`;
|
||||
const offset = common_vendor.ref(0);
|
||||
const instance = common_vendor.getCurrentInstance();
|
||||
const { children } = uni_modules_nutuiUni_components__hooks_useProvide.useProvide(menu.MENU_KEY)({ props, offset });
|
||||
const opened = common_vendor.computed(() => children.some((item) => {
|
||||
var _a;
|
||||
return (_a = item == null ? void 0 : item.state) == null ? void 0 : _a.showWrapper;
|
||||
}));
|
||||
const isScrollFixed = common_vendor.computed(() => {
|
||||
const { scrollFixed, scrollTop } = props;
|
||||
if (!scrollFixed)
|
||||
return false;
|
||||
return scrollTop > (typeof scrollFixed === "boolean" ? 30 : Number(scrollFixed));
|
||||
});
|
||||
const classes = common_vendor.computed(() => {
|
||||
return uni_modules_nutuiUni_components__utils_style.getMainClass(props, componentName, {
|
||||
"scroll-fixed": isScrollFixed.value
|
||||
});
|
||||
});
|
||||
function updateOffset(children2) {
|
||||
setTimeout(() => {
|
||||
uni_modules_nutuiUni_components__hooks_useRect.useRect(barId, instance).then((rect) => {
|
||||
if (props.direction === "down")
|
||||
offset.value = rect.bottom + common_vendor.index.getSystemInfoSync().windowTop;
|
||||
else
|
||||
offset.value = common_vendor.index.getSystemInfoSync().windowHeight - rect.top;
|
||||
children2.toggle();
|
||||
});
|
||||
}, 100);
|
||||
}
|
||||
function toggleItem(active) {
|
||||
children.forEach((item, index) => {
|
||||
if (index === active)
|
||||
updateOffset(item);
|
||||
else if (item.state.showPopup)
|
||||
item.toggle(false, { immediate: true });
|
||||
});
|
||||
}
|
||||
function getClasses(showPopup) {
|
||||
let str = "";
|
||||
const { titleClass } = props;
|
||||
if (showPopup)
|
||||
str += "active";
|
||||
if (titleClass)
|
||||
str += ` ${titleClass}`;
|
||||
return str;
|
||||
}
|
||||
return {
|
||||
barId,
|
||||
toggleItem,
|
||||
children,
|
||||
opened,
|
||||
classes,
|
||||
getClasses
|
||||
};
|
||||
}
|
||||
});
|
||||
if (!Array) {
|
||||
const _component_Icon = common_vendor.resolveComponent("Icon");
|
||||
_component_Icon();
|
||||
}
|
||||
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||||
return {
|
||||
a: common_vendor.f(_ctx.children, (item, index, i0) => {
|
||||
return common_vendor.e({
|
||||
a: common_vendor.t(item.renderTitle())
|
||||
}, _ctx.direction === "up" ? {
|
||||
b: "ff3f7e8c-0-" + i0,
|
||||
c: common_vendor.p({
|
||||
name: _ctx.upIcon
|
||||
})
|
||||
} : {
|
||||
d: "ff3f7e8c-1-" + i0,
|
||||
e: common_vendor.p({
|
||||
name: _ctx.downIcon
|
||||
})
|
||||
}, {
|
||||
f: common_vendor.n(_ctx.getClasses(item.state.showPopup)),
|
||||
g: item.disabled ? 1 : "",
|
||||
h: item.state.showPopup ? 1 : "",
|
||||
i: item.state.showPopup ? _ctx.activeColor : "",
|
||||
j: common_vendor.o(($event) => !item.disabled && _ctx.toggleItem(index), index),
|
||||
k: index
|
||||
});
|
||||
}),
|
||||
b: _ctx.direction === "up",
|
||||
c: _ctx.barId,
|
||||
d: _ctx.opened ? 1 : "",
|
||||
e: common_vendor.n(_ctx.classes),
|
||||
f: common_vendor.s(_ctx.customStyle)
|
||||
};
|
||||
}
|
||||
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
|
||||
wx.createComponent(Component);
|
||||
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/nutui-uni/components/menu/menu.js.map
|
||||
6
unpackage/dist/dev/mp-weixin/uni_modules/nutui-uni/components/menu/menu.json
vendored
Normal file
6
unpackage/dist/dev/mp-weixin/uni_modules/nutui-uni/components/menu/menu.json
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"icon": "../icon/icon"
|
||||
}
|
||||
}
|
||||
1
unpackage/dist/dev/mp-weixin/uni_modules/nutui-uni/components/menu/menu.wxml
vendored
Normal file
1
unpackage/dist/dev/mp-weixin/uni_modules/nutui-uni/components/menu/menu.wxml
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<view class="{{e}}" style="{{f}}"><view id="{{c}}" class="{{['nut-menu__bar', d && 'opened']}}"><block wx:for="{{a}}" wx:for-item="item" wx:key="k"><view class="{{['nut-menu__item', item.g && 'disabled', item.h && 'active']}}" style="{{'color:' + item.i}}" bindtap="{{item.j}}"><view class="{{['nut-menu__title', item.f]}}"><view class="nut-menu__title-text">{{item.a}}</view><view class="nut-menu__title-icon"><icon wx:if="{{b}}" u-i="{{item.b}}" bind:__l="__l" u-p="{{item.c}}"/><icon wx:else u-i="{{item.d}}" bind:__l="__l" u-p="{{item.e||''}}"/></view></view></view></block></view><slot/></view>
|
||||
106
unpackage/dist/dev/mp-weixin/uni_modules/nutui-uni/components/menu/menu.wxss
vendored
Normal file
106
unpackage/dist/dev/mp-weixin/uni_modules/nutui-uni/components/menu/menu.wxss
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
/**
|
||||
* 这里是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-menu .nut-menu__bar {
|
||||
background-color: var(--nut-dark-background, #131313);
|
||||
}
|
||||
.nut-theme-dark .nut-menu .nut-menu__bar .nut-menu__item {
|
||||
color: var(--nut-dark-color, var(--nut-white, #fff));
|
||||
}
|
||||
.nut-menu.scroll-fixed {
|
||||
position: fixed;
|
||||
top: var(--nut-menu-scroll-fixed-top, 0);
|
||||
z-index: var(--nut-menu-scroll-fixed-z-index, 1000);
|
||||
width: 100%;
|
||||
}
|
||||
.nut-menu .nut-menu__bar {
|
||||
position: relative;
|
||||
display: flex;
|
||||
line-height: var(--nut-menu-bar-line-height, 48px);
|
||||
background-color: var(--nut-white, #fff);
|
||||
box-shadow: var(--nut-menu-bar-box-shadow, 0 2px 12px rgba(89, 89, 89, 0.12));
|
||||
}
|
||||
.nut-menu .nut-menu__bar.opened {
|
||||
z-index: var(--nut-menu-bar-opened-z-index, 2001);
|
||||
}
|
||||
.nut-menu .nut-menu__bar .nut-menu__item {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
font-size: var(--nut-menu-item-font-size, var(--nut-font-size-2, 14px));
|
||||
color: var(--nut-menu-item-text-color, var(--nut-title-color, #1a1a1a));
|
||||
text-align: center;
|
||||
}
|
||||
.nut-menu .nut-menu__bar .nut-menu__item.active {
|
||||
color: var(--nut-menu-item-active-text-color, var(--nut-primary-color, #fa2c19));
|
||||
}
|
||||
.nut-menu .nut-menu__bar .nut-menu__item.disabled {
|
||||
color: var(--nut-menu-item-disabled-color, #969799);
|
||||
}
|
||||
.nut-menu .nut-menu__bar .nut-menu__item .nut-menu__title-icon {
|
||||
display: flex;
|
||||
transition: all 0.2s linear;
|
||||
}
|
||||
.nut-menu .nut-menu__bar .nut-menu__item .nut-menu__title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
max-width: 100%;
|
||||
}
|
||||
.nut-menu .nut-menu__bar .nut-menu__item .nut-menu__title .nut-menu__title-text {
|
||||
display: block;
|
||||
padding-right: var(--nut-menu-title-text-padding-right, 8px);
|
||||
padding-left: var(--nut-menu-title-text-padding-left, 8px);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.nut-menu .nut-menu__bar .nut-menu__item .nut-menu__title.active .nut-menu__title-icon {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
Reference in New Issue
Block a user