@webstudio-is/sdk-components-react 0.267.0 → 0.268.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 (2) hide show
  1. package/lib/time.js +52 -47
  2. package/package.json +7 -7
package/lib/time.js CHANGED
@@ -1,6 +1,6 @@
1
- import { jsx as S } from "react/jsx-runtime";
2
- import { forwardRef as A } from "react";
3
- const N = [
1
+ import { jsx as A } from "react/jsx-runtime";
2
+ import { forwardRef as N } from "react";
3
+ const U = [
4
4
  "af",
5
5
  "am",
6
6
  "ar",
@@ -72,7 +72,7 @@ const N = [
72
72
  "uz",
73
73
  "vi",
74
74
  "zh"
75
- ], g = [
75
+ ], E = [
76
76
  "AF",
77
77
  "AL",
78
78
  "DZ",
@@ -272,13 +272,13 @@ const N = [
272
272
  "YE",
273
273
  "ZM",
274
274
  "ZW"
275
- ], f = "dateTime attribute is not set", E = "", c = "en", u = "GB", G = "medium", I = "none", L = (t) => N.includes(t) ? t : c, h = (t) => g.includes(t) ? t : u, B = (t) => {
275
+ ], C = "dateTime attribute is not set", g = "", u = "en", S = "GB", f = "medium", I = "none", i = "UTC", L = (t) => U.includes(t) ? t : u, G = (t) => E.includes(t) ? t : S, h = (t) => {
276
276
  if (["full", "long", "medium", "short"].includes(t))
277
277
  return t;
278
- }, R = (t) => {
278
+ }, B = (t) => {
279
279
  if (["full", "long", "medium", "short"].includes(t))
280
280
  return t;
281
- }, U = (t) => {
281
+ }, R = (t) => {
282
282
  if (t === "")
283
283
  return;
284
284
  let e = new Date(t);
@@ -291,64 +291,69 @@ const N = [
291
291
  if (Number.isNaN(e.getTime()) === !1)
292
292
  return e;
293
293
  }, Y = (t, e, n = "en-US") => {
294
- const s = (r, o = 2) => String(r).padStart(o, "0"), T = new Intl.DateTimeFormat(n, {
294
+ const s = (o, r = 2) => String(o).padStart(r, "0"), D = new Intl.DateTimeFormat(n, {
295
+ timeZone: i,
295
296
  weekday: "long"
296
- }).format(t), D = new Intl.DateTimeFormat(n, {
297
+ }).format(t), M = new Intl.DateTimeFormat(n, {
298
+ timeZone: i,
297
299
  weekday: "short"
298
300
  }).format(t), l = new Intl.DateTimeFormat(n, {
301
+ timeZone: i,
299
302
  month: "long"
300
- }).format(t), M = new Intl.DateTimeFormat(n, {
303
+ }).format(t), a = new Intl.DateTimeFormat(n, {
304
+ timeZone: i,
301
305
  month: "short"
302
- }).format(t), m = {
303
- YYYY: t.getFullYear(),
304
- YY: String(t.getFullYear()).slice(-2),
306
+ }).format(t), T = {
307
+ YYYY: t.getUTCFullYear(),
308
+ YY: String(t.getUTCFullYear()).slice(-2),
305
309
  MMMM: l,
306
- MMM: M,
307
- MM: s(t.getMonth() + 1),
308
- M: t.getMonth() + 1,
309
- DDDD: T,
310
- DDD: D,
311
- DD: s(t.getDate()),
312
- D: t.getDate(),
313
- HH: s(t.getHours()),
314
- H: t.getHours(),
315
- mm: s(t.getMinutes()),
316
- m: t.getMinutes(),
317
- ss: s(t.getSeconds()),
318
- s: t.getSeconds()
319
- }, a = Object.keys(m).sort((r, o) => o.length - r.length), i = new RegExp(`\\b(${a.join("|")})\\b`, "g");
320
- return e.replace(i, (r) => String(m[r]));
321
- }, H = A(
310
+ MMM: a,
311
+ MM: s(t.getUTCMonth() + 1),
312
+ M: t.getUTCMonth() + 1,
313
+ DDDD: D,
314
+ DDD: M,
315
+ DD: s(t.getUTCDate()),
316
+ D: t.getUTCDate(),
317
+ HH: s(t.getUTCHours()),
318
+ H: t.getUTCHours(),
319
+ mm: s(t.getUTCMinutes()),
320
+ m: t.getUTCMinutes(),
321
+ ss: s(t.getUTCSeconds()),
322
+ s: t.getUTCSeconds()
323
+ }, c = Object.keys(T).sort((o, r) => r.length - o.length), m = new RegExp(`\\b(${c.join("|")})\\b`, "g");
324
+ return e.replace(m, (o) => String(T[o]));
325
+ }, O = N(
322
326
  ({
323
- language: t = c,
324
- country: e = u,
325
- dateStyle: n = G,
327
+ language: t = u,
328
+ country: e = S,
329
+ dateStyle: n = f,
326
330
  timeStyle: s = I,
327
- format: T,
328
- datetime: D = f,
331
+ format: D,
332
+ datetime: M = C,
329
333
  ...l
330
- }, M) => {
331
- const m = `${L(t)}-${h(
334
+ }, a) => {
335
+ const T = `${L(t)}-${G(
332
336
  e
333
- )}`, a = {
334
- dateStyle: B(n),
335
- timeStyle: R(s)
336
- }, i = D === null ? E : D.toString(), r = U(i);
337
- let o = i;
338
- if (r)
339
- if (T)
337
+ )}`, c = {
338
+ dateStyle: h(n),
339
+ timeStyle: B(s),
340
+ timeZone: i
341
+ }, m = M === null ? g : M.toString(), o = R(m);
342
+ let r = m;
343
+ if (o)
344
+ if (D)
340
345
  try {
341
- o = Y(r, T, m);
346
+ r = Y(o, D, T);
342
347
  } catch {
343
348
  }
344
349
  else
345
350
  try {
346
- o = new Intl.DateTimeFormat(m, a).format(r);
351
+ r = new Intl.DateTimeFormat(T, c).format(o);
347
352
  } catch {
348
353
  }
349
- return /* @__PURE__ */ S("time", { ref: M, dateTime: i, ...l, children: o });
354
+ return /* @__PURE__ */ A("time", { ref: a, dateTime: m, ...l, children: r });
350
355
  }
351
356
  );
352
357
  export {
353
- H as Time
358
+ O as Time
354
359
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webstudio-is/sdk-components-react",
3
- "version": "0.267.0",
3
+ "version": "0.268.0",
4
4
  "description": "Webstudio default library for react",
5
5
  "author": "Webstudio <github@webstudio.is>",
6
6
  "homepage": "https://webstudio.is",
@@ -44,10 +44,10 @@
44
44
  "colord": "^2.9.3",
45
45
  "micromark": "^4.0.2",
46
46
  "micromark-extension-gfm-table": "^2.1.1",
47
- "@webstudio-is/icons": "0.267.0",
48
- "@webstudio-is/image": "0.267.0",
49
- "@webstudio-is/sdk": "0.267.0",
50
- "@webstudio-is/react-sdk": "0.267.0"
47
+ "@webstudio-is/icons": "0.268.0",
48
+ "@webstudio-is/image": "0.268.0",
49
+ "@webstudio-is/sdk": "0.268.0",
50
+ "@webstudio-is/react-sdk": "0.268.0"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@testing-library/dom": "^10.4.0",
@@ -58,10 +58,10 @@
58
58
  "react": "18.3.0-canary-14898b6a9-20240318",
59
59
  "react-dom": "18.3.0-canary-14898b6a9-20240318",
60
60
  "vitest": "^3.1.2",
61
- "@webstudio-is/generate-arg-types": "0.0.0",
62
61
  "@webstudio-is/design-system": "0.0.0",
63
62
  "@webstudio-is/sdk-cli": "0.94.0",
64
- "@webstudio-is/template": "0.267.0",
63
+ "@webstudio-is/generate-arg-types": "0.0.0",
64
+ "@webstudio-is/template": "0.268.0",
65
65
  "@webstudio-is/tsconfig": "1.0.7"
66
66
  },
67
67
  "scripts": {