@cahyo-dimas/freeday 3.22.0 → 3.24.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.
Files changed (41) hide show
  1. package/CHANGELOG.md +112 -0
  2. package/COMPONENTS.md +77 -2
  3. package/README.id.md +1 -1
  4. package/README.md +1 -1
  5. package/adapters/blazor/FdyCfl.razor.cs +44 -8
  6. package/adapters/blazor/FdyTable.razor.cs +23 -1
  7. package/adapters/blazor/freeday-blazor.js +16 -2
  8. package/adapters/core/load-state.d.ts +17 -0
  9. package/adapters/core/load-state.js +37 -0
  10. package/adapters/react/components/FdyCfl.tsx +20 -5
  11. package/adapters/react/components/FdyDatepicker.tsx +10 -1
  12. package/adapters/react/components/FdyDrawer.tsx +8 -0
  13. package/adapters/react/components/FdyModal.tsx +11 -0
  14. package/adapters/react/components/FdyTable.tsx +28 -5
  15. package/adapters/react/index.d.ts +18 -0
  16. package/adapters/react/index.js +1 -0
  17. package/adapters/react/useFreeday.js +31 -0
  18. package/adapters/react/useLoad.js +53 -0
  19. package/adapters/vue/components/FdyCfl.vue +20 -6
  20. package/adapters/vue/components/FdyDatepicker.vue +10 -1
  21. package/adapters/vue/components/FdyDrawer.vue +10 -0
  22. package/adapters/vue/components/FdyModal.vue +12 -0
  23. package/adapters/vue/index.d.ts +18 -0
  24. package/adapters/vue/index.js +1 -0
  25. package/adapters/vue/useFreeday.js +32 -1
  26. package/adapters/vue/useLoad.js +47 -0
  27. package/dist/freeday-datepicker.js +25 -1
  28. package/dist/freeday-form.js +3 -0
  29. package/dist/freeday-stepper.js +14 -5
  30. package/dist/freeday-table.js +5 -1
  31. package/dist/freeday-tabs.js +76 -0
  32. package/dist/freeday-upload.js +17 -7
  33. package/dist/freeday.bundle.css +53 -0
  34. package/dist/freeday.css +53 -0
  35. package/dist/freeday.js +140 -14
  36. package/docs/getting-started.md +1 -1
  37. package/docs/reference-screen.html +1 -1
  38. package/docs/screen-states.md +3 -0
  39. package/package.json +2 -2
  40. package/src/components/link.css +14 -0
  41. package/src/components/tabs.css +38 -0
@@ -10,10 +10,73 @@
10
10
  * other pair is left entirely alone rather than bound as a second axis: Left and Right over a
11
11
  * column of tabs belong to whatever else is on the page, and a widget that preventDefaults a key
12
12
  * it has no meaning for has taken it from the page silently. Home/End answer on both.
13
+ *
14
+ * `.fdy-tabs--picker-narrow` on the root: this builds a `.fdy-tabs__picker` holding one combo of
15
+ * the same tabs, first in the root, and keeps the two in step both ways. tabs.css shows it instead
16
+ * of the list in a container of 40rem or less. It needs freeday-select.js (FreedayCombo), which
17
+ * dist/freeday.js carries; without it the list simply stays. A picker the author wrote is left alone.
13
18
  */
