first commit

This commit is contained in:
编码猿
2024-09-27 01:32:49 +08:00
commit 28ebe05a64
7399 changed files with 1174529 additions and 0 deletions

View File

@@ -0,0 +1 @@
2e959c4f-7b06-4e5f-a02e-18415c101b59

View File

@@ -0,0 +1 @@
"use strict";var _baseComponent=_interopRequireDefault(require("../helpers/baseComponent")),_classNames=_interopRequireDefault(require("../helpers/classNames")),_eventsMixin=_interopRequireDefault(require("../helpers/eventsMixin"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _objectSpread(t){for(var e=1;e<arguments.length;e++)if(e%2){var n=null!=arguments[e]?arguments[e]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(e){_defineProperty(t,e,n[e])})}else Object.defineProperties(t,Object.getOwnPropertyDescriptors(arguments[e]));return t}function _defineProperty(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function getOptions(){return(0<arguments.length&&void 0!==arguments[0]?arguments[0]:[]).map(function(e,t){return"string"==typeof e?{title:e,value:e,index:t}:_objectSpread({},e,{index:t})})}(0,_baseComponent.default)({useField:!0,behaviors:[(0,_eventsMixin.default)()],relations:{"../field/index":{type:"ancestor"},"../radio/index":{type:"child",observer:function(){this.debounce(this.changeValue)}}},properties:{prefixCls:{type:String,value:"wux-radio-group"},cellGroupPrefixCls:{type:String,value:"wux-cell-group"},value:{type:String,value:""},title:{type:String,value:""},label:{type:String,value:""},options:{type:Array,value:[]}},data:{inputValue:"",keys:[]},observers:{value:function(e){this.hasFieldDecorator||(this.updated(e),this.changeValue(e))},inputValue:function(e){this.hasFieldDecorator&&this.changeValue(e)},options:function(e){this.changeValue(this.data.inputValue,e)}},methods:{updated:function(e){this.data.inputValue!==e&&this.setData({inputValue:e})},changeValue:function(e,t){var n=0<arguments.length&&void 0!==e?e:this.data.inputValue,i=getOptions(1<arguments.length&&void 0!==t?t:this.data.options),a=this.getRelationNodes("../radio/index"),r=0<i.length?i:a?a.map(function(e){return e.data}):[];!i.length&&a&&0<a.length&&a.forEach(function(e,t){e.changeValue(n===e.data.value,t)}),this.data.keys!==r&&this.setData({keys:r})},onChange:function(e){this.triggerEvent("change",_objectSpread({},e,{},this.getValue(e.value),{name:this.data.name,value:e.value}))},onRadioChange:function(e){var t=e.currentTarget.dataset.index;this.onChange(_objectSpread({},e.detail,{index:t}))},getValue:function(e,t){var n=0<arguments.length&&void 0!==e?e:this.data.inputValue,i=1<arguments.length&&void 0!==t?t:this.data.keys,a=n?[n]:[],r=i.filter(function(e){return a.includes(e.value)}).map(function(e){return e.title})||[],u=i.map(function(e){return e.value}),o=a.map(function(e){return u.indexOf(e)});return{value:n,displayValue:r[0]||"",selectedIndex:o[0]||"",selectedValue:n,cols:i}},getBoundingClientRect:function(e){return this.cellGroup=this.cellGroup||this.selectComponent("#wux-cell-group"),this.cellGroup&&this.cellGroup.getBoundingClientRect(e)}}});

View File

@@ -0,0 +1,7 @@
{
"component": true,
"usingComponents": {
"wux-cell-group": "../cell-group/index",
"wux-radio": "../radio/index"
}
}

View File

@@ -0,0 +1,25 @@
<wux-cell-group id="wux-cell-group" wux-class="{{ prefixCls }}" prefixCls="{{ cellGroupPrefixCls }}" title="{{ title }}" label="{{ label }}">
<block wx:for="{{ common.getOptions(options) }}" wx:for-item="option" wx:key="" wx:if="{{ options.length > 0 }}">
<wux-radio
prefixCls="{{ option.prefixCls || 'wux-radio' }}"
cellPrefixCls="{{ option.cellPrefixCls || 'wux-cell' }}"
selectablePrefixCls="{{ option.selectablePrefixCls || 'wux-selectable' }}"
thumb="{{ option.thumb }}"
title="{{ option.title }}"
label="{{ option.label }}"
value="{{ option.value }}"
checked="{{ inputValue === option.value }}"
disabled="{{ option.disabled }}"
color="{{ option.color || 'balanced' }}"
data-index="{{ index }}"
bind:change="onRadioChange"
/>
</block>
<block wx:if="{{ options.length === 0 }}">
<slot></slot>
</block>
</wux-cell-group>
<wxs module="common">
module.exports.getOptions = function(options) { return options.map(function(option) { if (option.constructor === 'String') { return { title: option, value: option } } return option }) }
</wxs>