@avlcodemonkey/nilla-components 0.0.0-stage → 0.1.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.
Files changed (94) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/LICENSE +21 -0
  3. package/README.md +219 -3
  4. package/THIRD_PARTY_NOTICES.md +48 -0
  5. package/css/alert.css +48 -0
  6. package/css/autocomplete.css +38 -0
  7. package/css/dialog.css +61 -0
  8. package/css/file-to-textarea.css +8 -0
  9. package/css/html-editor.css +172 -0
  10. package/css/json.css +44 -0
  11. package/css/list.css +37 -0
  12. package/css/nav-toggle.css +92 -0
  13. package/css/nilla.css +16 -0
  14. package/css/pjax.css +58 -0
  15. package/css/slider-input.css +16 -0
  16. package/css/table.css +99 -0
  17. package/css/tokens.css +44 -0
  18. package/css/unsaved-changes.css +10 -0
  19. package/css/vendor/wysi.css +406 -0
  20. package/docs/llms.txt +319 -0
  21. package/package.json +121 -5
  22. package/src/components/Alert.js +24 -0
  23. package/src/components/Autocomplete.js +127 -0
  24. package/src/components/BaseComponent.js +78 -0
  25. package/src/components/BaseDialog.js +151 -0
  26. package/src/components/ConfirmDialog.js +34 -0
  27. package/src/components/CopyToClipboard.js +66 -0
  28. package/src/components/DateFormatter.js +51 -0
  29. package/src/components/DateTimeInput.js +63 -0
  30. package/src/components/DisplayToggle.js +53 -0
  31. package/src/components/FileToTextarea.js +81 -0
  32. package/src/components/HtmlEditor.js +309 -0
  33. package/src/components/InfoDialog.js +38 -0
  34. package/src/components/JsonFormatter.js +23 -0
  35. package/src/components/List.js +237 -0
  36. package/src/components/ListSortable.js +8 -0
  37. package/src/components/NavToggle.js +119 -0
  38. package/src/components/PJax.js +888 -0
  39. package/src/components/Share.js +41 -0
  40. package/src/components/SliderInput.js +26 -0
  41. package/src/components/Table.js +758 -0
  42. package/src/components/TimeOffsetSelect.js +29 -0
  43. package/src/components/UnsavedChanges.js +187 -0
  44. package/src/constants/Fetch.js +7 -0
  45. package/src/constants/HttpHeaders.js +19 -0
  46. package/src/constants/HttpMethods.js +14 -0
  47. package/src/constants/SortDirection.js +11 -0
  48. package/src/constants/TableElements.js +25 -0
  49. package/src/constants/TableSettings.js +14 -0
  50. package/src/errors/FetchError.js +7 -0
  51. package/src/events/ListReorderEvent.js +19 -0
  52. package/src/events/PJaxErrorEvent.js +38 -0
  53. package/src/events/PJaxNavigatingEvent.js +46 -0
  54. package/src/index.js +26 -0
  55. package/src/locales/en.json +55 -0
  56. package/src/locales/es.js +9 -0
  57. package/src/locales/es.json +55 -0
  58. package/src/models/TableSort.js +20 -0
  59. package/src/utils/ajaxHeaders.js +10 -0
  60. package/src/utils/announce.js +40 -0
  61. package/src/utils/defineElement.js +13 -0
  62. package/src/utils/editor/blockTools.js +256 -0
  63. package/src/utils/editor/elements.js +18 -0
  64. package/src/utils/editor/input.js +350 -0
  65. package/src/utils/editor/selection.js +125 -0
  66. package/src/utils/editor/tableTools.js +497 -0
  67. package/src/utils/escape.js +20 -0
  68. package/src/utils/fetchJsonArray.js +29 -0
  69. package/src/utils/filterArray.js +18 -0
  70. package/src/utils/formActionUrl.js +10 -0
  71. package/src/utils/formData.js +118 -0
  72. package/src/utils/index.js +18 -0
  73. package/src/utils/indexedCompare.js +18 -0
  74. package/src/utils/isSameOrigin.js +12 -0
  75. package/src/utils/locale.js +36 -0
  76. package/src/utils/notifyChange.js +10 -0
  77. package/src/utils/numberSetting.js +14 -0
  78. package/src/utils/pageLanguage.js +13 -0
  79. package/src/utils/parseUtcDate.js +22 -0
  80. package/src/utils/randomId.js +17 -0
  81. package/src/utils/registerTabTrap.js +60 -0
  82. package/src/utils/renderTemplate.js +44 -0
  83. package/src/utils/requestTimeout.js +12 -0
  84. package/src/utils/response.js +28 -0
  85. package/src/utils/sortedCompare.js +67 -0
  86. package/src/utils/storage.js +40 -0
  87. package/src/vendor/autocomplete.js +515 -0
  88. package/src/vendor/formatDate.js +236 -0
  89. package/src/vendor/licenses/autocomplete.LICENSE.md +21 -0
  90. package/src/vendor/licenses/fecha.LICENSE.md +21 -0
  91. package/src/vendor/licenses/pretty-print-json.LICENSE.md +21 -0
  92. package/src/vendor/licenses/wysi.LICENSE.md +21 -0
  93. package/src/vendor/prettyPrintJson.js +108 -0
  94. package/src/vendor/wyzi.js +2024 -0