14
19
  (function () {
15
20
  'use strict';
16
21
 
22
+ /* The picker's accessible name when the tablist has none of its own to lend it. */
23
+ var TEXT = {
24
+ picker: 'Section'
25
+ };
26
+ function textOf(root, key) {
27
+ var kebab = key.replace(/[A-Z]/g, function (c) { return '-' + c.toLowerCase(); });
28
+ var custom = root.getAttribute('data-fdy-text-' + kebab);
29
+ return custom != null && custom !== '' ? custom : TEXT[key];
30
+ }
31
+ var uidSeq = 0;
32
+ function uid(p) { uidSeq += 1; return p + '-' + uidSeq; }
33
+
34
+ /* The combo freeday-select.js reads, built from the tabs themselves: one option per tab, its value
35
+ the tab's id. Named by the tablist's own label when it has one, so the two read as one control. */
36
+ function buildPicker(root, list, tabs) {
37
+ var wrap = document.createElement('div');
38
+ wrap.className = 'fdy-tabs__picker';
39
+ var combo = document.createElement('div');
40
+ combo.className = 'fdy-combo';
41
+ combo.setAttribute('data-fdy-combo', '');
42
+ var button = document.createElement('button');
43
+ button.type = 'button';
44
+ button.className = 'fdy-combo__button';
45
+ button.setAttribute('role', 'combobox');
46
+ button.setAttribute('aria-haspopup', 'listbox');
47
+ button.setAttribute('aria-expanded', 'false');
48
+ var value = document.createElement('span');
49
+ value.className = 'fdy-combo__value';
50
+ value.id = uid('fdy-tabs-picker-value');
51
+ button.appendChild(value);
52
+ var labelledby = list ? list.getAttribute('aria-labelledby') : null;
53
+ var label = list ? list.getAttribute('aria-label') : null;
54
+ if (labelledby) button.setAttribute('aria-labelledby', labelledby + ' ' + value.id);
55
+ else button.setAttribute('aria-label', label || textOf(root, 'picker'));
56
+ var listbox = document.createElement('ul');
57
+ listbox.className = 'fdy-combo__listbox';
58
+ listbox.setAttribute('role', 'listbox');
59
+ listbox.hidden = true;
60
+ tabs.forEach(function (tab) {
61
+ if (!tab.id) tab.id = uid('fdy-tab');
62
+ var opt = document.createElement('li');
63
+ opt.className = 'fdy-combo__option';
64
+ opt.setAttribute('role', 'option');
65
+ opt.setAttribute('data-value', tab.id);
66
+ opt.setAttribute('aria-selected', 'false');
67
+ var check = document.createElement('span');
68
+ check.className = 'fdy-combo__check';
69
+ opt.appendChild(check);
70
+ opt.appendChild(document.createTextNode((tab.textContent || '').replace(/\s+/g, ' ').trim()));
71
+ listbox.appendChild(opt);
72
+ });
73
+ combo.appendChild(button);
74
+ combo.appendChild(listbox);
75
+ wrap.appendChild(combo);
76
+ root.insertBefore(wrap, root.firstChild);
77
+ return combo;
78
+ }
79
+
17
80
  function initTabs(root) {
18
81
  if (root.dataset.fdyTabsReady === '1') return;
19
82
  if (root.closest('[data-fdy-ignore]')) return;
@@ -31,6 +94,17 @@
31
94
  list.setAttribute('aria-orientation', 'vertical');
32
95
  }
33
96
  var vertical = list !== null && list.getAttribute('aria-orientation') === 'vertical';
97
+ var picker = null;
98
+ if (root.classList.contains('fdy-tabs--picker-narrow') && window.FreedayCombo
99
+ && root.querySelector(':scope > .fdy-tabs__picker') === null) {
100
+ picker = buildPicker(root, list, tabs);
101
+ window.FreedayCombo.init(picker);
102
+ picker.addEventListener('fdy-change', function (e) {
103
+ var id = e.detail && e.detail.value;
104
+ var tab = tabs.filter(function (t) { return t.id === id; })[0];
105
+ if (tab) select(tab, false);
106
+ });
107
+ }
34
108
  var NEXT_KEY = vertical ? 'ArrowDown' : 'ArrowRight';
35
109
  var PREV_KEY = vertical ? 'ArrowUp' : 'ArrowLeft';
36
110
 
@@ -46,6 +120,8 @@
46
120
  var panel = panelFor(t);
47
121
  if (panel) panel.hidden = !on;
48
122
  });
123
+ /* Silent: setValue raises no fdy-change, so the picker cannot echo a pick back here. */
124
+ if (picker) window.FreedayCombo.setValue(picker, tab.id);
49
125
  if (focus) tab.focus();
50
126
  }
51
127
 
@@ -144,6 +144,13 @@
144
144
  /* Back to a measured bar. While the indeterminate modifier is on it owns the bar's width, so an
145
145
  explicit one has to be restored when it comes off: .fdy-progress__bar is a plain block div, and
146
146
  with no width at all it fills the track, a full bar, which is the opposite of what 0% means. */
147
+ function showUploading() {
148
+ el.classList.remove('fdy-file--error', 'fdy-file--success');
149
+ icon.innerHTML = FILE_ICON;
150
+ sub.textContent = fmtSize(file.size) + ' · ' + textOf(zone, 'uploading');
151
+ ensureProgress();
152
+ determinate();
153
+ }
147
154
  function determinate() {
148
155
  progressEl.classList.remove('fdy-progress--indeterminate');
149
156
  if (!bar.style.width) bar.style.width = '0%';
@@ -161,13 +168,12 @@
161
168
  dropProgress();
162
169
  },
163
170
  uploading: function () {
164
- el.classList.remove('fdy-file--error', 'fdy-file--success');
165
- icon.innerHTML = FILE_ICON;
166
- sub.textContent = fmtSize(file.size) + ' · ' + textOf(zone, 'uploading');
167
- ensureProgress();
168
- determinate();
171
+ showUploading();
169
172
  },
