mnfst 0.5.175 → 0.5.176
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.
|
@@ -191,6 +191,7 @@
|
|
|
191
191
|
showClear: true, // Clear action (config: clear:false)
|
|
192
192
|
min: null, max: null,
|
|
193
193
|
disabled: [], // ISO strings, {from,to} ranges, or a predicate fn
|
|
194
|
+
format: null, // trigger display format (see formatValue)
|
|
194
195
|
mode: 'inline', // 'inline' (authored container) | 'menu' (plugin-owned dropdown)
|
|
195
196
|
field: null, // trigger element, if any
|
|
196
197
|
fieldPlaceholder: '', // captured initial label/placeholder text
|
|
@@ -218,10 +219,34 @@
|
|
|
218
219
|
return false;
|
|
219
220
|
},
|
|
220
221
|
|
|
222
|
+
// Trigger display text. `format` (config/attr) overrides the default
|
|
223
|
+
// localized medium style: a dateStyle keyword ('short'|'medium'|
|
|
224
|
+
// 'long'|'full'), an Intl.DateTimeFormat options object, 'iso',
|
|
225
|
+
// 'relative', or a (date) => string function. The emitted/model
|
|
226
|
+
// value stays ISO regardless — this only restyles the visible text.
|
|
221
227
|
formatValue(date) {
|
|
222
228
|
if (!date) return '';
|
|
223
|
-
|
|
224
|
-
|
|
229
|
+
const f = this.format, loc = this.locale();
|
|
230
|
+
try {
|
|
231
|
+
if (typeof f === 'function') return String(f(date));
|
|
232
|
+
if (f === 'iso') return D.toISO(date);
|
|
233
|
+
if (f === 'relative') {
|
|
234
|
+
const a = new Date(date.getFullYear(), date.getMonth(), date.getDate());
|
|
235
|
+
const b = new Date(); b.setHours(0, 0, 0, 0);
|
|
236
|
+
const days = Math.round((a - b) / 86400000), abs = Math.abs(days);
|
|
237
|
+
const rtf = new Intl.RelativeTimeFormat(loc, { numeric: 'auto' });
|
|
238
|
+
if (abs < 7) return rtf.format(days, 'day');
|
|
239
|
+
if (abs < 30) return rtf.format(Math.round(days / 7), 'week');
|
|
240
|
+
if (abs < 365) return rtf.format(Math.round(days / 30), 'month');
|
|
241
|
+
return rtf.format(Math.round(days / 365), 'year');
|
|
242
|
+
}
|
|
243
|
+
if (f && typeof f === 'object') return new Intl.DateTimeFormat(loc, f).format(date);
|
|
244
|
+
if (typeof f === 'string') return new Intl.DateTimeFormat(loc, { dateStyle: f }).format(date);
|
|
245
|
+
return new Intl.DateTimeFormat(loc, { dateStyle: 'medium' }).format(date);
|
|
246
|
+
} catch (_) {
|
|
247
|
+
try { return new Intl.DateTimeFormat(loc, { dateStyle: 'medium' }).format(date); }
|
|
248
|
+
catch (_) { return D.toISO(date); }
|
|
249
|
+
}
|
|
225
250
|
},
|
|
226
251
|
|
|
227
252
|
formatTime() {
|
|
@@ -246,6 +271,7 @@
|
|
|
246
271
|
return this.selectedDates.length + ' dates';
|
|
247
272
|
}
|
|
248
273
|
if (this.withTime && this.selected) {
|
|
274
|
+
if (this.format) return this.formatValue(this.selected) + ' ' + this.formatTime();
|
|
249
275
|
try {
|
|
250
276
|
const [h, mi] = this.time.split(':').map(Number);
|
|
251
277
|
const dt = new Date(this.selected.getFullYear(), this.selected.getMonth(), this.selected.getDate(), h || 0, mi || 0);
|
|
@@ -919,6 +945,8 @@
|
|
|
919
945
|
const max = el.getAttribute('max');
|
|
920
946
|
if (min) state.min = D.fromISO(min);
|
|
921
947
|
if (max) state.max = D.fromISO(max);
|
|
948
|
+
const format = el.getAttribute('format');
|
|
949
|
+
if (format) state.format = format; // string presets only; objects/fns via config
|
|
922
950
|
}
|
|
923
951
|
function bindConfigValue(state, el, expression) {
|
|
924
952
|
if (!expression) return;
|
|
@@ -935,6 +963,7 @@
|
|
|
935
963
|
if (cfg.max !== undefined) { state.max = cfg.max ? D.fromISO(cfg.max) : null; dirty = true; }
|
|
936
964
|
if (cfg.disabled !== undefined && (Array.isArray(cfg.disabled) || typeof cfg.disabled === 'function')) { state.disabled = cfg.disabled; dirty = true; }
|
|
937
965
|
if (Array.isArray(cfg.presets)) { state.presets = cfg.presets; dirty = true; }
|
|
966
|
+
if (cfg.format !== undefined) { state.format = cfg.format || null; dirty = true; }
|
|
938
967
|
if (dirty) { state.bump(); if (state._mounted) state.render(); }
|
|
939
968
|
});
|
|
940
969
|
}
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"manifest.combobox.js": "sha384-fE/SS0hPsSoCqn2x3H9u1HLY8dZ38PI/NCzrDpqL7+11QPOehG/f0f5MMGQqhBle",
|
|
11
11
|
"manifest.components.js": "sha384-eZDib+RFdwd9mOUdi6o53eNS0LBlEEkZPDegxtkAcE+GrGIFxsuB4O0ymfixGNfM",
|
|
12
12
|
"manifest.data.js": "sha384-3lLvGnqcQr4Ium80MdaQTr8RytjVbs5rnxd0q41BF3ppcoQccMFAcvgFSyZP/0sl",
|
|
13
|
-
"manifest.datepicker.js": "sha384-
|
|
13
|
+
"manifest.datepicker.js": "sha384-52BBZdlLN+EATiUorwTEQOWGJZiSNu0voy9q+WQxxWpUeYsGGkuS0QPPXGx2akxG",
|
|
14
14
|
"manifest.dropdowns.js": "sha384-7DtzNNGKAFzsXLO73x0qifvHxd/o+QSLoENOJA03rBRTDKHvHbXsRoMn1WJvX6VG",
|
|
15
15
|
"manifest.export.js": "sha384-NkqOydcrdQ6qFEcpBKc80JCbeSCuybASrTUGajuTMBrHMzt1OIe8b3ndNn9VfqSh",
|
|
16
16
|
"manifest.icons.js": "sha384-kKOINpX70YzNO3FvkV6umrmO3f0KIu0DNbwB+ej55a7y/lhU7v/myQtXL0bwCTbt",
|