Skip to content

Commit 35e4267

Browse files
authored
Merge pull request #46 from OneLiteFeatherNET/feat/new-fields
feat: more field types
2 parents 06b2c32 + 3cba985 commit 35e4267

37 files changed

+1043
-92
lines changed

bindings/CheckboxOptions.ts

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2+
import type { CheckboxStyle } from "./CheckboxStyle";
3+
4+
export interface CheckboxOptions { defaultState: boolean, style: CheckboxStyle, }

bindings/CheckboxResponse.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2+
3+
export interface CheckboxResponse { checked: boolean, }

bindings/CheckboxStyle.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2+
3+
export type CheckboxStyle = "switch" | "checkbox";

bindings/CreateFeedbackPromptFieldRequest.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
import type { FeedbackPromptInputOptions } from "./FeedbackPromptInputOptions";
33
import type { FeedbackPromptInputType } from "./FeedbackPromptInputType";
44

5-
export interface CreateFeedbackPromptFieldRequest { title: string, type: FeedbackPromptInputType, options: FeedbackPromptInputOptions, }
5+
export interface CreateFeedbackPromptFieldRequest { title: string, description: string | null, type: FeedbackPromptInputType, options: FeedbackPromptInputOptions, }
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
22

3-
export interface CreateFeedbackPromptRequest { title: string, active: boolean, }
3+
export interface CreateFeedbackPromptRequest { title: string, active: boolean, description: string, }

bindings/FeedbackPrompt.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
22

3-
export interface FeedbackPrompt { id: string, title: string, target: string, active: boolean, updated_at: Date, created_at: Date, }
3+
export interface FeedbackPrompt { id: string, title: string, description: string, target: string, active: boolean, updated_at: Date, created_at: Date, }

bindings/FeedbackPromptField.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
import type { FeedbackPromptInputOptions } from "./FeedbackPromptInputOptions";
33
import type { FeedbackPromptInputType } from "./FeedbackPromptInputType";
44

5-
export interface FeedbackPromptField { id: string, title: string, prompt: string, type: FeedbackPromptInputType, options: FeedbackPromptInputOptions, updated_at: Date, created_at: Date, }
5+
export interface FeedbackPromptField { id: string, title: string, description: string | null, prompt: string, type: FeedbackPromptInputType, options: FeedbackPromptInputOptions, updated_at: Date, created_at: Date, }

bindings/FeedbackPromptFieldData.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2+
import type { CheckboxResponse } from "./CheckboxResponse";
3+
import type { NumberResponse } from "./NumberResponse";
4+
import type { RangeResponse } from "./RangeResponse";
25
import type { RatingResponse } from "./RatingResponse";
6+
import type { SelectionResponse } from "./SelectionResponse";
37
import type { TextResponse } from "./TextResponse";
48

5-
export type FeedbackPromptFieldData = TextResponse | RatingResponse;
9+
export type FeedbackPromptFieldData = { "type": "text" } & TextResponse | { "type": "rating" } & RatingResponse | { "type": "checkbox" } & CheckboxResponse | { "type": "selection" } & SelectionResponse | { "type": "range" } & RangeResponse | { "type": "number" } & NumberResponse;
+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2+
import type { CheckboxOptions } from "./CheckboxOptions";
3+
import type { NumberOptions } from "./NumberOptions";
4+
import type { RangeOptions } from "./RangeOptions";
25
import type { RatingOptions } from "./RatingOptions";
6+
import type { SelectionOptions } from "./SelectionOptions";
37
import type { TextOptions } from "./TextOptions";
48

5-
export type FeedbackPromptInputOptions = TextOptions | RatingOptions;
9+
export type FeedbackPromptInputOptions = { "type": "text" } & TextOptions | { "type": "rating" } & RatingOptions | { "type": "checkbox" } & CheckboxOptions | { "type": "selection" } & SelectionOptions | { "type": "range" } & RangeOptions | { "type": "number" } & NumberOptions;

bindings/FeedbackPromptInputType.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
22

3-
export type FeedbackPromptInputType = "text" | "rating";
3+
export type FeedbackPromptInputType = "text" | "rating" | "checkbox" | "selection" | "range" | "number";