170
173
  setProgress: function (pct) {
174
+ /* A percentage means the file is uploading again, whatever the row said before. A retry that
175
+ reported progress straight after done() or fail() painted "Uploaded" over a moving bar. */
176
+ if (el.classList.contains('fdy-file--success') || el.classList.contains('fdy-file--error')) showUploading();
171
177
  ensureProgress();
172
178
  determinate();
173
179
  var v = Math.max(0, Math.min(100, pct));
@@ -248,9 +254,13 @@
248
254
  ['dragenter', 'dragover'].forEach(function (ev) {
249
255
  zone.addEventListener(ev, function (e) { e.preventDefault(); zone.classList.add('is-dragover'); });
250
256
  });
251
- ['dragleave', 'dragend'].forEach(function (ev) {
252
- zone.addEventListener(ev, function (e) { if (e.target === zone) zone.classList.remove('is-dragover'); });
257
+ /* Off when the pointer has left the ZONE, read from where it went: dragleave fires on whichever
258
+ child it was over, so `e.target === zone` missed a drag that left through the icon, and the
259
+ highlight stayed. A null relatedTarget is the window, or a drag cancelled with Escape. */
260
+ zone.addEventListener('dragleave', function (e) {
261
+ if (!e.relatedTarget || !zone.contains(e.relatedTarget)) zone.classList.remove('is-dragover');
253
262
  });
263
+ zone.addEventListener('dragend', function () { zone.classList.remove('is-dragover'); });
254
264
  zone.addEventListener('drop', function (e) {
255
265
  e.preventDefault();
256
266
  zone.classList.remove('is-dragover');
@@ -3489,6 +3489,21 @@ fieldset.fdy-field>legend{padding:0;float:none;margin-bottom:var(--space-2);}
3489
3489
  /* Freeday. Keyboard key */
3490
3490
  .fdy-kbd{display:inline-flex;align-items:center;justify-content:center;min-width:1.5rem;height:1.5rem;padding:0 var(--space-2);font-family:var(--font-mono);font-size:var(--text-xs);color:var(--color-text);background:var(--color-surface-2);border:var(--bw) solid var(--color-border-strong);border-bottom-width:2px;border-radius:var(--radius-sm);}
3491
3491
 
3492
+ /* Freeday. Text link
3493
+ * A bare `<a>` is already a link here: base.css paints it `--color-primary-strong` and the browser
3494
+ * underlines it. `.fdy-link` names that look so it can be found in COMPONENTS.md, sets the underline
3495
+ * the same way in every browser, and is the base the muted variant modifies.
3496
+ *
3497
+ * The underline stays in both, at rest. A link told apart by colour alone fails WCAG 1.4.1, and in
3498
+ * the muted variant there is no colour to tell it by. Hover thickens it; focus is base.css's ring. */
3499
+ .fdy-link{color:var(--color-primary-strong);text-decoration-line:underline;text-underline-offset:.2em;text-decoration-thickness:.06em;}
3500
+ .fdy-link:hover{text-decoration-thickness:.12em;}
3501
+ /* For a column of names that each open their own record: a table of accounts, each linking to its
3502
+ ledger. Twenty primary-coloured links in one column outweigh the numbers beside them. The text
3503
+ ink with a muted underline keeps every name reading as a link without competing with the data. */
3504
+ .fdy-link--muted{color:var(--color-text);text-decoration-color:var(--color-text-muted);}
3505
+ .fdy-link--muted:hover{color:var(--color-primary-strong);text-decoration-color:currentColor;}
3506
+
3492
3507
  /* Freeday. List: the FLAT row container.
3493
3508
  *
3494
3509
  * USAGE.md §3 puts list rows among the surfaces that should be flat, but until now the only
@@ -4023,6 +4038,44 @@ fieldset.fdy-field>legend{padding:0;float:none;margin-bottom:var(--space-2);}
4023
4038
  .fdy-tabs--vertical .fdy-tabs__tab[aria-selected="true"],.fdy-tabs--vertical .fdy-tabs__tab[aria-current="page"]{background:var(--color-primary-soft);color:var(--color-primary-strong);font-weight:var(--weight-semibold);}
4024
4039
  .fdy-tabs--vertical .fdy-tabs__panel{flex:1;min-width:0;padding:0;}
4025
4040
 
4041
+ /* PICKER IN A NARROW CONTAINER: `.fdy-tabs--picker-narrow`, opt-in, on either variant.
4042
+ *
4043
+ * At 40rem of its own width or less, the tab list gives way to `.fdy-tabs__picker`, a wrapper
4044
+ * holding one combo of the same sections. Six tabs with real labels do not fit a phone as a strip,
4045
+ * and as a column they fill the screen before the panel starts. A container query rather than a
4046
+ * viewport one, because the same tabs can sit in a page or in a 20rem drawer.
4047
+ *
4048
+ * The list is hidden only through `.fdy-tabs__picker ~ .fdy-tabs__list`, so the picker has to come
4049
+ * BEFORE the list, and tabs with no picker in them keep their list at every width: the class alone
4050
+ * can never leave a screen with no way between its sections. On the raw path freeday-tabs.js builds
4051
+ * the picker; in a typed stack it is a `FdyCombo` bound to the same state as the tabs.
4052
+ *
4053
+ * `flex-wrap` is what makes the vertical variant work: a container query styles what is inside the
4054
+ * container, never the container itself, so `.fdy-tabs--vertical` stays a flex row. The picker takes
4055
+ * a whole line and the panel wraps under it. While the list shows, the panel's `min-width:0` means it
4056
+ * never wraps.
4057
+ *
4058
+ * 40rem: a column of labels and a panel worth reading do not both fit under it. Below Safari 16
4059
+ * there are no container queries, and the same body applies by viewport width instead; that answers
4060
+ * every phone, and leaves tabs in a narrow drawer on a wide screen as lists. The two bodies are
4061
+ * copies, compared in test/baseline.test.mjs. */
4062
+ .fdy-tabs__picker{display:none;}
4063
+ .fdy-tabs--picker-narrow{flex-wrap:wrap;}
4064
+ .fdy-tabs__picker > .fdy-combo{max-width:none;}
4065
+ @supports (container-type:inline-size){
4066
+ .fdy-tabs--picker-narrow{container:fdy-tabs / inline-size;}
4067
+ @container fdy-tabs (max-width: 40rem){
4068
+ .fdy-tabs--picker-narrow > .fdy-tabs__picker{display:block;flex:0 0 100%;}
4069
+ .fdy-tabs--picker-narrow > .fdy-tabs__picker ~ .fdy-tabs__list{display:none;}
4070
+ }
4071
+ }
4072
+ @supports not (container-type:inline-size){
4073
+ @media (max-width:40rem){
4074
+ .fdy-tabs--picker-narrow > .fdy-tabs__picker{display:block;flex:0 0 100%;}
4075
+ .fdy-tabs--picker-narrow > .fdy-tabs__picker ~ .fdy-tabs__list{display:none;}
4076
+ }
4077
+ }
4078
+
4026
4079
  /* Freeday. Timeline (vertical event feed: dot markers on a connector line). Pure CSS. */
4027
4080
  .fdy-timeline{list-style:none;margin:0;padding:0;}
4028
4081
  .fdy-timeline__item{position:relative;padding:0 0 var(--space-5) var(--space-6);border-left:2px solid var(--color-border);}
package/dist/freeday.css CHANGED
@@ -1653,6 +1653,21 @@ fieldset.fdy-field>legend{padding:0;float:none;margin-bottom:var(--space-2);}
1653
1653
  /* Freeday. Keyboard key */
1654
1654
  .fdy-kbd{display:inline-flex;align-items:center;justify-content:center;min-width:1.5rem;height:1.5rem;padding:0 var(--space-2);font-family:var(--font-mono);font-size:var(--text-xs);color:var(--color-text);background:var(--color-surface-2);border:var(--bw) solid var(--color-border-strong);border-bottom-width:2px;border-radius:var(--radius-sm);}
1655
1655
 
1656
+ /* Freeday. Text link
1657
+ * A bare `<a>` is already a link here: base.css paints it `--color-primary-strong` and the browser
1658
+ * underlines it. `.fdy-link` names that look so it can be found in COMPONENTS.md, sets the underline
1659
+ * the same way in every browser, and is the base the muted variant modifies.
1660
+ *
1661
+ * The underline stays in both, at rest. A link told apart by colour alone fails WCAG 1.4.1, and in
1662
+ * the muted variant there is no colour to tell it by. Hover thickens it; focus is base.css's ring. */
1663
+ .fdy-link{color:var(--color-primary-strong);text-decoration-line:underline;text-underline-offset:.2em;text-decoration-thickness:.06em;}
1664
+ .fdy-link:hover{text-decoration-thickness:.12em;}
1665
+ /* For a column of names that each open their own record: a table of accounts, each linking to its
1666
+ ledger. Twenty primary-coloured links in one column outweigh the numbers beside them. The text
1667
+ ink with a muted underline keeps every name reading as a link without competing with the data. */
1668
+ .fdy-link--muted{color:var(--color-text);text-decoration-color:var(--color-text-muted);}
1669
+ .fdy-link--muted:hover{color:var(--color-primary-strong);text-decoration-color:currentColor;}
1670
+
1656
1671
  /* Freeday. List: the FLAT row container.
1657
1672
  *
1658
1673
  * USAGE.md §3 puts list rows among the surfaces that should be flat, but until now the only
@@ -2187,6 +2202,44 @@ fieldset.fdy-field>legend{padding:0;float:none;margin-bottom:var(--space-2);}
2187
2202
  .fdy-tabs--vertical .fdy-tabs__tab[aria-selected="true"],.fdy-tabs--vertical .fdy-tabs__tab[aria-current="page"]{background:var(--color-primary-soft);color:var(--color-primary-strong);font-weight:var(--weight-semibold);}
2188
2203
  .fdy-tabs--vertical .fdy-tabs__panel{flex:1;min-width:0;padding:0;}
2189
2204
 
2205
+ /* PICKER IN A NARROW CONTAINER: `.fdy-tabs--picker-narrow`, opt-in, on either variant.
2206
+ *
2207
+ * At 40rem of its own width or less, the tab list gives way to `.fdy-tabs__picker`, a wrapper
2208
+ * holding one combo of the same sections. Six tabs with real labels do not fit a phone as a strip,
2209
+ * and as a column they fill the screen before the panel starts. A container query rather than a
2210
+ * viewport one, because the same tabs can sit in a page or in a 20rem drawer.
2211
+ *
2212
+ * The list is hidden only through `.fdy-tabs__picker ~ .fdy-tabs__list`, so the picker has to come
2213
+ * BEFORE the list, and tabs with no picker in them keep their list at every width: the class alone
2214
+ * can never leave a screen with no way between its sections. On the raw path freeday-tabs.js builds
2215
+ * the picker; in a typed stack it is a `FdyCombo` bound to the same state as the tabs.
2216
+ *
2217
+ * `flex-wrap` is what makes the vertical variant work: a container query styles what is inside the
2218
+ * container, never the container itself, so `.fdy-tabs--vertical` stays a flex row. The picker takes
2219
+ * a whole line and the panel wraps under it. While the list shows, the panel's `min-width:0` means it
2220
+ * never wraps.
2221
+ *
2222
+ * 40rem: a column of labels and a panel worth reading do not both fit under it. Below Safari 16
2223
+ * there are no container queries, and the same body applies by viewport width instead; that answers
2224
+ * every phone, and leaves tabs in a narrow drawer on a wide screen as lists. The two bodies are
2225
+ * copies, compared in test/baseline.test.mjs. */
2226
+ .fdy-tabs__picker{display:none;}
2227
+ .fdy-tabs--picker-narrow{flex-wrap:wrap;}
2228
+ .fdy-tabs__picker > .fdy-combo{max-width:none;}
2229
+ @supports (container-type:inline-size){
2230
+ .fdy-tabs--picker-narrow{container:fdy-tabs / inline-size;}
2231
+ @container fdy-tabs (max-width: 40rem){
2232
+ .fdy-tabs--picker-narrow > .fdy-tabs__picker{display:block;flex:0 0 100%;}
2233
+ .fdy-tabs--picker-narrow > .fdy-tabs__picker ~ .fdy-tabs__list{display:none;}
2234
+ }
2235
+ }
2236
+ @supports not (container-type:inline-size){
2237
+ @media (max-width:40rem){
2238
+ .fdy-tabs--picker-narrow > .fdy-tabs__picker{display:block;flex:0 0 100%;}
2239
+ .fdy-tabs--picker-narrow > .fdy-tabs__picker ~ .fdy-tabs__list{display:none;}
2240
+ }
2241
+ }
2242
+
2190
2243
  /* Freeday. Timeline (vertical event feed: dot markers on a connector line). Pure CSS. */
2191
2244
  .fdy-timeline{list-style:none;margin:0;padding:0;}
2192
2245
  .fdy-timeline__item{position:relative;padding:0 0 var(--space-5) var(--space-6);border-left:2px solid var(--color-border);}
package/dist/freeday.js CHANGED
@@ -2430,13 +2430,24 @@
2430
2430
  return b;
2431
2431
  }
2432
2432
 
2433
+ /* Every arrow rebuilds the panel, and with it the arrow that was pressed, so focus fell to <body>
2434
+ and the next key press (another arrow, Escape) went nowhere. The arrow in the same place takes
2435
+ focus back, unless the handler already moved it somewhere in the panel on purpose. */
2433
2436
  function navButton(glyph, aria, onClick) {
2434
2437
  var b = document.createElement('button');
2435
2438
  b.type = 'button';
2436
2439
  b.className = 'fdy-cal__nav';
2437
2440
  b.textContent = glyph;
2438
2441
  b.setAttribute('aria-label', aria);
2439
- b.addEventListener('click', onClick);
2442
+ var side = glyph === '‹' ? 'prev' : 'next';
2443
+ b.setAttribute('data-fdy-nav', side);
2444
+ b.addEventListener('click', function () {
2445
+ onClick();
2446
+ if (!panel.contains(document.activeElement)) {
2447
+ var again = panel.querySelector('.fdy-cal__nav[data-fdy-nav="' + side + '"]');
2448
+ if (again) again.focus();
2449
+ }
2450
+ });
2440
2451
  return b;
2441
2452
  }
2442
2453
 
@@ -2930,6 +2941,19 @@
2930
2941
  }
2931
2942
 
2932
2943
  trigger.addEventListener('click', function () { panel.hidden ? open() : close(true); });
2944
+ /* Escape from anywhere in the panel. The grids handle it first and say so with preventDefault;
2945
+ this answers for the arrows and the title, where it used to do nothing. */
2946
+ panel.addEventListener('keydown', function (e) {
2947
+ if (e.key !== 'Escape' || e.defaultPrevented) return;
2948
+ e.preventDefault();
2949
+ close(true);
2950
+ });
2951
+ /* Focus leaving the field closes it, as the Vue and React pickers always have. A null target is
2952
+ a rebuilt panel taking the focused element with it, which is not focus leaving. */
2953
+ wrap.addEventListener('focusout', function (e) {
2954
+ var next = e.relatedTarget;
2955
+ if (next && !wrap.contains(next)) close(false);
2956
+ });
2933
2957
 
2934
2958
  updateDisplay();
2935
2959
 
@@ -3459,6 +3483,9 @@
3459
3483
  kitRoots(form).forEach(function (root) { paint(kitAria(root), ''); });
3460
3484
  }
3461
3485
  };
3486
+ /* The form's own <button type="reset"> empties the fields; the messages about them went with it
3487
+ only through api.reset(), so a reset form kept its red text and still counted as submitted. */
3488
+ form.addEventListener('reset', function () { api.reset(); });
3462
3489
  form._fdyForm = api;
3463
3490
  return api;
3464
3491
  }
