@visns-studio/visns-components 6.16.2 → 6.16.4

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
@@ -95,7 +95,7 @@
95
95
  "react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0"
96
96
  },
97
97
  "name": "@visns-studio/visns-components",
98
- "version": "6.16.2",
98
+ "version": "6.16.4",
99
99
  "description": "Various packages to assist in the development of our Custom Applications.",
100
100
  "main": "src/index.js",
101
101
  "files": [
@@ -2883,11 +2883,7 @@ const DataGrid = forwardRef(
2883
2883
  rowProps.columns[columnIndex].link.key;
2884
2884
  const rowData = rowProps.data[linkKey];
2885
2885
 
2886
- window.open(
2887
- `${linkPopup}/${rowData}`,
2888
- '',
2889
- 'width=1440,height=1024,menubar=1,resizable=1,status=1,titlebar=1,toolbar=1'
2890
- );
2886
+ openRecordWindow(`${linkPopup}/${rowData}`);
2891
2887
  } else {
2892
2888
  debugLog('🔍 Checking for update setting:', {
2893
2889
  settings: settingsRef.current,
@@ -3953,14 +3949,15 @@ const DataGrid = forwardRef(
3953
3949
  // screens) — columns then render a few px wide
3954
3950
  // with no horizontal scrollbar ever appearing.
3955
3951
  // A date filter needs room for its locale mask
3956
- // ("dd/mm/yyyy" + the picker glyph); below ~140px
3957
- // the native input clips its own value.
3952
+ // ("dd / mm / yyyy" in Firefox, glyph included -
3953
+ // Firefox will not hide it); below ~160px the
3954
+ // native input clips its own value.
3958
3955
  minWidth:
3959
3956
  column.minWidth ??
3960
3957
  (['date', 'datetime', 'datetime-local'].includes(
3961
3958
  column.type
3962
3959
  )
3963
- ? Math.max(grid.columnMinWidth, 140)
3960
+ ? Math.max(grid.columnMinWidth, 160)
3964
3961
  : grid.columnMinWidth),
3965
3962
  maxWidth: column.maxWidth ?? undefined,
3966
3963
  textAlign: column.textAlign ?? undefined,
@@ -1,4 +1,5 @@
1
1
  import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
2
+ import { openRecordWindow } from '../utils/popupWindow';
2
3
  import { Link } from 'react-router-dom';
3
4
  import {
4
5
  ChevronDown,
@@ -1061,11 +1062,7 @@ const CallQueuePop = ({
1061
1062
  return;
1062
1063
  }
1063
1064
 
1064
- window.open(
1065
- hrefForTask(task),
1066
- '',
1067
- 'width=1440,height=1024,menubar=1,resizable=1,status=1,titlebar=1,toolbar=1'
1068
- );
1065
+ openRecordWindow(hrefForTask(task));
1069
1066
  };
1070
1067
 
1071
1068
  /**
@@ -1,4 +1,5 @@
1
1
  import { useNavigate } from 'react-router-dom';
2
+ import { openRecordWindow } from '../utils/popupWindow';
2
3
  import { toast } from 'react-toastify';
3
4
  import { saveAs } from 'file-saver';
4
5
  import {
@@ -172,11 +173,7 @@ const DataGridSearch = ({
172
173
  }
173
174
  } else {
174
175
  if (form.url) {
175
- window.open(
176
- form.url,
177
- '',
178
- 'width=1440,height=1024,menubar=1,resizable=1,status=1,titlebar=1,toolbar=1'
179
- );
176
+ openRecordWindow(form.url);
180
177
  }
181
178
  }
182
179
  }}
@@ -194,11 +191,7 @@ const DataGridSearch = ({
194
191
  onClick={(e) => {
195
192
  e.preventDefault();
196
193
 
197
- window.open(
198
- form.url,
199
- '',
200
- 'width=1440,height=1024,menubar=1,resizable=1,status=1,titlebar=1,toolbar=1'
201
- );
194
+ openRecordWindow(form.url);
202
195
  }}
203
196
  >
204
197
  <Plus
@@ -541,6 +541,20 @@ body.tablet-mode .InovuaReactDataGrid__cell.cell-word-wrap > div {
541
541
  display: none;
542
542
  }
543
543
 
544
+ /* Firefox (109+) draws its calendar glyph as part of the control and ignores
545
+ the pseudo-element above, and it pads each date segment itself, which sat
546
+ the text high in the 32px row. Tighter metrics, and the column default below
547
+ (160px for date types) leaves the glyph its room. */
548
+ @-moz-document url-prefix() {
549
+ .visns-native-date-filter__input {
550
+ padding: 0 0 0 2px;
551
+ font-size: 12px;
552
+ line-height: 28px;
553
+ height: 28px;
554
+ align-self: center;
555
+ }
556
+ }
557
+
544
558
  .visns-native-date-filter__clear {
545
559
  flex: none;
546
560
  align-self: center;
@@ -0,0 +1,44 @@
1
+ /**
2
+ * One geometry for every record window the grid opens.
3
+ *
4
+ * The grid used to hard-code 1440×1024, which on a 1080p monitor left a
5
+ * third of the screen unused and on a laptop spilled off it. A record window
6
+ * now takes the whole available screen (inset 12px), on whichever monitor the
7
+ * browser is on, and is named so a second click raises the one already open
8
+ * instead of stacking another.
9
+ */
10
+ export const FEATURE_FLAGS = 'menubar=1,resizable=1,status=1,titlebar=1,toolbar=1';
11
+
12
+ export const popupFeatures = () => {
13
+ if (typeof window === 'undefined' || !window.screen) {
14
+ return `width=1440,height=1024,${FEATURE_FLAGS}`;
15
+ }
16
+
17
+ const { availWidth, availHeight, availLeft = 0, availTop = 0 } = window.screen;
18
+ const width = Math.max(960, (availWidth || 1440) - 24);
19
+ const height = Math.max(640, (availHeight || 1024) - 24);
20
+
21
+ return `width=${width},height=${height},left=${availLeft + 12},top=${availTop + 12},${FEATURE_FLAGS}`;
22
+ };
23
+
24
+ export const popupName = (url) =>
25
+ String(url || '')
26
+ .replace(/^https?:\/\/[^/]+/, '')
27
+ .replace(/[^a-z0-9]+/gi, '-')
28
+ .replace(/^-+|-+$/g, '') || 'record';
29
+
30
+ export const openRecordWindow = (url, name = popupName(url)) => {
31
+ if (typeof window === 'undefined') return null;
32
+
33
+ const popup = window.open(url, name, popupFeatures());
34
+
35
+ try {
36
+ popup?.focus();
37
+ } catch (error) {
38
+ // A blocked popup returns null; nothing to focus.
39
+ }
40
+
41
+ return popup;
42
+ };
43
+
44
+ export default openRecordWindow;