javascript-excel 2.0.0-alpha.1 → 2.0.0-alpha.2

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/dist/dom.js CHANGED
@@ -1,5 +1,6 @@
1
- import { c as hyperlinkSchemes, h as mergeStyles, i as DEFAULT_HYPERLINK_SCHEMES, l as textWidth, m as cellText, n as validateSheetName, r as AUTO_WIDTH } from "./sheet-names-CDsVK15c.js";
1
+ import { c as hyperlinkSchemes, h as mergeStyles, i as DEFAULT_HYPERLINK_SCHEMES, l as textWidth, m as cellText, n as validateSheetName, r as AUTO_WIDTH } from "./sheet-names-uT2EH5Ui.js";
2
2
  import { n as EnvironmentError, o as ValidationError } from "./errors-CvGlfw0E.js";
3
+ import { n as parseIsoDate } from "./iso-date-CXnn-9mT.js";
3
4
  // src/auto-width.ts
4
5
  /**
5
6
  * Auto column widths for builders (docs/api.md §4.3, §5.4).
@@ -184,7 +185,6 @@ function cellTextOf(el) {
184
185
  }
185
186
  const PLAIN_NUMBER = /^[+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?$/;
186
187
  const GROUPED_NUMBER = /^[+-]?\d{1,3}(?:,\d{3})+(?:\.\d+)?$/;
187
- const ISO_DATE = /^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3})\d*)?)?(Z|[+-]\d{2}:?\d{2})?)?$/;
188
188
  function parseNumber(s) {
189
189
  const t = s.trim();
190
190
  if (PLAIN_NUMBER.test(t)) return Number(t);
@@ -195,30 +195,6 @@ function parseBoolean(s) {
195
195
  if (t === "true" || t === "yes" || t === "1") return true;
196
196
  if (t === "false" || t === "no" || t === "0") return false;
197
197
  }
198
- /** ISO 8601 date or date-time. Without a zone, the local wall-clock time (dateZone 'local'). */
199
- function parseDate(s) {
200
- const m = ISO_DATE.exec(s.trim());
201
- if (!m) return void 0;
202
- const [y, mo, d, h = "0", mi = "0", sec = "0", ms = "0", zone] = m.slice(1);
203
- const parts = [
204
- Number(y),
205
- Number(mo) - 1,
206
- Number(d),
207
- Number(h),
208
- Number(mi),
209
- Number(sec),
210
- Number(ms.padEnd(3, "0"))
211
- ];
212
- let date;
213
- if (zone) {
214
- const off = zone === "Z" ? 0 : (zone[0] === "-" ? -1 : 1) * (Number(zone.slice(1, 3)) * 60 + Number(zone.slice(-2)));
215
- date = /* @__PURE__ */ new Date(Date.UTC(...parts) - off * 6e4);
216
- } else date = new Date(...parts);
217
- const wall = zone ? new Date(Date.UTC(...parts)) : date;
218
- const [month, day] = zone ? [wall.getUTCMonth(), wall.getUTCDate()] : [wall.getMonth(), wall.getDate()];
219
- if (month !== parts[1] || day !== parts[2]) return void 0;
220
- return Number.isFinite(date.getTime()) ? date : void 0;
221
- }
222
198
  function coerce(ctx, raw, type, ref) {
223
199
  if (type === null || type === "" || type === "string") {
224
200
  if (ctx.inferTypes) {
@@ -245,7 +221,7 @@ function coerce(ctx, raw, type, ref) {
245
221
  return n !== void 0 && Number.isFinite(n) ? n : fail();
246
222
  }
247
223
  case "boolean": return parseBoolean(raw) ?? fail();
248
- case "date": return parseDate(raw) ?? fail();
224
+ case "date": return parseIsoDate(raw) ?? fail();
249
225
  default:
250
226
  ctx.warn({
251
227
  code: "COERCION_FAILED",