@@ -4652,10 +4679,10 @@
4652
4679
  var marker = s.querySelector('.fdy-step__marker');
4653
4680
  if (marker) marker.innerHTML = i < active ? CHECK : (marker.dataset.num || String(i + 1));
4654
4681
  var btn = s.querySelector('.fdy-step__btn');
4655
- if (btn) btn.disabled = i > maxReached;
4682
+ if (btn) btn.disabled = i > maxReached || deciding;
4656
4683
  });
4657
4684
  panels.forEach(function (p, i) { p.hidden = i !== active; });
4658
- if (prevBtn) prevBtn.disabled = active === 0;
4685
+ if (prevBtn) prevBtn.disabled = deciding || active === 0;
4659
4686
  if (nextBtn) nextBtn.textContent = active === steps.length - 1 ? textOf(root, 'done') : (nextLabel || textOf(root, 'next'));
4660
4687
  root.dispatchEvent(new CustomEvent('fdy-step-change', { bubbles: true, detail: { index: active } }));
4661
4688
  }
@@ -4678,12 +4705,19 @@
4678
4705
  * opinion about form libraries and this is the line that keeps it that way. */
4679
4706
  var deciding = false;
4680
4707
 
4708
+ /* While a guard decides, nothing moves: Next, Back and the step headers alike. Only Next and Back
4709
+ used to check, so a header click went through mid-decision, and the decision then landed on a
4710
+ step it was never asked about. */
4681
4711
  function lock(on) {
4682
4712
  deciding = on;
4683
4713
  var list = root.querySelector('.fdy-stepper');
4684
4714
  if (list) { if (on) list.setAttribute('aria-busy', 'true'); else list.removeAttribute('aria-busy'); }
4685
4715
  if (prevBtn) prevBtn.disabled = on || active === 0;
4686
4716
  if (nextBtn) nextBtn.disabled = on;
4717
+ steps.forEach(function (s, i) {
4718
+ var btn = s.querySelector('.fdy-step__btn');
4719
+ if (btn) btn.disabled = on || i > maxReached;
4720
+ });
4687
4721
  }
