@dative-gpi/foundation-shared-components 1.0.87 → 1.0.89

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.
@@ -51,6 +51,11 @@ export default defineComponent({
51
51
  required: false,
52
52
  default: true
53
53
  },
54
+ hideHorizontalOverflow: {
55
+ type: Boolean,
56
+ required: false,
57
+ default: true
58
+ },
54
59
  disableTopMask: {
55
60
  type: Boolean,
56
61
  required: false,
@@ -84,11 +89,13 @@ export default defineComponent({
84
89
  "--fs-fade-out-max-height" : props.maxHeight ? sizeToVar(props.maxHeight) : undefined,
85
90
  "--fs-fade-out-width" : sizeToVar(props.width),
86
91
  "--fs-fade-out-padding" : sizeToVar(props.padding),
87
- "--fs-fade-out-width-offset" : props.scrollOutside ? '12px' : '0px',
92
+ "--fs-fade-out-width-offset" : props.scrollOutside ? '12px' : '0px',
88
93
  "--fs-fade-out-padding-offset" : props.scrollOutside ? '4px' : '0px',
94
+ "--fs-fade-out-margin-right" : props.scrollOutside ? '-12px' : '0px',
89
95
  "--fs-fade-out-mask-color" : backgrounds.base,
90
96
  "--fs-fade-out-top-mask-height" : props.disableTopMask ? '0px' : topMaskHeight.value,
91
- "--fs-fade-out-bottom-mask-height": props.disableBottomMask ? '0px' : bottomMaskHeight.value
97
+ "--fs-fade-out-bottom-mask-height": props.disableBottomMask ? '0px' : bottomMaskHeight.value,
98
+ "--fs-fade-out-x-overflow" : props.hideHorizontalOverflow ? 'hidden' : 'auto'
92
99
  }));
93
100
 
94
101
  const handleMasks = () => {
@@ -32,7 +32,7 @@ export default defineComponent({
32
32
  default: "0"
33
33
  },
34
34
  variant: {
35
- type: String as PropType<"standard" | "button" | "input" | "field" | "chip" | "text-h1" | "text-h2" | "text-h3" | "text-h4" | "text-body" | "text-button" | "text-overline">,
35
+ type: String as PropType<"standard" | "button" | "input" | "field" | "chip" | "text-h1" | "text-h2" | "text-h3" | "text-body" | "text-button" | "text-overline">,
36
36
  required: false,
37
37
  default: "standard"
38
38
  },
@@ -51,7 +51,7 @@ export default defineComponent({
51
51
  const style = computed((): StyleValue => ({
52
52
  "--fs-loader-background-color": backgrounds.base,
53
53
  "--fs-loader-border-radius" : ["chip"].includes(props.variant) ? "50px" : sizeToVar(props.borderRadius),
54
- "--fs-loader-padding" : sizeToVar(props.padding),
54
+ "--fs-loader-padding" : sizeToVar(getPadding.value),
55
55
  "--fs-loader-height" : sizeToVar(getHeight.value),
56
56
  "--fs-loader-width" : sizeToVar(getWidth.value)
57
57
  }));
@@ -63,17 +63,20 @@ export default defineComponent({
63
63
  case "input" :
64
64
  case "field" : return isMobileSized.value ? "36px" : "40px";
65
65
  case "chip" : return isMobileSized.value ? "20px" : "24px";
66
- case "text-h1" : return isMobileSized.value ? "32px" : "40px";
67
- case "text-h2" : return isMobileSized.value ? "24px" : "32px";
68
- case "text-h3" : return isMobileSized.value ? "20px" : "24px";
69
- case "text-h4" : return isMobileSized.value ? "16px" : "20px";
66
+
67
+ case "text-h1" : return isMobileSized.value ? "28px" : "36px";
68
+ case "text-h2" : return isMobileSized.value ? "22px" : "26px";
69
+ case "text-h3" : return isMobileSized.value ? "16px" : "20px";
70
70
  case "text-body" :
71
- case "text-button" : return isMobileSized.value ? "14px" : "16px";
72
- case "text-overline" : return "16px";
71
+ case "text-button" : return isMobileSized.value ? "12px" : "14px";
72
+ case "text-overline" : return isMobileSized.value ? "10px" : "12px";
73
73
  }
74
74
  });
75
75
 
76
76
  const getWidth = computed((): string | number => {
77
+ if (props.width != null) {
78
+ return sizeToVar(props.width);
79
+ }
77
80
  switch (props.variant) {
78
81
  case "standard": return sizeToVar(props.width);
79
82
  case "button" : return isMobileSized.value ? "36px" : "40px";
@@ -87,6 +90,21 @@ export default defineComponent({
87
90
  }
88
91
  });
89
92
 
93
+ const getPadding = computed((): string | number => {
94
+ if (props.padding !== "0") {
95
+ return sizeToVar(props.padding);
96
+ }
97
+ switch (props.variant) {
98
+ case "text-h1" : return "2px 0";
99
+ case "text-h2" : return isMobileSized.value ? "1px 0" : "3px 0";
100
+ case "text-h3" : return "2px 0";
101
+ case "text-body" :
102
+ case "text-button" : return isMobileSized.value ? "2px 0" : "3px 0";;
103
+ case "text-overline" : return isMobileSized.value ? "3px 0" : "2px 0";
104
+ default : return sizeToVar(props.padding);
105
+ }
106
+ });
107
+
90
108
  return {
91
109
  style
92
110
  };
@@ -1,8 +1,11 @@
1
1
  <template>
2
2
  <v-window
3
+ ref="windowRoot"
3
4
  class="fs-window"
4
- :style="style"
5
5
  :touch="false"
6
+ :style="style"
7
+ :modelValue="$props.modelValue"
8
+ @update:modelValue="$emit('update:modelValue', $event)"
6
9
  v-bind="$attrs"
7
10
  >
8
11
  <template
@@ -28,7 +31,7 @@
28
31
  </template>
29
32
 
30
33
  <script lang="ts">
31
- import { computed, defineComponent, type PropType, type StyleValue, type VNode } from "vue";
34
+ import { computed, defineComponent, type PropType, ref, type StyleValue, type VNode, watch } from "vue";
32
35
 
33
36
  import { useSlots } from "@dative-gpi/foundation-shared-components/composables";
34
37
  import { sizeToVar } from "@dative-gpi/foundation-shared-components/utils";
@@ -45,23 +48,43 @@ export default defineComponent({
45
48
  type: [Array, String, Number] as PropType<string[] | number[] | string | number | null>,
46
49
  required: false,
47
50
  default: null
51
+ },
52
+ modelValue: {
53
+ type: [String, Number, Object] as PropType<any>,
54
+ required: false,
55
+ default: 0
48
56
  }
49
57
  },
58
+ emits: ["update:modelValue"],
50
59
  setup(props) {
51
60
  const { slots, getChildren } = useSlots();
52
61
 
53
62
  delete slots.default;
54
63
 
64
+ const windowRoot = ref<HTMLElement | null>(null);
65
+
55
66
  const style = computed((): StyleValue => ({
56
- "--fs-window-width": sizeToVar(props.width),
57
- "--fs-window-height": sizeToVar(props.height)
67
+ "--fs-window-width" : sizeToVar(props.width),
68
+ "--fs-window-height" : sizeToVar(props.height)
58
69
  }));
59
70
 
60
71
  const value = (component: VNode, index: number): any => {
61
72
  return component?.props?.value ?? index;
62
73
  };
63
74
 
75
+ // Hide horizontal overflow when switching windows, otherwise let it visible for the FSFadeOut scrollbar
76
+ watch(() => props.modelValue, (): void => {
77
+ if (windowRoot.value == null) {
78
+ return;
79
+ }
80
+ (windowRoot.value as any).$el.style.setProperty("overflow", "hidden", "important");
81
+ setTimeout(() => {
82
+ (windowRoot.value as any).$el.style.setProperty("overflow", "visible", "important");
83
+ }, 1120);
84
+ });
85
+
64
86
  return {
87
+ windowRoot,
65
88
  slots,
66
89
  style,
67
90
  getChildren,
@@ -13,7 +13,7 @@
13
13
  }"
14
14
  align="center-center"
15
15
  >
16
- {{ day(i - 1) }}
16
+ {{ dayLabel(i - 1) }}
17
17
  </FSCol>
18
18
  </FSRow>
19
19
  <FSRow>
@@ -40,7 +40,7 @@
40
40
  import { startOfWeek, endOfWeek, endOfMonth, isSameDay, isBefore, isAfter, isSameMonth, addDays } from "date-fns";
41
41
  import { defineComponent, computed } from "vue";
42
42
 
43
- import { useTranslations } from "@dative-gpi/bones-ui";
43
+ import { dayLabel } from "../../tools";
44
44
 
45
45
  import { useAppTimeZone } from "@dative-gpi/foundation-shared-services/composables";
46
46
 
@@ -68,24 +68,9 @@ export default defineComponent({
68
68
  }
69
69
  },
70
70
  setup(props) {
71
- const { $tr } = useTranslations();
72
71
 
73
72
  const { getMachineOffset } = useAppTimeZone();
74
73
 
75
- const day = (i: number) => {
76
- switch(i)
77
- {
78
- case 0 : return $tr("ui.common.monday", "Monday");
79
- case 1 : return $tr("ui.common.tuesday", "Tuesday");
80
- case 2 : return $tr("ui.common.wednesday", "Wednesday");
81
- case 3 : return $tr("ui.common.thursday", "Thursday");
82
- case 4 : return $tr("ui.common.friday", "Friday");
83
- case 5 : return $tr("ui.common.saturday", "Saturday");
84
- case 6 : return $tr("ui.common.sunday", "Sunday");
85
- default: return "";
86
- }
87
- };
88
-
89
74
  const firstDayOfMonth = computed(() => {
90
75
  const date = new Date(props.year, props.month - 1, 1);
91
76
  const offset = getMachineOffset();
@@ -155,7 +140,7 @@ export default defineComponent({
155
140
  });
156
141
 
157
142
  return {
158
- day,
143
+ dayLabel,
159
144
  days
160
145
  };
161
146
 
@@ -191,8 +191,8 @@
191
191
  >
192
192
  <div
193
193
  class="fs-rich-text-field-content"
194
- :data-variable-values="JSON.stringify($props.variableValues)"
195
- :contenteditable="!readonly && $props.editable"
194
+ :data-variable-values="variableValues"
195
+ :contenteditable="!readonly && $props.editable && !loading"
196
196
  :data-readonly="$props.variant === 'readonly'"
197
197
  :id="id"
198
198
  />
@@ -275,7 +275,7 @@ export default defineComponent({
275
275
  default: null
276
276
  },
277
277
  modelValue: {
278
- type: String as PropType<string | null>,
278
+ type: [Object, String] as PropType<{ [key: string]: any } | string | null>,
279
279
  required: false,
280
280
  default: null
281
281
  },
@@ -323,6 +323,7 @@ export default defineComponent({
323
323
  const lights = getColors(ColorEnum.Light);
324
324
  const darks = getColors(ColorEnum.Dark);
325
325
 
326
+ const loading = ref(true);
326
327
  const canUndo = ref(false);
327
328
  const isLink = ref(false);
328
329
  const isBold = ref(false);
@@ -375,16 +376,8 @@ export default defineComponent({
375
376
  registerRichText(editor);
376
377
  registerHistory(editor, createEmptyHistoryState(), 250);
377
378
 
378
- if (props.modelValue != null) {
379
- editor.update((): void => {
380
- editor.setEditorState(editor.parseEditorState(props.modelValue!));
381
- });
382
- }
383
- else {
384
- editor.update((): void => {
385
- editor.setEditorState(editor.parseEditorState(emptyLexicalState));
386
- });
387
- }
379
+ updateEditorState();
380
+ loading.value = false;
388
381
  });
389
382
 
390
383
  const readonly = computed((): boolean => {
@@ -478,6 +471,10 @@ export default defineComponent({
478
471
  }
479
472
  });
480
473
 
474
+ const variableValues = computed(() => {
475
+ return JSON.stringify(props.variableValues)
476
+ });
477
+
481
478
  const updateToolbar = (): void => {
482
479
  const selection = $getSelection();
483
480
  isVariable.value = false;
@@ -498,11 +495,16 @@ export default defineComponent({
498
495
  editor.registerUpdateListener(({ editorState }) => {
499
496
  editorState.read(() => {
500
497
  updateToolbar();
501
- if (JSON.stringify(editorState.toJSON()) !== emptyLexicalState) {
502
- emit("update:modelValue", JSON.stringify(editorState.toJSON()));
498
+ if(loading.value) {
499
+ return;
503
500
  }
504
- else {
501
+ const editorModelValue = JSON.stringify(editorState.toJSON());
502
+ if(editorModelValue === emptyLexicalState) {
505
503
  emit("update:modelValue", null);
504
+ return;
505
+ }
506
+ if(editorModelValue !== props.modelValue) {
507
+ emit("update:modelValue", editorModelValue);
506
508
  }
507
509
  });
508
510
  });
@@ -665,24 +667,34 @@ export default defineComponent({
665
667
  isLink.value = false;
666
668
  }
667
669
 
668
- watch(() => props.modelValue, () => {
669
- if (JSON.stringify(editor.getEditorState().toJSON()) != props.modelValue) {
670
- if (props.modelValue != null) {
671
- editor.update(() => {
670
+ const updateEditorState = () => {
671
+ if (JSON.stringify(editor.getEditorState().toJSON()) === props.modelValue) {
672
+ return;
673
+ }
674
+ if (props.modelValue != null) {
675
+ editor.update(() => {
676
+ if(typeof props.modelValue === "string") {
672
677
  editor.setEditorState(editor.parseEditorState(props.modelValue!));
673
- });
674
- }
675
- else if (JSON.stringify(editor.getEditorState().toJSON()) !== emptyLexicalState) {
676
- editor.update(() => {
677
- editor.setEditorState(editor.parseEditorState(emptyLexicalState));
678
- });
679
- }
678
+ }
679
+ else {
680
+ editor.setEditorState(editor.parseEditorState(JSON.stringify(props.modelValue)));
681
+ }
682
+ });
683
+ return;
680
684
  }
685
+ editor.update(() => {
686
+ editor.setEditorState(editor.parseEditorState(emptyLexicalState));
687
+ });
688
+ }
689
+
690
+ watch(() => props.modelValue, () => {
691
+ updateEditorState();
681
692
  });
682
693
 
683
694
  return {
684
695
  FORMAT_ELEMENT_COMMAND,
685
696
  FORMAT_TEXT_COMMAND,
697
+ variableValues,
686
698
  toolbarColors,
687
699
  menuVariable,
688
700
  UNDO_COMMAND,
@@ -690,6 +702,7 @@ export default defineComponent({
690
702
  readonly,
691
703
  linkUrl,
692
704
  classes,
705
+ loading,
693
706
  isEmpty,
694
707
  editor,
695
708
  isLink,
@@ -1,14 +1,14 @@
1
1
  <template>
2
2
  <FSTextField
3
3
  class="fs-search-field"
4
- :editable="$props.editable"
5
4
  :placeholder="placeholder"
6
- @keydown.enter="onSearch"
7
- v-model="innerValue"
5
+ :modelValue="$props.modelValue"
6
+ prependInnerIcon="mdi-magnify"
7
+ @update:modelValue="$emit('update:modelValue', $event)"
8
8
  v-bind="$attrs"
9
9
  >
10
10
  <template
11
- v-for="(_, name) in slots"
11
+ v-for="(_, name) in $slots"
12
12
  v-slot:[name]="slotData"
13
13
  >
14
14
  <slot
@@ -16,60 +16,20 @@
16
16
  v-bind="slotData"
17
17
  />
18
18
  </template>
19
- <template
20
- v-if="$props.prependInnerIcon || $slots['prepend-inner']"
21
- #prepend-inner
22
- >
23
- <FSButton
24
- v-if="$props.prependInnerIcon"
25
- variant="icon"
26
- :icon="$props.prependInnerIcon"
27
- :editable="$props.editable"
28
- :color="ColorEnum.Dark"
29
- @click="onSearch"
30
- />
31
- <slot
32
- name="prepend-inner"
33
- />
34
- </template>
35
- <template
36
- v-if="$props.variant !== 'instant' || $slots.append"
37
- #append
38
- >
39
- <FSButton
40
- v-if="$props.variant !== 'instant'"
41
- :prependIcon="$props.buttonPrependIcon"
42
- :label="buttonLabel"
43
- :appendIcon="$props.buttonAppendIcon"
44
- :variant="$props.buttonVariant"
45
- :color="$props.buttonColor"
46
- :editable="$props.editable"
47
- @click="onSearch"
48
- />
49
- <slot
50
- name="append"
51
- />
52
- </template>
53
19
  </FSTextField>
54
20
  </template>
55
21
 
56
22
  <script lang="ts">
57
- import type { PropType} from "vue";
58
- import { computed, defineComponent, ref, watch } from "vue";
23
+ import { computed, defineComponent, type PropType } from "vue";
59
24
 
60
25
  import { useTranslations as useTranslationsProvider } from "@dative-gpi/bones-ui/composables";
61
- import { type ColorBase, ColorEnum } from "@dative-gpi/foundation-shared-components/models";
62
-
63
- import { useSlots } from "../../composables";
64
26
 
65
27
  import FSTextField from "./FSTextField.vue";
66
- import FSButton from "../FSButton.vue";
67
28
 
68
29
  export default defineComponent({
69
30
  name: "FSSearchField",
70
31
  components: {
71
- FSTextField,
72
- FSButton
32
+ FSTextField
73
33
  },
74
34
  props: {
75
35
  placeholder: {
@@ -77,89 +37,22 @@ export default defineComponent({
77
37
  required: false,
78
38
  default: null
79
39
  },
80
- prependInnerIcon: {
81
- type: String as PropType<string | null>,
82
- required: false,
83
- default: "mdi-magnify"
84
- },
85
- variant: {
86
- type: String as PropType<"standard" | "instant">,
87
- required: false,
88
- default: "instant"
89
- },
90
- buttonPrependIcon: {
91
- type: String as PropType<string | null>,
92
- required: false,
93
- default: null
94
- },
95
- buttonLabel: {
96
- type: String as PropType<string | null>,
97
- required: false,
98
- default: null
99
- },
100
- buttonAppendIcon: {
101
- type: String as PropType<string | null>,
102
- required: false,
103
- default: null
104
- },
105
- buttonVariant: {
106
- type: String as PropType<"standard" | "full" | "icon">,
107
- required: false,
108
- default: "standard"
109
- },
110
40
  modelValue: {
111
41
  type: String as PropType<string | null>,
112
42
  required: false,
113
43
  default: null
114
- },
115
- buttonColor: {
116
- type: String as PropType<ColorBase>,
117
- required: false,
118
- default: ColorEnum.Primary
119
- },
120
- editable: {
121
- type: Boolean,
122
- required: false,
123
- default: true
124
44
  }
125
45
  },
126
46
  emits: ["update:modelValue"],
127
- setup(props, { emit }) {
47
+ setup(props) {
128
48
  const { $tr } = useTranslationsProvider();
129
- const { slots } = useSlots();
130
-
131
- delete slots["prepend-inner"];
132
- delete slots.append;
133
-
134
- const innerValue = ref(props.modelValue);
135
49
 
136
50
  const placeholder = computed(() => {
137
51
  return props.placeholder ?? $tr('ui.search.placeholder', 'Search...');
138
52
  });
139
53
 
140
- const buttonLabel = computed(() => {
141
- return props.buttonLabel ?? $tr('ui.button.search', 'Search');
142
- });
143
-
144
- const onSearch = (event: Event) => {
145
- event.stopImmediatePropagation();
146
- event.preventDefault();
147
- emit('update:modelValue', innerValue.value);
148
- };
149
-
150
- watch(innerValue, () => {
151
- if (["instant"].includes(props.variant)) {
152
- emit("update:modelValue", innerValue.value);
153
- }
154
- });
155
-
156
54
  return {
157
55
  placeholder,
158
- buttonLabel,
159
- innerValue,
160
- ColorEnum,
161
- slots,
162
- onSearch
163
56
  };
164
57
  }
165
58
  });