@okf/ootils 1.9.0 → 1.9.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.
@@ -29,6 +29,48 @@ interface RichTextValue {
29
29
  [key: string]: any;
30
30
  }
31
31
  type TagNameInput = string | number | RichTextValue | null | undefined;
32
+ /**
33
+ * Generate a normalized tag ID from a tag name
34
+ *
35
+ * This function performs aggressive normalization to ensure that similar-looking
36
+ * tag names produce the same ID, preventing duplicates and collision errors.
37
+ *
38
+ * @param tagName - The tag name (string, number, or rich text object)
39
+ * @returns A normalized tag ID string
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * genTagId('Post-COVID') // → 'post_covid'
44
+ * genTagId('Post—COVID') // → 'post_covid' (em-dash)
45
+ * genTagId('Post–COVID') // → 'post_covid' (en-dash)
46
+ * genTagId('café') // → 'cafe'
47
+ * genTagId('CAFÉ') // → 'cafe'
48
+ * genTagId('Café') // → 'cafe'
49
+ * genTagId('C++') // → 'cplusplus'
50
+ * genTagId('New York') // → 'new_york' (double space)
51
+ * genTagId('José Müller') // → 'jose_muller'
52
+ * ```
53
+ *
54
+ * Normalization rules (applied in order):
55
+ * 1. Convert rich text to plain text
56
+ * 2. Normalize Unicode to NFD (Canonical Decomposition)
57
+ * 3. Remove all diacritical marks (accents, umlauts, etc.)
58
+ * 4. Trim whitespace from both ends
59
+ * 5. Convert to lowercase
60
+ * 6. Replace all non-alphanumeric characters with underscore
61
+ * 7. Replace '+' with 'plus'
62
+ * 8. Remove leading/trailing underscores
63
+ *
64
+ * Character variants that normalize to the same ID:
65
+ * - Dashes: hyphen (-), en-dash (–), em-dash (—), minus (−)
66
+ * - Whitespace: space, multiple spaces, tab, newline, non-breaking space
67
+ * - Quotes: straight ("), curly left ("), curly right ("), backtick (`)
68
+ * - Apostrophes: straight ('), curly (')
69
+ * - Accents: café/cafe, José/Jose, Müller/Muller, naïve/naive
70
+ * - Case: TestTag/testtag/TESTTAG
71
+ *
72
+ * @see TAG_NORMALIZATION_GUIDE.md in okf-be for comprehensive documentation
73
+ */
32
74
  declare const genTagId: (tagName: TagNameInput) => string;
33
75
 
34
76
  /**
package/dist/browser.d.ts CHANGED
@@ -29,6 +29,48 @@ interface RichTextValue {
29
29
  [key: string]: any;
30
30
  }
31
31
  type TagNameInput = string | number | RichTextValue | null | undefined;
32
+ /**
33
+ * Generate a normalized tag ID from a tag name
34
+ *
35
+ * This function performs aggressive normalization to ensure that similar-looking
36
+ * tag names produce the same ID, preventing duplicates and collision errors.
37
+ *
38
+ * @param tagName - The tag name (string, number, or rich text object)
39
+ * @returns A normalized tag ID string
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * genTagId('Post-COVID') // → 'post_covid'
44
+ * genTagId('Post—COVID') // → 'post_covid' (em-dash)
45
+ * genTagId('Post–COVID') // → 'post_covid' (en-dash)
46
+ * genTagId('café') // → 'cafe'
47
+ * genTagId('CAFÉ') // → 'cafe'
48
+ * genTagId('Café') // → 'cafe'
49
+ * genTagId('C++') // → 'cplusplus'
50
+ * genTagId('New York') // → 'new_york' (double space)
51
+ * genTagId('José Müller') // → 'jose_muller'
52
+ * ```
53
+ *
54
+ * Normalization rules (applied in order):
55
+ * 1. Convert rich text to plain text
56
+ * 2. Normalize Unicode to NFD (Canonical Decomposition)
57
+ * 3. Remove all diacritical marks (accents, umlauts, etc.)
58
+ * 4. Trim whitespace from both ends
59
+ * 5. Convert to lowercase
60
+ * 6. Replace all non-alphanumeric characters with underscore
61
+ * 7. Replace '+' with 'plus'
62
+ * 8. Remove leading/trailing underscores
63
+ *
64
+ * Character variants that normalize to the same ID:
65
+ * - Dashes: hyphen (-), en-dash (–), em-dash (—), minus (−)
66
+ * - Whitespace: space, multiple spaces, tab, newline, non-breaking space
67
+ * - Quotes: straight ("), curly left ("), curly right ("), backtick (`)
68
+ * - Apostrophes: straight ('), curly (')
69
+ * - Accents: café/cafe, José/Jose, Müller/Muller, naïve/naive
70
+ * - Case: TestTag/testtag/TESTTAG
71
+ *
72
+ * @see TAG_NORMALIZATION_GUIDE.md in okf-be for comprehensive documentation
73
+ */
32
74
  declare const genTagId: (tagName: TagNameInput) => string;