4688
4722
 
4689
4723
  function request(to, onAllowed) {
@@ -4708,16 +4742,18 @@
4708
4742
  );
4709
4743
  }
4710
4744
 
4711
- if (prevBtn) prevBtn.addEventListener('click', function () { go(active - 1); });
4745
+ if (prevBtn) prevBtn.addEventListener('click', function () { if (!deciding) go(active - 1); });
4712
4746
  if (nextBtn) nextBtn.addEventListener('click', function () {
4713
- if (active < steps.length - 1) request(active + 1, function () { go(active + 1); });
4747
+ /* The target is fixed when asked: the guard approves THIS move, whatever happens meanwhile. */
4748
+ var to = active + 1;
4749
+ if (active < steps.length - 1) request(to, function () { go(to); });
4714
4750
  else request(active + 1, function () { root.dispatchEvent(new CustomEvent('fdy-step-finish', { bubbles: true })); });
4715
4751
  });
4716
4752
  steps.forEach(function (s, i) {
4717
4753
  var btn = s.querySelector('.fdy-step__btn');
4718
4754
  if (!btn) return;
4719
4755
  btn.addEventListener('click', function () {
4720
- if (i > maxReached) return;
4756
+ if (deciding || i > maxReached) return;
4721
4757
  // Going BACK is always allowed — nothing is being committed. Jumping forward to a step
4722
4758
  // already reached still leaves the current one behind, so it asks the guard like Next does.
4723
4759
  if (i <= active) go(i);
@@ -5325,8 +5361,12 @@
5325
5361
  closePopover();
5326
5362
  }
5327
5363
  });
5364
+ /* preventDefault says the key was used. Without it a dialog's close watcher acted on the same
5365
+ Escape, and a filter open in a table inside a modal closed the modal with it. */
5328
5366
  document.addEventListener('keydown', function (e) {
5329
- if (e.key === 'Escape' && openPopover) closePopover(true);
5367
+ if (e.key !== 'Escape' || !openPopover) return;
5368
+ e.preventDefault();
5369
+ closePopover(true);
5330
5370
  });
5331
5371
 
5332
5372
  buildColumnFilters();
@@ -5361,10 +5401,73 @@
5361
5401
  * other pair is left entirely alone rather than bound as a second axis: Left and Right over a
5362
5402
  * column of tabs belong to whatever else is on the page, and a widget that preventDefaults a key
5363
5403
  * it has no meaning for has taken it from the page silently. Home/End answer on both.
5404
+ *
5405
+ * `.fdy-tabs--picker-narrow` on the root: this builds a `.fdy-tabs__picker` holding one combo of
5406
+ * the same tabs, first in the root, and keeps the two in step both ways. tabs.css shows it instead
5407
+ * of the list in a container of 40rem or less. It needs freeday-select.js (FreedayCombo), which
5408
+ * dist/freeday.js carries; without it the list simply stays. A picker the author wrote is left alone.
5364
5409
  */
5365
5410
  (function () {
5366
5411
  'use strict';
5367
5412
 
5413
+ /* The picker's accessible name when the tablist has none of its own to lend it. */
5414
+ var TEXT = {
5415
+ picker: 'Section'
5416
+ };
5417
+ function textOf(root, key) {
5418
+ var kebab = key.replace(/[A-Z]/g, function (c) { return '-' + c.toLowerCase(); });
5419
+ var custom = root.getAttribute('data-fdy-text-' + kebab);
5420
+ return custom != null && custom !== '' ? custom : TEXT[key];
5421
+ }
5422
+ var uidSeq = 0;
5423
+ function uid(p) { uidSeq += 1; return p + '-' + uidSeq; }
5424
+
5425
+ /* The combo freeday-select.js reads, built from the tabs themselves: one option per tab, its value
5426
+ the tab's id. Named by the tablist's own label when it has one, so the two read as one control. */
5427
+ function buildPicker(root, list, tabs) {
5428
+ var wrap = document.createElement('div');
5429
+ wrap.className = 'fdy-tabs__picker';
5430
+ var combo = document.createElement('div');
5431
+ combo.className = 'fdy-combo';
5432
+ combo.setAttribute('data-fdy-combo', '');
5433
+ var button = document.createElement('button');
5434
+ button.type = 'button';
5435
+ button.className = 'fdy-combo__button';
5436
+ button.setAttribute('role', 'combobox');
5437
+ button.setAttribute('aria-haspopup', 'listbox');
5438
+ button.setAttribute('aria-expanded', 'false');
5439
+ var value = document.createElement('span');
5440
+ value.className = 'fdy-combo__value';
5441
+ value.id = uid('fdy-tabs-picker-value');
5442
+ button.appendChild(value);
5443
+ var labelledby = list ? list.getAttribute('aria-labelledby') : null;
5444
+ var label = list ? list.getAttribute('aria-label') : null;
5445
+ if (labelledby) button.setAttribute('aria-labelledby', labelledby + ' ' + value.id);
5446
+ else button.setAttribute('aria-label', label || textOf(root, 'picker'));
5447
+ var listbox = document.createElement('ul');
5448
+ listbox.className = 'fdy-combo__listbox';
5449
+ listbox.setAttribute('role', 'listbox');
5450
+ listbox.hidden = true;
5451
+ tabs.forEach(function (tab) {
5452
+ if (!tab.id) tab.id = uid('fdy-tab');
5453
+ var opt = document.createElement('li');
5454
+ opt.className = 'fdy-combo__option';
5455
+ opt.setAttribute('role', 'option');
5456
+ opt.setAttribute('data-value', tab.id);
5457
+ opt.setAttribute('aria-selected', 'false');
5458
+ var check = document.createElement('span');
5459
+ check.className = 'fdy-combo__check';
5460
+ opt.appendChild(check);
5461
+ opt.appendChild(document.createTextNode((tab.textContent || '').replace(/\s+/g, ' ').trim()));
5462
+ listbox.appendChild(opt);
5463
+ });
5464
+ combo.appendChild(button);
5465
+ combo.appendChild(listbox);
5466
+ wrap.appendChild(combo);
5467
+ root.insertBefore(wrap, root.firstChild);
5468
+ return combo;
5469
+ }
5470
+
5368
5471
  function initTabs(root) {
5369
5472
  if (root.dataset.fdyTabsReady === '1') return;
5370
5473
  if (root.closest('[data-fdy-ignore]')) return;
@@ -5382,6 +5485,17 @@
5382
5485
  list.setAttribute('aria-orientation', 'vertical');
5383
5486
  }
5384
5487
  var vertical = list !== null && list.getAttribute('aria-orientation') === 'vertical';
5488
+ var picker = null;
5489
+ if (root.classList.contains('fdy-tabs--picker-narrow') && window.FreedayCombo
5490
+ && root.querySelector(':scope > .fdy-tabs__picker') === null) {
5491
+ picker = buildPicker(root, list, tabs);
5492
+ window.FreedayCombo.init(picker);
5493
+ picker.addEventListener('fdy-change', function (e) {
5494
+ var id = e.detail && e.detail.value;
5495
+ var tab = tabs.filter(function (t) { return t.id === id; })[0];
5496
+ if (tab) select(tab, false);
5497
+ });
5498
+ }
5385
5499
  var NEXT_KEY = vertical ? 'ArrowDown' : 'ArrowRight';
5386
5500
  var PREV_KEY = vertical ? 'ArrowUp' : 'ArrowLeft';
5387
5501
 
@@ -5397,6 +5511,8 @@
5397
5511
  var panel = panelFor(t);
5398
5512
  if (panel) panel.hidden = !on;
5399
5513
  });
5514
+ /* Silent: setValue raises no fdy-change, so the picker cannot echo a pick back here. */
5515
+ if (picker) window.FreedayCombo.setValue(picker, tab.id);
5400
5516
  if (focus) tab.focus();
5401
5517
  }
