@cahyo-dimas/freeday 3.16.1 → 3.18.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/CHANGELOG.md +113 -0
- package/COMPONENTS.md +60 -20
- package/README.id.md +1 -1
- package/README.md +1 -1
- package/adapters/blazor/FdyAutocomplete.razor +1 -1
- package/adapters/blazor/FdyAutocomplete.razor.cs +6 -1
- package/adapters/blazor/FdyCascade.razor.cs +1 -1
- package/adapters/blazor/FdyCfl.razor +2 -2
- package/adapters/blazor/FdyCfl.razor.cs +13 -0
- package/adapters/blazor/FdyCombo.razor.cs +1 -1
- package/adapters/blazor/FdyDateRange.razor +2 -2
- package/adapters/blazor/FdyDateRange.razor.cs +14 -0
- package/adapters/blazor/FdyDatepicker.razor.cs +1 -1
- package/adapters/blazor/FdyMonthpicker.razor.cs +1 -1
- package/adapters/blazor/FdyTimepicker.razor.cs +1 -1
- package/adapters/blazor/freeday-blazor.js +13 -4
- package/adapters/react/components/FdyAutocomplete.tsx +5 -0
- package/adapters/react/components/FdyCfl.tsx +11 -1
- package/adapters/react/components/FdyDateRange.tsx +5 -0
- package/adapters/react/index.d.ts +26 -0
- package/adapters/react/index.js +1 -0
- package/adapters/react/useTheme.js +35 -0
- package/adapters/vue/components/FdyAutocomplete.vue +5 -0
- package/adapters/vue/components/FdyCfl.vue +11 -1
- package/adapters/vue/components/FdyDateRange.vue +5 -0
- package/adapters/vue/index.d.ts +26 -0
- package/adapters/vue/index.js +1 -0
- package/adapters/vue/useTheme.js +47 -0
- package/dist/freeday-autocomplete.js +6 -1
- package/dist/freeday-cascade.js +13 -2
- package/dist/freeday-cfl.js +12 -1
- package/dist/freeday-datepicker.js +13 -2
- package/dist/freeday-form.js +21 -5
- package/dist/freeday-select.js +8 -1
- package/dist/freeday-theme.js +115 -0
- package/dist/freeday-timepicker.js +13 -2
- package/dist/freeday.js +202 -14
- package/docs/getting-started.md +4 -3
- package/package.json +2 -2
package/dist/freeday.js
CHANGED
|
@@ -251,6 +251,7 @@
|
|
|
251
251
|
root.dataset.fdyAcReady = '1';
|
|
252
252
|
|
|
253
253
|
var input = root.querySelector('input[role="combobox"]') || root.querySelector('input');
|
|
254
|
+
root._fdyInvalid = !!input && input.getAttribute('aria-invalid') === 'true';
|
|
254
255
|
var listbox = root.querySelector('[role="listbox"]');
|
|
255
256
|
if (!input || !listbox) return;
|
|
256
257
|
var options = Array.prototype.slice.call(listbox.querySelectorAll('[role="option"]'));
|
|
@@ -374,10 +375,14 @@
|
|
|
374
375
|
if (!input || !state) return;
|
|
375
376
|
if (state.disabled != null) input.disabled = !!state.disabled;
|
|
376
377
|
if (state.readonly != null) input.readOnly = !!state.readonly;
|
|
377
|
-
|
|
378
|
+
/* Only when the HOST changes it: an unchanged push must not erase what freeday-form.js painted (#114). */
|
|
379
|
+
if (state.invalid != null && !!state.invalid !== root._fdyInvalid) {
|
|
380
|
+
root._fdyInvalid = !!state.invalid;
|
|
378
381
|
if (state.invalid) input.setAttribute('aria-invalid', 'true');
|
|
379
382
|
else input.removeAttribute('aria-invalid');
|
|
380
383
|
}
|
|
384
|
+
/* Native `required` on the input itself: it is editable, so constraint validation applies (#114). */
|
|
385
|
+
if (state.required != null) input.required = !!state.required;
|
|
381
386
|
}
|
|
382
387
|
|
|
383
388
|
window.FreedayAutocomplete = { init: initAutocomplete, initAll: initAll, setState: setState };
|
|
@@ -995,16 +1000,26 @@
|
|
|
995
1000
|
trigger.disabled = stateDisabled;
|
|
996
1001
|
if (stateReadonly) trigger.setAttribute('aria-readonly', 'true');
|
|
997
1002
|
else trigger.removeAttribute('aria-readonly');
|
|
1003
|
+
if ((stateDisabled || stateReadonly) && !panel.hidden) close(false);
|
|
1004
|
+
}
|
|
1005
|
+
/* `invalid` is written only when the HOST changes it. A render-once host (Blazor) pushes every
|
|
1006
|
+
state on every parent re-render, and rewriting an unchanged `false` erased the mark
|
|
1007
|
+
freeday-form.js had painted, leaving its message under a field no longer red (#114). */
|
|
1008
|
+
function applyInvalid() {
|
|
998
1009
|
if (stateInvalid) trigger.setAttribute('aria-invalid', 'true');
|
|
999
1010
|
else trigger.removeAttribute('aria-invalid');
|
|
1000
1011
|
wrap.classList.toggle('fdy-cascade--error', stateInvalid);
|
|
1001
|
-
if ((stateDisabled || stateReadonly) && !panel.hidden) close(false);
|
|
1002
1012
|
}
|
|
1003
1013
|
function setState(next) {
|
|
1004
1014
|
if (!next) return;
|
|
1005
1015
|
if (next.disabled != null) stateDisabled = !!next.disabled;
|
|
1006
1016
|
if (next.readonly != null) stateReadonly = !!next.readonly;
|
|
1007
|
-
if (next.invalid != null
|
|
1017
|
+
if (next.invalid != null && !!next.invalid !== stateInvalid) {
|
|
1018
|
+
stateInvalid = !!next.invalid;
|
|
1019
|
+
applyInvalid();
|
|
1020
|
+
}
|
|
1021
|
+
/* `required` too: a render-once host (Blazor) has no other way to change it later (#114). */
|
|
1022
|
+
if (next.required != null) wrap.toggleAttribute('data-fdy-required', !!next.required);
|
|
1008
1023
|
applyState();
|
|
1009
1024
|
}
|
|
1010
1025
|
|
|
@@ -1065,6 +1080,7 @@
|
|
|
1065
1080
|
}
|
|
1066
1081
|
|
|
1067
1082
|
applyState();
|
|
1083
|
+
applyInvalid();
|
|
1068
1084
|
|
|
1069
1085
|
var api = {
|
|
1070
1086
|
wrap: wrap,
|
|
@@ -1201,15 +1217,26 @@
|
|
|
1201
1217
|
countEl.textContent = textOf(dialog, 'selected', { n: n });
|
|
1202
1218
|
}
|
|
1203
1219
|
|
|
1220
|
+
/* The row's `data-value`, else the text the field shows: what the group mirrors as its live
|
|
1221
|
+
value, so `freeday-form.js` can require a choose-from-list. Its input is readonly, which
|
|
1222
|
+
bars it from constraint validation, so a native `required` on it never refuses (#114). */
|
|
1223
|
+
function rowValue(row, key) {
|
|
1224
|
+
if (row.value != null && row.value !== '') return String(row.value);
|
|
1225
|
+
return row[key] != null ? String(row[key]) : '';
|
|
1226
|
+
}
|
|
1227
|
+
|
|
1204
1228
|
function fillGroup(detail) {
|
|
1205
1229
|
if (!activeGroup) return;
|
|
1230
|
+
var key = activeGroup.getAttribute('data-fdy-cfl-display') || 'value';
|
|
1231
|
+
activeGroup.setAttribute('data-value', detail.rows
|
|
1232
|
+
? detail.rows.map(function (r) { return rowValue(r, key); }).join(',')
|
|
1233
|
+
: rowValue(detail.row, key));
|
|
1206
1234
|
var input = activeGroup.querySelector('.fdy-input');
|
|
1207
1235
|
if (input) {
|
|
1208
1236
|
if (detail.rows) {
|
|
1209
1237
|
var tpl = activeGroup.getAttribute('data-fdy-cfl-summary') || '{n} selected';
|
|
1210
1238
|
input.value = detail.rows.length ? tpl.replace('{n}', String(detail.rows.length)) : '';
|
|
1211
1239
|
} else {
|
|
1212
|
-
var key = activeGroup.getAttribute('data-fdy-cfl-display') || 'value';
|
|
1213
1240
|
input.value = detail.row[key] != null ? detail.row[key] : (detail.row.value || '');
|
|
1214
1241
|
}
|
|
1215
1242
|
}
|
|
@@ -2701,16 +2728,26 @@
|
|
|
2701
2728
|
trigger.disabled = stateDisabled;
|
|
2702
2729
|
if (stateReadonly) trigger.setAttribute('aria-readonly', 'true');
|
|
2703
2730
|
else trigger.removeAttribute('aria-readonly');
|
|
2731
|
+
if ((stateDisabled || stateReadonly) && !panel.hidden) close(false);
|
|
2732
|
+
}
|
|
2733
|
+
/* `invalid` is written only when the HOST changes it. A render-once host (Blazor) pushes every
|
|
2734
|
+
state on every parent re-render, and rewriting an unchanged `false` erased the mark
|
|
2735
|
+
freeday-form.js had painted, leaving its message under a field no longer red (#114). */
|
|
2736
|
+
function applyInvalid() {
|
|
2704
2737
|
if (stateInvalid) trigger.setAttribute('aria-invalid', 'true');
|
|
2705
2738
|
else trigger.removeAttribute('aria-invalid');
|
|
2706
2739
|
wrap.classList.toggle('fdy-datepicker--error', stateInvalid);
|
|
2707
|
-
if ((stateDisabled || stateReadonly) && !panel.hidden) close(false);
|
|
2708
2740
|
}
|
|
2709
2741
|
function setState(next) {
|
|
2710
2742
|
if (!next) return;
|
|
2711
2743
|
if (next.disabled != null) stateDisabled = !!next.disabled;
|
|
2712
2744
|
if (next.readonly != null) stateReadonly = !!next.readonly;
|
|
2713
|
-
if (next.invalid != null
|
|
2745
|
+
if (next.invalid != null && !!next.invalid !== stateInvalid) {
|
|
2746
|
+
stateInvalid = !!next.invalid;
|
|
2747
|
+
applyInvalid();
|
|
2748
|
+
}
|
|
2749
|
+
/* `required` too: a render-once host (Blazor) has no other way to change it later (#114). */
|
|
2750
|
+
if (next.required != null) wrap.toggleAttribute('data-fdy-required', !!next.required);
|
|
2714
2751
|
applyState();
|
|
2715
2752
|
}
|
|
2716
2753
|
|
|
@@ -2747,6 +2784,7 @@
|
|
|
2747
2784
|
updateDisplay();
|
|
2748
2785
|
|
|
2749
2786
|
applyState();
|
|
2787
|
+
applyInvalid();
|
|
2750
2788
|
|
|
2751
2789
|
var api = {
|
|
2752
2790
|
wrap: wrap,
|
|
@@ -3061,10 +3099,11 @@
|
|
|
3061
3099
|
* data-fdy-required the app asking for it, on the control's ROOT
|
|
3062
3100
|
* data-value the live value, which every value-bearing kit control now mirrors
|
|
3063
3101
|
* and the element that takes aria-invalid and focus is found by `aria-haspopup`, which every
|
|
3064
|
-
* popup-style kit trigger already sets.
|
|
3065
|
-
*
|
|
3066
|
-
*
|
|
3067
|
-
*
|
|
3102
|
+
* popup-style kit trigger already sets. A choose-from-list belongs here too: its <input> is
|
|
3103
|
+
* `readonly`, and a readonly input is barred from constraint validation, so a native `required`
|
|
3104
|
+
* on it never refuses anything; its open button carries `aria-haspopup="dialog"`. An
|
|
3105
|
+
* autocomplete does NOT: its input is editable, so the native `required` is the one that fits,
|
|
3106
|
+
* and routing it through here would give one field two sources of truth (#114). */
|
|
3068
3107
|
function kitRoots(form) {
|
|
3069
3108
|
return Array.prototype.slice.call(form.querySelectorAll('[data-fdy-required]'));
|
|
3070
3109
|
}
|
|
@@ -3076,6 +3115,9 @@
|
|
|
3076
3115
|
}
|
|
3077
3116
|
|
|
3078
3117
|
function kitMessage(root) {
|
|
3118
|
+
/* Read again on every pass, not only when the root was collected: a field required only under
|
|
3119
|
+
a condition loses the attribute while its error is still painted (#114). */
|
|
3120
|
+
if (!root.hasAttribute('data-fdy-required')) return '';
|
|
3079
3121
|
if ((root.getAttribute('data-value') || '') !== '') return '';
|
|
3080
3122
|
var form = root.closest('form');
|
|
3081
3123
|
return root.getAttribute('data-fdy-msg-required')
|
|
@@ -3122,6 +3164,17 @@
|
|
|
3122
3164
|
return custom || el.getAttribute('data-fdy-msg') || (alias && textOf(form, alias)) || el.validationMessage || textOf(form, 'invalid');
|
|
3123
3165
|
}
|
|
3124
3166
|
|
|
3167
|
+
/* Two controls can share one `.fdy-field` and so one message slot: a date range's two ends, or two
|
|
3168
|
+
native inputs side by side. The slot is found per FIELD, so clearing the end that was filled
|
|
3169
|
+
used to erase the message the other end still needed, leaving it red with nothing to say why
|
|
3170
|
+
(#114). The slot is kept while any other control that points at it is still invalid. */
|
|
3171
|
+
function stillClaimed(errEl, except) {
|
|
3172
|
+
var scope = except.closest('form') || document;
|
|
3173
|
+
return Array.prototype.some.call(scope.querySelectorAll('[aria-invalid="true"]'), function (other) {
|
|
3174
|
+
return other !== except && (other.getAttribute('aria-describedby') || '').split(/\s+/).indexOf(errEl.id) !== -1;
|
|
3175
|
+
});
|
|
3176
|
+
}
|
|
3177
|
+
|
|
3125
3178
|
function paint(el, message) {
|
|
3126
3179
|
var errEl = ensureErrorEl(el);
|
|
3127
3180
|
if (message) {
|
|
@@ -3130,6 +3183,7 @@
|
|
|
3130
3183
|
errEl.hidden = false;
|
|
3131
3184
|
} else {
|
|
3132
3185
|
el.removeAttribute('aria-invalid');
|
|
3186
|
+
if (stillClaimed(errEl, el)) return;
|
|
3133
3187
|
errEl.textContent = '';
|
|
3134
3188
|
errEl.hidden = true;
|
|
3135
3189
|
}
|
|
@@ -3187,7 +3241,7 @@
|
|
|
3187
3241
|
root.dataset.fdyKitBound = '1';
|
|
3188
3242
|
new MutationObserver(function () {
|
|
3189
3243
|
if (submitted || eager) validateKit(root);
|
|
3190
|
-
}).observe(root, { attributes: true, attributeFilter: ['data-value'] });
|
|
3244
|
+
}).observe(root, { attributes: true, attributeFilter: ['data-value', 'data-fdy-required'] });
|
|
3191
3245
|
}
|
|
3192
3246
|
function validateOne(el) {
|
|
3193
3247
|
var msg = messageFor(el);
|
|
@@ -3901,6 +3955,7 @@
|
|
|
3901
3955
|
var options = Array.prototype.slice.call(root.querySelectorAll('.fdy-combo__option'));
|
|
3902
3956
|
if (!button || !listbox || !valueEl || options.length === 0) return;
|
|
3903
3957
|
root.dataset.fdyComboReady = '1';
|
|
3958
|
+
root._fdyInvalid = button.getAttribute('aria-invalid') === 'true';
|
|
3904
3959
|
|
|
3905
3960
|
seq += 1;
|
|
3906
3961
|
if (!listbox.id) listbox.id = 'fdy-combo-list-' + seq;
|
|
@@ -4084,10 +4139,16 @@
|
|
|
4084
4139
|
if (state.readonly) button.setAttribute('aria-readonly', 'true');
|
|
4085
4140
|
else button.removeAttribute('aria-readonly');
|
|
4086
4141
|
}
|
|
4087
|
-
|
|
4142
|
+
/* `invalid` is written only when the HOST changes it. A render-once host (Blazor) pushes every
|
|
4143
|
+
state on every parent re-render, and rewriting an unchanged `false` erased the mark
|
|
4144
|
+
freeday-form.js had painted, leaving its message under a field no longer red (#114). */
|
|
4145
|
+
if (state.invalid != null && !!state.invalid !== root._fdyInvalid) {
|
|
4146
|
+
root._fdyInvalid = !!state.invalid;
|
|
4088
4147
|
if (state.invalid) button.setAttribute('aria-invalid', 'true');
|
|
4089
4148
|
else button.removeAttribute('aria-invalid');
|
|
4090
4149
|
}
|
|
4150
|
+
/* `required` too: a render-once host (Blazor) has no other way to change it later (#114). */
|
|
4151
|
+
if (state.required != null) root.toggleAttribute('data-fdy-required', !!state.required);
|
|
4091
4152
|
}
|
|
4092
4153
|
|
|
4093
4154
|
window.FreedayCombo = { init: initCombo, initAll: initAll, setValue: setValue, setState: setState };
|
|
@@ -5221,6 +5282,122 @@
|
|
|
5221
5282
|
window.FreedayTabs = { init: initTabs, initAll: initAll };
|
|
5222
5283
|
})();
|
|
5223
5284
|
|
|
5285
|
+
/* Freeday, theme preference (optional, zero-dependency, no markup of its own).
|
|
5286
|
+
* The light/dark switch every app needs and each one used to write for itself, guessing the kit's
|
|
5287
|
+
* contract from the docs (CATATAN-FREEDAY §23). One preference per device: 'light', 'dark' or
|
|
5288
|
+
* 'system'.
|
|
5289
|
+
*
|
|
5290
|
+
* 'system' REMOVES data-theme instead of computing one. The tokens already follow
|
|
5291
|
+
* prefers-color-scheme whenever no data-theme says otherwise, so the page tracks an OS switch live,
|
|
5292
|
+
* with no listener deciding anything.
|
|
5293
|
+
*
|
|
5294
|
+
* The preference always lands on <html>. attach(el) adds another root that gets it too: a region
|
|
5295
|
+
* that carries its own data-theme in markup (a dark kiosk shell inside a light app) would otherwise
|
|
5296
|
+
* keep that fixed value, because a subtree's attribute wins over the document's. Attaching hands the
|
|
5297
|
+
* region to the user: with the preference at 'system' its fixed value is removed and it follows the
|
|
5298
|
+
* OS like the rest of the page.
|
|
5299
|
+
*
|
|
5300
|
+
* Every change fires "fdy-theme-change" on document, detail {theme, resolved}; so does an OS switch
|
|
5301
|
+
* while the preference is 'system', since `resolved` (what is actually shown) moved. The Vue and
|
|
5302
|
+
* React useTheme() import this same file, so a page has one preference whichever way it loaded.
|
|
5303
|
+
*
|
|
5304
|
+
* Only a script in <head> can apply the stored value before the first paint; this file runs too
|
|
5305
|
+
* late for that, and catches up on load. COMPONENTS.md has the one-line snippet. Exposes
|
|
5306
|
+
* window.FreedayTheme.
|
|
5307
|
+
*/
|
|
5308
|
+
(function () {
|
|
5309
|
+
'use strict';
|
|
5310
|
+
if (typeof window === 'undefined' || window.FreedayTheme) return;
|
|
5311
|
+
|
|
5312
|
+
var KEY = 'fdy-theme';
|
|
5313
|
+
var THEMES = ['light', 'dark', 'system'];
|
|
5314
|
+
var roots = [];
|
|
5315
|
+
var memory = null;
|
|
5316
|
+
var media = window.matchMedia ? window.matchMedia('(prefers-color-scheme: dark)') : null;
|
|
5317
|
+
|
|
5318
|
+
function valid(theme) {
|
|
5319
|
+
return THEMES.indexOf(theme) !== -1;
|
|
5320
|
+
}
|
|
5321
|
+
|
|
5322
|
+
/* Storage can throw (private mode, a blocked origin); the preference then lasts the page. */
|
|
5323
|
+
function read() {
|
|
5324
|
+
try {
|
|
5325
|
+
var stored = window.localStorage.getItem(KEY);
|
|
5326
|
+
if (valid(stored)) return stored;
|
|
5327
|
+
} catch (e) { /* fall through to the in-memory value */ }
|
|
5328
|
+
return memory !== null ? memory : 'system';
|
|
5329
|
+
}
|
|
5330
|
+
function write(theme) {
|
|
5331
|
+
memory = theme;
|
|
5332
|
+
try {
|
|
5333
|
+
if (theme === 'system') window.localStorage.removeItem(KEY);
|
|
5334
|
+
else window.localStorage.setItem(KEY, theme);
|
|
5335
|
+
} catch (e) { /* kept in memory only */ }
|
|
5336
|
+
}
|
|
5337
|
+
|
|
5338
|
+
function applyTo(el, theme) {
|
|
5339
|
+
if (theme === 'system') el.removeAttribute('data-theme');
|
|
5340
|
+
else el.setAttribute('data-theme', theme);
|
|
5341
|
+
}
|
|
5342
|
+
function targets() {
|
|
5343
|
+
return [document.documentElement].concat(roots);
|
|
5344
|
+
}
|
|
5345
|
+
|
|
5346
|
+
/* What <html> shows: its own attribute if it has one, the OS otherwise. Read from the DOM, not
|
|
5347
|
+
from the preference, so markup that ships data-theme="light" before anything is stored is
|
|
5348
|
+
reported as light, which is what the user sees. */
|
|
5349
|
+
function resolved() {
|
|
5350
|
+
var own = document.documentElement.getAttribute('data-theme');
|
|
5351
|
+
if (own === 'light' || own === 'dark') return own;
|
|
5352
|
+
return media && media.matches ? 'dark' : 'light';
|
|
5353
|
+
}
|
|
5354
|
+
|
|
5355
|
+
function emit() {
|
|
5356
|
+
document.dispatchEvent(new CustomEvent('fdy-theme-change', { detail: { theme: read(), resolved: resolved() } }));
|
|
5357
|
+
}
|
|
5358
|
+
|
|
5359
|
+
function set(theme) {
|
|
5360
|
+
if (!valid(theme)) {
|
|
5361
|
+
throw new TypeError('FreedayTheme.set: theme must be one of ' + THEMES.join(', ') + ', got ' + JSON.stringify(theme));
|
|
5362
|
+
}
|
|
5363
|
+
write(theme);
|
|
5364
|
+
targets().forEach(function (el) { applyTo(el, theme); });
|
|
5365
|
+
emit();
|
|
5366
|
+
}
|
|
5367
|
+
|
|
5368
|
+
/* Flips what is SHOWN, so the first press always changes the screen, even from 'system'. */
|
|
5369
|
+
function toggle() {
|
|
5370
|
+
set(resolved() === 'dark' ? 'light' : 'dark');
|
|
5371
|
+
}
|
|
5372
|
+
|
|
5373
|
+
function attach(el) {
|
|
5374
|
+
if (!el || roots.indexOf(el) !== -1) return detacher(el);
|
|
5375
|
+
roots.push(el);
|
|
5376
|
+
applyTo(el, read());
|
|
5377
|
+
return detacher(el);
|
|
5378
|
+
}
|
|
5379
|
+
function detacher(el) {
|
|
5380
|
+
return function () {
|
|
5381
|
+
var i = roots.indexOf(el);
|
|
5382
|
+
if (i !== -1) roots.splice(i, 1);
|
|
5383
|
+
};
|
|
5384
|
+
}
|
|
5385
|
+
|
|
5386
|
+
/* A stored choice is applied on load as well. The <head> snippet does it before first paint;
|
|
5387
|
+
without it the page shows the CSS default for a moment, and then still ends up right. Nothing
|
|
5388
|
+
stored means nothing is touched, so markup that ships its own data-theme keeps it. */
|
|
5389
|
+
var initial = read();
|
|
5390
|
+
if (initial !== 'system') applyTo(document.documentElement, initial);
|
|
5391
|
+
|
|
5392
|
+
if (media) {
|
|
5393
|
+
var onOs = function () { if (read() === 'system') emit(); };
|
|
5394
|
+
if (media.addEventListener) media.addEventListener('change', onOs);
|
|
5395
|
+
else if (media.addListener) media.addListener(onOs);
|
|
5396
|
+
}
|
|
5397
|
+
|
|
5398
|
+
window.FreedayTheme = { get: read, resolved: resolved, set: set, toggle: toggle, attach: attach };
|
|
5399
|
+
})();
|
|
5400
|
+
|
|
5224
5401
|
/* Freeday, time picker enhancer (optional, zero-dependency).
|
|
5225
5402
|
* Builds an input-styled trigger + scrollable time-list popover (WAI-ARIA listbox)
|
|
5226
5403
|
* from an empty [data-fdy-timepicker] wrapper. 24h HH:MM. Options run from
|
|
@@ -5340,16 +5517,26 @@
|
|
|
5340
5517
|
trigger.disabled = stateDisabled;
|
|
5341
5518
|
if (stateReadonly) trigger.setAttribute('aria-readonly', 'true');
|
|
5342
5519
|
else trigger.removeAttribute('aria-readonly');
|
|
5520
|
+
if ((stateDisabled || stateReadonly) && !panel.hidden) close(false);
|
|
5521
|
+
}
|
|
5522
|
+
/* `invalid` is written only when the HOST changes it. A render-once host (Blazor) pushes every
|
|
5523
|
+
state on every parent re-render, and rewriting an unchanged `false` erased the mark
|
|
5524
|
+
freeday-form.js had painted, leaving its message under a field no longer red (#114). */
|
|
5525
|
+
function applyInvalid() {
|
|
5343
5526
|
if (stateInvalid) trigger.setAttribute('aria-invalid', 'true');
|
|
5344
5527
|
else trigger.removeAttribute('aria-invalid');
|
|
5345
5528
|
wrap.classList.toggle('fdy-timepicker--error', stateInvalid);
|
|
5346
|
-
if ((stateDisabled || stateReadonly) && !panel.hidden) close(false);
|
|
5347
5529
|
}
|
|
5348
5530
|
function setState(next) {
|
|
5349
5531
|
if (!next) return;
|
|
5350
5532
|
if (next.disabled != null) stateDisabled = !!next.disabled;
|
|
5351
5533
|
if (next.readonly != null) stateReadonly = !!next.readonly;
|
|
5352
|
-
if (next.invalid != null
|
|
5534
|
+
if (next.invalid != null && !!next.invalid !== stateInvalid) {
|
|
5535
|
+
stateInvalid = !!next.invalid;
|
|
5536
|
+
applyInvalid();
|
|
5537
|
+
}
|
|
5538
|
+
/* `required` too: a render-once host (Blazor) has no other way to change it later (#114). */
|
|
5539
|
+
if (next.required != null) wrap.toggleAttribute('data-fdy-required', !!next.required);
|
|
5353
5540
|
applyState();
|
|
5354
5541
|
}
|
|
5355
5542
|
|
|
@@ -5437,6 +5624,7 @@
|
|
|
5437
5624
|
|
|
5438
5625
|
updateDisplay();
|
|
5439
5626
|
applyState();
|
|
5627
|
+
applyInvalid();
|
|
5440
5628
|
|
|
5441
5629
|
var api = {
|
|
5442
5630
|
wrap: wrap,
|
package/docs/getting-started.md
CHANGED
|
@@ -198,7 +198,7 @@ live docs also have a copy button per component.
|
|
|
198
198
|
```bash
|
|
199
199
|
npm i @cahyo-dimas/freeday
|
|
200
200
|
```
|
|
201
|
-
Lands in `package.json` as `"@cahyo-dimas/freeday": "^3.
|
|
201
|
+
Lands in `package.json` as `"@cahyo-dimas/freeday": "^3.18.0"` (public npm package). `dist/` is
|
|
202
202
|
committed and published → no build step; `npm ci` runs without auth.
|
|
203
203
|
|
|
204
204
|
### 2. Import the CSS + enhancers **once** in your entry (`src/main.ts`)
|
|
@@ -424,8 +424,9 @@ public partial class Panel : ComponentBase, IAsyncDisposable
|
|
|
424
424
|
<div data-fdy-datepicker></div>
|
|
425
425
|
</div>
|
|
426
426
|
```
|
|
427
|
-
Extras: `FreedayBlazor.toast(new { variant, title, message })` for toasts; `FreedayBlazor.toggleTheme()
|
|
428
|
-
|
|
427
|
+
Extras: `FreedayBlazor.toast(new { variant, title, message })` for toasts; `FreedayBlazor.toggleTheme()`,
|
|
428
|
+
`setTheme("light" | "dark" | "system")`, `getTheme()` and `getResolvedTheme()` for the stored theme
|
|
429
|
+
preference (COMPONENTS.md, "Theme preference"). Event DTOs are deserialized case-insensitively by Blazor.
|
|
429
430
|
|
|
430
431
|
### 4. Recommended: native typed components (`Freeday.Blazor` RCL)
|
|
431
432
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cahyo-dimas/freeday",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.18.0",
|
|
4
4
|
"description": "Freeday: token-driven, framework-agnostic UI KIT (design source-of-truth).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
"scripts": {
|
|
98
98
|
"build": "node tokens/build.mjs",
|
|
99
99
|
"test": "node --test",
|
|
100
|
-
"test:browser": "node --test --test-concurrency=3 browser/color-mix.mjs browser/vanilla.mjs browser/adapter.mjs browser/layout.mjs browser/theme.mjs browser/state.mjs browser/root-init.mjs browser/upload-states.mjs browser/number.mjs browser/card-stretch.mjs browser/stretch-warn.mjs browser/hidden-attr.mjs browser/form-grid-rows.mjs browser/text-override.mjs browser/control-heights.mjs browser/field-width.mjs browser/cfl-multi.mjs browser/cfl-dialog-only.mjs browser/crowding.mjs browser/over-dialog.mjs browser/chart-scale.mjs browser/overlay-stack.mjs browser/chart-a11y.mjs browser/app-shell.mjs browser/bottom-nav.mjs browser/picker-states.mjs browser/tabs-strip.mjs browser/tabs-vertical.mjs browser/menu-align.mjs browser/cfl-narrow.mjs browser/form-reveal.mjs browser/confirm-search-copy.mjs browser/daterange-settled.mjs browser/display-parts.mjs browser/table-empty.mjs browser/table-footer-text.mjs browser/month-mode.mjs browser/monthpicker.mjs browser/page-columns.mjs browser/table-hover.mjs browser/typed-popover.mjs browser/filter-parity.mjs browser/filter-wrap.mjs browser/filter-stack.mjs browser/timepicker.mjs browser/form-kit-required.mjs browser/picker-in-modal.mjs browser/harness-contract.mjs browser/app-owned.mjs browser/sortable.mjs browser/modal-phone.mjs browser/empty-ref.mjs browser/stack-standalone.mjs",
|
|
100
|
+
"test:browser": "node --test --test-concurrency=3 browser/color-mix.mjs browser/vanilla.mjs browser/adapter.mjs browser/layout.mjs browser/theme.mjs browser/state.mjs browser/root-init.mjs browser/upload-states.mjs browser/number.mjs browser/card-stretch.mjs browser/stretch-warn.mjs browser/hidden-attr.mjs browser/form-grid-rows.mjs browser/theme-pref.mjs browser/text-override.mjs browser/control-heights.mjs browser/field-width.mjs browser/cfl-multi.mjs browser/cfl-dialog-only.mjs browser/crowding.mjs browser/over-dialog.mjs browser/chart-scale.mjs browser/overlay-stack.mjs browser/chart-a11y.mjs browser/app-shell.mjs browser/bottom-nav.mjs browser/picker-states.mjs browser/tabs-strip.mjs browser/tabs-vertical.mjs browser/menu-align.mjs browser/cfl-narrow.mjs browser/form-reveal.mjs browser/confirm-search-copy.mjs browser/daterange-settled.mjs browser/display-parts.mjs browser/table-empty.mjs browser/table-footer-text.mjs browser/month-mode.mjs browser/monthpicker.mjs browser/page-columns.mjs browser/table-hover.mjs browser/typed-popover.mjs browser/filter-parity.mjs browser/filter-wrap.mjs browser/filter-stack.mjs browser/timepicker.mjs browser/form-kit-required.mjs browser/form-required-rest.mjs browser/picker-in-modal.mjs browser/harness-contract.mjs browser/app-owned.mjs browser/sortable.mjs browser/modal-phone.mjs browser/empty-ref.mjs browser/stack-standalone.mjs",
|
|
101
101
|
"prepack": "node tokens/build.mjs",
|
|
102
102
|
"version": "node tokens/build.mjs && git add dist",
|
|
103
103
|
"typecheck:react": "tsc -p adapters/react/tsconfig.json --noEmit",
|