File tree Expand file tree Collapse file tree 3 files changed +80
-0
lines changed
Expand file tree Collapse file tree 3 files changed +80
-0
lines changed Original file line number Diff line number Diff line change 5555 :fnType =" fnType"
5656 :blockFolded =" blockFolded"
5757 />
58+ <OptInputs
59+ v-if =" fnType.optInput"
60+ :dataItem =" dataItem"
61+ :fnType =" fnType"
62+ :blockFolded =" blockFolded"
63+ />
5864 </div >
5965 </div >
6066</template >
@@ -66,6 +72,7 @@ import StrInputs from "./dataBlockInner/strInputs.vue";
6672import CoordInputs from " ./dataBlockInner/coordInputs.vue" ;
6773import SwitchInputs from " ./dataBlockInner/switchInputs.vue" ;
6874import CoordArrInputs from " ./dataBlockInner/coordArrInputs.vue" ;
75+ import OptInputs from " ./dataBlockInner/optInputs.vue" ;
6976
7077const emit = defineEmits ([" delete" ]);
7178const dataItem = defineModel <FunctionPlotDatum >();
Original file line number Diff line number Diff line change 1+ <template >
2+ <div
3+ v-if =" !blockFolded"
4+ v-for =" input in fnType.optInput ?? []"
5+ class =" input-box opt-input optional"
6+ >
7+ <span class =" coord-label optin-label" >{{ input.label }}</span >
8+ <input
9+ :type =" input.type"
10+ :value =" dataItem[input.value] ?? ''"
11+ @input =" handleCoordInput(dataItem!, input, $event)"
12+ :placeholder =" input.placeholder"
13+ />
14+ </div >
15+ </template >
16+
17+ <script setup lang="ts">
18+ import { FnType , OptInput } from " ../../consts" ;
19+ import { FunctionPlotDatum } from " function-plot" ;
20+
21+ const { dataItem, fnType } = defineProps <{
22+ dataItem: FunctionPlotDatum ;
23+ fnType: FnType ;
24+ blockFolded: boolean ;
25+ }>();
26+
27+ function handleCoordInput(
28+ dataItem : FunctionPlotDatum ,
29+ input : OptInput ,
30+ event : Event
31+ ) {
32+ const raw = (<HTMLInputElement >event .target ).value ;
33+ if (raw === " " ) {
34+ delete dataItem [input .value ];
35+ return ;
36+ }
37+ if (input .type === " number" ) dataItem [input .value ] = Number (raw );
38+ else dataItem [input .value ] = raw ;
39+ }
40+ </script >
41+
42+ <style >
43+ .input-box.opt-input {
44+ display : flex ;
45+ color : #bbb ;
46+ gap : 10px ;
47+ }
48+ .input-box.opt-input span {
49+ font-size : 18px ;
50+ margin : auto 5px ;
51+ flex-shrink : 0 ;
52+ }
53+ .input-box.opt-input input {
54+ min-width : 3em ;
55+ padding : 6px 0 ;
56+ font-size : 18px ;
57+ flex-shrink : 1 ;
58+ }
59+ </style >
Original file line number Diff line number Diff line change @@ -52,13 +52,20 @@ export type CoordArr = {
5252 placeholder : [ string , string ] ;
5353} ;
5454
55+ export type OptInput = {
56+ label : string ;
57+ placeholder ?: string ;
58+ vif ?: keyof FunctionPlotDatum ;
59+ } & ( { value : "color" ; type : "text" } | { value : "nSamples" ; type : "number" } ) ;
60+
5561export type FnType = {
5662 value : FunctionPlotDatum [ "fnType" ] | "text" ;
5763 label : string ;
5864 inputs : InputType [ ] ;
5965 coord ?: CoordType [ ] ;
6066 coordArr ?: CoordArr ;
6167 switches ?: SwitchType [ ] ;
68+ optInput ?: OptInput [ ] ;
6269 notAllowedInInterval ?: boolean ;
6370} ;
6471
@@ -96,6 +103,13 @@ export const fnTypeArr = [
96103 folded : true ,
97104 } ,
98105 ] ,
106+ optInput : [
107+ {
108+ value : "color" ,
109+ type : "text" ,
110+ label : "颜色" ,
111+ } ,
112+ ] ,
99113 } ,
100114 {
101115 value : "implicit" ,
You can’t perform that action at this time.
0 commit comments