@uxland/primary-shell 1.1.0 → 2.0.0

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.
Files changed (109) hide show
  1. package/README.md +231 -0
  2. package/dist/UI/components/clinical-monitoring/clinical-monitoring.d.ts +11 -0
  3. package/dist/UI/components/clinical-monitoring/template.d.ts +3 -0
  4. package/dist/UI/components/index.d.ts +1 -0
  5. package/dist/UI/components/primaria-breadcumbs/primaria-breadcumbs.d.ts +9 -0
  6. package/dist/UI/components/primaria-breadcumbs/template.d.ts +3 -0
  7. package/dist/UI/components/primaria-shell/primaria-shell.d.ts +14 -0
  8. package/dist/UI/components/primaria-shell/template.d.ts +3 -0
  9. package/dist/UI/components/title-view/template.d.ts +3 -0
  10. package/dist/UI/components/title-view/title-view.d.ts +9 -0
  11. package/dist/UI/index.d.ts +2 -0
  12. package/dist/UI/shared-components/dss-container/dss-container.d.ts +7 -0
  13. package/dist/UI/shared-components/index.d.ts +2 -0
  14. package/dist/UI/shared-components/primaria-content-switcher/primaria-content-switcher.d.ts +14 -0
  15. package/dist/UI/shared-components/primaria-interaction/components/dialog-component.d.ts +20 -0
  16. package/dist/UI/shared-components/primaria-interaction/components/notifier-component.d.ts +12 -0
  17. package/dist/UI/shared-components/primaria-interaction/confirm-mixin.d.ts +16 -0
  18. package/dist/UI/shared-components/primaria-interaction/confirm.d.ts +3 -0
  19. package/dist/UI/shared-components/primaria-interaction/index.d.ts +4 -0
  20. package/dist/UI/shared-components/primaria-interaction/notify.d.ts +4 -0
  21. package/dist/UI/shared-components/primaria-interaction/typings.d.ts +28 -0
  22. package/dist/UI/shared-components/primaria-menu-item/primaria-menu-item.d.ts +10 -0
  23. package/dist/UI/shared-components/primaria-menu-item/template.d.ts +3 -0
  24. package/dist/UI/shared-components/primaria-text-editor/primaria-rich-text-editor.d.ts +57 -0
  25. package/dist/UI/shared-components/primaria-text-editor/template.d.ts +1 -0
  26. package/dist/UI/shared-components/primaria-text-editor/utils.d.ts +1 -0
  27. package/dist/UI/styles/theme/apply-theme.d.ts +1 -0
  28. package/dist/api/api.d.ts +27 -0
  29. package/dist/api/broker/factory.d.ts +3 -0
  30. package/dist/api/broker/factory.test.d.ts +1 -0
  31. package/dist/api/broker/primaria-broker.d.ts +5 -0
  32. package/dist/api/global-state/global-state.d.ts +35 -0
  33. package/dist/api/global-state/global-state.test.d.ts +1 -0
  34. package/dist/api/interaction-manager/interaction.d.ts +8 -0
  35. package/dist/api/localization/localization.test.d.ts +1 -0
  36. package/dist/constants.d.ts +2 -0
  37. package/dist/index.d.ts +8 -0
  38. package/dist/index.js +26335 -239
  39. package/dist/index.js.map +1 -0
  40. package/dist/index.umd.cjs +8647 -0
  41. package/dist/index.umd.cjs.map +1 -0
  42. package/dist/initializer.d.ts +1 -0
  43. package/dist/locales.d.ts +15 -0
  44. package/dist/plugin.d.ts +6 -0
  45. package/dist/region-manager.d.ts +16 -0
  46. package/dist/regions.d.ts +14 -0
  47. package/dist/style.css +3 -0
  48. package/package.json +23 -15
  49. package/src/UI/components/clinical-monitoring/clinical-monitoring.ts +28 -0
  50. package/src/UI/components/clinical-monitoring/styles.scss +29 -0
  51. package/src/UI/components/clinical-monitoring/template.ts +12 -0
  52. package/src/UI/components/index.ts +5 -0
  53. package/src/UI/components/primaria-breadcumbs/primaria-breadcumbs.ts +27 -0
  54. package/src/UI/components/primaria-breadcumbs/styles.scss +25 -0
  55. package/src/UI/components/primaria-breadcumbs/template.ts +15 -0
  56. package/src/UI/components/primaria-shell/primaria-shell.ts +37 -0
  57. package/src/UI/components/primaria-shell/styles.scss +68 -0
  58. package/src/UI/components/primaria-shell/template.ts +94 -0
  59. package/src/UI/components/title-view/styles.scss +5 -0
  60. package/src/UI/components/title-view/template.ts +6 -0
  61. package/src/UI/components/title-view/title-view.ts +23 -0
  62. package/src/UI/images/Gencat_Logotip.svg +70 -0
  63. package/src/UI/images/Salut_Logotip.svg +8 -0
  64. package/src/UI/index.ts +2 -0
  65. package/src/UI/shared-components/design-system.css +1 -0
  66. package/src/UI/shared-components/dss-container/dss-container.ts +32 -0
  67. package/src/UI/shared-components/dss-container/styles.scss +23 -0
  68. package/src/UI/shared-components/index.ts +5 -0
  69. package/src/UI/shared-components/primaria-content-switcher/primaria-content-switcher.ts +79 -0
  70. package/src/UI/shared-components/primaria-interaction/components/dialog-component-styles.scss +155 -0
  71. package/src/UI/shared-components/primaria-interaction/components/dialog-component.ts +120 -0
  72. package/src/UI/shared-components/primaria-interaction/components/notifier-component-styles.scss +128 -0
  73. package/src/UI/shared-components/primaria-interaction/components/notifier-component.ts +73 -0
  74. package/src/UI/shared-components/primaria-interaction/confirm-mixin.ts +39 -0
  75. package/src/UI/shared-components/primaria-interaction/confirm.ts +30 -0
  76. package/src/UI/shared-components/primaria-interaction/index.ts +4 -0
  77. package/src/UI/shared-components/primaria-interaction/notify.ts +153 -0
  78. package/src/UI/shared-components/primaria-interaction/typings.ts +32 -0
  79. package/src/UI/shared-components/primaria-menu-item/primaria-menu-item.ts +25 -0
  80. package/src/UI/shared-components/primaria-menu-item/styles.scss +10 -0
  81. package/src/UI/shared-components/primaria-menu-item/template.ts +8 -0
  82. package/src/UI/shared-components/primaria-text-editor/primaria-rich-text-editor.ts +230 -0
  83. package/src/UI/shared-components/primaria-text-editor/styles.scss +972 -0
  84. package/src/UI/shared-components/primaria-text-editor/template.ts +8 -0
  85. package/src/UI/shared-components/primaria-text-editor/utils.ts +39 -0
  86. package/src/UI/styles/_flex-layout.scss +203 -0
  87. package/src/UI/styles/_normalize.scss +3 -0
  88. package/src/UI/styles/_variables.scss +40 -0
  89. package/src/UI/styles/styles.scss +3 -0
  90. package/src/UI/styles/theme/apply-theme.ts +11 -0
  91. package/src/api/api.ts +63 -0
  92. package/src/api/broker/factory.test.ts +124 -0
  93. package/src/api/broker/factory.ts +122 -0
  94. package/src/api/broker/primaria-broker.ts +11 -0
  95. package/src/api/global-state/global-state.test.ts +53 -0
  96. package/src/api/global-state/global-state.ts +49 -0
  97. package/src/api/interaction-manager/interaction.ts +21 -0
  98. package/src/api/localization/localization.test.ts +61 -0
  99. package/src/api/localization/localization.ts +54 -0
  100. package/src/constants.ts +2 -0
  101. package/src/index.ts +12 -0
  102. package/src/initializer.ts +39 -4
  103. package/src/locales.ts +24 -0
  104. package/src/plugin.ts +9 -0
  105. package/src/region-manager.ts +155 -0
  106. package/src/regions.ts +17 -6
  107. package/dist/index.mjs +0 -3209
  108. package/index.ts +0 -3
  109. package/src/primary-shell.ts +0 -78