33
75
 
34
76
  /**
package/dist/browser.js CHANGED
@@ -184,6 +184,8 @@ var convertFromRichText = (value) => {
184
184
  };
185
185
  var genTagId = (tagName) => {
186
186
  let toReturn = convertFromRichText(tagName);
187
+ toReturn = toReturn.normalize("NFD");
188
+ toReturn = toReturn.replace(/\p{Mn}/gu, "");
187
189
  const regex = /[^\p{L}\p{N}\+]+/gui;
188
190
  toReturn = toReturn.trim().toLowerCase().replace(regex, "_");
189
191
  toReturn = toReturn.replace(/\+/g, "plus");
package/dist/browser.mjs CHANGED
@@ -148,6 +148,8 @@ var convertFromRichText = (value) => {
148
148
  };
149
149
  var genTagId = (tagName) => {
150
150
  let toReturn = convertFromRichText(tagName);
151
+ toReturn = toReturn.normalize("NFD");
152
+ toReturn = toReturn.replace(/\p{Mn}/gu, "");
151
153
  const regex = /[^\p{L}\p{N}\+]+/gui;
152
154
  toReturn = toReturn.trim().toLowerCase().replace(regex, "_");
153
155
  toReturn = toReturn.replace(/\+/g, "plus");
package/dist/node.d.mts CHANGED
@@ -36,6 +36,48 @@ interface RichTextValue {
36
36
  [key: string]: any;
37
37
  }
38
38
  type TagNameInput = string | number | RichTextValue | null | undefined;
39
+ /**
40
+ * Generate a normalized tag ID from a tag name
41
+ *
42
+ * This function performs aggressive normalization to ensure that similar-looking
43
+ * tag names produce the same ID, preventing duplicates and collision errors.
44
+ *
45
+ * @param tagName - The tag name (string, number, or rich text object)
46
+ * @returns A normalized tag ID string
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * genTagId('Post-COVID') // → 'post_covid'
51
+ * genTagId('Post—COVID') // → 'post_covid' (em-dash)
52
+ * genTagId('Post–COVID') // → 'post_covid' (en-dash)
53
+ * genTagId('café') // → 'cafe'
54
+ * genTagId('CAFÉ') // → 'cafe'
55
+ * genTagId('Café') // → 'cafe'
56
+ * genTagId('C++') // → 'cplusplus'
57
+ * genTagId('New York') // → 'new_york' (double space)
58
+ * genTagId('José Müller') // → 'jose_muller'
59
+ * ```
60
+ *
61
+ * Normalization rules (applied in order):
62
+ * 1. Convert rich text to plain text
63
+ * 2. Normalize Unicode to NFD (Canonical Decomposition)
64
+ * 3. Remove all diacritical marks (accents, umlauts, etc.)
65
+ * 4. Trim whitespace from both ends
66
+ * 5. Convert to lowercase
67
+ * 6. Replace all non-alphanumeric characters with underscore
68
+ * 7. Replace '+' with 'plus'
69
+ * 8. Remove leading/trailing underscores
70
+ *
71
+ * Character variants that normalize to the same ID:
72
+ * - Dashes: hyphen (-), en-dash (–), em-dash (—), minus (−)
73
+ * - Whitespace: space, multiple spaces, tab, newline, non-breaking space
74
+ * - Quotes: straight ("), curly left ("), curly right ("), backtick (`)
75
+ * - Apostrophes: straight ('), curly (')
76
+ * - Accents: café/cafe, José/Jose, Müller/Muller, naïve/naive
77
+ * - Case: TestTag/testtag/TESTTAG
78
+ *
79
+ * @see TAG_NORMALIZATION_GUIDE.md in okf-be for comprehensive documentation
80
+ */
39
81
  declare const genTagId: (tagName: TagNameInput) => string;
40
82
 
