@webstudio-is/sdk-components-react 0.230.0 → 0.232.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.
|
@@ -3,7 +3,7 @@ const e = {
|
|
|
3
3
|
required: !1,
|
|
4
4
|
control: "text",
|
|
5
5
|
type: "string",
|
|
6
|
-
description: "
|
|
6
|
+
description: ""
|
|
7
7
|
},
|
|
8
8
|
clientOnly: { required: !1, control: "boolean", type: "boolean" },
|
|
9
9
|
code: { required: !0, control: "text", type: "string" },
|
|
@@ -213,6 +213,14 @@ const e = {
|
|
|
213
213
|
defaultValue: "medium",
|
|
214
214
|
options: ["full", "long", "medium", "short", "none"]
|
|
215
215
|
},
|
|
216
|
+
format: {
|
|
217
|
+
description: `Custom format template string. When provided, overrides Date Style and Time Style.
|
|
218
|
+
Supports tokens: YYYY, YY, MM, M, DD, D, HH, H, mm, m, ss, s.
|
|
219
|
+
Example: "YYYY-MM-DD HH:mm:ss" displays as "2025-11-03 18:47:25"`,
|
|
220
|
+
required: !1,
|
|
221
|
+
control: "text",
|
|
222
|
+
type: "string"
|
|
223
|
+
},
|
|
216
224
|
language: {
|
|
217
225
|
required: !1,
|
|
218
226
|
control: "select",
|
package/lib/time.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as m } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
const
|
|
2
|
+
import { forwardRef as a } from "react";
|
|
3
|
+
const N = [
|
|
4
4
|
"af",
|
|
5
5
|
"am",
|
|
6
6
|
"ar",
|
|
@@ -272,7 +272,7 @@ const c = [
|
|
|
272
272
|
"YE",
|
|
273
273
|
"ZM",
|
|
274
274
|
"ZW"
|
|
275
|
-
],
|
|
275
|
+
], G = "dateTime attribute is not set", L = "", M = "en", u = "GB", f = "medium", Y = "none", g = (t) => N.includes(t) ? t : M, I = (t) => E.includes(t) ? t : u, B = (t) => {
|
|
276
276
|
if (["full", "long", "medium", "short"].includes(t))
|
|
277
277
|
return t;
|
|
278
278
|
}, R = (t) => {
|
|
@@ -281,40 +281,66 @@ const c = [
|
|
|
281
281
|
}, C = (t) => {
|
|
282
282
|
if (t === "")
|
|
283
283
|
return;
|
|
284
|
-
let
|
|
285
|
-
if (Number.isNaN(
|
|
286
|
-
return
|
|
284
|
+
let n = new Date(t);
|
|
285
|
+
if (Number.isNaN(n.getTime()) === !1)
|
|
286
|
+
return n;
|
|
287
287
|
if (/^\d+$/.test(t)) {
|
|
288
|
-
let
|
|
289
|
-
t.length === 10 && (
|
|
288
|
+
let e = Number(t);
|
|
289
|
+
t.length === 10 && (e *= 1e3), n = new Date(e);
|
|
290
290
|
}
|
|
291
|
-
if (Number.isNaN(
|
|
292
|
-
return
|
|
293
|
-
},
|
|
291
|
+
if (Number.isNaN(n.getTime()) === !1)
|
|
292
|
+
return n;
|
|
293
|
+
}, U = (t, n) => {
|
|
294
|
+
const e = (s, r = 2) => String(s).padStart(r, "0"), o = {
|
|
295
|
+
YYYY: t.getFullYear(),
|
|
296
|
+
YY: String(t.getFullYear()).slice(-2),
|
|
297
|
+
MM: e(t.getMonth() + 1),
|
|
298
|
+
M: t.getMonth() + 1,
|
|
299
|
+
DD: e(t.getDate()),
|
|
300
|
+
D: t.getDate(),
|
|
301
|
+
HH: e(t.getHours()),
|
|
302
|
+
H: t.getHours(),
|
|
303
|
+
mm: e(t.getMinutes()),
|
|
304
|
+
m: t.getMinutes(),
|
|
305
|
+
ss: e(t.getSeconds()),
|
|
306
|
+
s: t.getSeconds()
|
|
307
|
+
};
|
|
308
|
+
return n.replace(
|
|
309
|
+
/\b(YYYY|YY|MM|M|DD|D|HH|H|mm|m|ss|s)\b/g,
|
|
310
|
+
(s) => String(o[s])
|
|
311
|
+
);
|
|
312
|
+
}, h = a(
|
|
294
313
|
({
|
|
295
|
-
language: t =
|
|
296
|
-
country:
|
|
297
|
-
dateStyle:
|
|
298
|
-
timeStyle:
|
|
314
|
+
language: t = M,
|
|
315
|
+
country: n = u,
|
|
316
|
+
dateStyle: e = f,
|
|
317
|
+
timeStyle: o = Y,
|
|
318
|
+
format: s,
|
|
299
319
|
// native html attribute in react style
|
|
300
|
-
dateTime:
|
|
301
|
-
...
|
|
302
|
-
},
|
|
303
|
-
const
|
|
304
|
-
|
|
305
|
-
)}`,
|
|
306
|
-
dateStyle:
|
|
307
|
-
timeStyle: R(
|
|
308
|
-
},
|
|
309
|
-
let
|
|
310
|
-
if (
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
320
|
+
dateTime: r = G,
|
|
321
|
+
...c
|
|
322
|
+
}, S) => {
|
|
323
|
+
const A = `${g(t)}-${I(
|
|
324
|
+
n
|
|
325
|
+
)}`, D = {
|
|
326
|
+
dateStyle: B(e),
|
|
327
|
+
timeStyle: R(o)
|
|
328
|
+
}, i = r === null ? L : r.toString(), l = C(i);
|
|
329
|
+
let T = i;
|
|
330
|
+
if (l)
|
|
331
|
+
if (s)
|
|
332
|
+
try {
|
|
333
|
+
T = U(l, s);
|
|
334
|
+
} catch {
|
|
335
|
+
}
|
|
336
|
+
else
|
|
337
|
+
try {
|
|
338
|
+
T = new Intl.DateTimeFormat(A, D).format(l);
|
|
339
|
+
} catch {
|
|
340
|
+
}
|
|
341
|
+
return /* @__PURE__ */ m("time", { ref: S, dateTime: i, ...c, children: T });
|
|
316
342
|
}
|
|
317
343
|
);
|
|
318
344
|
export {
|
|
319
|
-
|
|
345
|
+
h as Time
|
|
320
346
|
};
|
package/lib/time.ws.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { time as
|
|
2
|
-
import { props as
|
|
1
|
+
import { time as t } from "@webstudio-is/sdk/normalize.css";
|
|
2
|
+
import { props as e } from "./__generated__/time.props.js";
|
|
3
3
|
const r = {
|
|
4
4
|
category: "localization",
|
|
5
5
|
description: "Converts machine-readable date and time to a human-readable format.",
|
|
@@ -8,10 +8,17 @@ const r = {
|
|
|
8
8
|
children: []
|
|
9
9
|
},
|
|
10
10
|
presetStyle: {
|
|
11
|
-
time:
|
|
11
|
+
time: t
|
|
12
12
|
},
|
|
13
|
-
initialProps: [
|
|
14
|
-
|
|
13
|
+
initialProps: [
|
|
14
|
+
"datetime",
|
|
15
|
+
"language",
|
|
16
|
+
"country",
|
|
17
|
+
"dateStyle",
|
|
18
|
+
"timeStyle",
|
|
19
|
+
"format"
|
|
20
|
+
],
|
|
21
|
+
props: e
|
|
15
22
|
};
|
|
16
23
|
export {
|
|
17
24
|
r as meta
|
package/lib/types/time.d.ts
CHANGED
|
@@ -9,8 +9,15 @@ export declare const Time: import("react").ForwardRefExoticComponent<Pick<import
|
|
|
9
9
|
country?: Country;
|
|
10
10
|
dateStyle?: DateStyle;
|
|
11
11
|
timeStyle?: TimeStyle;
|
|
12
|
+
/**
|
|
13
|
+
* Custom format template string. When provided, overrides Date Style and Time Style.
|
|
14
|
+
* Supports tokens: YYYY, YY, MM, M, DD, D, HH, H, mm, m, ss, s.
|
|
15
|
+
* Example: "YYYY-MM-DD HH:mm:ss" displays as "2025-11-03 18:47:25"
|
|
16
|
+
*/
|
|
17
|
+
format?: string;
|
|
12
18
|
} & import("react").RefAttributes<HTMLTimeElement>>;
|
|
13
19
|
export declare const __testing__: {
|
|
14
20
|
parseDate: (datetimeString: string) => Date | undefined;
|
|
21
|
+
formatDate: (date: Date, template: string) => string;
|
|
15
22
|
};
|
|
16
23
|
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.232.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.232.0",
|
|
48
|
+
"@webstudio-is/image": "0.232.0",
|
|
49
|
+
"@webstudio-is/sdk": "0.232.0",
|
|
50
|
+
"@webstudio-is/react-sdk": "0.232.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@testing-library/dom": "^10.4.0",
|
|
@@ -59,8 +59,8 @@
|
|
|
59
59
|
"react-dom": "18.3.0-canary-14898b6a9-20240318",
|
|
60
60
|
"vitest": "^3.1.2",
|
|
61
61
|
"@webstudio-is/generate-arg-types": "0.0.0",
|
|
62
|
-
"@webstudio-is/template": "0.230.0",
|
|
63
62
|
"@webstudio-is/tsconfig": "1.0.7",
|
|
63
|
+
"@webstudio-is/template": "0.232.0",
|
|
64
64
|
"@webstudio-is/sdk-cli": "0.94.0"
|
|
65
65
|
},
|
|
66
66
|
"scripts": {
|