@dative-gpi/foundation-shared-components 0.0.39 → 0.0.41

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.
@@ -27,8 +27,8 @@ export default defineComponent({
27
27
  default: "standard"
28
28
  }
29
29
  },
30
- emits: ["update:modelValue"],
31
- setup(props) {
30
+ emits: ["update:modelValue", "submit"],
31
+ setup(props, { emit }) {
32
32
  const formRef = ref<HTMLFormElement | null>(null);
33
33
  const submitted = ref(false);
34
34
 
@@ -40,10 +40,14 @@ export default defineComponent({
40
40
  }
41
41
  });
42
42
 
43
- const onSubmit = (event: SubmitEvent) => {
43
+ const onSubmit = async (event: SubmitEvent) => {
44
44
  event.stopImmediatePropagation();
45
45
  event.preventDefault();
46
46
  submitted.value = true;
47
+ await formRef.value.validate();
48
+ emit("update:modelValue", !!formRef.value.isValid);
49
+ emit("submit", !!formRef.value.isValid);
50
+
47
51
  };
48
52
 
49
53
  provide("validateOn", validateOn);
@@ -57,7 +57,7 @@
57
57
  :color="getColor(item)"
58
58
  :class="getClass(item)"
59
59
  :label="item.label"
60
- :icon="label.icon"
60
+ :icon="item.icon"
61
61
  :key="index"
62
62
  @click="toggle(item)"
63
63
  />
@@ -163,7 +163,7 @@
163
163
  import { $createParagraphNode, $getSelection, $isElementNode, $isRangeSelection, $setSelection, CAN_UNDO_COMMAND, createEditor, ElementNode, FORMAT_ELEMENT_COMMAND, FORMAT_TEXT_COMMAND, ParagraphNode, UNDO_COMMAND } from "lexical";
164
164
  import { $createHeadingNode, HeadingNode, HeadingTagType, registerRichText } from "@lexical/rich-text";
165
165
  import { createEmptyHistoryState, registerHistory } from "@lexical/history";
166
- import { computed, defineComponent, onMounted, PropType, ref } from "vue";
166
+ import { computed, defineComponent, onMounted, PropType, ref, watch } from "vue";
167
167
  import { $createLinkNode, $isLinkNode, LinkNode } from "@lexical/link";
168
168
  import { $wrapNodes } from "@lexical/selection";
169
169
 
@@ -243,9 +243,11 @@ export default defineComponent({
243
243
  const isStrikethrough = ref(false);
244
244
 
245
245
  const id = `${Math.random()}-editor`;
246
+ const emptyState = "{\"root\":{\"children\":[{\"children\":[],\"direction\":null,\"format\":\"\",\"indent\":0,\"type\":\"paragraph\",\"version\":1}],\"direction\":null,\"format\":\"\",\"indent\":0,\"type\":\"root\",\"version\":1}}";
246
247
 
247
- const linkUrl = ref("https://");
248
248
 
249
+ const linkUrl = ref("https://");
250
+
249
251
  const config = {
250
252
  namespace: "MyEditor",
251
253
  theme: {
@@ -285,6 +287,11 @@ export default defineComponent({
285
287
  editor.setEditorState(editor.parseEditorState(props.modelValue));
286
288
  });
287
289
  }
290
+ else {
291
+ editor.update((): void => {
292
+ editor.setEditorState(editor.parseEditorState(emptyState));
293
+ });
294
+ }
288
295
  });
289
296
 
290
297
  const readonly = computed((): boolean => {
@@ -533,6 +540,21 @@ export default defineComponent({
533
540
  isLink.value = false;
534
541
  }
535
542
 
543
+ watch(() => props.modelValue, () => {
544
+ if (props.modelValue != JSON.stringify(editor.getEditorState().toJSON())) {
545
+ if (props.modelValue != null) {
546
+ editor.update(() => {
547
+ editor.setEditorState(editor.parseEditorState(props.modelValue));
548
+ });
549
+ }
550
+ else {
551
+ editor.update(() => {
552
+ editor.setEditorState(editor.parseEditorState(emptyState));
553
+ });
554
+ }
555
+ }
556
+ });
557
+
536
558
  return {
537
559
  readonly,
538
560
  style,
@@ -71,7 +71,7 @@ export const useColors = () => {
71
71
  soft: getSoft(seed).hex(),
72
72
  softContrast: getContrast(seed, dark).hex(),
73
73
  base: seed.hex(),
74
- baseContrast: getContrast(seed, base).hex(),
74
+ baseContrast: getContrast(seed, dark).hex(),
75
75
  dark: dark.hex(),
76
76
  darkContrast: getContrast(dark, light).hex()
77
77
  };
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.39",
4
+ "version": "0.0.41",
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.39",
14
- "@dative-gpi/foundation-shared-services": "0.0.39",
13
+ "@dative-gpi/foundation-shared-domain": "0.0.41",
14
+ "@dative-gpi/foundation-shared-services": "0.0.41",
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": "f4259f72e37e80ea5276d61fa030956976738397"
35
+ "gitHead": "35e8912ae4de63d3e590f6f4f80eb95619c5b57b"
36
36
  }