41
83
  /**
package/dist/node.d.ts CHANGED
@@ -36,6 +36,48 @@ interface RichTextValue {
36
36
  [key: string]: any;
37
37
  }
38
38
  type TagNameInput = string | number | RichTextValue | null | undefined;
39
+ /**
40
+ * Generate a normalized tag ID from a tag name
41
+ *
42
+ * This function performs aggressive normalization to ensure that similar-looking
43
+ * tag names produce the same ID, preventing duplicates and collision errors.
44
+ *
45
+ * @param tagName - The tag name (string, number, or rich text object)
46
+ * @returns A normalized tag ID string
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * genTagId('Post-COVID') // → 'post_covid'
51
+ * genTagId('Post—COVID') // → 'post_covid' (em-dash)
52
+ * genTagId('Post–COVID') // → 'post_covid' (en-dash)
53
+ * genTagId('café') // → 'cafe'
54
+ * genTagId('CAFÉ') // → 'cafe'
55
+ * genTagId('Café') // → 'cafe'
56
+ * genTagId('C++') // → 'cplusplus'
57
+ * genTagId('New York') // → 'new_york' (double space)
58
+ * genTagId('José Müller') // → 'jose_muller'
59
+ * ```
60
+ *
61
+ * Normalization rules (applied in order):
62
+ * 1. Convert rich text to plain text
63
+ * 2. Normalize Unicode to NFD (Canonical Decomposition)
64
+ * 3. Remove all diacritical marks (accents, umlauts, etc.)
65
+ * 4. Trim whitespace from both ends
66
+ * 5. Convert to lowercase
67
+ * 6. Replace all non-alphanumeric characters with underscore
68
+ * 7. Replace '+' with 'plus'
69
+ * 8. Remove leading/trailing underscores
70
+ *
71
+ * Character variants that normalize to the same ID:
72
+ * - Dashes: hyphen (-), en-dash (–), em-dash (—), minus (−)
73
+ * - Whitespace: space, multiple spaces, tab, newline, non-breaking space
74
+ * - Quotes: straight ("), curly left ("), curly right ("), backtick (`)
75
+ * - Apostrophes: straight ('), curly (')
76
+ * - Accents: café/cafe, José/Jose, Müller/Muller, naïve/naive
77
+ * - Case: TestTag/testtag/TESTTAG
78
+ *
79
+ * @see TAG_NORMALIZATION_GUIDE.md in okf-be for comprehensive documentation
80
+ */
39
81
  declare const genTagId: (tagName: TagNameInput) => string;
40
82
 
41
83
  /**
package/dist/node.js CHANGED
@@ -1613,6 +1613,8 @@ var convertFromRichText = (value) => {
1613
1613
  };
1614
1614
  var genTagId = (tagName) => {
1615
1615
  let toReturn = convertFromRichText(tagName);
1616
+ toReturn = toReturn.normalize("NFD");
1617
+ toReturn = toReturn.replace(/\p{Mn}/gu, "");
1616
1618
  const regex = /[^\p{L}\p{N}\+]+/gui;
1617
1619
  toReturn = toReturn.trim().toLowerCase().replace(regex, "_");
1618
1620
  toReturn = toReturn.replace(/\+/g, "plus");
package/dist/node.mjs CHANGED
@@ -1583,6 +1583,8 @@ var convertFromRichText = (value) => {
1583
1583
  };
1584
1584
  var genTagId = (tagName) => {
1585
1585
  let toReturn = convertFromRichText(tagName);
1586
+ toReturn = toReturn.normalize("NFD");
1587
+ toReturn = toReturn.replace(/\p{Mn}/gu, "");
1586
1588
  const regex = /[^\p{L}\p{N}\+]+/gui;
1587
1589
  toReturn = toReturn.trim().toLowerCase().replace(regex, "_");
1588
1590
  toReturn = toReturn.replace(/\+/g, "plus");
@@ -29,6 +29,48 @@ interface RichTextValue {
29
29
  [key: string]: any;
30
30
  }
31
31
  type TagNameInput = string | number | RichTextValue | null | undefined;
32
+ /**
33
+ * Generate a normalized tag ID from a tag name
34
+ *
35
+ * This function performs aggressive normalization to ensure that similar-looking
36
+ * tag names produce the same ID, preventing duplicates and collision errors.
37
+ *
38
+ * @param tagName - The tag name (string, number, or rich text object)
39
+ * @returns A normalized tag ID string
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * genTagId('Post-COVID') // → 'post_covid'
44
+ * genTagId('Post—COVID') // → 'post_covid' (em-dash)
45
+ * genTagId('Post–COVID') // → 'post_covid' (en-dash)
46
+ * genTagId('café') // → 'cafe'
47
+ * genTagId('CAFÉ') // → 'cafe'
48
+ * genTagId('Café') // → 'cafe'
49
+ * genTagId('C++') // → 'cplusplus'
50
+ * genTagId('New York') // → 'new_york' (double space)
51
+ * genTagId('José Müller') // → 'jose_muller'
52
+ * ```
53
+ *
54
+ * Normalization rules (applied in order):
55
+ * 1. Convert rich text to plain text
56
+ * 2. Normalize Unicode to NFD (Canonical Decomposition)
57
+ * 3. Remove all diacritical marks (accents, umlauts, etc.)
58
+ * 4. Trim whitespace from both ends
59
+ * 5. Convert to lowercase
60
+ * 6. Replace all non-alphanumeric characters with underscore
61
+ * 7. Replace '+' with 'plus'
62
+ * 8. Remove leading/trailing underscores
63
+ *
64
+ * Character variants that normalize to the same ID:
65
+ * - Dashes: hyphen (-), en-dash (–), em-dash (—), minus (−)
66
+ * - Whitespace: space, multiple spaces, tab, newline, non-breaking space
67
+ * - Quotes: straight ("), curly left ("), curly right ("), backtick (`)
68
+ * - Apostrophes: straight ('), curly (')
69
+ * - Accents: café/cafe, José/Jose, Müller/Muller, naïve/naive
70
+ * - Case: TestTag/testtag/TESTTAG
71
+ *
72
+ * @see TAG_NORMALIZATION_GUIDE.md in okf-be for comprehensive documentation
73
+ */
32
74
  declare const genTagId: (tagName: TagNameInput) => string;
