@dative-gpi/foundation-shared-components 0.0.135 → 0.0.136

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,16 +1,20 @@
1
1
  <template>
2
2
  <FSTextField
3
- :label="$props.label"
4
- :description="$props.description"
5
- :color="$props.color"
6
- :hideHeader="$props.hideHeader"
7
- :required="$props.required"
8
3
  :editable="$props.editable"
9
4
  :placeholder="placeholder"
10
5
  @keydown.enter="onSearch"
11
6
  v-model="innerValue"
12
7
  v-bind="$attrs"
13
8
  >
9
+ <template
10
+ v-for="(_, name) in $slots"
11
+ v-slot:[name]="slotData"
12
+ >
13
+ <slot
14
+ :name="name"
15
+ v-bind="slotData"
16
+ />
17
+ </template>
14
18
  <template
15
19
  v-if="$props.prependInnerIcon"
16
20
  #prepend-inner
@@ -45,15 +49,6 @@
45
49
  />
46
50
  </slot>
47
51
  </template>
48
- <template
49
- v-for="(_, name) in $slots"
50
- v-slot:[name]="slotData"
51
- >
52
- <slot
53
- :name="name"
54
- v-bind="slotData"
55
- />
56
- </template>
57
52
  </FSTextField>
58
53
  </template>
59
54
 
