hayun-vite 0.3.1 → 0.4.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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "hayun-vite",
3
3
  "private": false,
4
- "version": "0.3.1",
4
+ "version": "0.4.0",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "dev": "vite",
package/src/Form/Form.js CHANGED
@@ -11,9 +11,7 @@ const svgNS = "http://www.w3.org/2000/svg";
11
11
 
12
12
 
13
13
  export default class Form {
14
- constructor({ container, template, image } = {}) {
15
- this.image = image;
16
- // const dims = template;
14
+ constructor({ container, template } = {}) {
17
15
  this.template = template;
18
16
  this.container = container;
19
17
  this.data = {};
@@ -67,11 +65,11 @@ export default class Form {
67
65
  this.LSpeech.draw({ dims: template.LSpeech, });
68
66
  }
69
67
  if (sections.RTympanogram) {
70
- this.RTympanogram = new Tympanogram({ container: sections.RTympanogram, dims: template.RTympanogram })
68
+ this.RTympanogram = new Tympanogram({ container: sections.RTympanogram, side: 'R' })
71
69
  this.RTympanogram.draw({ dims: template.RTympanogram });
72
70
  }
73
71
  if (sections.LTympanogram) {
74
- this.LTympanogram = new Tympanogram({ container: sections.LTympanogram, dims: template.LTympanogram })
72
+ this.LTympanogram = new Tympanogram({ container: sections.LTympanogram, side: 'L' })
75
73
  this.LTympanogram.draw({ dims: template.LTympanogram });
76
74
  }
77
75
  if (sections.RReflex) {
@@ -132,25 +130,24 @@ export default class Form {
132
130
  const { left, top } = margin;
133
131
 
134
132
  const backgroundImage = this.template.backgroundImage;
133
+
135
134
  let svg = document.createElementNS(svgNS, "svg");
136
135
  svg.setAttribute("viewBox", [-left, -top, width, height])
137
136
  svg.setAttribute("style", "background-color: BlanchedAlmond");
138
- if (this.image) {
139
- let image = document.createElementNS(svgNS, "image");
140
- image.setAttribute('class', 'non-print')
141
- image.setAttribute('width', width);
142
- image.setAttribute('height', height);
137
+ if (backgroundImage) {
138
+ let image = document.createElementNS(svgNS, "image")
139
+ image.setAttribute('class', 'no-print')
140
+ image.setAttribute('width', width)
141
+ // image.setAttribute('height', height)
143
142
 
144
143
  image.setAttribute('x', 0)
145
- image.setAttribute('y', -0.6)
144
+ image.setAttribute('y', 0)
146
145
  // image.setAttribute('height', height);
147
- image.setAttribute('href', this.image);
148
-
149
- svg.appendChild(image);
150
- }
146
+ image.setAttribute('href', backgroundImage)
151
147
 
152
- // div.appendChild(svg);
153
- return svg;
148
+ svg.appendChild(image)
149
+ }
150
+ return svg
154
151
  }
155
152
 
156
153
  update({ data, officeData, patientData, sessionIndex = 0 }) {
@@ -243,29 +240,17 @@ export default class Form {
243
240
  stroke-dasharray: 0.5;
244
241
  fill: transparent;
245
242
  `;
246
- putRect({ container, x: 0, y: 0, width, height, style })
247
- // Horizontal Lines
248
- // putLine({
249
- // container: container, x1: 0, y1: margin.top,
250
- // x2: width, y2: margin.top, style: style, name: 'form-border'
251
- // })
252
- // putLine({
253
- // container: container, x1: 0, y1: height - margin.bottom,
254
- // x2: width, y2: height - margin.bottom, style: style, name: 'form-border'
255
- // })
256
- // // Vertical Lines
257
- // putLine({
258
- // container: container, x1: margin.left, y1: 0,
259
- // x2: margin.left, y2: height, style: style, name: 'form-border'
260
- // })
261
- // putLine({
262
- // container: container, x1: width - margin.right, y1: 0,
263
- // x2: width - margin.right, y2: height, style: style, name: 'form-border'
264
- // })
265
- // // Middle Line
266
- // putLine({
267
- // container: container, x1: width / 2, y1: 0,
268
- // x2: width / 2, y2: height, style: style, name: 'form-border'
269
- // })
243
+ putRect({ container, x: 0, y: 0, width, height, style, className: 'no-print' })
244
+ }
245
+
246
+ // ایجاد دکمه تاگل خطوط مرزی فرم و سکشن و المان
247
+ toggleBorders({ activeForm, container = 'form' }) {
248
+ const borders = activeForm.querySelectorAll(`[data-name="${container}-border"]`);
249
+ // آبجکت نگهداری رنگ بوردرها
250
+ const color = { form: 'black', section: 'blue', element: 'green' }
251
+ borders.forEach(border => {
252
+ // console.log(border.style.stroke);
253
+ border.style.stroke = (border.style.stroke === 'transparent') ? color[container] : 'transparent';
254
+ })
270
255
  }
271
256
  }
package/src/Form/Forms.js CHANGED
@@ -4,97 +4,74 @@ import printForm from "./printForm.js";
4
4
  import Form from "./Form.js";
5
5
  import combo from "./templates/combo.js"; // این در حقیقیت یک تمپلت هست
6
6
  import rasaAud from "./templates/rasa_audiometry.js";
7
- // import rasaAudImage from './templates/rasaAud.png'
8
- import rasaAudImage from './templates/rasa_audiometry.jpg'
7
+ import rasaTymp from './templates/rasa_tymp_reflex.js'
9
8
 
10
9
  // خط کد زیر لازم هست
11
- import '../fonts/Vazirmatn-Regular.woff2'
10
+ import './fonts/Vazirmatn-Regular.woff2'
12
11
  import '../style.css'
13
12
 
14
13
  // کلاس جدید که فرم‌های مختلف را نمایش میدهد
15
14
  export default class Forms {
16
15
  constructor({ assets, container } = {}) {
16
+ this.container = container
17
+ this.addForms({ templates: [rasaAud, rasaTymp, combo] })
18
+ }
19
+
20
+ // افزودن فرم
21
+ addForms({ templates }) {
22
+ const container = this.container
17
23
  // ایجاد یک دیو برای قرار دادن دکمه ها و لینک های فرم
18
24
  const div = document.createElement('div');
19
25
  div.style = 'border: 1px solid brown; margin: 0; padding: 0;'
20
26
  container.appendChild(div);
27
+
21
28
  // اضافه کردن دکمه به دیو فرم
22
29
  let className = 'button-form persian';
23
- const btn = [];
24
- btn[0] = this.putButton({ container: div, text: rasaAud.label, className });
25
- btn[1] = this.putButton({ container: div, text: combo.label, className });
26
- const printBtn = this.putButton({ container: div, text: 'چاپ', className });
27
-
28
- // یک دیو تعریف میکنیم که سمت ادیولاگ برای تعریف لیستنر استفاده می‌شود
29
- this.div = document.createElement('div'); // این بخش فقط شامل بخش اس‌وی‌جی هست
30
- container.appendChild(this.div)
30
+ const btns = [];
31
31
 
32
- this.forms = []; // آرایه آبجکت های فرم های مختلف
33
- this.forms.push(new Form({ container: this.div, template: rasaAud, image: rasaAudImage }));
34
- this.forms.push(new Form({ container: this.div, template: combo }));
32
+ const forms = []; // آرایه آبجکت های فرم های مختلف
33
+ this.forms = forms;
35
34
 
36
- // انتخاب فرم پیش‌فرض
37
- this.forms[0].form.style.display = 'block';
38
- this.selectedForm = this.forms[0]
39
- btn[0].style.backgroundColor = ' #1c15e1'
35
+ templates.forEach((template, index) => {
36
+ btns[index] = this.putButton({ container: div, text: template.label, className });
37
+ this.forms.push(new Form({ container, template }));
38
+ });
40
39
 
40
+ const printBtn = this.putButton({ container: div, text: 'چاپ', className });
41
41
  // تعریف رویداد دکمه چاپ فرم نمایشی
42
- printBtn.addEventListener('click', () => { printForm({ container: this.selectedForm.form }) })
43
-
44
- btn[0].addEventListener('click', () => {
45
- this.forms[1].form.style.display = 'none'
46
- btn[1].style.backgroundColor = ' #7472e2'
42
+ printBtn.addEventListener('click', () => { printForm({ container: this.selectedForm.form }) });
47
43
 
48
- // this.forms[2].form.style.display = 'none'
49
- this.forms[0].form.style.display = 'block';
50
- btn[0].style.backgroundColor = ' #1c15e1'
44
+ // انتخاب فرم پیش‌فرض
45
+ forms[1].form.style.display = 'block';
46
+ this.selectedForm = this.forms[1]
47
+ btns[1].style.backgroundColor = ' #1c15e1'
51
48
 
52
- this.selectedForm = this.forms[0];
53
- this.update(this.allData);
49
+ btns.forEach((btn, index) => {
50
+ btn.addEventListener('click', () => {
51
+ // Hide All forms
52
+ forms.forEach((form, i) => {
53
+ form.form.style.display = 'none'
54
+ btns[i].style.backgroundColor = ' #7472e2'
54
55
 
55
- });
56
+ });
56
57
 
57
- btn[1].addEventListener('click', () => {
58
- this.forms[0].form.style.display = 'none'
59
- btn[0].style.backgroundColor = ' #7472e2'
58
+ forms[index].form.style.display = 'block';
59
+ btns[index].style.backgroundColor = ' #1c15e1'
60
60
 
61
- // this.forms[2].form.style.display = 'none'
62
- this.forms[1].form.style.display = 'block';
63
- btn[1].style.backgroundColor = ' #1c15e1'
61
+ this.selectedForm = forms[index];
62
+ this.update(this.allData);
64
63
 
65
- this.selectedForm = this.forms[1];
66
- // آپدیت فرم انتخاب شده
67
- this.update(this.allData);
68
- });
69
-
70
- // btn3.addEventListener('click', () => {
71
- // this.forms[0].form.style.display = 'none'
72
- // this.forms[1].form.style.display = 'none'
73
- // this.forms[2].form.style.display = 'block';
74
- // this.selectedForm = this.forms[2]
75
- // // آپدیت فرم انتخاب شده
76
- // this.update(this.allData);
77
-
78
- // });
79
- // for Develop
80
- // this.event();
64
+ })
65
+ })
81
66
  }
67
+
82
68
  // این تابع یک بار از بیرون کلاس فراخوانی میشه و یک بار وقتی از داخل تمپلت فرم را عوض میکنیم
83
69
  update({ data, officeData, patientData, sessionIndex = 0 }) {
84
70
  // ذخیره کل دیتا برای استفاده داخلی آپدیت فرم انتخاب شده
85
71
  this.allData = { data, officeData, patientData, sessionIndex }
86
72
  this.selectedForm.update({ data, officeData, patientData, sessionIndex })
87
73
  }
88
- // ایجاد دکمه تاگل خطوط مرزی فرم و سکشن و المان
89
- toggleBorders({ activeForm, container = 'form' }) {
90
- const borders = activeForm.querySelectorAll(`[data-name="${container}-border"]`);
91
- // آبجکت نگهداری رنگ بوردرها
92
- const color = { form: 'black', section: 'blue', element: 'green' }
93
- borders.forEach(border => {
94
- // console.log(border.style.stroke);
95
- border.style.stroke = (border.style.stroke === 'transparent') ? color[container] : 'transparent';
96
- })
97
- }
74
+
98
75
  // توابع داخلی ایجاد دکمه و لینک های بالای فرم
99
76
  putButton({ container, id, text, className }) {
100
77
  const button = document.createElement('button');
@@ -6,8 +6,6 @@ const svgNS = "http://www.w3.org/2000/svg";
6
6
  export default class Reflex {
7
7
  constructor({ container }) {
8
8
  this.container = container;
9
- // this.left = dims.pad.left;
10
- // this.top = dims.pad.top;
11
9
  }
12
10
 
13
11
  draw({ dims }) {
@@ -16,14 +14,8 @@ export default class Reflex {
16
14
  let x = dims.margin.left;
17
15
  let y = dims.margin.top;
18
16
  let style;
19
- // جدولی با ۳ سطر و ۵ ستون
20
-
21
- // تقسیم بر ۶ کردم تا با عرض باکس‌های گفتار یکی باشه. وگرنه اینجا ۵ تا ستون داریم. یک ستون میدیم کپشن عمودی ستون اول
22
- const cw = width / 6; // پهنای هر خانه
23
- const ch = height / 3; // ارتفاع هر خانه
24
17
 
25
18
  const svg = document.createElementNS(svgNS, "svg");
26
- // svg.setAttribute("id", id);
27
19
  svg.setAttribute("x", x);
28
20
  svg.setAttribute("y", y);
29
21
  svg.setAttribute("width", width);
@@ -31,7 +23,8 @@ export default class Reflex {
31
23
  svg.setAttribute("class", "reflex");
32
24
 
33
25
  let lable = ["", "500", "1000", "2000", "4000"]; // مقادیر برچسب‌های سطر اول
34
- let cw1 = width / 6; // پهنای خانه‌های سطر اول
26
+ // جدولی با ۳ سطر و ۵ ستون
27
+ let cw1 = width / 5; // پهنای خانه‌های سطر اول
35
28
  let ch1 = height / 3; // ارتفاع خانه‌های سطر اول
36
29
  let ch2 = height / 3; // ارتفاع خانه‌های سطر دوم
37
30
 
@@ -48,7 +41,7 @@ export default class Reflex {
48
41
  `;
49
42
  lable.forEach((value, i) => {
50
43
  if (value != "") {
51
- let x = cw1 / 2 + cw1 * (i + 1);
44
+ let x = cw1 / 2 + cw1 * i;
52
45
  let y = ch1 / 2;
53
46
  // putText(value, x, y, "", "middle", "middle"); // با استایل تراز عمودی پایین نسبت به خط پایه
54
47
  putText({ container: svg, value, x, y, style })
@@ -68,13 +61,13 @@ export default class Reflex {
68
61
  `;
69
62
  lable = ["Freq", "IPSI", "CONTRA"];
70
63
  // چاپ برچسب‌های ستون اول
71
- putText({ container: svg, value: "Freq", x: cw1 * 2, y: ch1 / 2, style: style })
72
- putText({ container: svg, value: "IPSI", x: cw1 * 2, y: ch1 * 3 / 2, style: style })
73
- putText({ container: svg, value: "CONTRA", x: cw1 * 2, y: ch1 * 5 / 2, style: style })
64
+ putText({ container: svg, value: "Freq", x: cw1, y: ch1 / 2, style: style })
65
+ putText({ container: svg, value: "IPSI", x: cw1, y: ch1 * 3 / 2, style: style })
66
+ putText({ container: svg, value: "CONTRA", x: cw1, y: ch1 * 5 / 2, style: style })
74
67
 
75
68
  //چاپ ده باکس سطر دوم و سوم
76
69
  for (let j = 1; j <= 2; j++) {
77
- for (let i = 2; i <= 5; i++) {
70
+ for (let i = 1; i <= 4; i++) {
78
71
  let x = cw1 / 2 + cw1 * i;
79
72
  let y = ch1 * j + ch2 / 2;
80
73
  let bw = cw1 * 0.80; // پهنای هر باکس
@@ -95,7 +88,7 @@ export default class Reflex {
95
88
  `;
96
89
  let names = ["IPSI_500", "IPSI_1000", "IPSI_2000", "IPSI_4000"];
97
90
  for (let index = 0; index < 4; index++) {
98
- x = cw1 / 2 + cw1 * (index + 2);
91
+ x = cw1 / 2 + cw1 * (index + 1);
99
92
  y = ch1 + ch2 / 2;
100
93
  putText({ container: svg, value: "", x: x, y: y, style: style, name: names[index] })
101
94
  }
@@ -106,11 +99,11 @@ export default class Reflex {
106
99
 
107
100
  for (let index = 0; index < 4; index++) {
108
101
  // const idValue = idValues[index];
109
- x = cw1 / 2 + cw1 * (index + 2);
102
+ x = cw1 / 2 + cw1 * (index + 1);
110
103
  y = ch1 * 2 + ch2 / 2;
111
104
  putText({ container: svg, value: "", x: x, y: y, style: style, name: names[index] })
112
105
  }
113
- // مربع احاطه‌کننده کل جدول برای راهنمای توسعه
106
+ // مربع احاطه‌کننده کل جدول برای راهنمای توسعه و دریافت رویداد کلیک روی فرم
114
107
  style = 'fill: transparent; stroke: green; stroke-width: 0.5;';
115
108
  putRect({ container: svg, x: 0, y: 0, width, height, style, name: dims.name })
116
109
  this.container.appendChild(svg);
@@ -130,13 +123,10 @@ export default class Reflex {
130
123
  }
131
124
 
132
125
  update(data) {
133
- this.chart.querySelector(`text[data-name="IPSI_500"]`).innerHTML = data?.IPSI?.["500"] || "";
134
- this.chart.querySelector(`text[data-name="IPSI_1000"]`).innerHTML = data?.IPSI?.["1000"] || "";
135
- this.chart.querySelector(`text[data-name="IPSI_2000"]`).innerHTML = data?.IPSI?.["2000"] || "";
136
- this.chart.querySelector(`text[data-name="IPSI_4000"]`).innerHTML = data?.IPSI?.["4000"] || "";
137
- this.chart.querySelector(`text[data-name="CONTRA_500"]`).innerHTML = data?.CONTRA?.["500"] || "";
138
- this.chart.querySelector(`text[data-name="CONTRA_1000"]`).innerHTML = data?.CONTRA?.["1000"] || "";
139
- this.chart.querySelector(`text[data-name="CONTRA_2000"]`).innerHTML = data?.CONTRA?.["2000"] || "";
140
- this.chart.querySelector(`text[data-name="CONTRA_4000"]`).innerHTML = data?.CONTRA?.["4000"] || "";
126
+ for (const key in data) {
127
+ for (const freq in data[key]) {
128
+ this.chart.querySelector(`text[data-name=${key}_${freq}]`).innerHTML = data?.[key]?.[freq] || "";
129
+ }
130
+ }
141
131
  }
142
132
  }
@@ -1,3 +1,5 @@
1
+ import putRect from "../common/putRect";
2
+
1
3
  export default class Sections {
2
4
  constructor({ container, dims }) {
3
5
  this.dims = dims
@@ -44,17 +46,11 @@ export default class Sections {
44
46
  // نگهداری مختصات رسم بوردر هر سکشن برای استفاده در متد داخلی رسم بودر تاپ لایر
45
47
  this.cords.push({ name: name, width: width, height: height, x: this.left, y: this.top });
46
48
 
47
- // بوردر راهنما
48
- let rect = document.createElementNS(svgNS, "rect");
49
- rect.setAttribute("x", 0);
50
- rect.setAttribute("y", 0);
51
- rect.setAttribute("width", width);
52
- rect.setAttribute("height", height);
53
- rect.setAttribute("fill", "transparent");
54
- rect.setAttribute("stroke", "blue");
55
- rect.setAttribute("stroke-width", "0.1mm");
56
- rect.setAttribute("data-name", "section-border");
57
- svg.appendChild(rect);
49
+ putRect({
50
+ container: svg, x: 0, y: 0, width, height,
51
+ style: 'fill: transparent; stroke: blue; stroke-width: 0.2',
52
+ className: 'no-print'
53
+ })
58
54
  this[name] = svg;
59
55
  this.container.appendChild(svg)
60
56
 
@@ -82,7 +82,6 @@ export default class Speech {
82
82
  // اینپوت‌ها
83
83
  style += 'text-anchor: middle; dominant-baseline: middle; /* تراز عمودی*/ ';
84
84
 
85
-
86
85
  // New
87
86
  if (!dims.forceInsert) {
88
87
  let index = 0;
@@ -102,7 +101,8 @@ export default class Speech {
102
101
  }
103
102
  // مربع احاطه‌کننده کل جدول برای راهنمای توسعه
104
103
  style = 'fill: transparent; stroke: green; stroke-width: 0.5;';
105
- putRect({ container: svg, x: 0, y: 0, width, height, style, name: dims.name })
104
+ let className = 'no-print'
105
+ putRect({ container: svg, x: 0, y: 0, width, height, style, name: dims.name, className })
106
106
  this.chart = svg;
107
107
  this.container.appendChild(svg);
108
108
 
@@ -50,7 +50,7 @@ export default class TextBox {
50
50
  });
51
51
 
52
52
  // مربع احاطه‌کننده کل جدول برای راهنمای توسعه
53
- const borderRect = putRect({ container: svg, x: 0, y: 0, width, height, name: dims.name });
53
+ const borderRect = putRect({ container: svg, x: 0, y: 0, width, height, name: dims.name, className: 'no-print' });
54
54
  this.borderRect = borderRect;
55
55
  // console.log(dims);
56
56
 
@@ -3,11 +3,12 @@ import putText from "../common/putText.js";
3
3
  const svgNS = "http://www.w3.org/2000/svg";
4
4
 
5
5
  export default class Tympanogram {
6
- constructor({ container } = {}) {
6
+ constructor({ container, side }) {
7
7
  this.pressure = { min: -600, max: +400, step: 200 };
8
8
  this.compliance = { min: -0.50, max: 3, step: 0.50 };
9
9
  this.padding = { right: 5, left: 8, top: 7, bottom: 14 };
10
10
  this.container = container;
11
+ this.side = side
11
12
  }
12
13
 
13
14
  draw({ dims }) {
@@ -30,7 +31,7 @@ export default class Tympanogram {
30
31
  svg.setAttribute("x", x);
31
32
  svg.setAttribute("y", y);
32
33
  svg.setAttribute("viewBox", [-padding.left, -padding.top, width, height]);
33
-
34
+
34
35
 
35
36
 
36
37
  const pressureAxiosLength = {
@@ -191,8 +192,8 @@ export default class Tympanogram {
191
192
  // console.log(this.container);
192
193
  // مربع احاطه‌کننده کل جدول برای راهنمای توسعه
193
194
  style = 'fill: transparent; stroke: green; stroke-width: 0.5;';
194
- // یک بوردر راهنمای توسعه برای اس‌ وی جی به تمام پهنا و ارتفاع رسم می‌کنیم
195
- putRect({ container: svg, x: -padding.left, y: -padding.top, width, height, name: dims.name, style })
195
+ // یک بوردر راهنمای توسعه برای اس‌ وی جی به تمام پهنا و ارتفاع رسم می‌کنیم
196
+ putRect({ container: svg, x: -padding.left, y: -padding.top, width, height, name: dims.name, style })
196
197
  this.chart = svg;
197
198
  this.container.appendChild(svg);
198
199
 
@@ -236,13 +237,10 @@ export default class Tympanogram {
236
237
 
237
238
  // جایگذاری مقادیر تمپانومتری در تکست‌باکس ها
238
239
  this.chart.querySelector(`text[data-name="Type"]`).innerHTML = data?.type || "";
239
- // container.getElementById(container.id + "_Type").innerHTML = data?.Type || "";
240
240
  this.chart.querySelector(`text[data-name="ECV"]`).innerHTML = data?.ECV || "";
241
241
  this.chart.querySelector(`text[data-name="MEP"]`).innerHTML = data?.MEP || "";
242
242
  this.chart.querySelector(`text[data-name="SC"]`).innerHTML = data?.SC || "";
243
243
  this.chart.querySelector(`text[data-name="G"]`).innerHTML = data?.G || "";
244
- // container.getElementById(container.id + "_SC").innerHTML = data?.SC || "";
245
- // document.getElementById(container + "_G").innerHTML = data.G;
246
244
  // پاک کردن منحنی قبلی از کانتینر جاری
247
245
  this.chart.querySelector(`path[data-name="curve"]`)?.remove();
248
246
  // رسم منحنی
@@ -312,7 +310,7 @@ export default class Tympanogram {
312
310
  let path = document.createElementNS(svgNS, "path");
313
311
  path.setAttribute("fill", "none");
314
312
  path.setAttribute("data-name", "curve");
315
- let color = ("R" == "R") ? "brown" : "blue";
313
+ let color = (this.side == "R") ? "red" : "blue";
316
314
  path.setAttribute("stroke", color);
317
315
  path.setAttribute("stroke-width", "0.5px");
318
316
  path.setAttribute(
@@ -4,6 +4,7 @@ export default function printForm({ container }) {
4
4
  iframe.style.display = "block";
5
5
  let style = `
6
6
  @import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@100..900&display=swap');
7
+ font-display: auto;
7
8
 
8
9
  @page {
9
10
 
@@ -42,7 +43,7 @@ export default function printForm({ container }) {
42
43
  padding: 0;
43
44
  break-inside: avoid;
44
45
  }
45
- .non-print {
46
+ .no-print {
46
47
  display: none;
47
48
  }
48
49
 
@@ -1,10 +1,10 @@
1
- import audDims from "../../Audiogram/dims.js";
1
+ import audDims from "../../Audiogram/dims.js"
2
+ import image from './rasa_audiometry.jpg'
2
3
 
3
-
4
- const templateRasaAud = {
4
+ const rasaAud = {
5
5
  name: 'rasa_audiometry',
6
6
  label: 'ادیومتری رسا',
7
- backgroundImage: 'backgroundImage',
7
+ backgroundImage: image, // Just Path of image
8
8
  margin: { left: 0, top: 0, right: 0, bottom: 0 },
9
9
  paper: { type: 'A4', case: 'portrait', width: 209, height: 294.5 },
10
10
 
@@ -238,11 +238,11 @@ const templateRasaAud = {
238
238
 
239
239
  }
240
240
 
241
- templateRasaAud.calc1()
242
- templateRasaAud.calc2()
243
- templateRasaAud.calcSectionsArray()
241
+ rasaAud.calc1()
242
+ rasaAud.calc2()
243
+ rasaAud.calcSectionsArray()
244
244
 
245
245
  // پهنا و ارتفاع قابل استفاده منهای پد ها میشه پهنا و ارتفاع اصلی
246
246
 
247
- export default templateRasaAud;
247
+ export default rasaAud;
248
248
 
@@ -0,0 +1,199 @@
1
+ import audDims from "../../Audiogram/dims.js"
2
+ import image from './rasa_tymp_reflex.jpg'
3
+
4
+ const rasaTymp = {
5
+ name: 'combo',
6
+ label: 'تمپانومتری رسا',
7
+ backgroundImage: image, // Just Path of image
8
+ margin: { left: 0, top: 0, right: 0, bottom: 0 },
9
+ paper: { type: 'A4', case: 'portrait', width: 209, height: 294.5 },
10
+
11
+ // Printable Dimention
12
+ calc1: function () {
13
+ this.width = this.paper.width - (this.margin.left + this.margin.right);
14
+ this.height = this.paper.height - (this.margin.top + this.margin.bottom);
15
+ let width = this.width;
16
+ // ابعاد و پدینگ المنت ها
17
+ // فضای خالی
18
+ this.blank = {
19
+ name: 'blank',
20
+ w: width, h: 20,
21
+ margin: { left: 0, top: 0, right: 0, bottom: 0 },
22
+ display: 'block',
23
+ }
24
+ this.header = {
25
+ // hideContext: true,
26
+ name: 'header',
27
+ w: width, h: 20,
28
+ margin: { left: 0, top: 0, right: 0, bottom: 0 },
29
+ display: 'block',
30
+ }
31
+ this.patient = {
32
+ name: 'patient',
33
+ w: width, h: 10,
34
+ margin: { left: 5, top: 1, right: 5, bottom: 1},
35
+ display: 'block',
36
+ }
37
+ this.history = {
38
+ name: 'history',
39
+ w: width, h: 10,
40
+ margin: { left: 1, top: 1, right: 1, bottom: 1 },
41
+ display: 'block',
42
+ }
43
+
44
+ this.RTympanogram = {
45
+ name: 'RTympanogram',
46
+ w: width / 2, h: 60,
47
+ margin: { left: 5, top: 2, right: 3, bottom: 2 },
48
+ display: 'inline',
49
+ }
50
+
51
+ this.LTympanogram = {
52
+ name: 'LTympanogram',
53
+ w: width / 2, h: 60,
54
+ margin: { left: 3, top: 2, right: 5, bottom: 2 },
55
+ display: 'block',
56
+ }
57
+ this.RReflex = {
58
+ name: 'RReflex',
59
+ w: width / 2, h: 30,
60
+ margin: { left: 5, top: 2, right: 3, bottom: 2 },
61
+ display: 'inline'
62
+ }
63
+
64
+ this.LReflex = {
65
+ name: 'LReflex',
66
+ w: width / 2, h: 30,
67
+ margin: { left: 3, top: 2, right: 5, bottom: 2 },
68
+ display: 'block'
69
+ }
70
+
71
+ this.report = {
72
+ name: 'report',
73
+ w: width, h: 20,
74
+ margin: { left: 1, top: 1, right: 1, bottom: 1 },
75
+ display: 'block'
76
+ }
77
+
78
+ this.footer = {
79
+ name: 'footer',
80
+ w: width, h: 10,
81
+ margin: { left: 1, top: 1, right: 1, bottom: 1 },
82
+ display: 'block'
83
+ }
84
+ },
85
+
86
+ calc2: function () {
87
+ // let dims = this.dims;
88
+ let width, height;
89
+
90
+ width = this.header.width = this.getWidth(this.header)
91
+ height = this.header.height = this.getHeight(this.header)
92
+
93
+ this.header.elements = [
94
+ { type: 'line', x1: 0, y1: height, x2: width, y2: height },
95
+ { type: 'text', x: 30, y: 5, value: 'تاریخ :' },
96
+ ]
97
+ this.header.inputs = [
98
+ { name: 'officeName', x: width - 20, y: height - 10 },
99
+ { name: 'date', x: 20, y: 5 },
100
+ ]
101
+
102
+ width = this.patient.width = this.getWidth(this.patient)
103
+ this.patient.height = this.getHeight(this.patient)
104
+ this.patient.elements = [
105
+ { type: 'line', x1: 0, y1: 20, x2: width, y2: 20 },
106
+ { type: 'text', x: width, y: 5, value: 'نام:' },
107
+ { type: 'text', x: width - 30, y: 5, value: 'نام خانوادگی:' },
108
+ { type: 'text', x: width - 90, y: 5, value: 'سن:' },
109
+ { type: 'text', x: width - 130, y: 5, value: 'ارجاع از:' }
110
+ ]
111
+ this.patient.inputs = [
112
+ { name: 'name', x: width - 5, y: 5 },
113
+ { name: 'lastName', x: width - 47, y: 5 },
114
+ { name: 'age', x: width - 97, y: 5 },
115
+ { name: 'referrer', x: width - 142, y: 5 }
116
+ ]
117
+ this.patient.forceInputs = [
118
+ { name: 'name', x: width - 10, y: 4 },
119
+ { name: 'lastName', x: width - 47, y: 5 },
120
+ { name: 'age', x: width - 97, y: 5 },
121
+ { name: 'referrer', x: width - 142, y: 5 }
122
+ ]
123
+
124
+ width = this.history.width = this.getWidth(this.history)
125
+ this.history.height = this.getHeight(this.history)
126
+ this.history.elements = [
127
+ { type: 'line', x1: 0, y1: 20, x2: width, y2: 20 },
128
+ { type: 'text', x: width, y: 5, value: 'شرح حال:' },
129
+ ]
130
+ this.history.inputs = [
131
+ { name: 'description', x: width - 13, y: 5 },
132
+ ]
133
+
134
+ width = this.RTympanogram.width = this.getWidth(this.RTympanogram)
135
+ this.RTympanogram.height = this.getHeight(this.RTympanogram)
136
+ width = this.LTympanogram.width = this.getWidth(this.LTympanogram)
137
+ this.LTympanogram.height = this.getHeight(this.LTympanogram)
138
+
139
+ width = this.RReflex.width = this.getWidth(this.RReflex)
140
+ this.RReflex.height = this.getHeight(this.RReflex)
141
+ width = this.LReflex.width = this.getWidth(this.LReflex)
142
+ this.LReflex.height = this.getHeight(this.LReflex)
143
+
144
+ width = this.report.width = this.getWidth(this.report)
145
+ this.report.height = this.getHeight(this.report)
146
+ this.report.elements = [
147
+ { type: 'text', x: width, y: 5, value: 'گزارش:' },
148
+ ]
149
+ this.report.inputs = [
150
+ { name: 'description', x: width - 10, y: 5 },
151
+ ]
152
+
153
+ width = this.footer.width = this.getWidth(this.footer)
154
+ this.footer.height = this.getHeight(this.footer)
155
+ this.footer.elements = [
156
+ { type: 'line', x1: 0, y1: 0, x2: width, y2: 0 },
157
+ { type: 'text', x: width, y: 5, value: 'آدرس:' },
158
+ { type: 'text', x: width - 120, y: 5, value: 'تلفن:' },
159
+ ]
160
+ this.footer.inputs = [
161
+ { name: 'address', x: width - 10, y: 5 },
162
+ { name: 'tel', x: width - 128, y: 5 },
163
+ ]
164
+ },
165
+
166
+ getWidth: function (element) {
167
+ return (element.w - (element.margin.left + element.margin.right))
168
+ },
169
+ getHeight: function (element) {
170
+ return (element.h - (element.margin.top + element.margin.bottom))
171
+ },
172
+
173
+ calcSectionsArray: function () {
174
+ // این آرایه دقیقا ترتیب قرارگیری سکشن ها را بدون اون اوردر قبلی تعیین میکند
175
+ this.sections = [
176
+ this.blank,
177
+ this.patient,
178
+ // this.history,
179
+ // this.RAudiogram,
180
+ // this.LAudiogram,
181
+ // this.RSpeech,
182
+ // this.LSpeech,
183
+ this.RTympanogram, this.LTympanogram,
184
+ this.RReflex, this.LReflex,
185
+ // this.report,
186
+ // this.footer
187
+
188
+ ]
189
+ },
190
+
191
+ }
192
+
193
+ rasaTymp.calc1()
194
+ rasaTymp.calc2()
195
+ rasaTymp.calcSectionsArray()
196
+ // پهنا و ارتفاع قابل استفاده منهای پد ها میشه پهنا و ارتفاع اصلی
197
+
198
+ export default rasaTymp;
199
+
@@ -1,12 +1,13 @@
1
1
  const svgNS = "http://www.w3.org/2000/svg";
2
2
 
3
- export default function putRect({ container, x, y, width, height, style = 'fill: transparent; stroke: green; stroke-width: 0.5;', name }) {
3
+ export default function putRect({ container, x, y, width, height, style = 'fill: transparent; stroke: green; stroke-width: 0.5;', name, className }) {
4
4
  let rect = document.createElementNS(svgNS, "rect");
5
5
  rect.setAttribute("x", x);
6
6
  rect.setAttribute("y", y);
7
7
  rect.setAttribute("width", width);
8
8
  rect.setAttribute("height", height);
9
9
  rect.setAttribute("style", style);
10
+ className && rect.setAttribute("class", className);
10
11
  rect.setAttribute("data-name", name);
11
12
  container.appendChild(rect);
12
13
  return rect;
package/src/style.css CHANGED
@@ -1,8 +1,9 @@
1
1
  @font-face {
2
2
  font-family: vazirmatn;
3
3
  src:
4
- url("./fonts/Vazirmatn-Regular.woff2") format("woff2"),
5
- url('./fonts/Vazirmatn-Regular.woff') format('woff');
4
+ url("fonts/Vazirmatn-Regular.woff2") format("woff2"),
5
+ url('fonts/Vazirmatn-Regular.woff') format('woff');
6
+ font-display: swap;
6
7
 
7
8
  }
8
9
 
@@ -32,6 +33,28 @@
32
33
  font-weight: bold;
33
34
  }
34
35
 
36
+ .container {
37
+ display: flex;
38
+ /* Use flexbox to align items */
39
+ align-items: center;
40
+ /* Center items vertically */
41
+ }
42
+
43
+ .left {
44
+ /* background-color: lightblue; */
45
+ padding: 20px;
46
+ margin-right: 10px;
47
+ /* Space between the two divs */
48
+ }
49
+
50
+ .right {
51
+ /* background-color: lightgreen; */
52
+ margin-left: 10px;
53
+
54
+ /* padding: 20px; */
55
+ }
56
+
57
+
35
58
  /* :root {
36
59
  font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
37
60
  line-height: 1.5;
@@ -149,4 +172,4 @@ button:focus-visible {
149
172
 
150
173
  /* body {
151
174
  font-family: vazirmatn;
152
- } */
175
+ } */
File without changes