33
75
 
34
76
  /**
@@ -29,6 +29,48 @@ interface RichTextValue {
29
29
  [key: string]: any;
30
30
  }
31
31
  type TagNameInput = string | number | RichTextValue | null | undefined;
32
+ /**
33
+ * Generate a normalized tag ID from a tag name
34
+ *
35
+ * This function performs aggressive normalization to ensure that similar-looking
36
+ * tag names produce the same ID, preventing duplicates and collision errors.
37
+ *
38
+ * @param tagName - The tag name (string, number, or rich text object)
39
+ * @returns A normalized tag ID string
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * genTagId('Post-COVID') // → 'post_covid'
44
+ * genTagId('Post—COVID') // → 'post_covid' (em-dash)
45
+ * genTagId('Post–COVID') // → 'post_covid' (en-dash)
46
+ * genTagId('café') // → 'cafe'
47
+ * genTagId('CAFÉ') // → 'cafe'
48
+ * genTagId('Café') // → 'cafe'
49
+ * genTagId('C++') // → 'cplusplus'
50
+ * genTagId('New York') // → 'new_york' (double space)
51
+ * genTagId('José Müller') // → 'jose_muller'
52
+ * ```
53
+ *
54
+ * Normalization rules (applied in order):
55
+ * 1. Convert rich text to plain text
56
+ * 2. Normalize Unicode to NFD (Canonical Decomposition)
57
+ * 3. Remove all diacritical marks (accents, umlauts, etc.)
58
+ * 4. Trim whitespace from both ends
59
+ * 5. Convert to lowercase
60
+ * 6. Replace all non-alphanumeric characters with underscore
61
+ * 7. Replace '+' with 'plus'
62
+ * 8. Remove leading/trailing underscores
63
+ *
64
+ * Character variants that normalize to the same ID:
65
+ * - Dashes: hyphen (-), en-dash (–), em-dash (—), minus (−)
66
+ * - Whitespace: space, multiple spaces, tab, newline, non-breaking space
67
+ * - Quotes: straight ("), curly left ("), curly right ("), backtick (`)
68
+ * - Apostrophes: straight ('), curly (')
69
+ * - Accents: café/cafe, José/Jose, Müller/Muller, naïve/naive
70
+ * - Case: TestTag/testtag/TESTTAG
71
+ *
72
+ * @see TAG_NORMALIZATION_GUIDE.md in okf-be for comprehensive documentation
73
+ */
32
74
  declare const genTagId: (tagName: TagNameInput) => string;
33
75
 
34
76
  /**
package/dist/universal.js CHANGED
@@ -184,6 +184,8 @@ var convertFromRichText = (value) => {
184
184
  };
185
185
  var genTagId = (tagName) => {
186
186
  let toReturn = convertFromRichText(tagName);
187
+ toReturn = toReturn.normalize("NFD");
188
+ toReturn = toReturn.replace(/\p{Mn}/gu, "");
187
189
  const regex = /[^\p{L}\p{N}\+]+/gui;
188
190
  toReturn = toReturn.trim().toLowerCase().replace(regex, "_");
189
191
  toReturn = toReturn.replace(/\+/g, "plus");
@@ -148,6 +148,8 @@ var convertFromRichText = (value) => {
148
148
  };
149
149
  var genTagId = (tagName) => {
150
150
  let toReturn = convertFromRichText(tagName);
151
+ toReturn = toReturn.normalize("NFD");
152
+ toReturn = toReturn.replace(/\p{Mn}/gu, "");
151
153
  const regex = /[^\p{L}\p{N}\+]+/gui;
152
154
  toReturn = toReturn.trim().toLowerCase().replace(regex, "_");
153
155
  toReturn = toReturn.replace(/\+/g, "plus");
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.9.0",
6
+ "version": "1.9.1",
7
7
  "description": "Utility functions for both browser and Node.js",
8
8
  "main": "dist/index.js",
9
9
  "module": "dist/index.mjs",