@dative-gpi/foundation-shared-components 0.0.19 → 0.0.21

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,6 +1,7 @@
1
1
  <template>
2
2
  <FSWrapGroup
3
3
  v-if="['wrap'].includes($props.variant)"
4
+ ref="toggleSetRef"
4
5
  :padding="$props.padding"
5
6
  :gap="$props.gap"
6
7
  >
@@ -40,6 +41,7 @@
40
41
  </FSWrapGroup>
41
42
  <FSSlideGroup
42
43
  v-else
44
+ ref="toggleSetRef"
43
45
  :padding="$props.padding"
44
46
  :gap="$props.gap"
45
47
  >
@@ -80,7 +82,7 @@
80
82
  </template>
81
83
 
82
84
  <script lang="ts">
83
- import { defineComponent, PropType } from "vue";
85
+ import { defineComponent, PropType, ref } from "vue";
84
86
 
85
87
  import { ColorBase, ColorEnum } from "@dative-gpi/foundation-shared-components/models";
86
88
  import { useSlots } from "@dative-gpi/foundation-shared-components/composables";
@@ -175,6 +177,8 @@ export default defineComponent({
175
177
 
176
178
  const firstChild = getFirstChild("item");
177
179
 
180
+ const toggleSetRef = ref(null);
181
+
178
182
  const getFromFirstChild = (prop: string, value: FSToggle): any => {
179
183
  switch (prop) {
180
184
  case "prependIcon":
@@ -269,12 +273,27 @@ export default defineComponent({
269
273
  }
270
274
  };
271
275
 
276
+ const goToStart = () => {
277
+ if (toggleSetRef.value) {
278
+ toggleSetRef.value.goToStart();
279
+ }
280
+ };
281
+
282
+ const goToEnd = () => {
283
+ if (toggleSetRef.value) {
284
+ toggleSetRef.value.goToEnd();
285
+ }
286
+ };
287
+
272
288
  return {
289
+ toggleSetRef,
273
290
  firstChild,
274
291
  getFromFirstChild,
275
292
  getVariant,
293
+ goToStart,
276
294
  getColor,
277
295
  getClass,
296
+ goToEnd,
278
297
  toggle
279
298
  };
280
299
  }
@@ -1,6 +1,7 @@
1
1
  <template>
2
2
  <v-slide-group
3
3
  class="fs-wrap-group"
4
+ ref="wrapGroupRef"
4
5
  :style="style"
5
6
  v-bind="$attrs"
6
7
  >
@@ -14,7 +15,7 @@
14
15
  </template>
15
16
 
16
17
  <script lang="ts">
17
- import { computed, defineComponent } from "vue";
18
+ import { computed, defineComponent, ref } from "vue";
18
19
 
19
20
  import { useColors, useSlots } from "@dative-gpi/foundation-shared-components/composables";
20
21
  import { ColorEnum } from "@dative-gpi/foundation-shared-components/models";
@@ -40,6 +41,8 @@ export default defineComponent({
40
41
 
41
42
  const darks = getColors(ColorEnum.Dark);
42
43
 
44
+ const wrapGroupRef = ref(null);
45
+
43
46
  const style = computed((): { [code: string]: string } & Partial<CSSStyleDeclaration> => ({
44
47
  "--fs-group-padding" : sizeToVar(props.padding),
45
48
  "--fs-group-gap" : sizeToVar(props.gap),
@@ -47,9 +50,26 @@ export default defineComponent({
47
50
  "--fs-group-hover-color": darks.dark
48
51
  }));
49
52
 
53
+ const goToStart = () => {
54
+ if (wrapGroupRef.value) {
55
+ wrapGroupRef.value.scrollOffset = 0;
56
+ }
57
+ };
58
+
59
+ const goToEnd = () => {
60
+ if (wrapGroupRef.value) {
61
+ const contentSize = wrapGroupRef.value.$el.children[1].children[0].clientWidth;
62
+ const containerSize = wrapGroupRef.value.$el.clientWidth;
63
+ wrapGroupRef.value.scrollOffset = (contentSize - containerSize);
64
+ }
65
+ };
66
+
50
67
  return {
68
+ wrapGroupRef,
51
69
  style,
52
- getChildren
70
+ getChildren,
71
+ goToStart,
72
+ goToEnd
53
73
  };
54
74
  }
55
75
  });
@@ -0,0 +1,84 @@
1
+ <template>
2
+ <div>
3
+ <FSButton
4
+ prependIcon="mdi-upload-outline"
5
+ :label="$tr('ui.button.import-file', 'Import file')"
6
+ :color="ColorEnum.Light"
7
+ @click="onClick"
8
+ v-bind="$attrs"
9
+ />
10
+ <form>
11
+ <input
12
+ v-show="false"
13
+ type="file"
14
+ ref="input"
15
+ :accept="$props.accept"
16
+ @input="onInput"
17
+ />
18
+ </form>
19
+ </div>
20
+ </template>
21
+
22
+ <script lang="ts">
23
+ import { defineComponent, ref } from "vue";
24
+ import { ColorEnum } from "@dative-gpi/foundation-shared-components/models";
25
+
26
+ import FSButton from "../FSButton.vue";
27
+
28
+ export default defineComponent({
29
+ name: "FSButtonFile",
30
+ components: {
31
+ FSButton
32
+ },
33
+ props: {
34
+ accept: {
35
+ type: String,
36
+ required: false,
37
+ default: "",
38
+ },
39
+ readFile: {
40
+ type: Boolean,
41
+ required: false,
42
+ default: true,
43
+ }
44
+ },
45
+ emits: ["update:modelValue"],
46
+ setup(props, { emit }) {
47
+ const input = ref(null);
48
+
49
+ const clear = () => {
50
+ input.value!.form && input.value!.form.reset();
51
+ };
52
+
53
+ const onClick = () => {
54
+ input.value!.click();
55
+ }
56
+
57
+ const onInput = () => {
58
+ const file = input.value!.files && input.value!.files[0];
59
+ if (!file) {
60
+ return;
61
+ }
62
+ if (!props.readFile) {
63
+ emit("update:modelValue", file);
64
+ clear();
65
+ }
66
+ else {
67
+ const reader = new FileReader();
68
+ reader.addEventListener("load", (fileEv) => {
69
+ emit("update:modelValue", fileEv.target && fileEv.target.result);
70
+ clear();
71
+ });
72
+ reader.readAsDataURL(file);
73
+ }
74
+ };
75
+
76
+ return {
77
+ ColorEnum,
78
+ input,
79
+ onClick,
80
+ onInput
81
+ };
82
+ }
83
+ });
84
+ </script>
@@ -0,0 +1,84 @@
1
+ <template>
2
+ <div>
3
+ <FSButton
4
+ icon="mdi-upload-outline"
5
+ variant="icon"
6
+ :color="ColorEnum.Light"
7
+ @click="onClick"
8
+ v-bind="$attrs"
9
+ />
10
+ <form>
11
+ <input
12
+ v-show="false"
13
+ type="file"
14
+ ref="input"
15
+ :accept="$props.accept"
16
+ @input="onInput"
17
+ />
18
+ </form>
19
+ </div>
20
+ </template>
21
+
22
+ <script lang="ts">
23
+ import { defineComponent, ref } from "vue";
24
+ import { ColorEnum } from "@dative-gpi/foundation-shared-components/models";
25
+
26
+ import FSButton from "../FSButton.vue";
27
+
28
+ export default defineComponent({
29
+ name: "FSButtonFileIcon",
30
+ components: {
31
+ FSButton
32
+ },
33
+ props: {
34
+ accept: {
35
+ type: String,
36
+ required: false,
37
+ default: "",
38
+ },
39
+ readFile: {
40
+ type: Boolean,
41
+ required: false,
42
+ default: true,
43
+ }
44
+ },
45
+ emits: ["update:modelValue"],
46
+ setup(props, { emit }) {
47
+ const input = ref(null);
48
+
49
+ const clear = () => {
50
+ input.value!.form && input.value!.form.reset();
51
+ };
52
+
53
+ const onClick = () => {
54
+ input.value!.click();
55
+ }
56
+
57
+ const onInput = () => {
58
+ const file = input.value!.files && input.value!.files[0];
59
+ if (!file) {
60
+ return;
61
+ }
62
+ if (!props.readFile) {
63
+ emit("update:modelValue", file);
64
+ clear();
65
+ }
66
+ else {
67
+ const reader = new FileReader();
68
+ reader.addEventListener("load", (fileEv) => {
69
+ emit("update:modelValue", fileEv.target && fileEv.target.result);
70
+ clear();
71
+ });
72
+ reader.readAsDataURL(file);
73
+ }
74
+ };
75
+
76
+ return {
77
+ ColorEnum,
78
+ input,
79
+ onClick,
80
+ onInput
81
+ };
82
+ }
83
+ });
84
+ </script>
@@ -0,0 +1,83 @@
1
+ <template>
2
+ <div>
3
+ <FSButton
4
+ :label="$tr('ui.button.import-file', 'Import file')"
5
+ :color="ColorEnum.Light"
6
+ @click="onClick"
7
+ v-bind="$attrs"
8
+ />
9
+ <form>
10
+ <input
11
+ v-show="false"
12
+ type="file"
13
+ ref="input"
14
+ :accept="$props.accept"
15
+ @input="onInput"
16
+ />
17
+ </form>
18
+ </div>
19
+ </template>
20
+
21
+ <script lang="ts">
22
+ import { defineComponent, ref } from "vue";
23
+ import { ColorEnum } from "@dative-gpi/foundation-shared-components/models";
24
+
25
+ import FSButton from "../FSButton.vue";
26
+
27
+ export default defineComponent({
28
+ name: "FSButtonFileLabel",
29
+ components: {
30
+ FSButton
31
+ },
32
+ props: {
33
+ accept: {
34
+ type: String,
35
+ required: false,
36
+ default: "",
37
+ },
38
+ readFile: {
39
+ type: Boolean,
40
+ required: false,
41
+ default: true,
42
+ }
43
+ },
44
+ emits: ["update:modelValue"],
45
+ setup(props, { emit }) {
46
+ const input = ref(null);
47
+
48
+ const clear = () => {
49
+ input.value!.form && input.value!.form.reset();
50
+ };
51
+
52
+ const onClick = () => {
53
+ input.value!.click();
54
+ }
55
+
56
+ const onInput = () => {
57
+ const file = input.value!.files && input.value!.files[0];
58
+ if (!file) {
59
+ return;
60
+ }
61
+ if (!props.readFile) {
62
+ emit("update:modelValue", file);
63
+ clear();
64
+ }
65
+ else {
66
+ const reader = new FileReader();
67
+ reader.addEventListener("load", (fileEv) => {
68
+ emit("update:modelValue", fileEv.target && fileEv.target.result);
69
+ clear();
70
+ });
71
+ reader.readAsDataURL(file);
72
+ }
73
+ };
74
+
75
+ return {
76
+ ColorEnum,
77
+ input,
78
+ onClick,
79
+ onInput
80
+ };
81
+ }
82
+ });
83
+ </script>
@@ -0,0 +1,83 @@
1
+ <template>
2
+ <div>
3
+ <FSButton
4
+ prependIcon="mdi-upload-outline"
5
+ :color="ColorEnum.Light"
6
+ @click="onClick"
7
+ v-bind="$attrs"
8
+ />
9
+ <form>
10
+ <input
11
+ v-show="false"
12
+ type="file"
13
+ ref="input"
14
+ :accept="$props.accept"
15
+ @input="onInput"
16
+ />
17
+ </form>
18
+ </div>
19
+ </template>
20
+
21
+ <script lang="ts">
22
+ import { defineComponent, ref } from "vue";
23
+ import { ColorEnum } from "@dative-gpi/foundation-shared-components/models";
24
+
25
+ import FSButton from "../FSButton.vue";
26
+
27
+ export default defineComponent({
28
+ name: "FSButtonFileMini",
29
+ components: {
30
+ FSButton
31
+ },
32
+ props: {
33
+ accept: {
34
+ type: String,
35
+ required: false,
36
+ default: "",
37
+ },
38
+ readFile: {
39
+ type: Boolean,
40
+ required: false,
41
+ default: true,
42
+ }
43
+ },
44
+ emits: ["update:modelValue"],
45
+ setup(props, { emit }) {
46
+ const input = ref(null);
47
+
48
+ const clear = () => {
49
+ input.value!.form && input.value!.form.reset();
50
+ };
51
+
52
+ const onClick = () => {
53
+ input.value!.click();
54
+ }
55
+
56
+ const onInput = () => {
57
+ const file = input.value!.files && input.value!.files[0];
58
+ if (!file) {
59
+ return;
60
+ }
61
+ if (!props.readFile) {
62
+ emit("update:modelValue", file);
63
+ clear();
64
+ }
65
+ else {
66
+ const reader = new FileReader();
67
+ reader.addEventListener("load", (fileEv) => {
68
+ emit("update:modelValue", fileEv.target && fileEv.target.result);
69
+ clear();
70
+ });
71
+ reader.readAsDataURL(file);
72
+ }
73
+ };
74
+
75
+ return {
76
+ ColorEnum,
77
+ input,
78
+ onClick,
79
+ onInput
80
+ };
81
+ }
82
+ });
83
+ </script>
@@ -25,20 +25,21 @@
25
25
  </FSTextField>
26
26
  <FSToggleSet
27
27
  class="fs-icon-field-set"
28
+ ref="toggleSetRef"
28
29
  variant="slide"
29
- :values="icons"
30
- :required="$props.required"
31
- :editable="$props.editable"
32
30
  :buttonColor="$props.buttonColor"
33
31
  :activeColor="$props.activeColor"
34
32
  :modelValue="$props.modelValue"
33
+ :required="$props.required"
34
+ :editable="$props.editable"
35
+ :values="icons"
35
36
  @update:modelValue="(value) => $emit('update:modelValue', value)"
36
37
  />
37
38
  </FSCol>
38
39
  </template>
39
40
 
40
41
  <script lang="ts">
41
- import { computed, defineComponent, PropType, ref } from "vue";
42
+ import { computed, defineComponent, PropType, ref, watch } from "vue";
42
43
 
43
44
  import { Icons, sortByLevenshteinDistance } from "@dative-gpi/foundation-shared-components/utils";
44
45
  import { useColors, useRules } from "@dative-gpi/foundation-shared-components/composables";
@@ -129,6 +130,7 @@ export default defineComponent({
129
130
  const lights = getColors(ColorEnum.Light);
130
131
  const darks = getColors(ColorEnum.Dark);
131
132
 
133
+ const toggleSetRef = ref(null);
132
134
  const innerValue = ref(null);
133
135
 
134
136
  const style = computed((): {[code: string]: string} & Partial<CSSStyleDeclaration> => {
@@ -170,7 +172,11 @@ export default defineComponent({
170
172
  }
171
173
  if (props.modelValue) {
172
174
  const selectedIcon = innerIcons.find((icon) => icon.id === props.modelValue);
173
- if (!selectedIcon) {
175
+ if (selectedIcon) {
176
+ innerIcons.splice(innerIcons.indexOf(selectedIcon), 1);
177
+ innerIcons.unshift(selectedIcon);
178
+ }
179
+ else {
174
180
  innerIcons.unshift({
175
181
  id: props.modelValue,
176
182
  prependIcon: props.modelValue
@@ -182,7 +188,14 @@ export default defineComponent({
182
188
 
183
189
  const messages = computed((): string[] => getMessages(props.modelValue, props.rules));
184
190
 
191
+ watch(() => props.modelValue, () => {
192
+ if (toggleSetRef.value) {
193
+ toggleSetRef.value.goToStart();
194
+ }
195
+ });
196
+
185
197
  return {
198
+ toggleSetRef,
186
199
  innerValue,
187
200
  validateOn,
188
201
  messages,
@@ -242,6 +242,7 @@
242
242
  v-if="innerRowsPerPage !== -1"
243
243
  class="fs-data-table-pagination"
244
244
  variant="slide"
245
+ :dash="pageOptions.length > 8"
245
246
  :values="pageOptions"
246
247
  :required="true"
247
248
  v-model="innerPage"
@@ -349,6 +350,7 @@
349
350
  v-if="innerRowsPerPage !== -1"
350
351
  class="fs-data-table-pagination"
351
352
  variant="slide"
353
+ :dash="pageOptions.length > 8"
352
354
  :values="pageOptions"
353
355
  :required="true"
354
356
  v-model="innerPage"
@@ -38,6 +38,7 @@
38
38
  gap="4px"
39
39
  >
40
40
  <FSConnectivity
41
+ v-if="$props.deviceConnectivity"
41
42
  :deviceConnectivity="$props.deviceConnectivity"
42
43
  />
43
44
  <FSWorstAlert
@@ -129,7 +130,7 @@ export default defineComponent({
129
130
  deviceAlerts: {
130
131
  type: Array as PropType<FSDeviceAlert[]>,
131
132
  required: false,
132
- default: null
133
+ default: () => []
133
134
  },
134
135
  modelStatuses: {
135
136
  type: Array as PropType<FSModelStatus[]>,
@@ -1,5 +1,7 @@
1
1
  import { computed, onMounted, onUnmounted, ref } from "vue";
2
2
 
3
+ let initialized = false;
4
+
3
5
  export const useBreakpoints = () => {
4
6
  const windowWidth = ref(window.innerWidth);
5
7
 
@@ -7,14 +9,6 @@ export const useBreakpoints = () => {
7
9
  windowWidth.value = window.innerWidth;
8
10
  };
9
11
 
10
- onMounted(() => {
11
- window.addEventListener("resize", onSizeChange);
12
- });
13
-
14
- onUnmounted(() => {
15
- window.removeEventListener("resize", onSizeChange);
16
- });
17
-
18
12
  const isTouchScreenEnabled = computed((): boolean => {
19
13
  return navigator.maxTouchPoints > 0;
20
14
  });
@@ -27,6 +21,11 @@ export const useBreakpoints = () => {
27
21
  return windowWidth.value < 600;
28
22
  });
29
23
 
24
+ if (!initialized) {
25
+ window.addEventListener("resize", onSizeChange);
26
+ initialized = true;
27
+ }
28
+
30
29
  return {
31
30
  isTouchScreenEnabled,
32
31
  isMobileSized,
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.19",
4
+ "version": "0.0.21",
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.19",
14
- "@dative-gpi/foundation-shared-services": "0.0.19",
13
+ "@dative-gpi/foundation-shared-domain": "0.0.21",
14
+ "@dative-gpi/foundation-shared-services": "0.0.21",
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": "b6113681d7768c430b48be2e13dcfa54dc5f6882"
35
+ "gitHead": "27642f99177d57e7349dd826e922442a6c0720cb"
36
36
  }
@@ -1,39 +1,3 @@
1
- .fs-button {
2
- padding: var(--fs-button-padding) !important;
3
- border-radius: 4px !important;
4
- border: 1px solid !important;
5
- box-shadow: none !important;
6
-
7
- background-color: var(--fs-button-background-color) !important;
8
- border-color: var(--fs-button-border-color) !important;
9
- color: var(--fs-button-color) !important;
10
-
11
- &.fs-button-full-width {
12
- width: 100%;
13
- }
14
-
15
- &:not(.fs-button--disabled):hover {
16
- background-color: var(--fs-button-hover-background-color) !important;
17
- color: var(--fs-button-hover-color) !important;
18
- }
19
-
20
- &:not(.fs-button--disabled):active {
21
- background-color: var(--fs-button-active-background-color) !important;
22
- border-color: var(--fs-button-active-border-color) !important;
23
- color: var(--fs-button-active-color) !important;
24
- }
25
-
26
- @include web {
27
- min-width: 40px !important;
28
- height: 40px !important;
29
- }
30
-
31
- @include mobile {
32
- min-width: 36px !important;
33
- height: 36px !important;
34
- }
35
- }
36
-
37
1
  .fs-button-icon {
38
2
  transition: color 0.28s cubic-bezier(0.4, 0, 0.2, 1) !important;
39
3
  color: var(--fs-button-color) !important;
@@ -0,0 +1,31 @@
1
+ .fs-clickable {
2
+ border-radius: var(--fs-clickable-border-radius) !important;
3
+ border: var(--fs-clickable-border-size) solid !important;
4
+ transition: all 0.28s cubic-bezier(0.4, 0, 0.2, 1);
5
+ cursor: pointer;
6
+
7
+ background-color: var(--fs-clickable-background-color) !important;
8
+ border-color: var(--fs-clickable-border-color) !important;
9
+ color: var(--fs-clickable-color) !important;
10
+
11
+ &.fs-clickable-disabled {
12
+ cursor: default;
13
+ }
14
+
15
+ &:not(.fs-clickable-disabled):hover {
16
+ background-color: var(--fs-clickable-hover-background-color) !important;
17
+ border-color: var(--fs-clickable-hover-border-color) !important;
18
+ color: var(--fs-clickable-hover-color) !important;
19
+ }
20
+
21
+ &:not(.fs-clickable-disabled):active {
22
+ background-color: var(--fs-clickable-active-background-color) !important;
23
+ border-color: var(--fs-clickable-active-border-color) !important;
24
+ color: var(--fs-clickable-active-color) !important;
25
+ }
26
+ }
27
+
28
+ a:has(.fs-clickable) {
29
+ text-decoration: none;
30
+ padding: 0 !important;
31
+ }
@@ -87,11 +87,11 @@
87
87
 
88
88
  .fs-data-table-pagination {
89
89
  @include web {
90
- max-width: 200px;
90
+ max-width: 280px;
91
91
  }
92
92
 
93
93
  @include mobile {
94
- max-width: 194px;
94
+ max-width: 274px;
95
95
  }
96
96
  }
97
97
 
@@ -6,6 +6,7 @@
6
6
  @import "fs_carousel.scss";
7
7
  @import "fs_checkbox.scss";
8
8
  @import "fs_chip.scss";
9
+ @import "fs_clickable.scss";
9
10
  @import "fs_clock.scss";
10
11
  @import "fs_col.scss";
11
12
  @import "fs_color_field.scss";