@xh/hoist 76.0.0-SNAPSHOT.1757274887417 → 76.0.0-SNAPSHOT.1757949377824

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/CHANGELOG.md CHANGED
@@ -22,6 +22,7 @@
22
22
  views will be pinned by default. This feature was deemed too confusing, and not useful in
23
23
  practice. App maintainers should ensure that all global views are appropriate and well
24
24
  organized enough to be shown immediately to new users in the view menu.
25
+ * New constraint rule: `validEmails` - to validate one or more email addresses in an input field.
25
26
 
26
27
  ### 🐞 Bug Fixes
27
28
 
@@ -40,6 +41,10 @@
40
41
  * Added control to trigger browser GC from app footer. Useful for troubleshooting memory issues.
41
42
  Requires running chromium-based browser via e.g. `start chrome --js-flags="--expose-gc`.
42
43
 
44
+ ### ⚙️ Typescript API Adjustments
45
+
46
+ * Corrected `ColChooserConfig` `width` and `height` types.
47
+
43
48
  ## 75.0.1 - 2025-08-11
44
49
 
45
50
  ### 🎁 New Features
@@ -99,9 +99,9 @@ export interface ColChooserConfig {
99
99
  */
100
100
  autosizeOnCommit?: boolean;
101
101
  /** Chooser width for popover and dialog. Desktop only. */
102
- width?: number;
102
+ width?: string | number;
103
103
  /** Chooser height for popover and dialog. Desktop only. */
104
- height?: number;
104
+ height?: string | number;
105
105
  }
106
106
  /**
107
107
  * Sort comparator function for a grid column. Note that this comparator will also be called if
@@ -10,10 +10,21 @@ import { Constraint } from './Rule';
10
10
  */
11
11
  export declare const required: Constraint;
12
12
  /**
13
- * Validate an email address.
14
- * https://stackoverflow.com/questions/46155/how-to-validate-an-email-address-in-javascript/46181#46181.
13
+ * Validate a single email address in a field that expects only one email address.
15
14
  */
16
15
  export declare const validEmail: Constraint<string>;
16
+ /**
17
+ * Validate all email addresses in a field that allows multiple email addresses
18
+ * separated by a semicolon - the separator used by Outlook for multiple email addresses.
19
+ * All email addresses must be unique.
20
+ */
21
+ export declare function validEmails(c?: ValidEmailsOptions): Constraint<string>;
22
+ export interface ValidEmailsOptions {
23
+ /** Require at least N email addresses. */
24
+ minCount?: number;
25
+ /** Require no more than N email addresses. */
26
+ maxCount?: number;
27
+ }
17
28
  /** Validate length of a string.*/
18
29
  export declare function lengthIs(c: LengthIsOptions): Constraint<string>;
19
30
  export interface LengthIsOptions {
package/cmp/grid/Types.ts CHANGED
@@ -136,10 +136,10 @@ export interface ColChooserConfig {
136
136
  autosizeOnCommit?: boolean;
137
137
 
138
138
  /** Chooser width for popover and dialog. Desktop only. */
139
- width?: number;
139
+ width?: string | number;
140
140
 
141
141
  /** Chooser height for popover and dialog. Desktop only. */
142
- height?: number;
142
+ height?: string | number;
143
143
  }
144
144
 
145
145
  /**
@@ -5,7 +5,7 @@
5
5
  * Copyright © 2025 Extremely Heavy Industries Inc.
6
6
  */
7
7
  import {LocalDate} from '@xh/hoist/utils/datetime';
8
- import {isArray, isEmpty, isFinite, isNil, isString} from 'lodash';
8
+ import {isArray, isEmpty, isFinite, isNil, isString, uniq} from 'lodash';
9
9
  import moment from 'moment';
10
10
  import {Constraint} from './Rule';
11
11
  /**
@@ -27,19 +27,52 @@ export const required: Constraint = ({value, displayName}) => {
27
27
  };
28
28
 
29
29
  /**
30
- * Validate an email address.
31
- * https://stackoverflow.com/questions/46155/how-to-validate-an-email-address-in-javascript/46181#46181.
30
+ * Validate a single email address in a field that expects only one email address.
32
31
  */
33
32
  export const validEmail: Constraint<string> = ({value, displayName}) => {
34
33
  if (isNil(value)) return null;
35
34
 
36
- // prettier-ignore
37
- // eslint-disable-next-line no-useless-escape
38
- const re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
39
- isValid = re.test(value);
40
- if (!isValid) return `${displayName} is not a properly formatted address.`;
35
+ const isValid = emailRegEx.test(value);
36
+ if (!isValid) return `${displayName} is not a properly formatted email address.`;
41
37
  };
42
38
 
39
+ /**
40
+ * Validate all email addresses in a field that allows multiple email addresses
41
+ * separated by a semicolon - the separator used by Outlook for multiple email addresses.
42
+ * All email addresses must be unique.
43
+ */
44
+ export function validEmails(c?: ValidEmailsOptions): Constraint<string> {
45
+ return ({value, displayName}) => {
46
+ if (isNil(value)) return null;
47
+
48
+ const emails = value
49
+ .split(';')
50
+ .map(it => it.trim())
51
+ .filter(Boolean);
52
+
53
+ if (uniq(emails).length !== emails.length) {
54
+ return `${displayName} must not contain duplicate email addresses.`;
55
+ }
56
+ if (emails.length < c?.minCount) {
57
+ return `${displayName} must contain at least ${c.minCount} email addresses.`;
58
+ }
59
+ if (!isNil(c?.maxCount) && emails.length > c.maxCount) {
60
+ return `${displayName} must contain no more than ${c.maxCount} email addresses.`;
61
+ }
62
+
63
+ const isValid = emails.every(it => emailRegEx.test(it));
64
+
65
+ if (!isValid) return `${displayName} has an improperly formatted email address.`;
66
+ };
67
+ }
68
+ export interface ValidEmailsOptions {
69
+ /** Require at least N email addresses. */
70
+ minCount?: number;
71
+
72
+ /** Require no more than N email addresses. */
73
+ maxCount?: number;
74
+ }
75
+
43
76
  /** Validate length of a string.*/
44
77
  export function lengthIs(c: LengthIsOptions): Constraint<string> {
45
78
  return ({value, displayName}) => {
@@ -197,3 +230,8 @@ export const isValidJson: Constraint = ({value, displayName}) => {
197
230
  return `${displayName} is not valid JSON`;
198
231
  }
199
232
  };
233
+
234
+ // https://stackoverflow.com/questions/46155/how-to-validate-an-email-address-in-javascript/46181#46181
235
+ // prettier-ignore
236
+ // eslint-disable-next-line no-useless-escape
237
+ const emailRegEx = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xh/hoist",
3
- "version": "76.0.0-SNAPSHOT.1757274887417",
3
+ "version": "76.0.0-SNAPSHOT.1757949377824",
4
4
  "description": "Hoist add-on for building and deploying React Applications.",
5
5
  "repository": "github:xh/hoist-react",
6
6
  "homepage": "https://xh.io",