Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(pro): add proTagSelect component #1867

Merged
merged 1 commit into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions packages/components/_private/trigger/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ import type { DefineComponent, HTMLAttributes, PropType, Slot } from 'vue'
export const triggerProps = {
value: { type: null, default: undefined },
raw: { type: Boolean, default: false },
borderless: Boolean,
clearable: Boolean,
borderless: { type: Boolean, default: undefined },
clearable: { type: Boolean, default: undefined },
clearIcon: { type: String as PropType<string>, default: 'close-circle' },
disabled: Boolean,
focused: Boolean,
disabled: { type: Boolean, default: undefined },
focused: { type: Boolean, default: undefined },
monitorFocus: { type: Boolean, default: true },
paddingless: { type: Boolean, default: false },
placeholder: String,
readonly: Boolean,
readonly: { type: Boolean, default: undefined },
size: { type: String as PropType<FormSize>, default: 'md' },
status: String as PropType<ValidateStatus>,
suffix: String as PropType<string>,
Expand Down
5 changes: 2 additions & 3 deletions packages/components/cascader/src/Cascader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ export default defineComponent({
focused={focused}
maxLabel={props.maxLabel}
multiple={props.multiple}
monitorFocus={false}
opened={opened}
placeholder={props.placeholder}
readonly={readonly}
Expand Down Expand Up @@ -225,8 +224,8 @@ export default defineComponent({
const controlTriggerProps = {
autofocus: props.autofocus,
overlayClassName: overlayClasses.value,
overlayContainer: props.overlayContainer,
overlayContainerFallback: `${mergedPrefixCls.value}-overlay-container`,
overlayContainer: props.overlayContainer ?? config.overlayContainer,
overlayContainerFallback: `.${mergedPrefixCls.value}-overlay-container`,
overlayMatchWidth: props.overlayMatchWidth ?? config.overlayMatchWidth,
class: mergedPrefixCls.value,
borderless,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export default defineComponent({
disabled: controlTriggerProps.disabled || controlTriggerProps.readonly,
offset: controlTriggerProps.offset ?? defaultOffset,
placement: props.placement ?? 'bottomStart',
showArrow: props.showArrow,
transitionName: `${common.prefixCls}-slide-auto`,
trigger: props.trigger ?? 'click',
triggerId: attrs.id,
Expand Down
1 change: 1 addition & 0 deletions packages/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ export * from '@idux/components/radio'
export * from '@idux/components/rate'
export * from '@idux/components/result'
export * from '@idux/components/select'
export * from '@idux/components/selector'
export * from '@idux/components/skeleton'
export * from '@idux/components/slider'
export * from '@idux/components/space'
Expand Down
5 changes: 2 additions & 3 deletions packages/components/select/src/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ export default defineComponent({
focused={focused}
maxLabel={props.maxLabel}
multiple={props.multiple}
monitorFocus={false}
opened={opened}
placeholder={props.placeholder}
readonly={readonly}
Expand Down Expand Up @@ -237,8 +236,8 @@ export default defineComponent({
const controlTriggerProps = {
autofocus: props.autofocus,
overlayClassName: overlayClasses.value,
overlayContainer: props.overlayContainer,
overlayContainerFallback: `${mergedPrefixCls.value}-overlay-container`,
overlayContainer: props.overlayContainer ?? config.overlayContainer,
overlayContainerFallback: `.${mergedPrefixCls.value}-overlay-container`,
overlayMatchWidth: props.overlayMatchWidth ?? config.overlayMatchWidth,
class: mergedPrefixCls.value,
borderless,
Expand Down
21 changes: 21 additions & 0 deletions packages/components/selector/style/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,16 @@
&-item {
.ellipsis();

max-width: 100%;
user-select: none;

&-label {
.ellipsis();
}

&-disabled {
color: var(--ix-color-text-disabled);
}
}

&-input {
Expand Down Expand Up @@ -60,4 +65,20 @@
cursor: auto;
}
}

&-sm {
.@{selector-prefix}-item {
max-width: calc(100% - var(--ix-font-size-icon) + var(--ix-control-padding-size-horizontal-sm));
}
}
&-md {
.@{selector-prefix}-item {
max-width: calc(100% - var(--ix-font-size-icon) + var(--ix-control-padding-size-horizontal-md));
}
}
&-lg {
.@{selector-prefix}-item {
max-width: calc(100% - var(--ix-font-size-icon) + var(--ix-control-padding-size-horizontal-lg));
}
}
}
3 changes: 1 addition & 2 deletions packages/components/tree-select/src/TreeSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ export default defineComponent({
focused={focused}
maxLabel={props.maxLabel}
multiple={props.multiple}
monitorFocus={false}
opened={opened}
placeholder={props.placeholder}
readonly={props.readonly}
Expand Down Expand Up @@ -198,7 +197,7 @@ export default defineComponent({
offset: props.offset ?? config.offset,
overlayClassName: overlayClasses.value,
overlayContainer: props.overlayContainer ?? config.overlayContainer,
overlayContainerFallback: `${mergedPrefixCls.value}-overlay-container`,
overlayContainerFallback: `.${mergedPrefixCls.value}-overlay-container`,
overlayMatchWidth: props.overlayMatchWidth ?? config.overlayMatchWidth,
'onUpdate:open': setOverlayOpened,
onFocus: handleFocus,
Expand Down
7 changes: 7 additions & 0 deletions packages/pro/config/src/defaultConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ export const defaultConfig: ProGlobalConfig = {
searchable: false,
},
},
tagSelect: {
borderless: false,
clearable: false,
clearIcon: 'close-circle',
size: 'md',
suffix: 'down',
},
tree: {
clearIcon: 'close-circle',
collapseIcon: ['collapse', 'expand'],
Expand Down
9 changes: 9 additions & 0 deletions packages/pro/config/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export interface ProGlobalConfig {

form: ProFormConfig
table: ProTableConfig
tagSelect: ProTagSelectConfig
tree: ProTreeConfig
textarea: ProTextareaConfig
search: ProSearchConfig
Expand Down Expand Up @@ -80,6 +81,14 @@ export interface ProTableConfig {
}
}

export interface ProTagSelectConfig {
borderless: boolean
clearable: boolean
clearIcon: string
size: FormSize
suffix: string
}

export interface ProTreeConfig {
clearIcon: string
collapseIcon: [string, string]
Expand Down
20 changes: 20 additions & 0 deletions packages/pro/dark.full.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions packages/pro/default.full.css
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,26 @@
--ix-pro-search-tree-select-panel-max-width: 400px;
}

/* ------ pro-tag-select css variables ------ */
:root {
--ix-pro-tag-select-preset-color-grey-label: #a1a7b3;
--ix-pro-tag-select-preset-color-grey-bg: rgb(246, 246, 247);

Check warning on line 82 in packages/pro/default.full.css

View check run for this annotation

codefactor.io / CodeFactor

packages/pro/default.full.css#L82

Expected modern color-function notation (color-function-notation)
--ix-pro-tag-select-preset-color-green-label: #39c317;
--ix-pro-tag-select-preset-color-green-bg: rgb(235, 249, 232);

Check warning on line 84 in packages/pro/default.full.css

View check run for this annotation

codefactor.io / CodeFactor

packages/pro/default.full.css#L84

Expected modern color-function notation (color-function-notation)
--ix-pro-tag-select-preset-color-blue-label: #1c6eff;
--ix-pro-tag-select-preset-color-blue-bg: rgb(232, 241, 255);

Check warning on line 86 in packages/pro/default.full.css

View check run for this annotation

codefactor.io / CodeFactor

packages/pro/default.full.css#L86

Expected modern color-function notation (color-function-notation)
--ix-pro-tag-select-preset-color-yellow-label: #f8d81a;
--ix-pro-tag-select-preset-color-yellow-bg: rgb(254, 251, 232);

Check warning on line 88 in packages/pro/default.full.css

View check run for this annotation

codefactor.io / CodeFactor

packages/pro/default.full.css#L88

Expected modern color-function notation (color-function-notation)
--ix-pro-tag-select-preset-color-red-label: #f52727;
--ix-pro-tag-select-preset-color-red-bg: rgb(254, 233, 233);

Check warning on line 90 in packages/pro/default.full.css

View check run for this annotation

codefactor.io / CodeFactor

packages/pro/default.full.css#L90

Expected modern color-function notation (color-function-notation)
--ix-pro-tag-select-preset-color-orange-label: #fa721b;
--ix-pro-tag-select-preset-color-orange-bg: rgb(255, 241, 232);

Check warning on line 92 in packages/pro/default.full.css

View check run for this annotation

codefactor.io / CodeFactor

packages/pro/default.full.css#L92

Expected modern color-function notation (color-function-notation)
--ix-pro-tag-select-color-indicator-size: 12px;
--ix-pro-tag-select-panel-max-height: 256px;
--ix-pro-tag-select-edit-panel-min-width: 225px;
--ix-pro-tag-select-tag-height: 20px;
}

/* ------ pro-textarea css variables ------ */
:root {
--ix-pro-textarea-index-col-color: #2f3540;
Expand Down
1 change: 1 addition & 0 deletions packages/pro/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
@import './form/style/index.less';
@import './layout/style/index.less';
@import './table/style/index.less';
@import './tag-select/style/index.less';

Check warning on line 6 in packages/pro/index.less

View check run for this annotation

codefactor.io / CodeFactor

packages/pro/index.less#L6

Expected "'./tag-select/style/index.less'" to be "url('./tag-select/style/index.less')" (import-notation)
@import './textarea/style/index.less';
@import './transfer/style/index.less';
@import './tree/style/index.less';
Expand Down
3 changes: 3 additions & 0 deletions packages/pro/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { IxProForm } from '@idux/pro/form'
import { IxProLayout, IxProLayoutSiderTrigger } from '@idux/pro/layout'
import { IxProSearch, IxProSearchShortcut } from '@idux/pro/search'
import { IxProTable, IxProTableLayoutTool } from '@idux/pro/table'
import { IxProTagSelect } from '@idux/pro/tag-select'
import { IxProTextarea } from '@idux/pro/textarea'
import { IxProTransfer } from '@idux/pro/transfer'
import { IxProTree } from '@idux/pro/tree'
Expand All @@ -24,6 +25,7 @@ const components = [
IxProLayoutSiderTrigger,
IxProTable,
IxProTableLayoutTool,
IxProTagSelect,
IxProTransfer,
IxProTree,
IxProTextarea,
Expand All @@ -50,6 +52,7 @@ export * from '@idux/pro/form'
export * from '@idux/pro/layout'
export * from '@idux/pro/search'
export * from '@idux/pro/table'
export * from '@idux/pro/tag-select'
export * from '@idux/pro/textarea'
export * from '@idux/pro/transfer'
export * from '@idux/pro/tree'
Expand Down
17 changes: 17 additions & 0 deletions packages/pro/locales/src/langs/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,23 @@ const enUS: ProLocale = {
noPinTitle: 'Unpinned',
},
},
tagSelect: {
colors: {
grey: 'grey',
green: 'green',
blue: 'blue',
yellow: 'yellow',
red: 'red',
orange: 'orange',
},
remove: 'delete',
createTag: 'Create tag',
removeTag: 'Remove tag',
maxExceededAlert: 'Tags count reached limit of ${0}',
empty: 'No Data',
ok: 'OK',
cancel: 'Cancel',
},
tree: {
expandAll: 'Expand',
collapseAll: 'Collapse',
Expand Down
17 changes: 17 additions & 0 deletions packages/pro/locales/src/langs/zh-CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,23 @@ const zhCN: ProLocale = {
noPinTitle: '不固定',
},
},
tagSelect: {
colors: {
grey: '灰',
green: '绿',
blue: '蓝',
yellow: '黄',
red: '红',
orange: '橙',
},
remove: '删除',
createTag: '创建标签',
removeTag: '删除标签',
maxExceededAlert: '标签已达${0}个上限,请及时清理',
empty: '暂无数据',
ok: '确定',
cancel: '取消',
},
tree: {
expandAll: '展开全部',
collapseAll: '收起全部',
Expand Down
19 changes: 19 additions & 0 deletions packages/pro/locales/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,29 @@ export interface ProSearchLocale {
switchToDatePanel: string
}

export interface ProTagSelectLocale {
colors: {
grey: string
green: string
blue: string
yellow: string
red: string
orange: string
}
remove: string
createTag: string
removeTag: string
maxExceededAlert: string
empty: string
ok: string
cancel: string
}

export interface ProLocale {
type: ProLocaleType

table: ProTableLocale
tagSelect: ProTagSelectLocale
tree: ProTreeLocale
search: ProSearchLocale
}
Expand Down
1 change: 1 addition & 0 deletions packages/pro/style/variable/prefix.less
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
@pro-textarea-prefix: ~'@{idux-pro-prefix}-textarea';
@pro-transfer-prefix: ~'@{idux-pro-prefix}-transfer';
@pro-tree-prefix: ~'@{idux-pro-prefix}-tree';
@pro-tag-select-prefix: ~'@{idux-pro-prefix}-tag-select';

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Vitest Snapshot v1

exports[`ProTagSelect > render work 1`] = `
"<div class=\\"ix-trigger ix-trigger-md ix-trigger-paddingless ix-selector ix-selector-md ix-selector-allow-input ix-selector-multiple ix-pro-tag-select ix-control-trigger ix-pro-tag-select\\" tabindex=\\"-1\\">
<!---->
<div class=\\"ix-selector-content\\">
<div class=\\"ix-selector-placeholder\\">
<!---->
</div>
<div class=\\"ix-overflow ix-selector-overflow \\">
<!---->
<div class=\\"ix-overflow-item ix-overflow-suffix\\">
<div class=\\"ix-selector-input\\"><input class=\\"ix-selector-input-inner\\" style=\\"opacity: 0; width: 0px;\\" readonly=\\"\\"><span class=\\"ix-selector-input-mirror\\" aria-hidden=\\"true\\"></span></div>
</div>
</div>
</div>
<div class=\\"ix-trigger-suffix\\"><i class=\\"ix-icon ix-icon-down\\" style=\\"transform: rotate(0deg);\\" role=\\"img\\" aria-label=\\"down\\"></i></div>
<!---->
</div>"
`;
25 changes: 25 additions & 0 deletions packages/pro/tag-select/__tests__/proTagSelect.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { MountingOptions, mount } from '@vue/test-utils'

import { renderWork } from '@tests'

import ProTagSelect from '../src/ProTagSelect'
import { ProTagSelectProps } from '../src/types'

describe.skip('ProTagSelect', () => {
const ProTagSelectMount = (options?: MountingOptions<Partial<ProTagSelectProps>>) =>
mount(ProTagSelect, { ...(options as MountingOptions<ProTagSelectProps>) })

renderWork<ProTagSelectProps>(ProTagSelect, {
props: {},
})

test('xxx work', async () => {
const wrapper = ProTagSelectMount({ props: { xxx: 'Xxx' } })

expect(wrapper.classes()).toContain('ix-Xxx')

await wrapper.setProps({ xxx: 'Yyy' })

expect(wrapper.classes()).toContain('ix-Yyy')
})
})
14 changes: 14 additions & 0 deletions packages/pro/tag-select/demo/Basic.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
order: 0
title:
zh: 基本使用
en: Basic usage
---

## zh

最简单的用法。

## en

The simplest usage.