@@ -73,16 +68,6 @@ export default defineComponent({
73
68
  FSButton
74
69
  },
75
70
  props: {
76
- label: {
77
- type: String as PropType<string | null>,
78
- required: false,
79
- default: null
80
- },
81
- description: {
82
- type: String as PropType<string | null>,
83
- required: false,
84
- default: null
85
- },
86
71
  placeholder: {
87
72
  type: String as PropType<string | null>,
88
73
  required: false,
@@ -123,26 +108,11 @@ export default defineComponent({
123
108
  required: false,
124
109
  default: null
125
110
  },
126
- color: {
127
- type: String as PropType<ColorBase>,
128
- required: false,
129
- default: ColorEnum.Dark
130
- },
131
111
  buttonColor: {
132
112
  type: String as PropType<ColorBase>,
133
113
  required: false,
134
114
  default: ColorEnum.Primary
135
115
  },
136
- hideHeader: {
137
- type: Boolean,
138
- required: false,
139
- default: true
140
- },
141
- required: {
142
- type: Boolean,
143
- required: false,
144
- default: false
145
- },
146
116
  editable: {
147
117
  type: Boolean,
148
118
  required: false,
@@ -7,6 +7,24 @@
7
7
  :editable="$props.editable"
8
8
  :messages="messages"
9
9
  >
10
+ <template
11
+ v-if="$slots.label"
12
+ v-slot:label="slotData"
13
+ >
14
+ <slot
15
+ name="label"
16
+ v-bind="slotData"
17
+ />
18
+ </template>
19
+ <template
20
+ v-if="$slots.description"
21
+ v-slot:label="slotData"
22
+ >
23
+ <slot
24
+ name="description"
25
+ v-bind="slotData"
26
+ />
27
+ </template>
10
28
  <v-text-field
11
29
  class="fs-text-field"
12
30
  variant="outlined"
@@ -23,7 +41,7 @@
23
41
  v-bind="$attrs"
24
42
  >
25
43
  <template
26
- v-for="(_, name) in $slots"
44
+ v-for="(_, name) in slots"
27
45
  v-slot:[name]="slotData"
28
46
  >
29
47
  <slot
@@ -49,7 +67,7 @@
49
67
  <script lang="ts">
50
68
  import { computed, defineComponent, PropType } from "vue";
51
69
 
52
- import { useColors, useRules } from "@dative-gpi/foundation-shared-components/composables";
70
+ import { useColors, useRules, useSlots } from "@dative-gpi/foundation-shared-components/composables";
53
71
  import { ColorEnum } from "@dative-gpi/foundation-shared-components/models";
54
72
 
55
73
  import FSBaseField from "./FSBaseField.vue";
@@ -117,6 +135,10 @@ export default defineComponent({
117
135
  setup(props) {
118
136
  const { validateOn, getMessages } = useRules();
119
137
  const { getColors } = useColors();
138
+ const { slots } = useSlots();
139
+
140
+ delete slots.label;
141
+ delete slots.description;
120
142
 
121
143
  const errors = getColors(ColorEnum.Error);
122
144
  const lights = getColors(ColorEnum.Light);
@@ -146,6 +168,7 @@ export default defineComponent({
146
168
  validateOn,
147
169
  ColorEnum,
148
170
  messages,
171
+ slots,
149
172
  style
150
173
  };
151
174
  }
@@ -0,0 +1,197 @@
1
+ <template>
2
+ <FSTextField
3
+ :editable="$props.editable"
4
+ :modelValue="$props.modelValue"
5
+ @update:modelValue="$emit('update:modelValue', $event)"
6
+ v-bind="$attrs"
7
+ >
8
+ <template
9
+ v-for="(_, name) in $slots"
10
+ v-slot:[name]="slotData"
11
+ >
12
+ <slot
13
+ :name="name"
14
+ v-bind="slotData"
15
+ />
16
+ </template>
17
+ <template
18
+ #append
19
+ >
20
+ <slot
21
+ name="append"
22
+ >
23
+ <FSButton
24
+ :prependIcon="$props.buttonPrependIcon"
25
+ :label="$props.buttonLabel"
26
+ :appendIcon="$props.buttonAppendIcon"
27
+ :variant="$props.buttonVariant"
28
+ :color="$props.buttonColor"
29
+ :load="fetchingLanguages"
30
+ @click="dialog = true"
31
+ />
32
+ </slot>
33
+ </template>
34
+ </FSTextField>
35
+ <FSDialogSubmit
36
+ :title="$tr('ui.translate-field.title', 'Handle translations')"
37
+ :submitButtonColor="$props.buttonColor"
38
+ @click:submitButton="onSubmit"
39
+ v-model="dialog"
40
+ >
41
+ <template
42
+ #body
43
+ >
44
+ <FSCol
45
+ gap="32px"
46
+ >
47
+ <FSTextField
48
+ :label="$tr('ui.translate-field.default-value', 'Default value')"
49
+ :editable="false"
50
+ :modelValue="$props.modelValue"
51
+ />
52
+ <FSCol
53
+ gap="16px"
54
+ >
55
+ <FSTextField
56
+ v-for="(language, index) in languages"
57
+ :editable="$props.editable"
58
+ :key="index"
59
+ v-model="innerTranslations[language.code]"
60
+ >
61
+ <template
62
+ #label
63
+ >
64
+ <FSRow
65
+ :wrap="false"
66
+ >
67
+ <FSSpan
68
+ class="fs-translate-field-label"
69
+ font="text-overline"
70
+ :style="style"
71
+ >
72
+ {{ $tr("ui.translate-field.translate-in", "Translate in {0}", language.label) }}
73
+ </FSSpan>
74
+ <FSIcon>
75
+ {{ language.icon }}
76
+ </FSIcon>
77
+ </FSRow>
78
+ </template>
79
+ </FSTextField>
80
+ </FSCol>
81
+ </FSCol>
82
+ </template>
83
+ </FSDialogSubmit>
84
+ </template>
85
+
86
+ <script lang="ts">
87
+ import { computed, defineComponent, onMounted, PropType, ref } from "vue";
88
+
89
+ import { ColorBase, ColorEnum } from "@dative-gpi/foundation-shared-components/models";
90
+ import { useLanguages } from "@dative-gpi/foundation-shared-services/composables";
91
+
92
+ import { useColors } from "../../composables";
93
+
94
+ import FSDialogSubmit from "../FSDialogSubmit.vue";
95
+ import FSTextField from "./FSTextField.vue";
96
+ import FSButton from "../FSButton.vue";
97
+ import FSIcon from "../FSIcon.vue";
98
+ import FSSpan from "../FSSpan.vue";
99
+ import FSRow from "../FSRow.vue";
100
+
101
+ export default defineComponent({
102
+ name: "FSTranslateField",
103
+ components: {
104
+ FSDialogSubmit,
105
+ FSTextField,
106
+ FSButton,
107
+ FSIcon,
108
+ FSSpan,
109
+ FSRow
110
+ },
111
+ props: {
112
+ buttonPrependIcon: {
113
+ type: String as PropType<string | null>,
114
+ required: false,
115
+ default: "mdi-translate"
116
+ },
117
+ buttonLabel: {
118
+ type: String as PropType<string | null>,
119
+ required: false,
120
+ default: null
121
+ },
122
+ buttonAppendIcon: {
123
+ type: String as PropType<string | null>,
124
+ required: false,
125
+ default: null
126
+ },
127
+ buttonVariant: {
128
+ type: String as PropType<"standard" | "full" | "icon">,
129
+ required: false,
130
+ default: "standard"
131
+ },
132
+ modelValue: {
133
+ type: String as PropType<string | null>,
134
+ required: false,
135
+ default: null
136
+ },
137
+ translations: {
138
+ type: Object as PropType<{ [key: string]: string }>,
139
+ required: false,
140
+ default: () => ({})
141
+ },
142
+ buttonColor: {
143
+ type: String as PropType<ColorBase>,
144
+ required: false,
145
+ default: ColorEnum.Primary
146
+ },
147
+ editable: {
148
+ type: Boolean,
149
+ required: false,
150
+ default: true
151
+ }
152
+ },
153
+ emits: ["update:modelValue", "update:translations"],
154
+ setup(props, { emit }) {
155
+ const { getMany: getManyLanguages, fetching: fetchingLanguages, entities: languages } = useLanguages();
156
+ const { getColors } = useColors();
157
+
158
+ const innerTranslations = ref(props.translations ?? {});
159
+ const dialog = ref(false);
160
+
161
+ const lights = getColors(ColorEnum.Light);
162
+ const darks = getColors(ColorEnum.Dark);
163
+
164
+ const style = computed((): { [key: string] : string | null | undefined } => {
165
+ if (!props.editable) {
166
+ return {
167
+ "--fs-translate-field-color": lights.dark
168
+ };
169
+ }
170
+ return {
171
+ "--fs-translate-field-color": darks.base
172
+ };
173
+ });
174
+
175
+ const onSubmit = (): void => {
176
+ dialog.value = false;
177
+ if (props.editable) {
178
+ emit("update:translations", innerTranslations.value);
179
+ }
180
+ };
181
+
182
+ onMounted(() => {
183
+ getManyLanguages();
184
+ });
185
+
186
+ return {
187
+ fetchingLanguages,
188
+ innerTranslations,
189
+ ColorEnum,
190
+ languages,
191
+ dialog,
192
+ style,
193
+ onSubmit
194
+ };
195
+ }
196
+ });
197
+ </script>
@@ -26,18 +26,21 @@
26
26
  v-if="!isExtraSmall"
27
27
  name="toolbar"
28
28
  />
29
- <v-spacer />
30
- <FSRow
29
+ <template
31
30
  v-if="!$props.disableTable && !$props.disableIterator"
32
- align="center-right"
33
31
  >
34
- <FSOptionGroup
35
- :values="modeOptions"
36
- :singleColor="true"
37
- :required="true"
38
- v-model="innerMode"
39
- />
40
- </FSRow>
32
+ <v-spacer />
33
+ <FSRow
34
+ align="center-right"
35
+ >
36
+ <FSOptionGroup
37
+ :values="modeOptions"
38
+ :singleColor="true"
39
+ :required="true"
40
+ v-model="innerMode"
41
+ />
42
+ </FSRow>
43
+ </template>
41
44
  </FSRow>
42
45
  <FSRow
43
46
  v-if="isExtraSmall && hasToolbar"
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dative-gpi/foundation-shared-components",
3
3
  "sideEffects": false,
4
- "version": "0.0.135",
4
+ "version": "0.0.136",
5
5
  "description": "",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -10,8 +10,8 @@
10
10
  "author": "",
11
11
  "license": "ISC",
12
12
  "dependencies": {
13
- "@dative-gpi/foundation-shared-domain": "0.0.135",
14
- "@dative-gpi/foundation-shared-services": "0.0.135",
13
+ "@dative-gpi/foundation-shared-domain": "0.0.136",
14
+ "@dative-gpi/foundation-shared-services": "0.0.136",
15
15
  "@fontsource/montserrat": "^5.0.16",
16
16
  "@lexical/clipboard": "^0.12.5",
17
17
  "@lexical/history": "^0.12.5",
@@ -32,5 +32,5 @@
32
32
  "sass": "^1.69.5",
33
33
  "sass-loader": "^13.3.2"
34
34
  },
35
- "gitHead": "96e5e31c3bf2de7421798f572b09102bb32d1e18"
35
+ "gitHead": "07ed80382fe8c568e70e165a75f4e6feff0829fa"
36
36
  }
@@ -0,0 +1,3 @@
1
+ .fs-translate-field-label {
2
+ color: var(--fs-translate-field-color);
3
+ }
@@ -57,5 +57,6 @@
57
57
  @import "fs_time_field.scss";
58
58
  @import "fs_timeslot_field.scss";
59
59
  @import "fs_tooltip.scss";
60
+ @import "fs_translate_field.scss";
60
61
  @import "fs_window.scss";
61
62
  @import "fs_wrap_group.scss";
@@ -49,14 +49,22 @@
49
49
  }
50
50
  }
51
51
 
52
- & .v-input__prepend {
53
- margin-inline-end: 0 !important;
52
+ &:has(.v-input__control):has(.v-input__append) > .v-input__append {
53
+ margin-inline-start: 8px !important;
54
54
  }
55
55
 
56
- & .v-input__append {
56
+ &:not(:has(.v-input__control)):has(.v-input__append) > .v-input__append {
57
57
  margin-inline-start: 0 !important;
58
58
  }
59
59
 
60
+ &:has(.v-input__control):has(.v-input__prepend) > .v-input__prepend {
61
+ margin-inline-end: 8px !important;
62
+ }
63
+
64
+ &:not(:has(.v-input__control)):has(.v-input__prepend) > .v-input__prepend {
65
+ margin-inline-end: 0 !important;
66
+ }
67
+
60
68
  & > .v-input__control > .v-field {
61
69
  border-radius: 4px !important;
62
70