@webstudio-is/sdk-components-react 0.266.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.
- package/lib/time.js +52 -47
- package/package.json +8 -8
package/lib/time.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
const
|
|
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
|
-
],
|
|
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
|
-
],
|
|
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
|
-
},
|
|
278
|
+
}, B = (t) => {
|
|
279
279
|
if (["full", "long", "medium", "short"].includes(t))
|
|
280
280
|
return t;
|
|
281
|
-
},
|
|
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 = (
|
|
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),
|
|
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),
|
|
303
|
+
}).format(t), a = new Intl.DateTimeFormat(n, {
|
|
304
|
+
timeZone: i,
|
|
301
305
|
month: "short"
|
|
302
|
-
}).format(t),
|
|
303
|
-
YYYY: t.
|
|
304
|
-
YY: String(t.
|
|
306
|
+
}).format(t), T = {
|
|
307
|
+
YYYY: t.getUTCFullYear(),
|
|
308
|
+
YY: String(t.getUTCFullYear()).slice(-2),
|
|
305
309
|
MMMM: l,
|
|
306
|
-
MMM:
|
|
307
|
-
MM: s(t.
|
|
308
|
-
M: t.
|
|
309
|
-
DDDD:
|
|
310
|
-
DDD:
|
|
311
|
-
DD: s(t.
|
|
312
|
-
D: t.
|
|
313
|
-
HH: s(t.
|
|
314
|
-
H: t.
|
|
315
|
-
mm: s(t.
|
|
316
|
-
m: t.
|
|
317
|
-
ss: s(t.
|
|
318
|
-
s: t.
|
|
319
|
-
},
|
|
320
|
-
return e.replace(
|
|
321
|
-
},
|
|
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 =
|
|
324
|
-
country: e =
|
|
325
|
-
dateStyle: n =
|
|
327
|
+
language: t = u,
|
|
328
|
+
country: e = S,
|
|
329
|
+
dateStyle: n = f,
|
|
326
330
|
timeStyle: s = I,
|
|
327
|
-
format:
|
|
328
|
-
datetime:
|
|
331
|
+
format: D,
|
|
332
|
+
datetime: M = C,
|
|
329
333
|
...l
|
|
330
|
-
},
|
|
331
|
-
const
|
|
334
|
+
}, a) => {
|
|
335
|
+
const T = `${L(t)}-${G(
|
|
332
336
|
e
|
|
333
|
-
)}`,
|
|
334
|
-
dateStyle:
|
|
335
|
-
timeStyle:
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
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
|
-
|
|
346
|
+
r = Y(o, D, T);
|
|
342
347
|
} catch {
|
|
343
348
|
}
|
|
344
349
|
else
|
|
345
350
|
try {
|
|
346
|
-
|
|
351
|
+
r = new Intl.DateTimeFormat(T, c).format(o);
|
|
347
352
|
} catch {
|
|
348
353
|
}
|
|
349
|
-
return /* @__PURE__ */
|
|
354
|
+
return /* @__PURE__ */ A("time", { ref: a, dateTime: m, ...l, children: r });
|
|
350
355
|
}
|
|
351
356
|
);
|
|
352
357
|
export {
|
|
353
|
-
|
|
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.
|
|
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.
|
|
48
|
-
"@webstudio-is/
|
|
49
|
-
"@webstudio-is/
|
|
50
|
-
"@webstudio-is/react-sdk": "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",
|
|
@@ -59,10 +59,10 @@
|
|
|
59
59
|
"react-dom": "18.3.0-canary-14898b6a9-20240318",
|
|
60
60
|
"vitest": "^3.1.2",
|
|
61
61
|
"@webstudio-is/design-system": "0.0.0",
|
|
62
|
-
"@webstudio-is/generate-arg-types": "0.0.0",
|
|
63
62
|
"@webstudio-is/sdk-cli": "0.94.0",
|
|
64
|
-
"@webstudio-is/
|
|
65
|
-
"@webstudio-is/template": "0.
|
|
63
|
+
"@webstudio-is/generate-arg-types": "0.0.0",
|
|
64
|
+
"@webstudio-is/template": "0.268.0",
|
|
65
|
+
"@webstudio-is/tsconfig": "1.0.7"
|
|
66
66
|
},
|
|
67
67
|
"scripts": {
|
|
68
68
|
"build": "vite build --config ../../vite.sdk-components.config.ts",
|