5402
5518
 
@@ -6358,6 +6474,13 @@
6358
6474
  /* Back to a measured bar. While the indeterminate modifier is on it owns the bar's width, so an
6359
6475
  explicit one has to be restored when it comes off: .fdy-progress__bar is a plain block div, and
6360
6476
  with no width at all it fills the track, a full bar, which is the opposite of what 0% means. */
6477
+ function showUploading() {
6478
+ el.classList.remove('fdy-file--error', 'fdy-file--success');
6479
+ icon.innerHTML = FILE_ICON;
6480
+ sub.textContent = fmtSize(file.size) + ' · ' + textOf(zone, 'uploading');
6481
+ ensureProgress();
6482
+ determinate();
6483
+ }
6361
6484
  function determinate() {
6362
6485
  progressEl.classList.remove('fdy-progress--indeterminate');
6363
6486
  if (!bar.style.width) bar.style.width = '0%';
@@ -6375,13 +6498,12 @@
6375
6498
  dropProgress();
6376
6499
  },
6377
6500
  uploading: function () {
6378
- el.classList.remove('fdy-file--error', 'fdy-file--success');
6379
- icon.innerHTML = FILE_ICON;
6380
- sub.textContent = fmtSize(file.size) + ' · ' + textOf(zone, 'uploading');
6381
- ensureProgress();
6382
- determinate();
6501
+ showUploading();
6383
6502
  },