@@ -0,0 +1,236 @@
1
+ /**
2
+ * Formats a date. Subset of functionality from
3
+ * fecha ~~ https://github.com/taylorhakes/fecha ~~ MIT License
4
+ * Names come from the browser, in any language.
5
+ */
6
+ import pageLanguage from '../utils/pageLanguage.js';
7
+
8
+ /**
9
+ * Regex for matching date format tokens.
10
+ * @type {RegExp}
11
+ */
12
+ const token = /d{1,4}|M{1,4}|YY(?:YY)?|S{1,3}|Do|ZZ|Z|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
13
+
14
+ /**
15
+ * Regex for matching literal text in format strings.
16
+ * @type {RegExp}
17
+ */
18
+ const literal = /\[([^]*?)\]/gm;
19
+
20
+ /**
21
+ * Formatters, which are slow to create, by language and options.
22
+ * @type {Map<string, Intl.DateTimeFormat>}
23
+ */
24
+ const formatters = new Map();
25
+
26
+ /**
27
+ * Gets a formatter. Its calendar is the one the numbers use, which isn't the usual one in every language.
28
+ * @param {string} lang - Language tag.
29
+ * @param {Intl.DateTimeFormatOptions} options - What to format.
30
+ * @returns {Intl.DateTimeFormat} Formatter.
31
+ */
32
+ const formatter = function(lang, options) {
33
+ const key = lang + JSON.stringify(options);
34
+ if (!formatters.has(key)) {
35
+ formatters.set(key, new Intl.DateTimeFormat(lang, { ...options, calendar: 'gregory' }));
36
+ }
37
+ return formatters.get(key);
38
+ };
39
+
40
+ /**
41
+ * Gets am or pm.
42
+ * @param {Date} dateObj - Date.
43
+ * @param {string} lang - Language tag.
44
+ * @returns {string} Text for the half of the day.
45
+ */
46
+ const dayPeriod = function(dateObj, lang) {
47
+ const parts = formatter(lang, { hour: 'numeric', hour12: true }).formatToParts(dateObj);
48
+ return parts.find(x => x.type === 'dayPeriod')?.value ?? '';
49
+ };
50
+
51
+ /**
52
+ * Endings for English days of the month.
53
+ * @type {Record<string, string>}
54
+ */
55
+ const ordinals = { one: 'st', two: 'nd', few: 'rd', other: 'th' };
56
+
57
+ /**
58
+ * Checks for English, which writes days of the month with an ending, and AM and PM in capitals.
59
+ * @param {string} lang - Language tag.
60
+ * @returns {boolean} True for English.
61
+ */
62
+ const isEnglish = lang => /^en\b/i.test(lang);
63
+
64
+ /**
65
+ * Pads a value with leading zeros.
66
+ * @param {string|number} val - Value to pad.
67
+ * @param {number} len - Desired length.
68
+ * @returns {string} Padded value as a string.
69
+ */
70
+ const pad = function(val, len) {
71
+ if (len === void 0) {
72
+ len = 2;
73
+ }
74
+ val = String(val);
75
+ while (val.length < len) {
76
+ val = '0' + val;
77
+ }
78
+ return val;
79
+ };
80
+
81
+ /**
82
+ * Formatting flags for date tokens.
83
+ * Each property is a function that returns a formatted string for a given date.
84
+ * @type {{ [key: string]: function(Date, string): string }}
85
+ */
86
+ const formatFlags = {
87
+ D: function(dateObj) {
88
+ return String(dateObj.getDate());
89
+ },
90
+ DD: function(dateObj) {
91
+ return pad(dateObj.getDate());
92
+ },
93
+ Do: function(dateObj, lang) {
94
+ const day = dateObj.getDate();
95
+ return isEnglish(lang) ? day + ordinals[new Intl.PluralRules('en', { type: 'ordinal' }).select(day)] : String(day);
96
+ },
97
+ d: function(dateObj) {
98
+ return String(dateObj.getDay());
99
+ },
100
+ dd: function(dateObj) {
101
+ return pad(dateObj.getDay());
102
+ },
103
+ ddd: function(dateObj, lang) {
104
+ return formatter(lang, { weekday: 'short' }).format(dateObj);
105
+ },
106
+ dddd: function(dateObj, lang) {
107
+ return formatter(lang, { weekday: 'long' }).format(dateObj);
108
+ },
109
+ M: function(dateObj) {
110
+ return String(dateObj.getMonth() + 1);
111
+ },
112
+ MM: function(dateObj) {
113
+ return pad(dateObj.getMonth() + 1);
114
+ },
115
+ MMM: function(dateObj, lang) {
116
+ return formatter(lang, { month: 'short' }).format(dateObj);
117
+ },
118
+ MMMM: function(dateObj, lang) {
119
+ return formatter(lang, { month: 'long' }).format(dateObj);
120
+ },
121
+ YY: function(dateObj) {
122
+ return pad(String(dateObj.getFullYear()), 4).slice(2);
123
+ },
124
+ YYYY: function(dateObj) {
125
+ return pad(dateObj.getFullYear(), 4);
126
+ },
127
+ h: function(dateObj) {
128
+ return String(dateObj.getHours() % 12 || 12);
129
+ },
130
+ hh: function(dateObj) {
131
+ return pad(dateObj.getHours() % 12 || 12);
132
+ },
133
+ H: function(dateObj) {
134
+ return String(dateObj.getHours());
135
+ },
136
+ HH: function(dateObj) {
137
+ return pad(dateObj.getHours());
138
+ },
139
+ m: function(dateObj) {
140
+ return String(dateObj.getMinutes());
141
+ },
142
+ mm: function(dateObj) {
143
+ return pad(dateObj.getMinutes());
144
+ },
145
+ s: function(dateObj) {
146
+ return String(dateObj.getSeconds());
147
+ },
148
+ ss: function(dateObj) {
149
+ return pad(dateObj.getSeconds());
150
+ },
151
+ S: function(dateObj) {
152
+ return String(Math.floor(dateObj.getMilliseconds() / 100));
153
+ },
154
+ SS: function(dateObj) {
155
+ return pad(Math.floor(dateObj.getMilliseconds() / 10), 2);
156
+ },
157
+ SSS: function(dateObj) {
158
+ return pad(dateObj.getMilliseconds(), 3);
159
+ },
160
+ a: function(dateObj, lang) {
161
+ return dayPeriod(dateObj, lang).toLowerCase();
162
+ },
163
+ A: function(dateObj, lang) {
164
+ const text = dayPeriod(dateObj, lang);
165
+ return isEnglish(lang) ? text.toUpperCase() : text;
166
+ },
167
+ ZZ: function(dateObj) {
168
+ const offset = dateObj.getTimezoneOffset();
169
+ return ((offset > 0 ? '-' : '+')
170
+ + pad(Math.floor(Math.abs(offset) / 60) * 100 + (Math.abs(offset) % 60), 4));
171
+ },
172
+ Z: function(dateObj) {
173
+ const offset = dateObj.getTimezoneOffset();
174
+ return ((offset > 0 ? '-' : '+')
175
+ + pad(Math.floor(Math.abs(offset) / 60), 2)
176
+ + ':'
177
+ + pad(Math.abs(offset) % 60, 2));
178
+ },
179
+ };
180
+
181
+ /**
182
+ * Common date and time format masks.
183
+ * @type {{ [key: string]: string }}
184
+ */
185
+ const globalMasks = {
186
+ default: 'ddd MMM DD YYYY HH:mm:ss',
187
+ shortDate: 'M/D/YY',
188
+ mediumDate: 'MMM D, YYYY',
189
+ longDate: 'MMMM D, YYYY',
190
+ fullDate: 'dddd, MMMM D, YYYY',
191
+ isoDate: 'YYYY-MM-DD',
192
+ isoDateTime: 'YYYY-MM-DDTHH:mm:ssZ',
193
+ shortTime: 'HH:mm',
194
+ mediumTime: 'HH:mm:ss',
195
+ longTime: 'HH:mm:ss.SSS',
196
+ };
197
+
198
+ /***
199
+ * Format a date.
200
+ * @param {Date|number} dateObj - Date object or timestamp to format
201
+ * @param {string} mask - Format of the date, i.e. 'mm-dd-yy' or 'shortDate'
202
+ * @param {string} [lang] - Language tag for names. The default is the page's language, or English without one
203
+ * @returns {string} Formatted date string
204
+ */
205
+ const formatDate = function(dateObj, mask, lang = pageLanguage() ?? 'en') {
206
+ if (mask === void 0) {
207
+ mask = globalMasks['default'];
208
+ }
209
+ if (typeof dateObj === 'number') {
210
+ dateObj = new Date(dateObj);
211
+ }
212
+ if (Object.prototype.toString.call(dateObj) !== '[object Date]' || Number.isNaN(dateObj.getTime())) {
213
+ throw new Error('Invalid Date pass to format');
214
+ }
215
+ mask = globalMasks[mask] || mask;
216
+
217
+ const literals = [];
218
+ // Make literals inactive by replacing them with @@@
219
+ mask = mask.replaceAll(literal, function($0, $1) {
220
+ literals.push($1);
221
+ return '@@@';
222
+ });
223
+
224
+ // Apply formatting rules
225
+ mask = mask.replaceAll(token, function($0) {
226
+ // the only matches without a formatter are quoted text, which is printed without its quotes
227
+ return Object.hasOwn(formatFlags, $0) ? formatFlags[$0](dateObj, lang) : $0.slice(1, -1);
228
+ });
229
+
230
+ // Inline literal values back into the formatted value
231
+ return mask.replaceAll('@@@', function() {
232
+ return literals.shift();
233
+ });
234
+ };
235
+
236
+ export { formatDate };
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Denis Taran
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Taylor Hakes
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018-2025 Individual contributors to pretty-print-json
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 Momo Bassit
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Pretty prints JSON data as syntax-highlighted HTML. Subset of functionality from
3
+ * pretty-print-json v3.0.5 ~~ https://pretty-print-json.js.org ~~ MIT License
4
+ */
5
+
6
+ /**
7
+ * Regex to match HTML special characters and escaped quotes for safe output.
8
+ * @type {RegExp}
9
+ */
10
+ const invalidHtml = /[<>&]|\\"/g;
11
+
12
+ /**
13
+ * Regex to match lines in pretty-printed JSON for further processing.
14
+ * @type {RegExp}
15
+ */
16
+ const jsonLine = /^( *)("[^"]+": )?("[^"]*"|[\w.+-]*)?([{}[\],]*)?$/mg;
17
+
18
+ /**
19
+ * Escapes special HTML characters for safe rendering.
20
+ * @param {string} char - Character to escape.
21
+ * @returns {string} Escaped HTML entity.
22
+ */
23
+ const toHtml = (char) => {
24
+ let result;
25
+ if (char === '<') {
26
+ result = '&lt;';
27
+ } else if (char === '>') {
28
+ result = '&gt;';
29
+ } else if (char === '&') {
30
+ result = '&amp;';
31
+ } else {
32
+ result = '&bsol;&quot;';
33
+ }
34
+ return result;
35
+ };
36
+
37
+ /**
38
+ * Wraps a value in a span with a class for syntax highlighting.
39
+ * @param {string} type - JSON value type (e.g., 'key', 'string', 'number').
40
+ * @param {string} display - Value to display inside the span.
41
+ * @returns {string} HTML span string or empty string if display is falsy.
42
+ */
43
+ const spanTag = (type, display) => display ? '<span class="json-' + type + '">' + display + '</span>' : '';
44
+
45
+ /**
46
+ * Builds HTML for a JSON value with appropriate syntax highlighting.
47
+ * @param {string} value - JSON value as a string.
48
+ * @returns {string} HTML string for the value.
49
+ */
50
+ const buildValueHtml = (value) => {
51
+ const strType = value.startsWith('"') && 'string';
52
+ const boolType = ['true', 'false'].includes(value) && 'boolean';
53
+ const nullType = value === 'null' && 'null';
54
+ const type = boolType || nullType || strType || 'number';
55
+ return spanTag(type, value);
56
+ };
57
+
58
+ /**
59
+ * Default options for prettyPrintJson.
60
+ * @type {{ indent: number, quoteKeys: boolean, trailingCommas: boolean }}
61
+ */
62
+ const defaults = {
63
+ indent: 4,
64
+ quoteKeys: true,
65
+ trailingCommas: false,
66
+ };
67
+
68
+ /**
69
+ * Utility for pretty-printing JSON as syntax-highlighted HTML.
70
+ * @namespace
71
+ */
72
+ const prettyPrintJson = {
73
+ /**
74
+ * Converts a JavaScript value to pretty-printed, syntax-highlighted HTML.
75
+ * @param {object} data - Data to pretty-print (object, array, etc).
76
+ * @param {object} [options] - Formatting options.
77
+ * @returns {string} HTML string representing the pretty-printed JSON.
78
+ */
79
+ toHtml(data, options) {
80
+ const settings = { ...defaults, ...options };
81
+
82
+ /**
83
+ * Replaces each JSON line with syntax-highlighted HTML.
84
+ * @param {string} match - Full matched line.
85
+ * @param {...string} parts - Regex capture groups: indent, key, value, end.
86
+ * @returns {string} HTML for the line.
87
+ */
88
+ const replacer = (match, ...parts) => {
89
+ const part = { indent: parts[0], key: parts[1], value: parts[2], end: parts[3] };
90
+ const findName = settings.quoteKeys ? /(.*)(): / : /"([\w$]+)": |(.*): /;
91
+ const indentHtml = part.indent || '';
92
+ const keyName = part.key?.replace(findName, '$1$2');
93
+ const keyHtml = part.key ? spanTag('key', keyName) + spanTag('mark', ': ') : '';
94
+ const valueHtml = part.value ? buildValueHtml(part.value) : '';
95
+ const noComma = !part.end || [']', '}'].includes(match.at(-1));
96
+ const addComma = settings.trailingCommas && match.at(0) === ' ' && noComma;
97
+ const endHtml = spanTag('mark', addComma ? (part.end ?? '') + ',' : part.end);
98
+ return indentHtml + keyHtml + valueHtml + endHtml;
99
+ };
100
+
101
+ const json = JSON.stringify(data, null, settings.indent) || 'undefined';
102
+ const html = json.replaceAll(invalidHtml, toHtml).replaceAll(jsonLine, replacer);
103
+
104
+ return html;
105
+ },
106
+ };
107
+
108
+ export { prettyPrintJson };