hayun-vite 0.1.3 → 0.3.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.1.3",
4
+ "version": "0.3.0",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "dev": "vite",
@@ -2,14 +2,11 @@ import putLine from "../common/putLine.js";
2
2
  import putPoint from "../common/putPoint.js";
3
3
  import putRect from "../common/putRect.js";
4
4
  import getAllSymbolsSVG from "../Symbol/getAllSymbolsSVG.js";
5
-
6
5
  const svgNS = "http://www.w3.org/2000/svg";
7
6
 
8
7
  export default class AudiogramChart {
9
8
  constructor({ container, side, x = 0, y = 0, pname, events = true, dims }) {
10
-
11
9
  const { width, height, chartPadding, symbolDims, vFrequency, vToFreq, freqToV, intensity, styles } = dims;
12
-
13
10
  x = dims.margin.left
14
11
  y = dims.margin.top
15
12
 
@@ -25,100 +22,76 @@ export default class AudiogramChart {
25
22
  this.side = side;
26
23
  let style;
27
24
 
28
-
29
25
  const xArea = { min: chartPadding.left, max: width - (chartPadding.right) }
30
-
31
26
  const yArea = { min: chartPadding.top, max: height - (chartPadding.bottom) }
32
27
  const xAxiosLength = { mm: width - (chartPadding.left + chartPadding.right), hz: 14 }
33
28
  const yAxiosLength = height
34
-
35
29
  const vFrequencyAxiosLength = {
36
30
  mm: width - (chartPadding.left + chartPadding.right),
37
31
  hz: vFrequency.max - vFrequency.min
38
32
  }
39
33
  this.vFrequencyAxiosLength = vFrequencyAxiosLength;
40
-
41
34
  const intensityAxiosLength = {
42
35
  mm: height - (chartPadding.top + chartPadding.bottom),
43
36
  db: intensity.max - intensity.min,
44
37
  }
45
38
  this.intensityAxiosLength = intensityAxiosLength;
46
-
47
39
  const svg = document.createElementNS(svgNS, "svg");
48
- this.svg = svg;
49
-
40
+ this.svg = svg; // کل نودی که به کانتینر اپند میشه
50
41
  svg.setAttribute("width", width);
51
42
  svg.setAttribute("height", height);
52
43
  svg.setAttribute("x", x);
53
44
  svg.setAttribute("y", y);
54
45
  svg.setAttribute("viewBox", [-chartPadding.left, -chartPadding.top, width, height]);
55
46
 
56
- // محدوده مختصات خطوط جدول
57
- const chartArea = putRect({
58
- container: svg,
59
- x: this.getX(vFrequency.min), y: this.getY(intensity.min),
60
- width: vFrequencyAxiosLength.mm, height: intensityAxiosLength.mm,
61
- style: 'stroke-width: 0.4; stroke: gray; fill: transparent'
62
- })
63
47
 
64
48
  const currentPointer = putPoint({ container: svg, x: 0, y: 0, r: 4, color: 'black' });
65
49
  this.currentPointer = currentPointer;
66
-
67
- // رسم خطوط افقی از بالا به پایین
68
- let x1 = this.getX(vFrequency.min);
69
- let x2 = this.getX(vFrequency.max);
70
- for (let i = intensity.min; i <= intensity.max; i += intensity.step) {
71
- const y1 = this.getY(i)
72
- const y2 = y1
73
- putLine({ container: svg, x1, y1, x2, y2, style: styles.line })
74
- }
75
-
76
- // رسم خطوط عمودی از چپ به راست
77
- let y1 = this.getY(intensity.min)
78
- let y2 = this.getY(intensity.max)
79
- for (let f = vFrequency.min; f <= vFrequency.max; f += vFrequency.step) {
80
- const x1 = this.getX(f)
81
- const x2 = x1
82
- putLine({ container: svg, x1, y1, x2, y2, style: styles.line })
50
+ // برای فرم‌های پیش چاپ شده
51
+ if (!dims.blank) {
52
+ // محدوده مختصات خطوط جدول
53
+ const chartArea = putRect({
54
+ container: svg,
55
+ x: this.getX(vFrequency.min), y: this.getY(intensity.min),
56
+ width: vFrequencyAxiosLength.mm, height: intensityAxiosLength.mm,
57
+ style: 'stroke-width: 0.4; stroke: gray; fill: transparent'
58
+ })
59
+ // رسم خطوط افقی از بالا به پایین
60
+ let x1 = this.getX(vFrequency.min);
61
+ let x2 = this.getX(vFrequency.max);
62
+ for (let i = intensity.min; i <= intensity.max; i += intensity.step) {
63
+ const y1 = this.getY(i)
64
+ const y2 = y1
65
+ putLine({ container: svg, x1, y1, x2, y2, style: styles.line })
66
+ }
67
+ // رسم خطوط عمودی از چپ به راست
68
+ let y1 = this.getY(intensity.min)
69
+ let y2 = this.getY(intensity.max)
70
+ for (let f = vFrequency.min; f <= vFrequency.max; f += vFrequency.step) {
71
+ const x1 = this.getX(f)
72
+ const x2 = x1
73
+ putLine({ container: svg, x1, y1, x2, y2, style: styles.line })
74
+ }
83
75
  }
84
-
85
76
  // یک بوردر راهنمای توسعه برای اس‌ وی جی به تمام پهنا و ارتفاع رسم می‌کنیم
86
77
  // این مربع مرزی را آخرین ایجاد میکنیم تا بالاترین لایه باشد و روی ریودادها درست عمل کند
87
- const borderRect = putRect({ container: svg, x: -chartPadding.left, y: -chartPadding.top, width, height, name: 'RAudiogram' });
78
+ const borderRect = putRect({ container: svg, x: -chartPadding.left, y: -chartPadding.top, width, height, name: 'RAudiogram', style: style = 'fill: transparent;' });
88
79
  this.borderRect = borderRect;
89
-
90
80
  // ایجاد رویدادها روی فقط چارت جدول
91
81
  borderRect.addEventListener('mousemove', (e) => {
92
82
  const x = e.offsetX
93
83
  const y = e.offsetY
94
-
95
84
  currentPointer.setAttribute('cx', x - chartPadding.left)
96
85
  currentPointer.setAttribute('cy', y - chartPadding.top)
97
86
  console.log('x:', x, 'f:', getFreq(x));
98
- // تبدیل مختصات به مختصات فرکانس و شدت
99
-
100
87
  })
101
88
 
89
+ container && container.appendChild(svg);
90
+
102
91
  // تبدیل مقدار ایکس مختصات به فرکانس
103
92
  function getFreq(x) {
104
93
  return vToFreq[Math.round((x - xArea.min) * (xAxiosLength.hz / xAxiosLength.mm))]
105
94
  }
106
-
107
- container && container.appendChild(svg);
108
-
109
- // تست تابع آپدیت
110
- // this.update({
111
- // data: {
112
- // // R_AC_M: { 8000: 25, 2000: 5, 1500: 0, },
113
- // R_AC: { 1000: 25, 500: 15, 750: 20, 250: 10, 6000: 35, 2000: 45 },
114
- // R_AC_NR: { 1500: 85 },
115
- // R_BC_M: { 2000: 25, 6000: 25 },
116
- // R_BC_M_NR: { 3000: 85 },
117
- // R_BC: { 1000: 20, 500: 10, 750: 15, 250: 5, 4000: 20 },
118
- // },
119
- // side: this.side,
120
- // })
121
-
122
95
  }
123
96
 
124
97
  getX(f) {
@@ -132,12 +105,15 @@ export default class AudiogramChart {
132
105
  }
133
106
 
134
107
  update({ data, side }) {
108
+ // پاک کردن نودهای سمبل دیتای قبلی در صورت وجود از نود مربوطه
109
+ this.svg.querySelectorAll('[data-name=symbol]').forEach(symbol => symbol.remove())
110
+ // پاک کردن خطوط اتصال دیتای قبلی در صورت وجود از نود مربوطه
111
+ this.svg.querySelectorAll('[data-name=junction]').forEach(symbol => symbol.remove())
112
+
113
+
135
114
  const junctions = { AC: {}, BC: {}, side };
136
115
  this.junctions = junctions;
137
- // console.log(data);
138
-
139
116
  for (const symbolName in data) {
140
-
141
117
  for (const freq in data[symbolName]) {
142
118
  const x = this.getX(this.freqToV[freq]);
143
119
  const y = this.getY(data[symbolName][freq]);
@@ -150,10 +126,8 @@ export default class AudiogramChart {
150
126
  }
151
127
  }
152
128
  this.drawJunctions();
153
-
154
129
  // بالا آوردن مستطیل احاطه کننده به بالاترین لایه برای دریافت صحیح رویدادهای موس
155
130
  this.svg.appendChild(this.borderRect)
156
-
157
131
  }
158
132
 
159
133
  drawJunctions() {
@@ -173,7 +147,7 @@ export default class AudiogramChart {
173
147
  type === "BC"
174
148
  ? this.styles.juncDashLine + `stroke: ${color}`
175
149
  : this.styles.juncLine + `stroke: ${color}`;
176
- x1 && !NR1 && !NR2 && putLine({ container: this.svg, x1, y1, x2, y2, style });
150
+ x1 && !NR1 && !NR2 && putLine({ container: this.svg, x1, y1, x2, y2, style, name: 'junction' });
177
151
  }
178
152
  }
179
153
  }
@@ -43,7 +43,8 @@ const dims = {
43
43
  juncLine: `stroke-width: 1; stroke-opacity: 0.8;`,
44
44
  }
45
45
  },
46
- rasa: {
46
+ rasa_audiometry: {
47
+ blank: true, // define Blank Chart for PrePrinted Chart, Lines do not draw
47
48
  // width: 70.6,
48
49
  // height: 70,
49
50
  // margin: { left: 17, top: 18.5, },
package/src/Form/Form.js CHANGED
@@ -142,7 +142,7 @@ export default class Form {
142
142
  image.setAttribute('height', height);
143
143
 
144
144
  image.setAttribute('x', 0)
145
- image.setAttribute('y', 0)
145
+ image.setAttribute('y', -0.6)
146
146
  // image.setAttribute('height', height);
147
147
  image.setAttribute('href', this.image);
148
148
 
@@ -174,6 +174,7 @@ export default class Form {
174
174
  gender: patientData?.gender,
175
175
  age: patientData.sessions[sessionIndex]?.age,
176
176
  referrer: patientData.sessions[sessionIndex]?.referrer,
177
+ date: new Date().toLocaleDateString('fa-IR'),
177
178
 
178
179
  },
179
180
  footer: {
package/src/Form/Forms.js CHANGED
@@ -3,8 +3,10 @@ const svgNS = "http://www.w3.org/2000/svg";
3
3
  import printForm from "./printForm.js";
4
4
  import Form from "./Form.js";
5
5
  import combo from "./templates/combo.js"; // این در حقیقیت یک تمپلت هست
6
- import rasaAud from "./templates/rasaAud.js";
7
- import rasaAudImage from './templates/rasaAud.png'
6
+ import rasaAud from "./templates/rasa_audiometry.js";
7
+ // import rasaAudImage from './templates/rasaAud.png'
8
+ import rasaAudImage from './templates/rasa_audiometry.png'
9
+
8
10
  // خط کد زیر لازم هست
9
11
  import '../fonts/Vazirmatn-Regular.woff2'
10
12
  import '../style.css'
@@ -32,10 +34,9 @@ export default class Forms {
32
34
  this.forms.push(new Form({ container: this.div, template: combo }));
33
35
 
34
36
  // انتخاب فرم پیش‌فرض
35
- this.forms[1].form.style.display = 'block';
36
- this.selectedForm = this.forms[1]
37
- btn[1].style.backgroundColor = ' #1c15e1'
38
-
37
+ this.forms[0].form.style.display = 'block';
38
+ this.selectedForm = this.forms[0]
39
+ btn[0].style.backgroundColor = ' #1c15e1'
39
40
 
40
41
  // تعریف رویداد دکمه چاپ فرم نمایشی
41
42
  printBtn.addEventListener('click', () => { printForm({ container: this.selectedForm.form }) })
@@ -76,13 +77,7 @@ export default class Forms {
76
77
 
77
78
  // });
78
79
  // for Develop
79
- this.event();
80
- }
81
-
82
- event() {
83
- this.div.addEventListener('click', (e) => {
84
- console.log(e.target);
85
- })
80
+ // this.event();
86
81
  }
87
82
  // این تابع یک بار از بیرون کلاس فراخوانی میشه و یک بار وقتی از داخل تمپلت فرم را عوض میکنیم
88
83
  update({ data, officeData, patientData, sessionIndex = 0 }) {
@@ -102,21 +97,11 @@ export default class Forms {
102
97
  }
103
98
  // توابع داخلی ایجاد دکمه و لینک های بالای فرم
104
99
  putButton({ container, id, text, className }) {
105
-
106
100
  const button = document.createElement('button');
107
101
  button.setAttribute('id', id);
108
102
  className && button.setAttribute('class', className);
109
103
  button.innerHTML = text;
110
-
111
- // button.addEventListener('mouseenter', () => {
112
- // button.style.backgroundColor = 'rgb(54, 115, 115)'; // Change color on hover
113
- // });
114
- // button.addEventListener('mouseleave', () => {
115
- // button.style.backgroundColor = 'rgb(0, 149, 149)'; // Revert color when not hovering
116
- // });
117
-
118
104
  container.appendChild(button);
119
105
  return button;
120
-
121
106
  }
122
107
  }
@@ -2,11 +2,11 @@ import audDims from "../../Audiogram/dims.js";
2
2
 
3
3
 
4
4
  const templateRasaAud = {
5
- name: 'rasa',
5
+ name: 'rasa_audiometry',
6
6
  label: 'ادیومتری رسا',
7
7
  backgroundImage: 'backgroundImage',
8
8
  margin: { left: 0, top: 0, right: 0, bottom: 0 },
9
- paper: { type: 'A4', case: 'portrait', width: 210, height: 296 },
9
+ paper: { type: 'A4', case: 'portrait', width: 209, height: 294.5 },
10
10
 
11
11
  // Printable Dimention
12
12
  calc1: function () {
@@ -55,8 +55,8 @@ const templateRasaAud = {
55
55
  audDims[this.name],
56
56
  {
57
57
  name: 'RAudiogram',
58
- w: width / 2, h: 100,
59
- margin: { left: 17, top: 18.5, right: 17.2, bottom: 11.5 },
58
+ w: width / 2, h: 99,
59
+ margin: { left: 18.1, top: 18.5, right: 16.4, bottom: 11.2 },
60
60
  display: 'inline',
61
61
  });
62
62
 
@@ -65,8 +65,8 @@ const templateRasaAud = {
65
65
  audDims[this.name],
66
66
  {
67
67
  name: 'LAudiogram',
68
- w: width / 2, h: 100, // پهنای سکشن هست
69
- margin: { left: 17.7, top: 18.5, right: 16.8, bottom: 11.5 },
68
+ w: width / 2, h: 99, // پهنای سکشن هست
69
+ margin: { left: 18.2, top: 18.5, right: 16.4, bottom: 11.2 },
70
70
  display: 'block',
71
71
  });
72
72
 
@@ -74,7 +74,7 @@ const templateRasaAud = {
74
74
 
75
75
  this.RSpeech = {
76
76
  name: 'RSpeech',
77
- w: width / 2, h: 38.2,
77
+ w: width / 2, h: 37.6,
78
78
  margin: { left: 0, top: 0, right: 0, bottom: 0 },
79
79
  display: 'inline',
80
80
  hideContext: true,
@@ -82,39 +82,16 @@ const templateRasaAud = {
82
82
  }
83
83
  this.LSpeech = {
84
84
  name: 'LSpeech',
85
- w: width / 2, h: 38.2,
85
+ w: width / 2, h: 37.6,
86
86
  margin: { left: 0, top: 0, right: 0, bottom: 0 },
87
87
  display: 'block',
88
88
  hideContext: true,
89
89
  forceInsert: true,
90
90
  }
91
- this.RTympanogram = {
92
- name: 'RTympanogram',
93
- w: width / 2, h: 60,
94
- margin: { left: 2, top: 2, right: 2, bottom: 2 },
95
- display: 'inline',
96
- }
97
- this.LTympanogram = {
98
- name: 'LTympanogram',
99
- w: width / 2, h: 60,
100
- margin: { left: 2, top: 2, right: 2, bottom: 2 },
101
- display: 'block',
102
- }
103
- this.RReflex = {
104
- name: 'RReflex',
105
- w: width / 2, h: 30,
106
- margin: { left: 2, top: 2, right: 2, bottom: 2 },
107
- display: 'inline'
108
- }
109
- this.LReflex = {
110
- name: 'LReflex',
111
- w: width / 2, h: 30,
112
- margin: { left: 2, top: 2, right: 2, bottom: 2 },
113
- display: 'block'
114
- }
91
+
115
92
  this.report = {
116
93
  name: 'report',
117
- w: width, h: 37.4,
94
+ w: width, h: 36.9,
118
95
  margin: { left: 0, top: 0, right: 0, bottom: 0 },
119
96
  display: 'block',
120
97
  hideContext: true,
@@ -131,13 +108,7 @@ const templateRasaAud = {
131
108
  calc2: function () {
132
109
  // let dims = this.dims;
133
110
  let width, height;
134
- //آیتم های روی این تمپلت
135
- // روش جدید محاسبه ابعاد منطقی تر و تمیز تر
136
- // Object.assign(this.header, {
137
- // width: this.getWidth(this.header),
138
- // height: this.getHeight(this.header),
139
- // })
140
- // New
111
+
141
112
  width = this.header.width = this.getWidth(this.header)
142
113
  height = this.header.height = this.getHeight(this.header)
143
114
 
@@ -169,7 +140,8 @@ const templateRasaAud = {
169
140
  { name: 'name', x: width - 45, y: 12 },
170
141
  { name: 'lastName', x: width - 75, y: 12 },
171
142
  { name: 'age', x: width - 105, y: 12 },
172
- { name: 'referrer', x: width - 150, y: 12 }
143
+ { name: 'referrer', x: width - 150, y: 12 },
144
+ { name: 'date', x: width - 185, y: 12 }
173
145
  ]
174
146
 
175
147
  width = this.history.width = this.getWidth(this.history)
@@ -192,32 +164,22 @@ const templateRasaAud = {
192
164
  this.RSpeech.height = this.getHeight(this.RSpeech)
193
165
  this.RSpeech.labels = ["SRT", "MCL", "SDS", 'UCL']
194
166
  this.RSpeech.forceInputs = [
195
- { name: 'SRT', x: 23, y: 26 },
196
- { name: 'MCL', x: 35, y: 26 },
197
- { name: 'SDS', x: 47, y: 26 },
198
- { name: 'UCL', x: 59, y: 26 },
167
+ { name: 'SRT', x: 24, y: 26 },
168
+ { name: 'MCL', x: 36, y: 26 },
169
+ { name: 'SDS', x: 48, y: 26 },
170
+ { name: 'UCL', x: 60, y: 26 },
199
171
  ]
200
172
 
201
173
  width = this.LSpeech.width = this.getWidth(this.LSpeech)
202
174
  this.LSpeech.height = this.getHeight(this.LSpeech)
203
175
  this.LSpeech.labels = ["SRT", "MCL", "SDS", 'UCL']
204
176
  this.LSpeech.forceInputs = [
205
- { name: 'SRT', x: 33, y: 26 },
206
- { name: 'MCL', x: 45, y: 26 },
207
- { name: 'SDS', x: 57, y: 26 },
208
- { name: 'UCL', x: 69, y: 26 },
177
+ { name: 'SRT', x: 34, y: 26 },
178
+ { name: 'MCL', x: 46, y: 26 },
179
+ { name: 'SDS', x: 58, y: 26 },
180
+ { name: 'UCL', x: 70, y: 26 },
209
181
  ]
210
182
 
211
- width = this.RTympanogram.width = this.getWidth(this.RTympanogram)
212
- this.RTympanogram.height = this.getHeight(this.RTympanogram)
213
- width = this.LTympanogram.width = this.getWidth(this.LTympanogram)
214
- this.LTympanogram.height = this.getHeight(this.LTympanogram)
215
-
216
- width = this.RReflex.width = this.getWidth(this.RReflex)
217
- this.RReflex.height = this.getHeight(this.RReflex)
218
- width = this.LReflex.width = this.getWidth(this.LReflex)
219
- this.LReflex.height = this.getHeight(this.LReflex)
220
-
221
183
  width = this.report.width = this.getWidth(this.report)
222
184
  this.report.height = this.getHeight(this.report)
223
185
  this.report.elements = [
@@ -231,7 +193,6 @@ const templateRasaAud = {
231
193
 
232
194
  ]
233
195
 
234
-
235
196
  width = this.footer.width = this.getWidth(this.footer)
236
197
  this.footer.height = this.getHeight(this.footer)
237
198
  this.footer.elements = [
package/src/style.css CHANGED
@@ -105,7 +105,7 @@ a:hover {
105
105
  padding: 0.6em 1.2em;
106
106
  font-size: 1em;
107
107
  font-weight: 500;
108
- font-family: inherit;
108
+ /* font-family: inherit; */
109
109
  background-color: #7472e2;
110
110
  color: #ffffff;
111
111
  cursor: pointer;
Binary file
package/src/counter.js DELETED
@@ -1,9 +0,0 @@
1
- export function setupCounter(element) {
2
- let counter = 0
3
- const setCounter = (count) => {
4
- counter = count
5
- element.innerHTML = `count is ${counter}`
6
- }
7
- element.addEventListener('click', () => setCounter(counter + 1))
8
- setCounter(0)
9
- }
@@ -1 +0,0 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="32" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path fill="#F7DF1E" d="M0 0h256v256H0V0Z"></path><path d="m67.312 213.932l19.59-11.856c3.78 6.701 7.218 12.371 15.465 12.371c7.905 0 12.89-3.092 12.89-15.12v-81.798h24.057v82.138c0 24.917-14.606 36.259-35.916 36.259c-19.245 0-30.416-9.967-36.087-21.996m85.07-2.576l19.588-11.341c5.157 8.421 11.859 14.607 23.715 14.607c9.969 0 16.325-4.984 16.325-11.858c0-8.248-6.53-11.17-17.528-15.98l-6.013-2.58c-17.357-7.387-28.87-16.667-28.87-36.257c0-18.044 13.747-31.792 35.228-31.792c15.294 0 26.292 5.328 34.196 19.247l-18.732 12.03c-4.125-7.389-8.591-10.31-15.465-10.31c-7.046 0-11.514 4.468-11.514 10.31c0 7.217 4.468 10.14 14.778 14.608l6.014 2.577c20.45 8.765 31.963 17.7 31.963 37.804c0 21.654-17.012 33.51-39.867 33.51c-22.339 0-36.774-10.654-43.819-24.574"></path></svg>