hayun-vite 0.11.0 → 0.11.1

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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "hayun-vite",
3
3
  "private": false,
4
- "version": "0.11.0",
4
+ "version": "0.11.1",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "dev": "vite",
package/src/Form/Form.js CHANGED
@@ -1,5 +1,3 @@
1
- // import Symbols from "../Symbol/Symbols.js";
2
- import Box from "../Box/Box.js";
3
1
  import Header from "../Header/Header.js";
4
2
  import Reflex from "../Reflex/Reflex.js";
5
3
  import Sections from "./Sections.js";
@@ -7,9 +5,9 @@ import Speech from "../Speech/Speech.js";
7
5
  import Tympanogram from "../Tympanogram/Tympanogram.js";
8
6
  import putRect from "../common/putRect.js";
9
7
  import AudiogramChart from "../Audiogram/Audiogram.js";
8
+ import MultiText from "../MultiText/MultiText.js";
10
9
  const svgNS = "http://www.w3.org/2000/svg";
11
10
 
12
-
13
11
  export default class Form {
14
12
  constructor({ container, template } = {}) {
15
13
  this.template = template;
@@ -18,6 +16,7 @@ export default class Form {
18
16
  let { width, height, margin, paper } = template;
19
17
  this.form = this.create({ paper, margin });
20
18
  this.form.style.display = 'none';
19
+ let dims;
21
20
  // رسم مارجین های فرم
22
21
  this.drawMarginLines({ container: this.form, width, height });
23
22
 
@@ -29,18 +28,17 @@ export default class Form {
29
28
  this.header.draw({ dims: template.header });
30
29
  }
31
30
  if (sections.patient) {
32
- // (template.label === 'تمپانومتری رسا') && console.log(template.patient);
33
-
34
- this.patient = new Box({ container: sections.patient });
35
- this.patient.draw({ dims: template.patient });
31
+ dims = template.patient;
32
+ this.patient = new MultiText({ container: sections.patient, dims });
36
33
  }
37
34
  if (sections.history) {
38
- this.history = new Box({ container: sections.history })
39
- this.history.draw({ dims: template.history });
35
+ dims = template.history;
36
+ this.history = new MultiText({ container: sections.history, dims })
37
+ // this.history.draw({ dims: template.history });
40
38
  }
41
39
  if (sections['Audiogram Titles']) {
42
- const titles = new Box({ container: sections['Audiogram Titles'] });
43
- titles.draw({ dims: template['Audiogram Titles'] });
40
+ dims = template['Audiogram Titles'];
41
+ new MultiText({ container: sections['Audiogram Titles'], dims });
44
42
  }
45
43
  if (sections.RAudiogram) {
46
44
  this.RAudiogram = new AudiogramChart({
@@ -48,9 +46,7 @@ export default class Form {
48
46
  dims: template.RAudiogram,
49
47
  side: 'R',
50
48
  events: false
51
- });
52
- console.log(template.RAudiogram);
53
-
49
+ })
54
50
  }
55
51
  if (sections.LAudiogram) {
56
52
  this.LAudiogram = new AudiogramChart({
@@ -58,51 +54,51 @@ export default class Form {
58
54
  dims: template.LAudiogram,
59
55
  side: 'L',
60
56
  events: false
61
- });
57
+ })
62
58
  }
63
59
  if (sections['Speech Titles']) {
64
- const titles = new Box({ container: sections['Speech Titles'] });
65
- titles.draw({ dims: template['Speech Titles'] });
60
+ dims= template['Speech Titles'];
61
+ const titles = new MultiText({ container: sections['Speech Titles'], dims });
66
62
  }
67
63
  if (sections['RSpeech']) {
68
- this.RSpeech = new Speech({ container: sections.RSpeech, side: 'R' })
69
- this.RSpeech.draw({ dims: template.RSpeech, })
64
+ dims= template.RSpeech
65
+ this.RSpeech = new Speech({ container: sections.RSpeech, side: 'R', dims})
70
66
  }
71
67
  if (sections.LSpeech) {
72
- this.LSpeech = new Speech({ container: sections.LSpeech, side: 'L' })
73
- this.LSpeech.draw({ dims: template.LSpeech, });
68
+ dims= template.LSpeech
69
+ this.LSpeech = new Speech({ container: sections.LSpeech, side: 'L', dims })
74
70
  }
75
71
  if (sections['Tympanogram Titles']) {
76
- const titles = new Box({ container: sections['Tympanogram Titles'] });
77
- titles.draw({ dims: template['Tympanogram Titles'] });
72
+ dims= template['Tympanogram Titles'];
73
+ new MultiText({ container: sections['Tympanogram Titles'], dims });
78
74
  }
79
75
  if (sections.RTympanogram) {
80
- this.RTympanogram = new Tympanogram({ container: sections.RTympanogram, side: 'R' })
81
- this.RTympanogram.draw({ dims: template.RTympanogram });
76
+ dims= template.RTympanogram
77
+ this.RTympanogram = new Tympanogram({ container: sections.RTympanogram, side: 'R', dims })
82
78
  }
83
79
  if (sections.LTympanogram) {
84
- this.LTympanogram = new Tympanogram({ container: sections.LTympanogram, side: 'L' })
85
- this.LTympanogram.draw({ dims: template.LTympanogram });
80
+ dims= template.LTympanogram
81
+ this.LTympanogram = new Tympanogram({ container: sections.LTympanogram, side: 'L', dims })
86
82
  }
87
- if (sections['Reflex Titles']) {
88
- const titles = new Box({ container: sections['Reflex Titles'] });
89
- titles.draw({ dims: template['Reflex Titles'] });
83
+ if (sections['Reflex Titles']) {
84
+ dims= template['Reflex Titles'];
85
+ const titles = new MultiText({ container: sections['Reflex Titles'], dims });
90
86
  }
91
87
  if (sections.RReflex) {
92
- this.RReflex = new Reflex({ container: sections.RReflex, side: 'R' })
93
- this.RReflex.draw({ dims: template.RReflex });
88
+ dims= template.RReflex
89
+ this.RReflex = new Reflex({ container: sections.RReflex, side: 'R', dims })
94
90
  }
95
91
  if (sections.LReflex) {
96
- this.LReflex = new Reflex({ container: sections.LReflex, side: 'L' })
97
- this.LReflex.draw({ dims: template.LReflex });
92
+ dims= template.LReflex
93
+ this.LReflex = new Reflex({ container: sections.LReflex, side: 'L', dims })
98
94
  }
99
95
  if (sections.report) {
100
- this.report = new Box({ container: sections.report })
101
- this.report.draw({ dims: template.report });
96
+ dims= template.report;
97
+ this.report = new MultiText({ container: sections.report, dims })
102
98
  }
103
99
  if (sections.footer) {
104
- this.footer = new Box({ container: sections.footer })
105
- this.footer.draw({ dims: template.footer });
100
+ dims= template.footer;
101
+ this.footer = new MultiText({ container: sections.footer, dims})
106
102
  }
107
103
 
108
104
  this.container.appendChild(this.form);
@@ -1,37 +1,99 @@
1
- export default class MultiText {
2
- constructor({ box }) {
3
- this.box = box;
4
- this.container = box.container;
5
- // this.draw({ box })
1
+ import putLine from "../common/putLine.js";
2
+ import putRect from "../common/putRect.js";
3
+ import putSVG from "../common/putSVG.js";
4
+ import putText from "../common/putText.js";
5
+ const svgNS = "http://www.w3.org/2000/svg";
6
6
 
7
+ export default class MultiText {
8
+ constructor({ container, dims }) {
9
+ this.container = container;
10
+ this.draw({ dims })
7
11
  }
8
12
 
13
+ draw({ dims }) {
14
+ // دریافت اطلاعات مختصات چاپ ورودی ها به جز عادی محاسبه شده
15
+ this.inputs = (dims.forceInsert) ? dims.forceInputs : dims.inputs;
9
16
 
17
+ let value;
18
+ let width = dims.width;
19
+ let height = dims.height;
20
+ let x = dims.margin.left;
21
+ let y = dims.margin.top;
10
22
 
23
+ let style, className;
24
+ style = `
25
+ font-family: Vazir;
26
+ font-size: 1mm;
27
+ white-space: break-spaces;
28
+ /* font-weight: bold; */
29
+ direction: rtl !important;
30
+ user-select: none;
31
+ dominant-baseline: middle;
32
+ `;
33
+ const svg = putSVG({ x, y, width, height, style })
11
34
 
12
- draw({ box }) {
13
- // همه چیز را توی کانتینر باکس آبجکت رسم کن
14
- const { container, elements, width, height } = box
15
- console.log(box);
35
+ // اگر مقدار استروک درست بود لیبل ها را چاپ کن
36
+ if (!dims.hideContext) {
37
+ dims.elements
38
+ .forEach(
39
+ element => {
40
+ switch (element.type) {
41
+ case 'text':
42
+ ({ x, y, value, style } = element);
43
+ putText({ container: svg, value, x, y, style, className: 'persian bold' });
44
+ break;
45
+ case 'line':
46
+ let { x1, y1, x2, y2 } = element;
47
+ putLine({ container: svg, x1, y1, x2, y2 });
48
+ break;
49
+ }
50
+ });
51
+ }
16
52
 
17
- elements.forEach(element => {
18
- const { name, value, x, y, style } = element;
53
+ // محل اینپوت‌های دیتا
54
+ let name;
55
+ this.inputs && this.inputs.
56
+ forEach(input => {
57
+ ({ name, x, y } = input);
58
+ putText({ container: svg, x, y, className: 'persian', name });
59
+ });
19
60
 
20
- switch (element.type) {
21
- case 'label':
22
- // const { value, x, y, style } = element
23
- putText({ container, value, x, y, style })
24
- break;
25
- case 'input':
26
- putText({ container, x, y, style, name });
61
+ // مربع احاطه‌کننده کل جدول برای راهنمای توسعه
62
+ const borderRect = putRect({
63
+ container: svg, x: 0, y: 0, width, height,
64
+ name: dims.name, className: 'no-print',
65
+ style: 'stroke: green; fill: transparent; stroke-width: 0.3;'
66
+ });
27
67
 
28
- break;
29
- default:
30
- break;
31
- }
68
+ this.borderRect = borderRect;
69
+ this.container.appendChild(svg)
70
+ }
32
71
 
33
- });
72
+ update(data) {
73
+ this.inputs.forEach(input => {
74
+ let value = data?.[input.name];
75
+ const textInput = this.container.querySelector(`text[data-name=${input.name}]`)
34
76
 
77
+ // پیدا کردن کاراکترهای رفتن به سرخط در متن
78
+ const textLines = value.toString().split(/\n|\r|\r\n/);
79
+ const x = textInput.getAttribute('x')
80
+ // اگر متن چند خطی بود
81
+ if (textLines.length >= 2) {
82
+ let y = 5;
83
+ textLines.forEach(value => {
84
+ putTspan({ container: textInput, value, x, y });
85
+ y += 6;
86
+ })
87
+ } else textInput.innerHTML = value || "";
88
+ });
35
89
  }
90
+ }
36
91
 
92
+ function putTspan({ container, value, x, y = 5, dx = 0, dy = 0, style }) {
93
+ const tspan = document.createElementNS(svgNS, "tspan");
94
+ tspan.setAttribute('x', x);
95
+ tspan.setAttribute('y', y)
96
+ tspan.textContent = value;
97
+ container && container.appendChild(tspan)
98
+ return tspan;
37
99
  }
@@ -0,0 +1,37 @@
1
+ export default class MultiText {
2
+ constructor({ box }) {
3
+ this.box = box;
4
+ this.container = box.container;
5
+ // this.draw({ box })
6
+
7
+ }
8
+
9
+
10
+
11
+
12
+ draw({ box }) {
13
+ // همه چیز را توی کانتینر باکس آبجکت رسم کن
14
+ const { container, elements, width, height } = box
15
+ console.log(box);
16
+
17
+ elements.forEach(element => {
18
+ const { name, value, x, y, style } = element;
19
+
20
+ switch (element.type) {
21
+ case 'label':
22
+ // const { value, x, y, style } = element
23
+ putText({ container, value, x, y, style })
24
+ break;
25
+ case 'input':
26
+ putText({ container, x, y, style, name });
27
+
28
+ break;
29
+ default:
30
+ break;
31
+ }
32
+
33
+ });
34
+
35
+ }
36
+
37
+ }
@@ -5,9 +5,10 @@ import putCell from "../common/putCell.js";
5
5
  import units from "./units.js";
6
6
 
7
7
  export default class Reflex {
8
- constructor({ container, side }) {
8
+ constructor({ container, side, dims }) {
9
9
  this.container = container;
10
10
  this.side = side; // این برای تعیین رنگ راست و چپ استفاده می‌شود
11
+ this.draw({dims})
11
12
  }
12
13
 
13
14
  draw({ dims }) {
@@ -6,9 +6,10 @@ import units from "./units.js";
6
6
  const svgNS = "http://www.w3.org/2000/svg";
7
7
 
8
8
  export default class Speech {
9
- constructor({ container, side = 'R' }) {
9
+ constructor({ container, side = 'R', dims }) {
10
10
  this.container = container;
11
11
  this.side = side;
12
+ this.draw({dims})
12
13
  }
13
14
 
14
15
  draw({ dims }) {
@@ -49,7 +50,6 @@ export default class Speech {
49
50
  }
50
51
  }
51
52
 
52
-
53
53
  // ایجاد ماتریکس سلول های چارت که آدرس و مختصات مرکز هر سلول را نگهداری میکند
54
54
  const matrix = [
55
55
  [],
@@ -5,12 +5,13 @@ import units from "./units.js";
5
5
  const svgNS = "http://www.w3.org/2000/svg";
6
6
 
7
7
  export default class Tympanogram {
8
- constructor({ container, side }) {
8
+ constructor({ container, side, dims }) {
9
9
  this.pressure = { min: -600, max: +400, step: 200 };
10
10
  this.compliance = { min: -0.50, max: 3, step: 0.50 };
11
11
  this.padding = { right: 5, left: 8, top: 7, bottom: 14 };
12
12
  this.container = container;
13
13
  this.side = side
14
+ this.draw({dims})
14
15
  }
15
16
 
16
17
  draw({ dims }) {
package/src/main.js CHANGED
@@ -6,7 +6,8 @@ import template from "../assets/templates/template_combo.js";
6
6
  import Tympanogram from "./Tympanogram/Tympanogram.js";
7
7
  import Speech from "./Speech/Speech.js";
8
8
  import Reflex from "./Reflex/Reflex.js";
9
- import Box from "./Box/Box.js";
9
+ import MultiText from "./MultiText/MultiText.js";
10
+
10
11
 
11
12
 
12
13
  document.querySelector('#app').innerHTML = `
@@ -40,9 +41,8 @@ let dims = {
40
41
  ]
41
42
  }
42
43
 
43
- const RSpeech = new Speech({ container, side: 'R' })
44
- RSpeech.draw({ dims })
45
- RSpeech.update({ MCL: '55', SAT: '25', SDS: '98', UCL: '120', SRT: '30' })
44
+ // const RSpeech = new Speech({ container, side: 'R' , dims})
45
+ // RSpeech.update({ MCL: '55', SAT: '25', SDS: '98', UCL: '120', SRT: '30' })
46
46
 
47
47
  dims = {
48
48
  "name": "RTympanogram",
@@ -59,8 +59,7 @@ dims = {
59
59
  "height": 60 * 6
60
60
  }
61
61
 
62
- const RTympanogram = new Tympanogram({ container, side: 'R' })
63
- RTympanogram.draw({ dims });
62
+ // const RTympanogram = new Tympanogram({ container, side: 'R', dims })
64
63
 
65
64
  dims = {
66
65
  "name": "RReflex",
@@ -77,13 +76,12 @@ dims = {
77
76
  "height": 30 * 6
78
77
  }
79
78
 
80
- const RReflex = new Reflex({ container, side: 'R' })
81
- RReflex.draw({ dims });
79
+ // const RReflex = new Reflex({ container, side: 'R' , dims})
82
80
 
83
81
  dims = {
84
- "name": "report",
82
+ "name": "patient",
85
83
  "w": 200,
86
- "h": 20,
84
+ "h": 8,
87
85
  "margin": {
88
86
  "left": 1,
89
87
  "top": 0,
@@ -92,26 +90,80 @@ dims = {
92
90
  },
93
91
  "display": "block",
94
92
  "width": 198,
95
- "height": 20,
93
+ "height": 8,
96
94
  "elements": [
97
95
  {
98
96
  "type": "text",
99
97
  "x": 198,
100
98
  "y": 5,
101
- "value": "گزارش:"
99
+ "value": "نام:"
100
+ },
101
+ {
102
+ "type": "text",
103
+ "x": 160,
104
+ "y": 5,
105
+ "value": "نام خانوادگی:"
106
+ },
107
+ {
108
+ "type": "text",
109
+ "x": 108,
110
+ "y": 5,
111
+ "value": "سن:"
112
+ },
113
+ {
114
+ "type": "text",
115
+ "x": 68,
116
+ "y": 5,
117
+ "value": "ارجاع از:"
102
118
  }
103
119
  ],
104
120
  "inputs": [
105
121
  {
106
- "name": "description",
107
- "x": 186,
122
+ "name": "name",
123
+ "x": 191,
124
+ "y": 5
125
+ },
126
+ {
127
+ "name": "lastName",
128
+ "x": 139,
129
+ "y": 5
130
+ },
131
+ {
132
+ "name": "age",
133
+ "x": 100,
134
+ "y": 5
135
+ },
136
+ {
137
+ "name": "referrer",
138
+ "x": 55,
139
+ "y": 5
140
+ }
141
+ ],
142
+ "forceInputs": [
143
+ {
144
+ "name": "name",
145
+ "x": 188,
146
+ "y": 4
147
+ },
148
+ {
149
+ "name": "lastName",
150
+ "x": 151,
151
+ "y": 5
152
+ },
153
+ {
154
+ "name": "age",
155
+ "x": 101,
156
+ "y": 5
157
+ },
158
+ {
159
+ "name": "referrer",
160
+ "x": 56,
108
161
  "y": 5
109
162
  }
110
163
  ]
111
164
  }
112
165
 
113
- // const report = new Box({ container })
114
- // report.draw({ dims });
166
+ const patient = new MultiText({ container, dims })
115
167
 
116
168
  dims = {
117
169
  "blank": false,
@@ -130,7 +182,7 @@ dims = {
130
182
  "height": 600
131
183
  }
132
184
 
133
- const RAudiogram = new Audiogram({ container, side: 'R', dims })
185
+ // const RAudiogram = new Audiogram({ container, side: 'R', dims })
134
186
  // RAudiogram.update({
135
187
  // data: {
136
188
  // // R_AC_M: { 8000: 25, 2000: 5, 1500: 0, },
package/src/Box/Box.js DELETED
@@ -1,105 +0,0 @@
1
- import putLine from "../common/putLine.js";
2
- import putRect from "../common/putRect.js";
3
- import putText from "../common/putText.js";
4
- const svgNS = "http://www.w3.org/2000/svg";
5
-
6
- export default class Box {
7
- constructor({ container }) {
8
- this.container = container;
9
- }
10
- draw({ dims, stroke = true }) {
11
- // دریافت اطلاعات مختصات چاپ ورودی ها به جز عادی محاسبه شده
12
- this.inputs = (dims.forceInsert) ? dims.forceInputs : dims.inputs
13
-
14
- let value;
15
- let width = dims.width;
16
- let height = dims.height;
17
- let x = dims.margin.left;
18
- let y = dims.margin.top;
19
-
20
- let style, className;
21
- style = `
22
- /* font-family: Arial, Helvetica, sans-serif !important; */
23
- font-size: 1mm;
24
- white-space: break-spaces;
25
- /* font-weight: bold; */
26
- direction: rtl !important;
27
- user-select: none;
28
- /* dominant-baseline: middle; /* تراز عمودی*/
29
- `;
30
- // بوردر کل چارت
31
- const svg = document.createElementNS(svgNS, "svg");
32
- svg.setAttribute("x", x);
33
- svg.setAttribute("y", y);
34
- svg.setAttribute("width", width);
35
- svg.setAttribute("height", height);
36
- svg.setAttribute('style', style)
37
- // svg.setAttribute('class', 'text-box')
38
-
39
- // اگر مقدار استروک درست بود لیبل ها را چاپ کن
40
- if (!dims.hideContext) {
41
- dims.elements
42
- .forEach(
43
- element => {
44
- switch (element.type) {
45
- case 'text':
46
- ({ x, y, value, style } = element);
47
- putText({ container: svg, value, x, y, style, className: 'persian bold' });
48
- break;
49
- case 'line':
50
- let { x1, y1, x2, y2 } = element;
51
- putLine({ container: svg, x1, y1, x2, y2 });
52
- break;
53
- }
54
- });
55
- }
56
-
57
- // محل اینپوت‌های دیتا
58
- let name;
59
- this.inputs && this.inputs.forEach(input => {
60
- ({ name, x, y } = input);
61
- putText({ container: svg, x, y, className: 'persian', name });
62
- });
63
-
64
- // مربع احاطه‌کننده کل جدول برای راهنمای توسعه
65
- const borderRect = putRect({
66
- container: svg, x: 0, y: 0, width, height,
67
- name: dims.name, className: 'no-print',
68
- style: 'stroke: transparent; fill: transparent '
69
- });
70
- this.borderRect = borderRect;
71
- // console.log(dims);
72
-
73
- this.container.appendChild(svg)
74
- // this.patient = svg;
75
-
76
- }
77
-
78
- update(data) {
79
- this.inputs.forEach(input => {
80
- let value = data?.[input.name];
81
- const textInput = this.container.querySelector(`text[data-name=${input.name}]`)
82
-
83
- // پیدا کردن کاراکترهای رفتن به سرخط در متن
84
- const textLines = value.toString().split(/\n|\r|\r\n/);
85
- const x = textInput.getAttribute('x')
86
- // اگر متن چند خطی بود
87
- if (textLines.length >= 2) {
88
- let y = 5;
89
- textLines.forEach(value => {
90
- putTspan({ container: textInput, value, x, y });
91
- y += 6;
92
- })
93
- } else textInput.innerHTML = value || "";
94
- });
95
- }
96
- }
97
-
98
- function putTspan({ container, value, x , y = 5, dx = 0, dy = 0, style }) {
99
- const tspan = document.createElementNS(svgNS, "tspan");
100
- tspan.setAttribute('x', x);
101
- tspan.setAttribute('y', y)
102
- tspan.textContent = value;
103
- container && container.appendChild(tspan)
104
- return tspan;
105
- }