bindings/NumberOptions.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2+
3+
export interface NumberOptions { min: number, max: number, placeholder: string, }

bindings/NumberResponse.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2+
3+
export interface NumberResponse { number: number, }

bindings/RangeOptions.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2+
3+
export interface RangeOptions { min: number, max: number, }

bindings/RangeResponse.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2+
3+
export interface RangeResponse { start: number, end: number, }

bindings/RatingOptions.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
22

3-
export interface RatingOptions { description: string, max: number, }
3+
export interface RatingOptions { max: number, }

bindings/RatingResponse.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
22

3-
export interface RatingResponse { data: number, }
3+
export interface RatingResponse { rating: number, }

bindings/SelectionOptions.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2+
3+
export interface SelectionOptions { values: Array<string>, multiple: boolean, combobox: boolean, }

bindings/SelectionResponse.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2+
3+
export interface SelectionResponse { values: Array<string>, }

bindings/TextOptions.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
22

3-
export interface TextOptions { description: string, placeholder: string, }
3+
export interface TextOptions { placeholder: string, lines: number, }

bindings/TextResponse.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
22

3-
export interface TextResponse { data: string, }
3+
export interface TextResponse { text: string, }

bindings/index.ts

+9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
export * from './CheckboxOptions';
2+
export * from './CheckboxResponse';
3+
export * from './CheckboxStyle';
14
export * from './CreateFeedbackPromptFieldRequest';
25
export * from './CreateFeedbackPromptRequest';
36
export * from './CreateFeedbackTargetRequest';
@@ -10,12 +13,18 @@ export * from './FeedbackPromptInputType';
1013
export * from './FeedbackPromptResponse';
1114
export * from './FeedbackTarget';
1215
export * from './GetFeedbackPromptResponsesResponseWrapper';
16+
export * from './NumberOptions';
17+
export * from './NumberResponse';
1318
export * from './Page';
1419
export * from './PutFeedbackPromptFieldRequest';
1520
export * from './PutFeedbackPromptRequest';
1621
export * from './PutFeedbackTargetRequest';
22+
export * from './RangeOptions';
23+
export * from './RangeResponse';
1724
export * from './RatingOptions';
1825
export * from './RatingResponse';
26+
export * from './SelectionOptions';
27+
export * from './SelectionResponse';
1928
export * from './SubmitFeedbackPromptResponseRequest';
2029
export * from './TextOptions';
2130
export * from './TextResponse';

lib/core/src/locales/en.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ export default {
66
submit: "submit",
77
finished: "Thank you for participating in our survery!",
88
close: "close",
9-
error: "An error occurred while processing your request"
9+
error: "An error occurred while processing your request",
10+
field: {
11+
number: {
12+
error: "Values must lie within {{ min }} and {{ max }}"
13+
}
14+
}
1015
},
1116
};

lib/vue/docs/.vitepress/theme/index.ts

