@yuneta/gobj-ui 7.31.6 → 7.31.8
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/README.md +13 -5
- package/dist/gobj-ui.cjs.js +205 -51
- package/dist/gobj-ui.es.js +205 -51
- package/package.json +1 -1
- package/src/c_yui_json_graph.js +247 -76
- package/src/fmt_date_time.test.js +55 -0
- package/src/json_graph_lit_edge.wiring.test.js +90 -4
- package/src/yui_date_text.js +27 -2
- package/src/yui_icons.css +7 -0
package/src/yui_date_text.js
CHANGED
|
@@ -69,6 +69,30 @@ const DATE_TIME_OPTIONS = {
|
|
|
69
69
|
hourCycle: "h23"
|
|
70
70
|
};
|
|
71
71
|
|
|
72
|
+
/* The formatters of fmt_date_time(), by locale and time zone. A
|
|
73
|
+
* filter over a time column formats every row on every keystroke,
|
|
74
|
+
* and building an Intl.DateTimeFormat costs some 20 times what one
|
|
75
|
+
* format() costs. A formatter keeps the time zone it was built in,
|
|
76
|
+
* so the key carries the zone's offsets in January and in July: a
|
|
77
|
+
* zone that changes under the page (TZ in node, the system's in a
|
|
78
|
+
* browser) gets a new one. Plain Dates, not Intl: nothing of Intl
|
|
79
|
+
* is built at module top level (see safe_locale). */
|
|
80
|
+
const __date_time_formatters__ = new Map();
|
|
81
|
+
const JANUARY = new Date(Date.UTC(2026, 0, 1));
|
|
82
|
+
const JULY = new Date(Date.UTC(2026, 6, 1));
|
|
83
|
+
|
|
84
|
+
function date_time_formatter(locale)
|
|
85
|
+
{
|
|
86
|
+
let loc = safe_locale(locale);
|
|
87
|
+
let key = `${loc}|${JANUARY.getTimezoneOffset()}|${JULY.getTimezoneOffset()}`;
|
|
88
|
+
let f = __date_time_formatters__.get(key);
|
|
89
|
+
if(!f) {
|
|
90
|
+
f = date_time_format(loc, DATE_TIME_OPTIONS);
|
|
91
|
+
__date_time_formatters__.set(key, f);
|
|
92
|
+
}
|
|
93
|
+
return f;
|
|
94
|
+
}
|
|
95
|
+
|
|
72
96
|
/***************************************************************
|
|
73
97
|
* A moment as a VIEW shows it as text: the day, the month and the
|
|
74
98
|
* year, then the clock of 24 hours with its seconds, in the APP's
|
|
@@ -79,7 +103,8 @@ const DATE_TIME_OPTIONS = {
|
|
|
79
103
|
* fmt_date_time(d, "en") -> "Oct 14, 2026, 15:05:09"
|
|
80
104
|
*
|
|
81
105
|
* "" for anything that is not a valid Date. A locale Intl refuses
|
|
82
|
-
* writes in the environment's (date_time_format).
|
|
106
|
+
* writes in the environment's (date_time_format). The formatter is
|
|
107
|
+
* built once per locale and time zone (date_time_formatter).
|
|
83
108
|
*
|
|
84
109
|
* The time cells of C_YUI_FORM and C_YUI_TREEDB_TOPIC_WITH_FORM and
|
|
85
110
|
* the reading C_YUI_JSON writes beside a time field all come from
|
|
@@ -90,7 +115,7 @@ function fmt_date_time(date, locale)
|
|
|
90
115
|
if(!(date instanceof Date) || isNaN(date.getTime())) {
|
|
91
116
|
return "";
|
|
92
117
|
}
|
|
93
|
-
return
|
|
118
|
+
return date_time_formatter(locale).format(date);
|
|
94
119
|
}
|
|
95
120
|
|
|
96
121
|
|
package/src/yui_icons.css
CHANGED
|
@@ -795,6 +795,13 @@
|
|
|
795
795
|
mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'%3E%3Cpath d='M0 352L0 128C0 75 43 32 96 32l320 0c53 0 96 43 96 96l0 224c0 53-43 96-96 96l-120 0c-5.2 0-10.2 1.7-14.4 4.8L166.4 539.2c-4.2 3.1-9.2 4.8-14.4 4.8-13.3 0-24-10.7-24-24l0-72-32 0c-53 0-96-43-96-96z'/%3E%3C/svg%3E");
|
|
796
796
|
}
|
|
797
797
|
|
|
798
|
+
/* A QR code: what a label carries for a reader to scan, the identity of a
|
|
799
|
+
* box printed on it (FontAwesome Free 7.3.1, solid "qrcode"). */
|
|
800
|
+
.yi-qrcode::before {
|
|
801
|
+
-webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 448 512'%3E%3Cpath d='M64 160l64 0 0-64-64 0 0 64zM0 80C0 53.5 21.5 32 48 32l96 0c26.5 0 48 21.5 48 48l0 96c0 26.5-21.5 48-48 48l-96 0c-26.5 0-48-21.5-48-48L0 80zM64 416l64 0 0-64-64 0 0 64zM0 336c0-26.5 21.5-48 48-48l96 0c26.5 0 48 21.5 48 48l0 96c0 26.5-21.5 48-48 48l-96 0c-26.5 0-48-21.5-48-48l0-96zM320 96l0 64 64 0 0-64-64 0zM304 32l96 0c26.5 0 48 21.5 48 48l0 96c0 26.5-21.5 48-48 48l-96 0c-26.5 0-48-21.5-48-48l0-96c0-26.5 21.5-48 48-48zM288 352a32 32 0 1 1 0-64 32 32 0 1 1 0 64zm0 64c17.7 0 32 14.3 32 32s-14.3 32-32 32-32-14.3-32-32 14.3-32 32-32zm96 32c0-17.7 14.3-32 32-32s32 14.3 32 32-14.3 32-32 32-32-14.3-32-32zm32-96a32 32 0 1 1 0-64 32 32 0 1 1 0 64zm-32 32a32 32 0 1 1 -64 0 32 32 0 1 1 64 0z'/%3E%3C/svg%3E");
|
|
802
|
+
mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 448 512'%3E%3Cpath d='M64 160l64 0 0-64-64 0 0 64zM0 80C0 53.5 21.5 32 48 32l96 0c26.5 0 48 21.5 48 48l0 96c0 26.5-21.5 48-48 48l-96 0c-26.5 0-48-21.5-48-48L0 80zM64 416l64 0 0-64-64 0 0 64zM0 336c0-26.5 21.5-48 48-48l96 0c26.5 0 48 21.5 48 48l0 96c0 26.5-21.5 48-48 48l-96 0c-26.5 0-48-21.5-48-48l0-96zM320 96l0 64 64 0 0-64-64 0zM304 32l96 0c26.5 0 48 21.5 48 48l0 96c0 26.5-21.5 48-48 48l-96 0c-26.5 0-48-21.5-48-48l0-96c0-26.5 21.5-48 48-48zM288 352a32 32 0 1 1 0-64 32 32 0 1 1 0 64zm0 64c17.7 0 32 14.3 32 32s-14.3 32-32 32-32-14.3-32-32 14.3-32 32-32zm96 32c0-17.7 14.3-32 32-32s32 14.3 32 32-14.3 32-32 32-32-14.3-32-32zm32-96a32 32 0 1 1 0-64 32 32 0 1 1 0 64zm-32 32a32 32 0 1 1 -64 0 32 32 0 1 1 64 0z'/%3E%3C/svg%3E");
|
|
803
|
+
}
|
|
804
|
+
|
|
798
805
|
/*
|
|
799
806
|
* A user icon drawn straight from its svg, before (or without) being
|
|
800
807
|
* registered as a class -- the preview of the form, the cells of
|