@webstudio-is/sdk-components-react 0.252.2 → 0.253.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/__generated__/time.props.js +10 -3
- package/lib/time.js +55 -46
- package/lib/types/time.d.ts +11 -4
- package/package.json +7 -7
|
@@ -214,9 +214,16 @@ const e = {
|
|
|
214
214
|
options: ["full", "long", "medium", "short", "none"]
|
|
215
215
|
},
|
|
216
216
|
format: {
|
|
217
|
-
description: `Custom format template
|
|
218
|
-
|
|
219
|
-
|
|
217
|
+
description: `Custom format template. Overrides Date Style and Time Style.
|
|
218
|
+
|
|
219
|
+
Tokens: YYYY/YY (year), MMMM/MMM/MM/M (month), DDDD/DDD/DD/D (day), HH/H (hours), mm/m (minutes), ss/s (seconds)
|
|
220
|
+
|
|
221
|
+
Examples:
|
|
222
|
+
"YYYY-MM-DD" → 2025-11-03
|
|
223
|
+
"DDDD, MMMM D" → Monday, November 3
|
|
224
|
+
"DDD, D. MMM YYYY" → Mon, 3. Nov 2025
|
|
225
|
+
|
|
226
|
+
Day and month names use the selected language.`,
|
|
220
227
|
required: !1,
|
|
221
228
|
control: "text",
|
|
222
229
|
type: "string"
|
package/lib/time.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { forwardRef as
|
|
1
|
+
import { jsx as S } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as A } from "react";
|
|
3
3
|
const N = [
|
|
4
4
|
"af",
|
|
5
5
|
"am",
|
|
@@ -72,7 +72,7 @@ const N = [
|
|
|
72
72
|
"uz",
|
|
73
73
|
"vi",
|
|
74
74
|
"zh"
|
|
75
|
-
],
|
|
75
|
+
], g = [
|
|
76
76
|
"AF",
|
|
77
77
|
"AL",
|
|
78
78
|
"DZ",
|
|
@@ -272,75 +272,84 @@ const N = [
|
|
|
272
272
|
"YE",
|
|
273
273
|
"ZM",
|
|
274
274
|
"ZW"
|
|
275
|
-
],
|
|
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) => {
|
|
276
276
|
if (["full", "long", "medium", "short"].includes(t))
|
|
277
277
|
return t;
|
|
278
278
|
}, R = (t) => {
|
|
279
279
|
if (["full", "long", "medium", "short"].includes(t))
|
|
280
280
|
return t;
|
|
281
|
-
},
|
|
281
|
+
}, U = (t) => {
|
|
282
282
|
if (t === "")
|
|
283
283
|
return;
|
|
284
|
-
let
|
|
285
|
-
if (Number.isNaN(
|
|
286
|
-
return
|
|
284
|
+
let e = new Date(t);
|
|
285
|
+
if (Number.isNaN(e.getTime()) === !1)
|
|
286
|
+
return e;
|
|
287
287
|
if (/^\d+$/.test(t)) {
|
|
288
|
-
let
|
|
289
|
-
t.length === 10 && (
|
|
288
|
+
let n = Number(t);
|
|
289
|
+
t.length === 10 && (n *= 1e3), e = new Date(n);
|
|
290
290
|
}
|
|
291
|
-
if (Number.isNaN(
|
|
292
|
-
return
|
|
293
|
-
},
|
|
294
|
-
const
|
|
291
|
+
if (Number.isNaN(e.getTime()) === !1)
|
|
292
|
+
return e;
|
|
293
|
+
}, Y = (t, e, n = "en-US") => {
|
|
294
|
+
const r = (o, s = 2) => String(o).padStart(s, "0"), D = new Intl.DateTimeFormat(n, {
|
|
295
|
+
weekday: "long"
|
|
296
|
+
}).format(t), T = new Intl.DateTimeFormat(n, {
|
|
297
|
+
weekday: "short"
|
|
298
|
+
}).format(t), l = new Intl.DateTimeFormat(n, {
|
|
299
|
+
month: "long"
|
|
300
|
+
}).format(t), M = new Intl.DateTimeFormat(n, {
|
|
301
|
+
month: "short"
|
|
302
|
+
}).format(t), m = {
|
|
295
303
|
YYYY: t.getFullYear(),
|
|
296
304
|
YY: String(t.getFullYear()).slice(-2),
|
|
297
|
-
|
|
305
|
+
MMMM: l,
|
|
306
|
+
MMM: M,
|
|
307
|
+
MM: r(t.getMonth() + 1),
|
|
298
308
|
M: t.getMonth() + 1,
|
|
299
|
-
|
|
309
|
+
DDDD: D,
|
|
310
|
+
DDD: T,
|
|
311
|
+
DD: r(t.getDate()),
|
|
300
312
|
D: t.getDate(),
|
|
301
|
-
HH:
|
|
313
|
+
HH: r(t.getHours()),
|
|
302
314
|
H: t.getHours(),
|
|
303
|
-
mm:
|
|
315
|
+
mm: r(t.getMinutes()),
|
|
304
316
|
m: t.getMinutes(),
|
|
305
|
-
ss:
|
|
317
|
+
ss: r(t.getSeconds()),
|
|
306
318
|
s: t.getSeconds()
|
|
307
|
-
};
|
|
308
|
-
return
|
|
309
|
-
|
|
310
|
-
(s) => String(o[s])
|
|
311
|
-
);
|
|
312
|
-
}, h = a(
|
|
319
|
+
}, a = Object.keys(m).sort((o, s) => s.length - o.length), i = new RegExp(`\\b(${a.join("|")})\\b`, "g");
|
|
320
|
+
return e.replace(i, (o) => String(m[o]));
|
|
321
|
+
}, H = A(
|
|
313
322
|
({
|
|
314
|
-
language: t =
|
|
315
|
-
country:
|
|
316
|
-
dateStyle:
|
|
317
|
-
timeStyle:
|
|
318
|
-
format:
|
|
323
|
+
language: t = c,
|
|
324
|
+
country: e = u,
|
|
325
|
+
dateStyle: n = G,
|
|
326
|
+
timeStyle: r = I,
|
|
327
|
+
format: D,
|
|
319
328
|
// native html attribute in react style
|
|
320
|
-
dateTime:
|
|
321
|
-
...
|
|
322
|
-
},
|
|
323
|
-
const
|
|
324
|
-
|
|
325
|
-
)}`,
|
|
326
|
-
dateStyle: B(
|
|
327
|
-
timeStyle: R(
|
|
328
|
-
}, i =
|
|
329
|
-
let
|
|
330
|
-
if (
|
|
331
|
-
if (
|
|
329
|
+
dateTime: T = f,
|
|
330
|
+
...l
|
|
331
|
+
}, M) => {
|
|
332
|
+
const m = `${L(t)}-${h(
|
|
333
|
+
e
|
|
334
|
+
)}`, a = {
|
|
335
|
+
dateStyle: B(n),
|
|
336
|
+
timeStyle: R(r)
|
|
337
|
+
}, i = T === null ? E : T.toString(), o = U(i);
|
|
338
|
+
let s = i;
|
|
339
|
+
if (o)
|
|
340
|
+
if (D)
|
|
332
341
|
try {
|
|
333
|
-
|
|
342
|
+
s = Y(o, D, m);
|
|
334
343
|
} catch {
|
|
335
344
|
}
|
|
336
345
|
else
|
|
337
346
|
try {
|
|
338
|
-
|
|
347
|
+
s = new Intl.DateTimeFormat(m, a).format(o);
|
|
339
348
|
} catch {
|
|
340
349
|
}
|
|
341
|
-
return /* @__PURE__ */
|
|
350
|
+
return /* @__PURE__ */ S("time", { ref: M, dateTime: i, ...l, children: s });
|
|
342
351
|
}
|
|
343
352
|
);
|
|
344
353
|
export {
|
|
345
|
-
|
|
354
|
+
H as Time
|
|
346
355
|
};
|
package/lib/types/time.d.ts
CHANGED
|
@@ -10,14 +10,21 @@ export declare const Time: import("react").ForwardRefExoticComponent<Pick<import
|
|
|
10
10
|
dateStyle?: DateStyle;
|
|
11
11
|
timeStyle?: TimeStyle;
|
|
12
12
|
/**
|
|
13
|
-
* Custom format template
|
|
14
|
-
*
|
|
15
|
-
*
|
|
13
|
+
* Custom format template. Overrides Date Style and Time Style.
|
|
14
|
+
*
|
|
15
|
+
* Tokens: YYYY/YY (year), MMMM/MMM/MM/M (month), DDDD/DDD/DD/D (day), HH/H (hours), mm/m (minutes), ss/s (seconds)
|
|
16
|
+
*
|
|
17
|
+
* Examples:
|
|
18
|
+
* - "YYYY-MM-DD" → 2025-11-03
|
|
19
|
+
* - "DDDD, MMMM D" → Monday, November 3
|
|
20
|
+
* - "DDD, D. MMM YYYY" → Mon, 3. Nov 2025
|
|
21
|
+
*
|
|
22
|
+
* Day and month names use the selected language.
|
|
16
23
|
*/
|
|
17
24
|
format?: string;
|
|
18
25
|
} & import("react").RefAttributes<HTMLTimeElement>>;
|
|
19
26
|
export declare const __testing__: {
|
|
20
27
|
parseDate: (datetimeString: string) => Date | undefined;
|
|
21
|
-
formatDate: (date: Date, template: string) => string;
|
|
28
|
+
formatDate: (date: Date, template: string, locale?: string) => string;
|
|
22
29
|
};
|
|
23
30
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webstudio-is/sdk-components-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.253.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/
|
|
47
|
+
"@webstudio-is/icons": "0.253.0",
|
|
48
|
+
"@webstudio-is/react-sdk": "0.253.0",
|
|
49
|
+
"@webstudio-is/image": "0.253.0",
|
|
50
|
+
"@webstudio-is/sdk": "0.253.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@testing-library/dom": "^10.4.0",
|
|
@@ -60,8 +60,8 @@
|
|
|
60
60
|
"vitest": "^3.1.2",
|
|
61
61
|
"@webstudio-is/generate-arg-types": "0.0.0",
|
|
62
62
|
"@webstudio-is/sdk-cli": "0.94.0",
|
|
63
|
-
"@webstudio-is/
|
|
64
|
-
"@webstudio-is/
|
|
63
|
+
"@webstudio-is/tsconfig": "1.0.7",
|
|
64
|
+
"@webstudio-is/template": "0.253.0"
|
|
65
65
|
},
|
|
66
66
|
"scripts": {
|
|
67
67
|
"build": "vite build --config ../../vite.sdk-components.config.ts",
|