@@ -0,0 +1,230 @@
1
+ import { css, html, LitElement, unsafeCSS } from "lit";
2
+ import { customElement, property } from "lit/decorators.js";
3
+ import Quill from "uxl-quill/dist/quill";
4
+ import styles from "./styles.scss?inline";
5
+ import { template } from "./template";
6
+ import { fixSpellCheckerIssue } from "./utils";
7
+
8
+ fixSpellCheckerIssue(Quill);
9
+
10
+ @customElement("primaria-rich-text-editor")
11
+ export class PrimariaRichTextEditor extends LitElement {
12
+ render() {
13
+ return html` ${template(this)} `;
14
+ }
15
+
16
+ static styles = css`
17
+ ${unsafeCSS(styles)}
18
+ `;
19
+
20
+ firstUpdated() {
21
+ // const rte: PrimariaRichTextEditor = this;
22
+ this.quill = new Quill(this.shadowRoot?.querySelector("#rte"), this._getOptions());
23
+ this.quill.on("text-change", (delta, oldDelta, source) => {
24
+ const plainValue = this.quill.getText();
25
+ const values = {
26
+ html: (<any>this).shadowRoot.querySelector(".ql-editor").innerHTML,
27
+ plain: plainValue,
28
+ };
29
+
30
+ const textChanged = new CustomEvent("text-changed", {
31
+ composed: true,
32
+ detail: values,
33
+ });
34
+ (<any>this).dispatchEvent(textChanged);
35
+ this.range = this.getCursorPosition();
36
+ });
37
+ this.quill.on("selection-change", (range, oldRange, source) => {
38
+ if (range) this.range = range;
39
+ });
40
+ }
41
+
42
+ @property()
43
+ quill: Quill | null;
44
+
45
+ @property()
46
+ options: string;
47
+
48
+ @property({ type: Object })
49
+ range: { index: number; length: number };
50
+
51
+ @property({ type: Array })
52
+ availableOptions: string[] = [
53
+ "bold",
54
+ "italic",
55
+ "underline",
56
+ "strike",
57
+ "blockquote",
58
+ "code-block",
59
+ "image",
60
+ "video",
61
+ "link",
62
+ "color",
63
+ "background",
64
+ "ol",
65
+ "ul",
66
+ "subindex",
67
+ "superindex",
68
+ // 'outdent',
69
+ // 'indent',
70
+ "size",
71
+ "header",
72
+ "font",
73
+ "align",
74
+ // "clear",
75
+ "undo",
76
+ "redo",
77
+ ];
78
+
79
+ @property({ type: Array })
80
+ availableFormats: string[] = [
81
+ "background",
82
+ "bold",
83
+ "color",
84
+ "font",
85
+ "code",
86
+ "italic",
87
+ "link",
88
+ "size",
89
+ "strike",
90
+ "script",
91
+ "underline",
92
+ "blockquote",
93
+ "header",
94
+ // 'indent',
95
+ "list",
96
+ "align",
97
+ "direction",
98
+ "code-block",
99
+ "formula",
100
+ "image",
101
+ "video",
102
+ ];
103
+
104
+ @property()
105
+ formats: string;
106
+
107
+ _getOptions() {
108
+ let toolbarOptions = [];
109
+ const availableOpts = this.availableOptions;
110
+ if (this.options === undefined || this.options.length === 0) {
111
+ toolbarOptions = [
112
+ ["bold", "italic", "underline", "strike"],
113
+ ["blockquote", "code-block"],
114
+ [{ header: 1 }, { header: 2 }],
115
+ [{ list: "ordered" }, { list: "bullet" }],
116
+ [{ script: "sub" }, { script: "super" }],
117
+ // [{indent: '-1'}, {indent: '+1'}],
118
+ [{ direction: "rtl" }],
119
+ [{ size: ["small", false, "large", "huge", "20px"] }],
120
+ [{ header: [1, 2, 3, 4, 5, 6, false] }],
121
+ [{ color: [] }, { background: [] }],
122
+ [{ font: [] }],
123
+ [{ align: [] }],
124
+ ["image"],
125
+ ["video"],
126
+ // ["clean"],
127
+ ];
128
+ } else {
129
+ toolbarOptions = this.options.split(",");
130
+ toolbarOptions.forEach((option) => {
131
+ if (availableOpts.indexOf(option) <= -1)
132
+ toolbarOptions.splice(toolbarOptions.indexOf(option), 1);
133
+ });
134
+ toolbarOptions = toolbarOptions.map(function (option) {
135
+ if (option == "color") return { color: [] };
136
+ else if (option == "ol") return { list: "ordered" };
137
+ else if (option == "ul") return { list: "bullet" };
138
+ else if (option == "subindex") return { script: "sub" };
139
+ else if (option == "superindex") return { script: "super" };
140
+ // else if (option == 'outdent') return {indent: '-1'};
141
+ // else if (option == 'indent') return {indent: '+1'};
142
+ else if (option == "size") return { size: ["small", false, "large", "huge"] };
143
+ else if (option == "header") return { header: [1, 2, 3, 4, 5, 6, false] };
144
+ else if (option == "background") return { background: [] };
145
+ else if (option == "font") return { font: [] };
146
+ else if (option == "align") return { align: [] };
147
+ /* else if (option == 'undo') return {undo: undo_icon};
148
+ else if (option == 'redo') return {redo: redo_icon}; */ else return option;
149
+ });
150
+ // if (toolbarOptions.indexOf("clean") < 0) {
151
+ // toolbarOptions.push("clean");
152
+ // }
153
+ }
154
+
155
+ /* const icons = Quill.import('ui/icons');
156
+ icons['undo'] = undo_icon;
157
+ icons['redo'] = redo_icon; */
158
+
159
+ let formats = this.availableFormats;
160
+ if (this.formats) {
161
+ formats = this.formats.split(",");
162
+ }
163
+
164
+ return {
165
+ modules: {
166
+ toolbar: {
167
+ container: toolbarOptions,
168
+ handlers: {
169
+ redo() {
170
+ this.quill.history.redo();
171
+ },
172
+ undo() {
173
+ this.quill.history.undo();
174
+ },
175
+ },
176
+ },
177
+ history: {
178
+ delay: 1000,
179
+ maxStack: 50,
180
+ userOnly: false,
181
+ },
182
+ keyboard: {
183
+ bindings: {
184
+ indent: {
185
+ // highlight tab or tab at beginning of list, indent or blockquote
186
+ key: "Tab",
187
+ format: ["blockquote", "indent", "list"],
188
+ handler(range, context) {
189
+ if (
190
+ (context.collapsed && context.offset !== 0) ||
191
+ context.format?.list === "ordered" // disable ordered list auto-numbering on indentation
192
+ )
193
+ return true;
194
+ this.quill.format("indent", "+1", Quill.sources.USER);
195
+ return false;
196
+ },
197
+ },
198
+ "list autofill": {
199
+ key: " ",
200
+ shiftKey: null,
201
+ collapsed: true,
202
+ format: {
203
+ "code-block": false,
204
+ blockquote: false,
205
+ table: false,
206
+ },
207
+ prefix: /^\s*?(\d+\.|-|\*)$/,
208
+ handler(range, context) {
209
+ if (this.quill.scroll.query("list") == null) return true;
210
+ const { length } = context.prefix;
211
+ const line = this.quill.getLine(range.index);
212
+ const offset = line[1];
213
+ if (offset > length) return true;
214
+ this.quill.insertText(range.index, " ", Quill.sources.USER);
215
+ this.quill.setSelection(range.index - length, Quill.sources.SILENT);
216
+ return false;
217
+ },
218
+ },
219
+ },
220
+ },
221
+ },
222
+ theme: "snow",
223
+ formats: formats,
224
+ };
225
+ }
226
+
227
+ public getCursorPosition() {
228
+ return this.quill.getSelection();
229
+ }
230
+ }