From 383961fb09a6c90c21456264a41dae2f26e0c768 Mon Sep 17 00:00:00 2001 From: Kagol Date: Fri, 17 Mar 2023 15:18:37 +0800 Subject: [PATCH 1/4] chore: checkout release branch --- .github/workflows/auto-publish.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/auto-publish.yml b/.github/workflows/auto-publish.yml index 30cc124..10fbd7f 100644 --- a/.github/workflows/auto-publish.yml +++ b/.github/workflows/auto-publish.yml @@ -11,6 +11,8 @@ jobs: steps: - name: CheckOut Code uses: actions/checkout@master + with: + ref: release - name: Setup Node uses: actions/setup-node@v3 From 1df1dbc2a115e9abb034462e974aa61dc1340e1d Mon Sep 17 00:00:00 2001 From: zhanyini Date: Tue, 1 Aug 2023 00:55:34 -0700 Subject: [PATCH 2/4] =?UTF-8?q?feat(input):=20input=20=E6=96=B0=E5=A2=9Edi?= =?UTF-8?q?splayOnly=20=E5=8A=9F=E8=83=BD=EF=BC=8C=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/input/index.js | 56 +++++++++++++++++++++++++++++++++++++-------- src/input/vue.js | 57 ++++++++++++++++++++++++++++++++++------------ 2 files changed, 88 insertions(+), 25 deletions(-) diff --git a/src/input/index.js b/src/input/index.js index 3c810fc..c64d325 100644 --- a/src/input/index.js +++ b/src/input/index.js @@ -1,14 +1,14 @@ /** -* Copyright (c) 2022 - present TinyVue Authors. -* Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd. -* -* Use of this source code is governed by an MIT-style license. -* -* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, -* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR -* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS. -* -*/ + * Copyright (c) 2022 - present TinyVue Authors. + * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd. + * + * Use of this source code is governed by an MIT-style license. + * + * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, + * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR + * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS. + * + */ import { isSame } from '@opentiny/vue-renderless/common/type' @@ -315,3 +315,39 @@ export const hasSelection = (api) => () => { const input = api.getInput() return input && input.selectionStart !== input.selectionEnd } + +export const handleEnterDisplayOnlyContent = ({ state, props }) => ($event, type) => { + const target = $event.target + + if (target && (target.scrollWidth > target.offsetWidth || (type === 'textarea' && target.scrollHeight > target.offsetHeight))) { + state.displayOnlyTooltip = props.displayContent || state.nativeInputValue + } +} + +export const hiddenPassword = ({ state, props }) => () => { + let str = '' + const password = props.displayOnlyContent || state.nativeInputValue + + for (let i = 0; i < password.length; i++) { + str += '*' + } + + return str +} + +export const dispatchDisplayedValue = ({ state, props, dispatch, api }) => () => { + if (state.isDisplayOnly) { + dispatch('FormItem', 'displayed-value-changed', { + type: props.type || 'text', + val: api.getDisplayedValue() + }) + } +} + +export const getDisplayedValue = ({ state, props }) => () => { + if (props.type === 'password') { + return state.hiddenPassword || '-' + } else { + return props.displayOnlyContent || state.nativeInputValue || '-' + } +} diff --git a/src/input/vue.js b/src/input/vue.js index 1f9c2df..a48d153 100644 --- a/src/input/vue.js +++ b/src/input/vue.js @@ -1,14 +1,14 @@ /** -* Copyright (c) 2022 - present TinyVue Authors. -* Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd. -* -* Use of this source code is governed by an MIT-style license. -* -* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, -* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR -* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS. -* -*/ + * Copyright (c) 2022 - present TinyVue Authors. + * Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd. + * + * Use of this source code is governed by an MIT-style license. + * + * THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, + * BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR + * A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS. + * + */ import { blur, @@ -34,7 +34,11 @@ import { handlePasswordVisible, handleCompositionStart, handleCompositionUpdate, - hasSelection + hasSelection, + handleEnterDisplayOnlyContent, + hiddenPassword, + dispatchDisplayedValue, + getDisplayedValue } from './index' import useStorageBox from '@opentiny/vue-renderless/tall-storage/vue-storage-box' @@ -66,7 +70,9 @@ export const api = [ 'selectedMemory', 'storageData', 'isMemoryStorage', - 'hasSelection' + 'hasSelection', + 'handleEnterDisplayOnlyContent', + 'hiddenPassword' ] const initState = ({ reactive, computed, mode, props, parent, constants }) => { @@ -105,7 +111,12 @@ const initState = ({ reactive, computed, mode, props, parent, constants }) => { !state.inputDisabled && !props.readonly && !props.showPassword - ) + ), + isDisplayOnly: computed( + () => (props.displayOnly || (parent.tinyForm || {}).displayOnly) && ['text', 'textarea', 'password', 'number'].includes(props.type) + ), + displayOnlyTooltip: '', + hiddenPassword: computed(() => api.hiddenPassword()) }) return state @@ -125,7 +136,9 @@ const initApi = ({ api, state, dispatch, broadcast, emit, refs, props, CLASS_PRE getSuffixVisible: getSuffixVisible({ parent, props, state }), calculateNodeStyling: calculateNodeStyling(), handleCompositionStart: handleCompositionStart(state), - handleCompositionUpdate: handleCompositionUpdate(state) + handleCompositionUpdate: handleCompositionUpdate(state), + dispatchDisplayedValue: dispatchDisplayedValue({ state, props, dispatch, api }), + getDisplayedValue: getDisplayedValue({ state, props }) }) } @@ -161,7 +174,9 @@ const mergeApi = ({ storages, api, componentName, props, emit, eventName, nextTi setNativeInputValue: setNativeInputValue({ api, state }), handleCompositionEnd: handleCompositionEnd({ api, state }), handlePasswordVisible: handlePasswordVisible({ api, nextTick, state }), - hasSelection: hasSelection(api) + hasSelection: hasSelection(api), + handleEnterDisplayOnlyContent: handleEnterDisplayOnlyContent({ state, props }), + hiddenPassword: hiddenPassword({ state, props }) }) } @@ -206,6 +221,18 @@ const initWatch = ({ watch, state, api, props, nextTick, emit, componentName, ev } ) + watch( + () => state.isDisplayOnly, + () => { + nextTick(() => { + api.setNativeInputValue() + api.resizeTextarea() + api.updateIconOffset() + api.dispatchDisplayedValue() + }) + } + ) + watch( () => state.sheetvalue, (value) => api.watchFormSelect(value), From 5d58dd4f2468887eb9bcc85a5df54b17863db58d Mon Sep 17 00:00:00 2001 From: zhanyini Date: Tue, 1 Aug 2023 00:58:22 -0700 Subject: [PATCH 3/4] =?UTF-8?q?feat(select):=20select=20=E6=A0=B9=E6=8D=AE?= =?UTF-8?q?input=E7=9A=84=E6=96=B0dom=E7=BB=93=E6=9E=84=E5=8F=98=E6=9B=B4?= =?UTF-8?q?=E8=AE=A1=E7=AE=97input=E9=AB=98=E5=BA=A6=E7=9A=84=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/select/index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/select/index.js b/src/select/index.js index c010a7c..5a838b9 100644 --- a/src/select/index.js +++ b/src/select/index.js @@ -12,6 +12,7 @@ import { find } from '@opentiny/vue-renderless/common/array' import { getObj, isEqual } from '@opentiny/vue-renderless/common/object' +import { hasClass } from '@opentiny/vue-renderless/common/deps/dom' import { isKorean } from '@opentiny/vue-renderless/common/string' import scrollIntoView from '@opentiny/vue-renderless/common/deps/scroll-into-view' import PopupManager from '@opentiny/vue-renderless/common/deps/popup-manager' @@ -527,8 +528,9 @@ export const resetInputHeight = ({ constants, nextTick, props, refs, state }) => return } - let inputChildNodes = refs.reference.$el.childNodes - let input = [].filter.call(inputChildNodes, (item) => item.tagName === 'INPUT')[0] + const inputChildNodes = refs.reference.$el.childNodes + const inputContainer = [].filter.call(inputChildNodes,(item)=>hasClass(item,'tiny-input-display-only'))[0] + const input = inputContainer&&inputContainer.querySelector('input') const tags = refs.tags if (!input) { From 03956a0ed0f5392745344b3ea91824833abe033b Mon Sep 17 00:00:00 2001 From: zhanyini Date: Tue, 1 Aug 2023 01:58:51 -0700 Subject: [PATCH 4/4] =?UTF-8?q?git=20commit=20-m=20"fix(select):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=88=9B=E5=BB=BA=E6=9D=A1=E7=9B=AE=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E6=9C=89=E5=8C=B9=E9=85=8D=E9=A1=B9=E5=8D=B4=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E4=BA=86=E6=9D=A1=E7=9B=AE"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/select/index.js | 64 +++++++++++++++++++++++++-------------------- src/select/vue.js | 21 ++++++++++----- 2 files changed, 51 insertions(+), 34 deletions(-) diff --git a/src/select/index.js b/src/select/index.js index 5a838b9..0a14122 100644 --- a/src/select/index.js +++ b/src/select/index.js @@ -300,41 +300,49 @@ const getResultOfSetSelected = ({ props, isGrid, isTree, api }) => { return result } -export const setSelected = ({ api, constants, nextTick, props, refs, state }) => () => { +export const setGridOrTreeSelected = ({ props, state, vm, isTree, api }) => () => { + if (!props.modelValue) { + state.selectedLabel = '' + state.selected = {} + state.currentKey = '' + vm.$refs.selectGrid && vm.$refs.selectGrid.clearRadioRow() + vm.$refs.selectTree && vm.$refs.selectTree.setCurrentKey && vm.$refs.selectTree.setCurrentKey(null) + return + } + + const isRemote = state.filterOrSearch && props.remote && typeof props.remoteMethod === 'function' + const nestdata = isRemote ? state.remoteData : isTree ? api.getTreeData(state.treeData) : state.gridData + const data = find(nestdata, (item) => props.modelValue == item[props.valueField]) + + if (isEmptyObject(data)) { + return + } + + const obj = { ...data } + const label = data[props.textField] + + obj.currentLabel = label + state.selectedLabel = label + state.selected = obj + state.currentKey = data[props.valueField] +} + +export const setSelected = ({ api, constants, nextTick, props, vm, state }) => () => { const isTree = props.renderType === constants.TYPE.Tree const isGrid = props.renderType === constants.TYPE.Grid if (!props.multiple) { if (isGrid || isTree) { - if (!props.modelValue) { - state.selectedLabel = '' - state.selected = {} - state.currentKey = '' - refs.selectGrid && refs.selectGrid.clearRadioRow() - refs.selectTree && refs.selectTree.setCurrentKey && refs.selectTree.setCurrentKey(null) - return - } - - const isRemote = state.filterOrSearch && props.remote && typeof props.remoteMethod === 'function' - const nestdata = isRemote ? state.remoteData : isTree ? api.getTreeData(state.treeData) : state.gridData - const data = find(nestdata, (item) => props.modelValue == item[props.valueField]) - - if (isEmptyObject(data)) { - return - } - - const obj = { ...data } - const label = data[props.textField] - obj.currentLabel = label - state.selectedLabel = label - state.selected = obj - state.currentKey = data[props.valueField] + setGridOrTreeSelected({ props, state, vm, isTree, api }) } else { const option = getOptionOfSetSelected({ api, props }) nextTick(() => { state.selected = option state.selectedLabel = option.state.currentLabel || option.currentLabel - props.filterable && (state.query = state.selectedLabel) + + if (state.filterOrSearch && !props.shape && !props.allowCreate) { + state.query = state.selectedLabel + } }) } @@ -345,7 +353,7 @@ export const setSelected = ({ api, constants, nextTick, props, refs, state }) => state.selectCls = result.length ? (result.length === state.options.length ? 'checked-sur' : 'halfselect') : 'check' state.selected = result - refs.selectTree && refs.selectTree.setCheckedNodes && refs.selectTree.setCheckedNodes(state.selected) + vm.$refs.selectTree && vm.$refs.selectTree.setCheckedNodes && vm.$refs.selectTree.setCheckedNodes(state.selected) state.tips = state.selected.map((item) => (item.state ? item.state.currentLabel : item.currentLabel)).join(',') nextTick(api.resetInputHeight) @@ -529,8 +537,8 @@ export const resetInputHeight = ({ constants, nextTick, props, refs, state }) => } const inputChildNodes = refs.reference.$el.childNodes - const inputContainer = [].filter.call(inputChildNodes,(item)=>hasClass(item,'tiny-input-display-only'))[0] - const input = inputContainer&&inputContainer.querySelector('input') + const inputContainer = [].filter.call(inputChildNodes, (item) => hasClass(item, 'tiny-input-display-only'))[0] + const input = inputContainer && inputContainer.querySelector('input') const tags = refs.tags if (!input) { diff --git a/src/select/vue.js b/src/select/vue.js index b1830a0..793198c 100644 --- a/src/select/vue.js +++ b/src/select/vue.js @@ -249,7 +249,7 @@ const addApi = ({ api, props, state, refs, emit, constants, parent, nextTick, di watchValue: watchValue({ api, constants, dispatch, props, refs, state }), toHide: toHide({ constants, state, props, vm, api }), toVisible: toVisible({ constants, state, props, vm, api, nextTick }), - setSelected: setSelected({ api, constants, nextTick, props, refs, state }), + setSelected: setSelected({ api, constants, nextTick, props, vm, state }), selectOption: selectOption({ api, state, props }), handleResize: handleResize({ api, props }), watchOptions: watchOptions({ api, constants, nextTick, parent, props, state }), @@ -335,19 +335,26 @@ const initApi = ({ api, props, state, refs, emit, maskState, constants, parent, const addWatch = ({ watch, props, api, state }) => { watch(() => [...state.options], api.watchOptions) - watch(() => state.gridData, api.setSelected, { immediate: true }) + if (props.renderType === 'grid') { + watch(() => state.gridData, api.setSelected, { immediate: true }) + } - watch(() => state.treeData, api.setSelected, { immediate: true }) + if (props.renderType === 'tree') { + watch(() => state.treeData, api.setSelected, { immediate: true }) + } watch(() => state.hoverIndex, api.watchHoverIndex) - props.options && watch(() => props.options, api.watchPropsOption, { immediate: true, deep: true }) + if (props.options) { + watch(() => props.options, api.watchPropsOption, { immediate: true, deep: true }) + } + watch(() => state.optimizeOpts, api.watchOptimizeOpts) } const initWatch = ({ watch, props, api, state, nextTick, refs }) => { - props.treeOp.data && + if (props.renderType === 'tree' && props.treeOp.data) { watch( () => props.treeOp.data, (data) => { @@ -355,8 +362,9 @@ const initWatch = ({ watch, props, api, state, nextTick, refs }) => { }, { immediate: true, deep: true } ) + } - props.gridOp.data && + if (props.renderType === 'grid' && props.gridOp.data) { watch( () => props.gridOp.data, (data) => { @@ -364,6 +372,7 @@ const initWatch = ({ watch, props, api, state, nextTick, refs }) => { }, { immediate: true, deep: true } ) + } watch( () => state.selectDisabled,