@tangible/ui 0.2.43 → 0.2.44
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/components/Pager/Pager.js +5 -2
- package/components/Table/BulkActionsBar.js +2 -1
- package/figma-tokens.json +1 -1
- package/icons/icons.svg +1 -1
- package/icons/sprite-version.js +1 -1
- package/icons/sprite.php +1 -1
- package/package.json +1 -1
- package/skills/building-with-tui/SKILL.md +12 -0
- package/styles/all.css +1 -1
- package/styles/all.expanded.css +26 -12
- package/styles/all.expanded.unlayered.css +26 -12
- package/styles/all.unlayered.css +1 -1
- package/styles/components/button.scss +18 -11
- package/styles/components/modal.scss +12 -1
- package/styles/components/table.scss +10 -0
- package/tui-manifest.json +2 -2
- package/utils/scroll-lock.js +51 -5
- package/vanilla/modal.min.js +1 -1
- package/vanilla/styles.css +1 -1
- package/vanilla/styles.unlayered.css +1 -1
|
@@ -440,15 +440,19 @@ $_typography-lineHeight: var(--#{sys.$prefix}button-line-height, 1.4);
|
|
|
440
440
|
// Forced colors (high contrast mode)
|
|
441
441
|
// ---------------------------------------------------------------------------
|
|
442
442
|
@media (forced-colors: active) {
|
|
443
|
+
// !important throughout: the base rules set these colours !important (to
|
|
444
|
+
// beat WordPress), so without it none of this block ever applied. The
|
|
445
|
+
// colours match IconButton's, so both buttons read alike.
|
|
443
446
|
.#{sys.$prefix}interface .#{sys.$prefix}button {
|
|
444
447
|
forced-color-adjust: none;
|
|
445
|
-
background-color:
|
|
446
|
-
color:
|
|
447
|
-
border-color: CanvasText;
|
|
448
|
+
background-color: Canvas !important;
|
|
449
|
+
color: CanvasText !important;
|
|
450
|
+
border-color: CanvasText !important;
|
|
448
451
|
|
|
449
452
|
&:is(:hover, :active) {
|
|
450
|
-
background-color: Highlight;
|
|
451
|
-
|
|
453
|
+
background-color: Highlight !important;
|
|
454
|
+
color: Canvas !important;
|
|
455
|
+
border-color: Highlight !important;
|
|
452
456
|
}
|
|
453
457
|
|
|
454
458
|
&:focus-visible {
|
|
@@ -457,16 +461,19 @@ $_typography-lineHeight: var(--#{sys.$prefix}button-line-height, 1.4);
|
|
|
457
461
|
}
|
|
458
462
|
|
|
459
463
|
&.is-style-link {
|
|
460
|
-
background-color: transparent;
|
|
461
|
-
color: LinkText;
|
|
462
|
-
border-color: transparent;
|
|
464
|
+
background-color: transparent !important;
|
|
465
|
+
color: LinkText !important;
|
|
466
|
+
border-color: transparent !important;
|
|
463
467
|
}
|
|
464
468
|
|
|
469
|
+
// aria-disabled too, as IconButton does: Pager's boundary buttons and
|
|
470
|
+
// loading Buttons are aria-disabled.
|
|
465
471
|
&[disabled],
|
|
472
|
+
&[aria-disabled="true"],
|
|
466
473
|
&.is-disabled {
|
|
467
|
-
color: GrayText;
|
|
468
|
-
border-color: GrayText;
|
|
469
|
-
background-color: Canvas;
|
|
474
|
+
color: GrayText !important;
|
|
475
|
+
border-color: GrayText !important;
|
|
476
|
+
background-color: Canvas !important;
|
|
470
477
|
}
|
|
471
478
|
}
|
|
472
479
|
}
|
|
@@ -396,8 +396,19 @@
|
|
|
396
396
|
}
|
|
397
397
|
}
|
|
398
398
|
|
|
399
|
-
// Body scroll locking helper
|
|
399
|
+
// Body scroll locking helper (src/utils/scroll-lock.ts). The padding fills
|
|
400
|
+
// the gutter the hidden scrollbar leaves, on the side it was on, so the
|
|
401
|
+
// page doesn't shift. Keyed to the lock class: whoever removes the class
|
|
402
|
+
// removes the padding. !important so a host's body padding can't undo it.
|
|
400
403
|
.#{sys.$prefix}modal-open {
|
|
401
404
|
overflow: hidden;
|
|
405
|
+
|
|
406
|
+
&.#{sys.$prefix}scroll-lock-pad-right {
|
|
407
|
+
padding-right: var(--#{sys.$prefix}scroll-lock-pad) !important;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
&.#{sys.$prefix}scroll-lock-pad-left {
|
|
411
|
+
padding-left: var(--#{sys.$prefix}scroll-lock-pad) !important;
|
|
412
|
+
}
|
|
402
413
|
}
|
|
403
414
|
}
|
|
@@ -61,11 +61,21 @@
|
|
|
61
61
|
|
|
62
62
|
&__bulkActions {
|
|
63
63
|
display: flex;
|
|
64
|
+
flex-wrap: wrap;
|
|
64
65
|
align-items: center;
|
|
65
66
|
gap: var(--#{sys.$prefix}spacing-sm);
|
|
66
67
|
padding-inline: var(--_padding);
|
|
67
68
|
padding-block: var(--_padding);
|
|
68
69
|
}
|
|
70
|
+
|
|
71
|
+
// The consumer's actions and Clear, spaced like any button row. Without
|
|
72
|
+
// its own flex the wrapper stacked its buttons flush against each other.
|
|
73
|
+
&__bulkActions__actions {
|
|
74
|
+
display: flex;
|
|
75
|
+
flex-wrap: wrap;
|
|
76
|
+
align-items: center;
|
|
77
|
+
gap: var(--#{sys.$prefix}spacing-xs);
|
|
78
|
+
}
|
|
69
79
|
// Selection checkboxes
|
|
70
80
|
input[type="checkbox"] {
|
|
71
81
|
accent-color: var(--#{sys.$prefix}theme-primary-base);
|
package/tui-manifest.json
CHANGED
package/utils/scroll-lock.js
CHANGED
|
@@ -3,23 +3,69 @@
|
|
|
3
3
|
// Blocks or L&L markup (vanilla) share a page. The count lives on <body>, not
|
|
4
4
|
// in module scope, because each vanilla script is its own bundle with its own
|
|
5
5
|
// copy of this module. The lock lifts only when the last holder releases it.
|
|
6
|
+
//
|
|
7
|
+
// Hiding overflow removes a classic scrollbar, so the page would widen under
|
|
8
|
+
// the dialog and anything centred or end-aligned would jump. The lock pads
|
|
9
|
+
// the body on the side the scrollbar was on, by exactly the width gained:
|
|
10
|
+
// measured, so overlay scrollbars and a reserved gutter (scrollbar-gutter:
|
|
11
|
+
// stable) get nothing. The side is measured too, not read from `dir`: it
|
|
12
|
+
// follows the root's direction, and browsers differ.
|
|
13
|
+
//
|
|
14
|
+
// The padding is a stylesheet rule keyed to the lock class (Modal's styles,
|
|
15
|
+
// which the vanilla sheet includes), fed by custom properties set here. So an
|
|
16
|
+
// older TUI bundle that only knows to remove the class still takes the
|
|
17
|
+
// padding with it, and `!important` in a layer beats a host's body padding.
|
|
18
|
+
// While locked, `--tui-scroll-lock-gutter-left` / `-right` on <body> carry the
|
|
19
|
+
// width for hosts to shift their own fixed bars by.
|
|
6
20
|
const CLASS = 'tui-modal-open';
|
|
7
21
|
const COUNT = 'tuiScrollLock'; // data-tui-scroll-lock
|
|
22
|
+
const PAD = '--tui-scroll-lock-pad';
|
|
23
|
+
const GUTTER = '--tui-scroll-lock-gutter';
|
|
24
|
+
const SIDES = ['left', 'right'];
|
|
8
25
|
function count() {
|
|
9
26
|
return Number(document.body.dataset[COUNT] ?? 0) || 0;
|
|
10
27
|
}
|
|
28
|
+
/** Undoes the padding: on the last unlock, and before a first lock, in case an older bundle left it. */
|
|
29
|
+
function clearPadding(body) {
|
|
30
|
+
body.style.removeProperty(PAD);
|
|
31
|
+
for (const side of SIDES) {
|
|
32
|
+
body.classList.remove(`tui-scroll-lock-pad-${side}`);
|
|
33
|
+
body.style.removeProperty(`${GUTTER}-${side}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
11
36
|
/** Locks body scroll. Pair every call with one `unlockScroll()`. */
|
|
12
37
|
export function lockScroll() {
|
|
13
|
-
|
|
14
|
-
|
|
38
|
+
const body = document.body;
|
|
39
|
+
const first = count() === 0;
|
|
40
|
+
body.dataset[COUNT] = String(count() + 1);
|
|
41
|
+
if (!first)
|
|
42
|
+
return;
|
|
43
|
+
clearPadding(body);
|
|
44
|
+
const root = document.documentElement;
|
|
45
|
+
const width = root.clientWidth;
|
|
46
|
+
const left = body.getBoundingClientRect().left;
|
|
47
|
+
body.classList.add(CLASS);
|
|
48
|
+
// clientWidth is a whole number, so at a fractional zoom this can be 1px off
|
|
49
|
+
const gained = root.clientWidth - width;
|
|
50
|
+
if (gained <= 0)
|
|
51
|
+
return;
|
|
52
|
+
// A scrollbar on the left held the page's start edge in; without it, the
|
|
53
|
+
// body moves left.
|
|
54
|
+
const side = body.getBoundingClientRect().left < left ? 'left' : 'right';
|
|
55
|
+
const own = parseFloat(getComputedStyle(body)[side === 'left' ? 'paddingLeft' : 'paddingRight']) || 0;
|
|
56
|
+
body.style.setProperty(PAD, `${own + gained}px`);
|
|
57
|
+
body.style.setProperty(`${GUTTER}-${side}`, `${gained}px`);
|
|
58
|
+
body.classList.add(`tui-scroll-lock-pad-${side}`);
|
|
15
59
|
}
|
|
16
60
|
/** Releases one lock; scroll returns when none are left. */
|
|
17
61
|
export function unlockScroll() {
|
|
62
|
+
const body = document.body;
|
|
18
63
|
const next = count() - 1;
|
|
19
64
|
if (next > 0) {
|
|
20
|
-
|
|
65
|
+
body.dataset[COUNT] = String(next);
|
|
21
66
|
return;
|
|
22
67
|
}
|
|
23
|
-
delete
|
|
24
|
-
|
|
68
|
+
delete body.dataset[COUNT];
|
|
69
|
+
body.classList.remove(CLASS);
|
|
70
|
+
clearPadding(body);
|
|
25
71
|
}
|
package/vanilla/modal.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{var
|
|
1
|
+
(()=>{var Y=Object.defineProperty;var J=(t,e)=>{for(var n in e)Y(t,n,{get:e[n],enumerable:!0})};var D={};J(D,{MODAL_CLOSE_EVENT:()=>j,MODAL_OPEN_EVENT:()=>y,close:()=>p,init:()=>S,open:()=>K});var Q=["[data-autofocus]","a[href]","area[href]","button:not([disabled])",'input:not([disabled]):not([type="hidden"])',"select:not([disabled])","textarea:not([disabled])","iframe","audio[controls]","video[controls]",'[contenteditable]:not([contenteditable="false"])','[tabindex]:not([tabindex="-1"])'].join(",");function h(t,e){if(t.matches(":disabled")||t.closest("[inert]"))return!1;if(typeof t.checkVisibility=="function")return t.checkVisibility({visibilityProperty:!0});for(let n=t;n&&n!==e;n=n.parentElement){if(n.hidden)return!1;let o=getComputedStyle(n);if(o.display==="none"||n===t&&o.visibility==="hidden")return!1}return!0}function x(t){return Array.from(t.querySelectorAll(Q)).filter(e=>h(e,t))}var k="tui-modal-open",g="tuiScrollLock",C="--tui-scroll-lock-pad",w="--tui-scroll-lock-gutter",Z=["left","right"];function L(){return Number(document.body.dataset[g]??0)||0}function P(t){t.style.removeProperty(C);for(let e of Z)t.classList.remove(`tui-scroll-lock-pad-${e}`),t.style.removeProperty(`${w}-${e}`)}function _(){let t=document.body,e=L()===0;if(t.dataset[g]=String(L()+1),!e)return;P(t);let n=document.documentElement,o=n.clientWidth,r=t.getBoundingClientRect().left;t.classList.add(k);let i=n.clientWidth-o;if(i<=0)return;let l=t.getBoundingClientRect().left<r?"left":"right",a=parseFloat(getComputedStyle(t)[l==="left"?"paddingLeft":"paddingRight"])||0;t.style.setProperty(C,`${a+i}px`),t.style.setProperty(`${w}-${l}`,`${i}px`),t.classList.add(`tui-scroll-lock-pad-${l}`)}function O(){let t=document.body,e=L()-1;if(e>0){t.dataset[g]=String(e);return}delete t.dataset[g],t.classList.remove(k),P(t)}var b="data-tui-modal-open",c="data-tui-modal-close",tt="data-tui-modal-backdrop",M="data-tui-modal-src",R="data-tui-modal-restore-focus",et=".tui-modal__close",nt=":scope > .tui-modal__dialog",ot="iframe, object, embed, audio, video",it=1e3,y="tui-modal-open",j="tui-modal-close",m=new WeakMap,f=new WeakMap,B=new WeakSet,v=null,E=null,N=0;function s(t){console.warn(`[TUI modal] ${t}`)}function u(t){let e=t.getAttribute("data-state");return e==="open"||e==="closing"}function T(t){return t.querySelector(nt)}function I(t){return t.matches(":disabled")||t.closest('[aria-disabled="true"]')!==null}function z(t){if(typeof t!="string")return t;let e=document.getElementById(t);return e instanceof HTMLDialogElement?e:(s(e?`#${t} is a <${e.tagName.toLowerCase()}>, not a <dialog>. The modal must be a <dialog> element.`:`No element with id "${t}".`),null)}function q(t){return t.split(/\s+/).filter(e=>e&&!document.getElementById(e))}function rt(t){if(B.has(t))return;B.add(t);let e=`<dialog id="${t.id}">`,n=t.getAttribute("aria-labelledby"),o=t.getAttribute("aria-describedby");if(n){let i=q(n);i.length&&s(`${e} has aria-labelledby="${n}", but nothing has the id ${i.map(l=>`"${l}"`).join(", ")}, so the dialog has no name. Give the heading that id.`)}else t.hasAttribute("aria-label")||s(`${e} has no accessible name. Point aria-labelledby at its visible heading (WCAG 4.1.2).`);o&&q(o).length&&s(`${e} has aria-describedby="${o}", but not every id in it exists.`),t.getAttribute("role")==="alertdialog"&&!o&&s(`${e} is role="alertdialog" without aria-describedby. Point it at the message, or screen readers announce the heading and nothing about what is being confirmed.`),T(t)||s(`${e} has no .tui-modal__dialog box as its child. The box is the visible dialog; without it the backdrop can't be told apart and backdrop clicks are ignored.`),t.querySelector(`[${c}], form[method="dialog"]`)||Array.from(document.querySelectorAll(`[${c}]`)).some(i=>i.getAttribute(c)===t.id)||s(`${e} has no close control. Touch screen-reader users have no Escape key; add a button with ${c}.`)}function lt(t){let e=t.getAttribute(tt);return e==="dismiss"?!0:e==="static"?!1:t.getAttribute("role")!=="alertdialog"}function F(t){let e=getComputedStyle(t),n=i=>{let l=parseFloat(i);return Number.isNaN(l)?0:i.trim().endsWith("ms")?l:l*1e3},o=e.transitionDuration.split(","),r=e.transitionDelay.split(",");return Math.max(0,...o.map((i,l)=>n(i)+n(r[l%r.length]??"")))}function st(t){let e=T(t),n=Math.min(it,Math.max(F(t),e?F(e):0));return n>0?new Promise(o=>setTimeout(o,n)):Promise.resolve()}function at(t){let e=t.querySelector("[autofocus], [data-autofocus]");if(e&&h(e,t))return e;let n=x(t).filter(o=>!o.matches(ot));return n.find(o=>!o.matches(et))??n[0]??t}function K(t,e){let n=z(t);if(!n)return!1;if(n.getAttribute("data-state")==="closing")return f.delete(n),e&&m.set(n,e),n.setAttribute("data-state","open"),A(n,y,{opener:m.get(n)??null}),!0;if(n.open&&u(n))return!0;u(n)&&H(n),n.open&&(s(`<dialog id="${n.id}"> was already open, not as a modal. Drop the open attribute from the markup.`),n.close()),rt(n);try{n.showModal()}catch(a){return s(`<dialog id="${n.id}"> couldn't open: ${a.message}`),!1}_();let o=document.activeElement,r=e??(o instanceof HTMLElement&&o!==document.body?o:null);m.set(n,r);for(let a of n.querySelectorAll(`[${M}]`))a.hasAttribute("src")||a.setAttribute("src",a.getAttribute(M)??"");let i=T(n)??n,l=at(i);return l===i&&!i.hasAttribute("tabindex")&&(i.tabIndex=-1),l.focus(),n.offsetWidth,n.setAttribute("data-state","open"),A(n,y,{opener:r}),!0}function p(t){let e=z(t);if(!e?.open)return Promise.resolve();if(!u(e))return e.close(),Promise.resolve();let n=f.get(e);if(n)return n;e.setAttribute("data-state","closing");let o=st(e).then(()=>{f.get(e)===o&&(e.close(),H(e))});return f.set(e,o),o}function A(t,e,n){t.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:n}))}function H(t){if(!u(t))return;t.setAttribute("data-state","closed"),f.delete(t);for(let n of t.querySelectorAll("audio, video"))n.paused||n.pause();for(let n of t.querySelectorAll(`[${M}][src]`)){n.removeAttribute("src");let o=n.parentNode,r=n.nextSibling;n.remove(),o?.insertBefore(n,r)}O();let e=m.get(t)??null;m.delete(t),ct(t,e),A(t,j,{opener:e,returnValue:t.returnValue})}function ct(t,e){let n=t.getAttribute(R),o=[n?document.getElementById(n):null,e,...Array.from(document.querySelectorAll(`[${b}]`)).filter(r=>r.getAttribute(b)===t.id)];for(let r of o)if(!(!r?.isConnected||r===document.body)&&(r.focus(),document.activeElement===r))return;!e&&!n||s(`Focus had nowhere to return when <dialog id="${t.id}"> closed: its trigger is gone or can't take focus, so focus fell to <body> (WCAG 2.4.3). Set ${R}="<id>" on the dialog to name an element that will still be there.`)}function ut(t){return t.matches('a[href], input[type="submit"]')?!0:t instanceof HTMLButtonElement&&t.type==="submit"&&t.form!==null}function W(t){v=t.target,E=null}function U(t){E=t.target}function V(t){let e=v,n=E;v=E=null;let o=t.target;if(!(o instanceof Element))return;let r=o.closest(`[${b}]`);if(r){if(I(r))return;t.preventDefault(),K(r.getAttribute(b)??"",r);return}let i=o.closest(`[${c}]`);if(i){if(I(i))return;let a=i.getAttribute(c)||i.closest("dialog");if(!a){s(`A [${c}] control is outside any <dialog>. Give it the dialog's id as its value.`);return}ut(i)||t.preventDefault(),p(a);return}o instanceof HTMLDialogElement&&u(o)&&e===o&&n===o&&T(o)!==null&<(o)&&!dt(o,t)&&p(o)}function dt(t,e){let{clientWidth:n,clientHeight:o}=t;return n>0&&e.offsetX>=n||o>0&&e.offsetY>=o}function G(t){let e=t.target;!(e instanceof HTMLDialogElement)||!u(e)||t.cancelable&&(t.preventDefault(),p(e))}function X(t){let e=t.target;e instanceof HTMLDialogElement&&!e.open&&H(e)}function S(){N++===0&&(document.addEventListener("pointerdown",W,!0),document.addEventListener("pointerup",U,!0),document.addEventListener("click",V),document.addEventListener("cancel",G,!0),document.addEventListener("close",X,!0));let t=!1;return()=>{t||(t=!0,!(--N>0)&&(document.removeEventListener("pointerdown",W,!0),document.removeEventListener("pointerup",U,!0),document.removeEventListener("click",V),document.removeEventListener("cancel",G,!0),document.removeEventListener("close",X,!0)))}}var $=Symbol.for("tangible-ui/vanilla/modal"),d=globalThis;d[$]||(d[$]=D,S());d.TangibleUI=d.TangibleUI||{};d.TangibleUI.modal=d[$];})();
|