6384
6503
  setProgress: function (pct) {
6504
+ /* A percentage means the file is uploading again, whatever the row said before. A retry that
6505
+ reported progress straight after done() or fail() painted "Uploaded" over a moving bar. */
6506
+ if (el.classList.contains('fdy-file--success') || el.classList.contains('fdy-file--error')) showUploading();
6385
6507
  ensureProgress();
6386
6508
  determinate();
6387
6509
  var v = Math.max(0, Math.min(100, pct));
@@ -6462,9 +6584,13 @@
6462
6584
  ['dragenter', 'dragover'].forEach(function (ev) {
6463
6585
  zone.addEventListener(ev, function (e) { e.preventDefault(); zone.classList.add('is-dragover'); });
6464
6586
  });
6465
- ['dragleave', 'dragend'].forEach(function (ev) {
6466
- zone.addEventListener(ev, function (e) { if (e.target === zone) zone.classList.remove('is-dragover'); });
6587
+ /* Off when the pointer has left the ZONE, read from where it went: dragleave fires on whichever
6588
+ child it was over, so `e.target === zone` missed a drag that left through the icon, and the
6589
+ highlight stayed. A null relatedTarget is the window, or a drag cancelled with Escape. */
6590
+ zone.addEventListener('dragleave', function (e) {
6591
+ if (!e.relatedTarget || !zone.contains(e.relatedTarget)) zone.classList.remove('is-dragover');
6467
6592
  });
6593
+ zone.addEventListener('dragend', function () { zone.classList.remove('is-dragover'); });
6468
6594
  zone.addEventListener('drop', function (e) {
6469
6595
  e.preventDefault();
6470
6596
  zone.classList.remove('is-dragover');
@@ -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.22.0"` (public npm package). `dist/` is
201
+ Lands in `package.json` as `"@cahyo-dimas/freeday": "^3.24.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`)
@@ -81,7 +81,7 @@
81
81
 
82
82
  <!-- .fdy-app__title carries an auto-spacer (margin-right:auto): everything after it sits at
83
83
  the right edge. -->
84
- <h1 class="fdy-app__title fdy-hide-below-md">Receivables</h1>
84
+ <h1 class="fdy-app__title">Receivables</h1>
85
85
 
86
86
  <div class="fdy-input-group fdy-hide-below-md" style="max-width:14rem">
87
87
  <span class="fdy-input-group__addon fdy-input-group__addon--icon">
@@ -75,6 +75,9 @@ Notes:
75
75
  These replace one data area (a table, a list, a card), not the page. Put the `.fdy-state` inside
76
76
  the card or section it replaces, so the page header and its actions stay usable.
77
77
 
78
+ In Vue and React, `useLoad` holds which of these a data area is in, as one value; see `.fdy-state`
79
+ in COMPONENTS.md.
80
+
78
81
  ### 10. Ideal
79
82
 
80
83
  The data as designed. Design it last, after the four below, because those decide whether the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cahyo-dimas/freeday",
3
- "version": "3.22.0",
3
+ "version": "3.24.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/axis-nesting.mjs browser/palette-os-dark.mjs browser/primary-fill.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/actionbar.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/daterange-single.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/autocomplete-open.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/axis-nesting.mjs browser/palette-os-dark.mjs browser/primary-fill.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/actionbar.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/daterange-single.mjs browser/child-hydration.mjs browser/tabs-picker.mjs browser/cfl-async.mjs browser/table-process.mjs browser/modal-locked.mjs browser/datepicker-escape.mjs browser/raw-escape-reset.mjs browser/use-load.mjs browser/upload-leftovers.mjs browser/stepper-pending.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/autocomplete-open.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",
@@ -0,0 +1,14 @@
1
+ /* Freeday. Text link
2
+ * A bare `<a>` is already a link here: base.css paints it `--color-primary-strong` and the browser
3
+ * underlines it. `.fdy-link` names that look so it can be found in COMPONENTS.md, sets the underline
4
+ * the same way in every browser, and is the base the muted variant modifies.
5
+ *
6
+ * The underline stays in both, at rest. A link told apart by colour alone fails WCAG 1.4.1, and in
7
+ * the muted variant there is no colour to tell it by. Hover thickens it; focus is base.css's ring. */
8
+ .fdy-link{color:var(--color-primary-strong);text-decoration-line:underline;text-underline-offset:.2em;text-decoration-thickness:.06em;}
9
+ .fdy-link:hover{text-decoration-thickness:.12em;}
10
+ /* For a column of names that each open their own record: a table of accounts, each linking to its
11
+ ledger. Twenty primary-coloured links in one column outweigh the numbers beside them. The text
12
+ ink with a muted underline keeps every name reading as a link without competing with the data. */
13
+ .fdy-link--muted{color:var(--color-text);text-decoration-color:var(--color-text-muted);}
14
+ .fdy-link--muted:hover{color:var(--color-primary-strong);text-decoration-color:currentColor;}