Compare commits
	
		
			No commits in common. "b2eff20b6eb3285479524e02707dcd3eb46e2712" and "c84c0b903bfbc373da8c79a72d58768cfa82fb47" have entirely different histories.
		
	
	
		
			b2eff20b6e
			...
			c84c0b903b
		
	
		
| @ -5,11 +5,10 @@ import "./ErrorMessage.scss"; | ||||
| interface IErrorMessageProps { | ||||
|     i18nKey: AllI18nKeys; | ||||
|     options?: Record<string, string>; | ||||
|     className?: string; | ||||
| } | ||||
| 
 | ||||
| const ErrorMessage: FunctionComponent<IErrorMessageProps> = (props) => { | ||||
|     return <div className={["panel-error-message", props.className].filter(c => !!c).join(" ")}> | ||||
|     return <div className="panel-error-message"> | ||||
|         <Localization i18nKey={props.i18nKey} options={props.options}/> | ||||
|     </div> | ||||
| } | ||||
|  | ||||
| @ -1,9 +1,5 @@ | ||||
| @import "../Theme/Theme.scss"; | ||||
| 
 | ||||
| div.label-list-root { | ||||
|     margin: -5px; | ||||
| } | ||||
| 
 | ||||
| div.label { | ||||
|     width: auto; | ||||
|     height: auto; | ||||
|  | ||||
| @ -1,4 +1,4 @@ | ||||
| import { Component, RefObject } from "react"; | ||||
| import { Component } from "react"; | ||||
| import { Label } from "@Model/Label"; | ||||
| import { Icon } from "@fluentui/react"; | ||||
| import { useSetting, IMixinSettingProps, Themes } from "@Context/Setting"; | ||||
| @ -10,7 +10,6 @@ interface ILabelListProps { | ||||
|     maxWidth?: number; | ||||
|     width?: number; | ||||
|     labels: Label[]; | ||||
|     addRef?: RefObject<HTMLDivElement>; | ||||
|     focusLabel?: Label; | ||||
|     clickLabel?: (label: Label) => any; | ||||
|     deleteLabel?: (label: Label) => any; | ||||
| @ -35,7 +34,6 @@ class LabelList extends Component<ILabelListProps & IMixinSettingProps> { | ||||
|             classList.push("one-line"); | ||||
|         } | ||||
|         const colorCss = `rgb(${label.color.join(",")})`; | ||||
|         const isDelete = label.isDeleted(); | ||||
| 
 | ||||
|         return <div | ||||
|             style={{ | ||||
| @ -55,13 +53,7 @@ class LabelList extends Component<ILabelListProps & IMixinSettingProps> { | ||||
|                 backgroundColor: colorCss, | ||||
|                 borderRadius: isFocus ? 0 : 3 | ||||
|             }}/> | ||||
|             <div | ||||
|                 className="label-name" | ||||
|                 style={{ | ||||
|                     textDecoration: isDelete ? "line-through" : undefined, | ||||
|                     opacity: isDelete ? ".6" : undefined | ||||
|                 }} | ||||
|             > | ||||
|             <div className="label-name"> | ||||
|                 <div>{label.name}</div> | ||||
|             </div> | ||||
|             { | ||||
| @ -87,17 +79,17 @@ class LabelList extends Component<ILabelListProps & IMixinSettingProps> { | ||||
|         }); | ||||
|     } | ||||
| 
 | ||||
|     private renderAddButton() { | ||||
|     private renderAddButton(isNoMargin: boolean = false) { | ||||
|         const theme = this.props.setting?.themes ?? Themes.dark; | ||||
|         const classList: string[] = ["label", "add-button"]; | ||||
|         classList.push( theme === Themes.dark ? "dark" : "light" ); | ||||
| 
 | ||||
|         return <div | ||||
|             className={classList.join(" ")} | ||||
|             ref={this.props.addRef} | ||||
|             style={{ | ||||
|                 minHeight: this.props.minHeight, | ||||
|                 minWidth: this.props.minHeight | ||||
|                 minWidth: this.props.minHeight, | ||||
|                 marginLeft: isNoMargin ? "0" : undefined | ||||
|             }} | ||||
|             onClick={() => { | ||||
|                 this.props.addLabel ? this.props.addLabel() : null | ||||
| @ -108,10 +100,17 @@ class LabelList extends Component<ILabelListProps & IMixinSettingProps> { | ||||
|     } | ||||
|      | ||||
|     public render() { | ||||
|         return <div className="label-list-root"> | ||||
|             {this.renderAllLabels()} | ||||
|             {this.props.addLabel ? this.renderAddButton() : null} | ||||
|         </div>; | ||||
|         if (this.props.labels.length > 0) { | ||||
|             return <> | ||||
|                 {this.renderAllLabels()} | ||||
|                 {this.props.addLabel ? this.renderAddButton() : null} | ||||
|             </>; | ||||
|         } else { | ||||
|             return <> | ||||
|                 <ErrorMessage i18nKey="Panel.Info.Label.List.Error.Nodata"/> | ||||
|                 {this.props.addLabel ? this.renderAddButton(true) : null} | ||||
|             </>; | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
|  | ||||
| @ -1,31 +0,0 @@ | ||||
| @import "../Theme/Theme.scss"; | ||||
| 
 | ||||
| $line-min-height: 26px; | ||||
| 
 | ||||
| div.label-picker-root { | ||||
| 	width: 100%; | ||||
| 	display: flex; | ||||
| 	flex-wrap: wrap; | ||||
| 	min-height: $line-min-height; | ||||
| 	padding: 5px 0; | ||||
| 
 | ||||
|     div.input-intro { | ||||
| 		width: 50%; | ||||
| 		height: 100%; | ||||
| 		max-width: 220px; | ||||
| 		display: flex; | ||||
| 		align-items: center; | ||||
|         padding-right: 5px; | ||||
|         box-sizing: border-box; | ||||
| 	} | ||||
| 
 | ||||
|     div.root-content { | ||||
|         width: 50%; | ||||
|         height: 100%; | ||||
|         max-width: 180px; | ||||
|         min-height: $line-min-height; | ||||
|         border-radius: 3px; | ||||
|         overflow: hidden; | ||||
|         display: flex; | ||||
| 	} | ||||
| } | ||||
| @ -1,93 +0,0 @@ | ||||
| import { AllI18nKeys, Localization } from "@Component/Localization/Localization"; | ||||
| import { PickerList } from "../PickerList/PickerList"; | ||||
| import { Label } from "@Model/Label"; | ||||
| import { useStatusWithEvent, IMixinStatusProps } from "@Context/Status"; | ||||
| import { Component, ReactNode, createRef } from "react"; | ||||
| import { LabelList } from "../LabelList/LabelList"; | ||||
| import "./LabelPicker.scss" | ||||
| 
 | ||||
| interface ILabelPickerProps { | ||||
| 	keyI18n: AllI18nKeys; | ||||
|     infoI18n?: AllI18nKeys; | ||||
| 	labels: Label[]; | ||||
| 	labelAdd?: (label: Label) => any; | ||||
| 	labelDelete?: (label: Label) => any; | ||||
| } | ||||
| 
 | ||||
| interface ILabelPickerState { | ||||
|     isPickerVisible: boolean; | ||||
| } | ||||
| 
 | ||||
| @useStatusWithEvent("labelAttrChange", "labelChange") | ||||
| class LabelPicker extends Component<ILabelPickerProps & IMixinStatusProps, ILabelPickerState> { | ||||
| 
 | ||||
| 	public constructor(props: ILabelPickerProps) { | ||||
|         super(props); | ||||
|         this.state = { | ||||
|             isPickerVisible: false | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
| 	private addButtonRef = createRef<HTMLDivElement>(); | ||||
| 
 | ||||
| 	private getOtherLabel() { | ||||
| 		let res: Label[] = []; | ||||
| 		let nowLabel: Label[] = this.props.labels ?? []; | ||||
| 		if (this.props.status) { | ||||
| 			this.props.status.model.labelPool.forEach((aLabel) => { | ||||
| 				let isHas = false; | ||||
| 				nowLabel.forEach((nLabel) => { | ||||
| 					if (aLabel.equal(nLabel)) isHas = true; | ||||
| 				}) | ||||
| 				if (!isHas) { | ||||
| 					res.push(aLabel); | ||||
| 				} | ||||
| 			}) | ||||
| 		} | ||||
| 		return res; | ||||
| 	} | ||||
| 
 | ||||
| 	public render(): ReactNode { | ||||
| 		return <div | ||||
| 			className="label-picker-root" | ||||
| 		> | ||||
| 			<div className="input-intro"> | ||||
| 				<Localization i18nKey={this.props.keyI18n}/> | ||||
| 			</div> | ||||
| 			<div className="root-content"> | ||||
| 				<LabelList | ||||
| 					addRef={this.addButtonRef} | ||||
| 					labels={this.props.labels} | ||||
| 					minHeight={26} | ||||
| 					deleteLabel={(label) => { | ||||
| 						this.props.labelDelete ? this.props.labelDelete(label) : 0; | ||||
| 					}} | ||||
| 					addLabel={() => { | ||||
| 						this.setState({ | ||||
| 							isPickerVisible: true | ||||
| 						}); | ||||
| 					}} | ||||
| 				/> | ||||
| 				{this.state.isPickerVisible ? <PickerList | ||||
| 					objectList={this.getOtherLabel()} | ||||
| 					dismiss={() => { | ||||
| 						this.setState({ | ||||
| 							isPickerVisible: false | ||||
| 						}); | ||||
| 					}} | ||||
| 					click={(label) => { | ||||
| 						if (label instanceof Label && this.props.labelAdd) { | ||||
| 							this.props.labelAdd(label) | ||||
| 						} | ||||
| 						this.setState({ | ||||
| 							isPickerVisible: false | ||||
| 						}); | ||||
| 					}} | ||||
| 					target={this.addButtonRef} | ||||
| 				/> : null} | ||||
| 			</div> | ||||
| 		</div> | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| export { LabelPicker } | ||||
| @ -1,12 +0,0 @@ | ||||
| import { Component, ReactNode } from "react"; | ||||
| 
 | ||||
| interface IObjectPickerProps {} | ||||
| 
 | ||||
| class ObjectPicker extends Component<IObjectPickerProps> { | ||||
| 
 | ||||
| 	public render(): ReactNode { | ||||
| 		return <div></div> | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| export { ObjectPicker } | ||||
| @ -1,72 +0,0 @@ | ||||
| div.picker-list-root { | ||||
| 	max-width: 200px; | ||||
| 	padding: 0px; | ||||
| 	margin: 0px; | ||||
| 	overflow-y: auto; | ||||
| 
 | ||||
| 	div.picker-list-item { | ||||
| 		width: 200px; | ||||
| 		height: 36px; | ||||
| 		display: flex; | ||||
| 		justify-content: center; | ||||
| 		align-items: center; | ||||
| 		vertical-align: middle; | ||||
| 		cursor: pointer; | ||||
| 		user-select: none; | ||||
| 		border-radius: 3px; | ||||
| 		overflow: hidden; | ||||
| 
 | ||||
| 		div.list-item-color { | ||||
| 			width: 3px; | ||||
| 			height: calc( 100% - 6px ); | ||||
| 			margin: 3px 0 3px 3px; | ||||
| 			flex-shrink: 0; | ||||
| 			border-radius: 1000px; | ||||
| 			overflow: hidden; | ||||
| 			background-color: black; | ||||
| 		} | ||||
| 
 | ||||
| 		div.list-item-icon { | ||||
| 			width: 30px; | ||||
| 			flex-shrink: 0; | ||||
| 			display: flex; | ||||
| 			justify-content: center; | ||||
| 			align-items: center; | ||||
| 		} | ||||
| 
 | ||||
| 		div.list-item-name { | ||||
| 			width: 100%; | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	div.picker-list-item:hover { | ||||
| 		background-color: rgba($color: #000000, $alpha: .1); | ||||
| 	} | ||||
| 
 | ||||
| 	span.picker-list-nodata { | ||||
| 		display: inline-block; | ||||
| 		padding: 5px; | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| div.picker-list-root::-webkit-scrollbar { | ||||
| 	width : 0;  /*高宽分别对应横竖滚动条的尺寸*/ | ||||
| 	height: 0; | ||||
| } | ||||
| 
 | ||||
| div.picker-list-root::-webkit-scrollbar { | ||||
| 	width : 8px;  /*高宽分别对应横竖滚动条的尺寸*/ | ||||
| 	  height: 0; | ||||
| } | ||||
| 
 | ||||
| div.picker-list-root::-webkit-scrollbar-thumb { | ||||
| 	/*滚动条里面小方块*/ | ||||
| 	border-radius: 8px; | ||||
| 	background-color: rgba($color: #000000, $alpha: .1); | ||||
| } | ||||
| 
 | ||||
| div.picker-list-root::-webkit-scrollbar-track { | ||||
| 	/*滚动条里面轨道*/ | ||||
| 	border-radius: 8px; | ||||
| 	background-color: rgba($color: #000000, $alpha: 0); | ||||
| } | ||||
| @ -1,87 +0,0 @@ | ||||
| import { Localization } from "@Component/Localization/Localization"; | ||||
| import { Callout, DirectionalHint, Icon } from "@fluentui/react"; | ||||
| import { CtrlObject } from "@Model/CtrlObject"; | ||||
| import { Group } from "@Model/Group"; | ||||
| import { Label } from "@Model/Label"; | ||||
| import { Range } from "@Model/Range"; | ||||
| import { Component, ReactNode, RefObject } from "react"; | ||||
| import "./PickerList.scss"; | ||||
| 
 | ||||
| type IPickerListItem = CtrlObject | Label; | ||||
| 
 | ||||
| interface IPickerListProps { | ||||
| 	objectList?: IPickerListItem[]; | ||||
| 	target?: RefObject<any>; | ||||
| 	dismiss?: () => any; | ||||
| 	click?: (item: IPickerListItem) => any; | ||||
| } | ||||
| 
 | ||||
| class PickerList extends Component<IPickerListProps> { | ||||
| 
 | ||||
| 	private renderItem(item: IPickerListItem) { | ||||
| 
 | ||||
| 		let color: number[] = []; | ||||
| 		let icon: string = "tag"; | ||||
| 		let name: string = ""; | ||||
| 
 | ||||
| 		if (item instanceof Range) { | ||||
| 			icon = "CubeShape" | ||||
| 		} | ||||
| 		if (item instanceof Group) { | ||||
| 			icon = "WebAppBuilderFragment" | ||||
| 		} | ||||
| 		if (item instanceof CtrlObject) { | ||||
| 			color[0] = Math.round(item.color[0] * 255); | ||||
| 			color[1] = Math.round(item.color[1] * 255); | ||||
| 			color[2] = Math.round(item.color[2] * 255); | ||||
| 			name = item.displayName; | ||||
| 		} | ||||
| 		if (item instanceof Label) { | ||||
| 			icon = "tag"; | ||||
| 			color = item.color.concat([]); | ||||
| 			name = item.name; | ||||
| 		} | ||||
| 
 | ||||
| 		return <div | ||||
| 			className="picker-list-item" | ||||
| 			key={item.id} | ||||
| 			onClick={() => { | ||||
| 				if (this.props.click) { | ||||
| 					this.props.click(item) | ||||
| 				} | ||||
| 			}} | ||||
| 		> | ||||
| 			<div className="list-item-color" | ||||
| 				style={{ | ||||
| 					backgroundColor: `rgb(${color[0]},${color[1]},${color[2]})` | ||||
| 				}} | ||||
| 			></div> | ||||
| 			<div className="list-item-icon"> | ||||
| 				<Icon iconName={icon}/> | ||||
| 			</div> | ||||
| 			<div className="list-item-name"> | ||||
| 				{name} | ||||
| 			</div> | ||||
| 		</div>; | ||||
| 	} | ||||
| 
 | ||||
| 	public render(): ReactNode { | ||||
| 		return <Callout | ||||
| 			onDismiss={this.props.dismiss} | ||||
| 			target={this.props.target} | ||||
| 			directionalHint={DirectionalHint.topAutoEdge} | ||||
| 		> | ||||
| 			<div className="picker-list-root"> | ||||
| 				{this.props.objectList ? this.props.objectList.map((item) => { | ||||
| 					return this.renderItem(item); | ||||
| 				}) : null} | ||||
| 				{!this.props.objectList || (this.props.objectList && this.props.objectList.length <= 0) ? | ||||
| 					<Localization className="picker-list-nodata" i18nKey="Common.Attr.Key.Label.Picker.Nodata"/> | ||||
| 					: null | ||||
| 				} | ||||
| 			</div> | ||||
| 		</Callout> | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| export { PickerList } | ||||
| @ -30,7 +30,6 @@ interface IStatusEvent { | ||||
|     focusObjectChange: void; | ||||
|     focusLabelChange: void; | ||||
|     objectChange: void; | ||||
|     rangeLabelChange: void; | ||||
|     labelChange: void; | ||||
|     rangeAttrChange: void; | ||||
|     labelAttrChange: void; | ||||
| @ -122,22 +121,6 @@ class Status extends Emitter<IStatusEvent> { | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     public addRangeLabel(id: ObjectID, val: Label) { | ||||
|         const range = this.model.getObjectById(id); | ||||
|         if (range && range instanceof Range) { | ||||
|             range.addLabel(val); | ||||
|             this.emit("rangeLabelChange"); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     public deleteRangeLabel(id: ObjectID, val: Label) { | ||||
|         const range = this.model.getObjectById(id); | ||||
|         if (range && range instanceof Range) { | ||||
|             range.removeLabel(val); | ||||
|             this.emit("rangeLabelChange"); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 修改范围属性 | ||||
|      */ | ||||
| @ -154,7 +137,7 @@ class Status extends Emitter<IStatusEvent> { | ||||
|             findLabel[key] = val; | ||||
|             this.emit("labelAttrChange"); | ||||
|         } | ||||
|     } | ||||
|      } | ||||
| 
 | ||||
|     /** | ||||
|      * 鼠标工具状态 | ||||
|  | ||||
| @ -51,9 +51,7 @@ const EN_US = { | ||||
|     "Common.Attr.Key.Display": "Display", | ||||
|     "Common.Attr.Key.Update": "Update", | ||||
|     "Common.Attr.Key.Delete": "Delete", | ||||
|     "Common.Attr.Key.Label": "Label", | ||||
|     "Common.Attr.Key.Error.Multiple": "Multiple values", | ||||
|     "Common.Attr.Key.Label.Picker.Nodata": "No tags can be added", | ||||
|     "Panel.Info.Range.Details.Attr.Error.Not.Range": "Object is not a Range", | ||||
|     "Panel.Info.Range.Details.Attr.Error.Unspecified": "Unspecified range object", | ||||
|     "Panel.Info.Label.Details.Error.Unspecified": "Label object not specified", | ||||
|  | ||||
| @ -51,9 +51,7 @@ const ZH_CN = { | ||||
|     "Common.Attr.Key.Display": "显示", | ||||
|     "Common.Attr.Key.Update": "更新", | ||||
|     "Common.Attr.Key.Delete": "删除", | ||||
|     "Common.Attr.Key.Label": "标签", | ||||
|     "Common.Attr.Key.Error.Multiple": "多重数值", | ||||
|     "Common.Attr.Key.Label.Picker.Nodata": "没有可以被添加的标签", | ||||
|     "Panel.Info.Range.Details.Attr.Error.Not.Range": "对象不是一个范围", | ||||
|     "Panel.Info.Range.Details.Attr.Error.Unspecified": "未指定范围对象", | ||||
|     "Panel.Info.Label.Details.Error.Unspecified": "未指定标签对象", | ||||
|  | ||||
| @ -6,7 +6,3 @@ div.label-list-panel-root { | ||||
|     padding: 10px; | ||||
|     box-sizing: border-box; | ||||
| } | ||||
| 
 | ||||
| div.label-list-pabel-err-msg { | ||||
|     padding-bottom: 5px; | ||||
| } | ||||
| @ -3,7 +3,6 @@ import { Component } from "react"; | ||||
| import { useStatusWithEvent, IMixinStatusProps } from "@Context/Status"; | ||||
| import { useSetting, IMixinSettingProps } from "@Context/Setting"; | ||||
| import { Label } from "@Model/Label"; | ||||
| import { ErrorMessage } from "@Component/ErrorMessage/ErrorMessage"; | ||||
| import "./LabelList.scss"; | ||||
| 
 | ||||
| interface ILabelListProps { | ||||
| @ -30,12 +29,6 @@ class LabelList extends Component<ILabelListProps & IMixinStatusProps & IMixinSe | ||||
|                 this.labelInnerClick = false; | ||||
|             }} | ||||
|         > | ||||
|             {labels.length <=0 ?  | ||||
|                 <ErrorMessage | ||||
|                     className="label-list-pabel-err-msg" | ||||
|                     i18nKey="Panel.Info.Label.List.Error.Nodata" | ||||
|                 /> : null | ||||
|             } | ||||
|             <LabelListComponent | ||||
|                 labels={labels} | ||||
|                 focusLabel={this.props.status ? this.props.status.focusLabel : undefined} | ||||
|  | ||||
| @ -7,15 +7,13 @@ import { Range } from "@Model/Range"; | ||||
| import { ObjectID } from "@Model/Renderer"; | ||||
| import { ColorInput } from "@Component/ColorInput/ColorInput"; | ||||
| import { TogglesInput } from "@Component/TogglesInput/TogglesInput"; | ||||
| import { LabelPicker } from "@Component/LabelPicker/LabelPicker"; | ||||
| import "./RangeDetails.scss"; | ||||
| 
 | ||||
| @useStatusWithEvent("rangeAttrChange", "focusObjectChange", "rangeLabelChange") | ||||
| @useStatusWithEvent("rangeAttrChange", "focusObjectChange") | ||||
| class RangeDetails extends Component<IMixinStatusProps> { | ||||
|      | ||||
|     public readonly AttrI18nKey: AllI18nKeys[] = [ | ||||
|         "Common.Attr.Key.Display.Name", | ||||
|         "Common.Attr.Key.Label", | ||||
|         "Common.Attr.Key.Display", | ||||
|         "Common.Attr.Key.Update", | ||||
|         "Common.Attr.Key.Color", | ||||
| @ -61,20 +59,6 @@ class RangeDetails extends Component<IMixinStatusProps> { | ||||
|                 status.changeRangeAttrib(range.id, "displayName", val); | ||||
|             })} | ||||
|              | ||||
|             <LabelPicker keyI18n={this.AttrI18nKey[keyIndex ++]} | ||||
|                 labels={range.allLabels()} | ||||
|                 labelAdd={(label) => { | ||||
|                     if (this.props.status) { | ||||
|                         this.props.status.addRangeLabel(range.id, label); | ||||
|                     } | ||||
|                 }} | ||||
|                 labelDelete={(label) => { | ||||
|                     if (this.props.status) { | ||||
|                         this.props.status.deleteRangeLabel(range.id, label); | ||||
|                     } | ||||
|                 }} | ||||
|             /> | ||||
|              | ||||
|             <TogglesInput keyI18n={this.AttrI18nKey[keyIndex ++]} value={range.display} valueChange={(val) => { | ||||
|                 if (this.props.status) { | ||||
|                     this.props.status.changeRangeAttrib(range.id, "display", val); | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user