+98-3
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,23 @@ fetchMock
3535
"prompt": "prompt",
3636
"title": "Text1",
3737
"type": "text",
38+
"description": "description",
3839
"options": {
39-
"description": "description",
4040
"placeholder": "placeholder",
41+
"lines": 1
42+
},
43+
"updated_at": new Date(),
44+
"created_at": new Date(),
45+
},
46+
{
47+
"id": "textarea",
48+
"prompt": "prompt",
49+
"title": "Textarea",
50+
"type": "text",
51+
"description": "description",
52+
"options": {
53+
"placeholder": "placeholder",
54+
"lines": 3,
4155
},
4256
"updated_at": new Date(),
4357
"created_at": new Date(),
@@ -47,8 +61,8 @@ fetchMock
4761
"prompt": "prompt",
4862
"title": "Rating1",
4963
"type": "rating",
64+
"description": "description",
5065
"options": {
51-
"description": "description",
5266
"max": 5,
5367
},
5468
"updated_at": new Date(),
@@ -59,8 +73,89 @@ fetchMock
5973
"prompt": "prompt",
6074
"title": "Text2",
6175
"type": "text",
76+
"description": "description",
77+
"options": {
78+
"placeholder": "placeholder",
79+
"lines": 1,
80+
},
81+
"updated_at": new Date(),
82+
"created_at": new Date(),
83+
},
84+
{
85+
"id": "checkbox",
86+
"prompt": "prompt",
87+
"type": "checkbox",
88+
"title": "Checkbox",
89+
"description": "description",
90+
"options": {
91+
"defaultState": true,
92+
"style": "checkbox",
93+
},
94+
"updated_at": new Date(),
95+
"created_at": new Date(),
96+
},
97+
{
98+
"id": "switch",
99+
"prompt": "prompt",
100+
"type": "checkbox",
101+
"title": "Switch",
102+
"description": "description",
103+
"options": {
104+
"defaultState": false,
105+
"style": "switch",
106+
},
107+
"updated_at": new Date(),
108+
"created_at": new Date(),
109+
},
110+
111+
{
112+
"id": "selection",
113+
"prompt": "prompt",
114+
"title": "Selection",
115+
"type": "selection",
116+
"description": "description",
117+
"options": {
118+
"values": ["foo", "bar"],
119+
"combobox": false,
120+
},
121+
"updated_at": new Date(),
122+
"created_at": new Date(),
123+
},
124+
{
125+
"id": "combobox",
126+
"title": "Combobox",
127+
"prompt": "prompt",
128+
"type": "selection",
129+
"description": "description",
130+
"options": {
131+
"values": ["foo", "bar"],
132+
"combobox": true,
133+
},
134+
"updated_at": new Date(),
135+
"created_at": new Date(),
136+
},
137+
138+
{
139+
"id": "range",
140+
"title": "Range",
141+
"prompt": "prompt",
142+
"type": "range",
143+
"options": {
144+
"min": 1,
145+
"max": 10,
146+
},
147+
"updated_at": new Date(),
148+
"created_at": new Date(),
149+
},
150+
{
151+
"id": "number",
152+
"prompt": "prompt",
153+
"title": "Number",
154+
"type": "number",
155+
"description": "description",
62156
"options": {
63-
"description": "description",
157+
"min": 1,
158+
"max": 10,
64159
"placeholder": "placeholder",
65160
},
66161
"updated_at": new Date(),

lib/vue/src/components/Checkbox.vue

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<template>
2+
<div class="feedback-fusion__field__checkbox">
3+
<input v-if="props.style === 'checkbox'" v-model="data" type="checkbox">
4+
5+
<label v-else>
6+
<input type="checkbox">
7+
8+
<span />
9+
</label>
10+
</div>
11+
</template>
12+
13+
<script setup lang="ts">
14+
import { FeedbackFusionState, CheckboxOptions } from '@onelitefeathernet/feedback-fusion-core';
15+
import { computed, inject, ref } from 'vue';
16+
17+
interface CheckboxFieldOptions extends CheckboxOptions {
18+
theme?: string;
19+
value: any;
20+
}
21+
22+
const { config } = inject<FeedbackFusionState>('feedbackFusionState')!;
23+
const theme = computed(() => config.themes[props.theme || config.defaultTheme])
24+
const props = defineProps<CheckboxFieldOptions>();
25+
const emit = defineEmits(["update"]);
26+
27+
const data = computed({
28+
get() {
29+
return props.value || props.defaulState;
30+
},
31+
set(value: any) {
32+
emit("update", value);
33+
}
34+
})
35+
</script>
36+
37+
<style lang="scss" scoped>
38+
.feedback-fusion__field__checkbox {
39+
label {
40+
input {
41+
height: 0;
42+
width: 0;
43+
display: none;
44+
visibility: hidden;
45+
}
46+
47+
span {
48+
position: relative;
49+
width: 60px;
50+
height: 35px;
51+
display: inline-block;
52+
border-radius: 16px;
53+
background: v-bind("theme.inactive");
54+
55+
&:after {
56+
position: absolute;
57+
top: 5px;
58+
bottom: 5px;
59+
left: 5px;
60+
width: 25px;
61+
content: "";
62+
border-radius: 50%;
63+
background: white;
64+
transition: 0.15s ease-out;
65+
}
66+
}
67+
68+
input:checked + span {
69+
background: v-bind("theme.primary");
70+
71+
&:after {
72+
left: 30px;
73+
}
74+
}
75+
}
76+
}
77+
</style>

0 commit comments

Comments
 (0)