@popovandrii/ui-elements 0.2.1 → 0.3.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/README.md +49 -0
- package/dist/SpinBox.d.ts +33 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +76 -33
- package/dist/index.umd.js +1 -1
- package/dist/questionLabel.d.ts +23 -0
- package/dist/style.css +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -10,6 +10,7 @@ Lightweight TypeScript UI component library — **SpinBox**, **Select** (with se
|
|
|
10
10
|
- SPA-friendly lifecycle: idempotent `scan()`, optional root scoping and `MutationObserver` auto re-scan, teardown-only `destroy()`
|
|
11
11
|
- Custom DOM events + programmatic `setValue`
|
|
12
12
|
- Ripple and flash animations (opt-out per element)
|
|
13
|
+
- Themed label tooltip (`.UIql`) with optional viewport-aware auto-flip
|
|
13
14
|
- Ships as ES, CJS and UMD bundles with type declarations
|
|
14
15
|
|
|
15
16
|
## Components
|
|
@@ -285,6 +286,52 @@ Opt out per element or for any ancestor container:
|
|
|
285
286
|
<body class="ui-no-ripple ui-no-flash">
|
|
286
287
|
```
|
|
287
288
|
|
|
289
|
+
## Label tooltip (`.UIql`)
|
|
290
|
+
|
|
291
|
+
A small question-mark icon with a hover/focus tooltip you can drop into any
|
|
292
|
+
component label. It's pure CSS — the visible hint text lives in the inner
|
|
293
|
+
`<span>`:
|
|
294
|
+
|
|
295
|
+
```html
|
|
296
|
+
<div class="UIsp-label">
|
|
297
|
+
Amount
|
|
298
|
+
<span class="UIql" tabindex="0" aria-label="Help">
|
|
299
|
+
<span class="UIql__text" role="tooltip">Your hint goes here.</span>
|
|
300
|
+
</span>
|
|
301
|
+
</div>
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
- **Themed automatically** — nested in any component (spin box, switch, select,
|
|
305
|
+
button, button-group) the circle and bubble inherit that component's color;
|
|
306
|
+
standalone they fall back to grey. Override the `--ql-*` custom properties
|
|
307
|
+
(`--ql-bg`, `--ql-fg`, `--ql-border`, `--ql-tip-bg`, `--ql-tip-fg`) to retheme.
|
|
308
|
+
- **Opens on hover and keyboard focus**, and a mouse click keeps it open until
|
|
309
|
+
you click away (`tabindex="0"` is required for the focus/click behavior).
|
|
310
|
+
- **Stays on screen** — the bubble is capped to the viewport width. Near a
|
|
311
|
+
viewport edge, add `.UIql--right` (opens right, for icons near the left edge)
|
|
312
|
+
or `.UIql--left` (opens left, for icons near the right edge).
|
|
313
|
+
|
|
314
|
+
### Auto-flip the tooltip (optional)
|
|
315
|
+
|
|
316
|
+
To place those edge modifiers automatically, call `initQuestionTooltips()`
|
|
317
|
+
**once**. It attaches one delegated listener pair to a root (`document` by
|
|
318
|
+
default), so every `.UIql` — including ones added to the DOM later — is handled
|
|
319
|
+
with no per-element wiring. Before a tooltip opens it measures the room on each
|
|
320
|
+
side, flips the bubble inward if needed, and caps its width to the available
|
|
321
|
+
space (re-adapting on resize):
|
|
322
|
+
|
|
323
|
+
```js
|
|
324
|
+
import { initQuestionTooltips } from "@popovandrii/ui-elements";
|
|
325
|
+
|
|
326
|
+
const teardown = initQuestionTooltips(); // whole page
|
|
327
|
+
// initQuestionTooltips(myDialog); // or scope to a container
|
|
328
|
+
// teardown(); // remove the listeners
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
It's optional — the CSS works on its own; the helper just sets the modifiers for
|
|
332
|
+
you (pure CSS can't detect the viewport edge across all browsers). With the UMD
|
|
333
|
+
build it's `UiElements.initQuestionTooltips()`.
|
|
334
|
+
|
|
288
335
|
## Usage without a bundler (NodeJS + Express, UMD)
|
|
289
336
|
|
|
290
337
|
Serve the package's `dist` folder as static assets:
|
|
@@ -326,6 +373,8 @@ examples:
|
|
|
326
373
|
- [ButtonGroup (radio)](docs/button-group-radio/README.md) — radio group styled as buttons
|
|
327
374
|
- [Button](docs/button/README.md) — styled button / link with event dispatch
|
|
328
375
|
|
|
376
|
+
The shared [label tooltip (`.UIql`)](#label-tooltip-uiql) works with any of them.
|
|
377
|
+
|
|
329
378
|
<p align="center">
|
|
330
379
|
<img src="https://gitlab.com/AndreyPopov/ui-elements/-/raw/main/docs/images/button-group-UI.png" alt="ButtonGroup Preview" width="700">
|
|
331
380
|
</p>
|
package/dist/SpinBox.d.ts
CHANGED
|
@@ -18,13 +18,45 @@ export declare class SpinBox {
|
|
|
18
18
|
private root;
|
|
19
19
|
private observer;
|
|
20
20
|
private rescanTimer;
|
|
21
|
+
/**
|
|
22
|
+
* Per-element value applier registered during {@link scan}. Clamps to
|
|
23
|
+
* min/max, formats, syncs the +/- buttons and aria, and (unless silent)
|
|
24
|
+
* emits `ui-spinbox-change`. Reused by {@link setValue} and {@link refresh}
|
|
25
|
+
* so they share the exact same logic as the input `change` handler.
|
|
26
|
+
*/
|
|
27
|
+
private valueControls;
|
|
21
28
|
constructor(selectors?: Partial<SelectorMap>, debug?: boolean, options?: InitOptions);
|
|
22
29
|
/** Watch the root for added/removed nodes and re-scan (debounced). */
|
|
23
30
|
private observe;
|
|
24
31
|
private state;
|
|
25
32
|
destroy(): void;
|
|
26
33
|
private disableEl;
|
|
27
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Programmatically set a spin box value.
|
|
36
|
+
*
|
|
37
|
+
* The value is always clamped to min/max and the +/- buttons are kept in
|
|
38
|
+
* sync. Two independent flags control the side-effects:
|
|
39
|
+
*
|
|
40
|
+
* - `silent` (default `false`) — when `true`, the `ui-spinbox-change` event
|
|
41
|
+
* is not emitted. Use it to fill a form from data without triggering
|
|
42
|
+
* consumer side-effects on every field.
|
|
43
|
+
* - `flash` (default `true`) — when `false`, the flash animation is skipped.
|
|
44
|
+
* Use it to suppress the glow by design, independently of the event.
|
|
45
|
+
*
|
|
46
|
+
* For a quiet bulk fill, combine both: `{ silent: true, flash: false }`.
|
|
47
|
+
*/
|
|
48
|
+
setValue(el: HTMLElement, value: string | number, { silent, flash, }?: {
|
|
49
|
+
silent?: boolean;
|
|
50
|
+
flash?: boolean;
|
|
51
|
+
}): void;
|
|
52
|
+
/** Brief `box-shadow` glow on the element (unless an ancestor opts out). */
|
|
53
|
+
private playFlash;
|
|
54
|
+
/**
|
|
55
|
+
* Re-sync the +/- buttons (and aria) to the current input value without
|
|
56
|
+
* changing the value's meaning or emitting any event. Handy after the value
|
|
57
|
+
* was assigned directly to the input, bypassing {@link setValue}.
|
|
58
|
+
*/
|
|
59
|
+
refresh(el: HTMLElement): void;
|
|
28
60
|
getValidDataNumber: (el: HTMLElement, attr: string) => number;
|
|
29
61
|
/** Bind every not-yet-bound `.UIsp`. Safe to call repeatedly (SPA re-render). */
|
|
30
62
|
scan(): void;
|
package/dist/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=class{selectors;spinBoxes=null;abortController=new AbortController;debug;root;observer=null;rescanTimer=null;constructor(e={},t=!1,n={}){this.debug=t,this.root=n.root??document;let r={main:`UIsp`,btn:`UIsp__btn`,input:`UIsp__input`,disabledBtn:`disabled`};this.selectors={...r,...e},this.scan(),n.observe&&this.observe()}observe(){let e=this.root===document?document.body:this.root;this.observer=new MutationObserver(()=>{this.rescanTimer===null&&(this.rescanTimer=window.setTimeout(()=>{this.rescanTimer=null,this.scan()},50))}),this.observer.observe(e,{childList:!0,subtree:!0})}state=(e,t,n,r=0,i=0)=>{e==r||e<r?(t.classList.add(this.selectors.disabledBtn),t.disabled=!0):(t.classList.remove(this.selectors.disabledBtn),t.disabled=!1),i!==0&&(e==i||e>i?(n.classList.add(this.selectors.disabledBtn),n.disabled=!0):(n.classList.remove(this.selectors.disabledBtn),n.disabled=!1))};destroy(){this.observer?.disconnect(),this.observer=null,this.rescanTimer!==null&&(clearTimeout(this.rescanTimer),this.rescanTimer=null),this.abortController.abort(),this.spinBoxes?.forEach(e=>delete e.dataset.uispBound),this.spinBoxes=null,this.abortController=new AbortController}disableEl(e){let t=e.querySelector(`.${this.selectors.input}`),n=e.querySelectorAll(`.${this.selectors.btn}`);t&&(t.disabled=!0),n.forEach(e=>{e.classList.add(this.selectors.disabledBtn),e.disabled=!0}),e.setAttribute(`tabindex`,`-1`),e.setAttribute(`aria-disabled`,`true`)}setValue(e,t){let n=e.querySelector(`.${this.selectors.input}`);if(!n){this.debug&&console.warn(`UISpinBox: input not found`);return}n.value=String(t),n.dispatchEvent(new Event(`change`)),!e.closest(`.ui-no-flash`)&&(e.classList.remove(`UIsp--flash`),e.offsetWidth,e.classList.add(`UIsp--flash`),n.addEventListener(`animationend`,()=>e.classList.remove(`UIsp--flash`),{once:!0}))}getValidDataNumber=(e,t)=>{let n=e.getAttribute(`data-${t}`);return n===null||n.trim()===``||isNaN(Number(n))?0:Number(n)};scan(){this.spinBoxes=this.root.querySelectorAll(`.${this.selectors.main}`);let e=this.abortController.signal;this.spinBoxes.forEach(t=>{if(t.dataset.uispBound)return;t.dataset.uispBound=`1`;let n,r=t.querySelectorAll(`.${this.selectors.btn}`),i=t.querySelector(`.${this.selectors.input}`);this.debug&&(r||console.log(`Buttons (${this.selectors.btn}) not found in container`),i||console.log(`Input (${this.selectors.input}) not found in container`));let a=r[0],o=r[1];i.disabled=!1,[a,o].forEach(e=>{e.classList.remove(this.selectors.disabledBtn),e.disabled=!1}),t.setAttribute(`tabindex`,`0`),t.removeAttribute(`aria-disabled`);let s=t.hasAttribute(`data-decimals`)?this.getValidDataNumber(t,`decimals`):this.getValidDataNumber(t,`step`),c=Math.min(Math.max(Math.trunc(s),0),100),l=this.getValidDataNumber(t,`min`),u=this.getValidDataNumber(t,`max`);if(t.hasAttribute(`data-disabled`)){Number(i.value)<=l&&(i.value=l.toFixed(c)),u===0?i.value=Number(i.value).toFixed(c):Number(i.value)>=u&&(i.value=u.toFixed(c)),this.disableEl(t),t.addEventListener(`click`,e=>{e.preventDefault(),e.stopImmediatePropagation()},{capture:!0,signal:e});return}let d=e=>{t.setAttribute(`aria-valuenow`,String(e)),t.setAttribute(`aria-valuetext`,`${e} items`)};Number(i.value)<=l&&(i.value=l.toFixed(c)),u===0?i.value=Number(i.value).toFixed(c):(Number(i.value)>=u&&(i.value=u.toFixed(c)),u&&t.setAttribute(`aria-valuemax`,u.toFixed(c))),l&&t.setAttribute(`aria-valuemin`,l.toFixed(c)),this.state(Number(i.value),a,o,l,u),d(i.value);let f=null,p=(e,t=1)=>{i.value=String(Math.abs(Number(i.value)));let n=parseFloat(i.value)||0;return n+=e*t/10**c,e===1&&u!==0&&n>u&&(n=u),e===-1&&n<l&&(n=l),i.value=n.toFixed(c),this.state(Number(i.value),a,o,l,u),d(i.value),i.value},m=(e,t=150)=>{f===null&&(f=window.setInterval(e,t))},h=()=>{f!==null&&(clearInterval(f),f=null)};o.addEventListener(`mousedown`,e=>{let t=e.shiftKey?3:1;m(()=>p(1,t))},{signal:e}),o.addEventListener(`touchstart`,()=>m(()=>p(1)),{signal:e}),[`mouseup`,`mouseleave`,`mouseout`,`touchend`,`touchcancel`].forEach(t=>{o.addEventListener(t,h,{signal:e})}),o.addEventListener(`click`,e=>{let t=e.shiftKey?3:1;f===null&&(n=p(1,t),this.ripple(o),this.customEvent(i,n))},{signal:e}),a.addEventListener(`click`,e=>{let t=e.shiftKey?3:1;f===null&&(n=p(-1,t),this.ripple(a),this.customEvent(i,n))},{signal:e}),a.addEventListener(`mousedown`,e=>{let t=e.shiftKey?3:1;m(()=>p(-1,t),100)},{signal:e}),a.addEventListener(`touchstart`,()=>m(()=>p(-1),100),{signal:e}),[`mouseup`,`mouseleave`,`mouseout`,`touchend`,`touchcancel`].forEach(t=>{a.addEventListener(t,h,{signal:e})}),i.addEventListener(`keydown`,e=>{let t=e.key,n=e.shiftKey?5:1;if([`Backspace`,`Delete`,`ArrowLeft`,`ArrowRight`,`Tab`,`Enter`,`Home`,`End`].includes(t)||(e.ctrlKey||e.metaKey)&&[`a`,`c`,`v`,`x`].includes(t.toLowerCase()))return;if([`e`,`+`,`-`].includes(t)){e.preventDefault();return}if(t===`ArrowUp`||t===`ArrowDown`){e.preventDefault(),p(t===`ArrowUp`?1:-1,n);return}let r=t===`,`?`.`:t,a=/^[0-9]$/.test(r),o=r===`.`,s=i.value.includes(`.`);(c===0&&!a||c>0&&!(a||o)||o&&s)&&e.preventDefault()},{signal:e}),i.addEventListener(`keyup`,e=>{(e.key===`ArrowUp`||e.key===`ArrowDown`)&&this.customEvent(i,i.value)},{signal:e}),i.addEventListener(`change`,()=>{Number(i.value)<l&&(i.value=l.toFixed(c)),Number(i.value)>u&&u!==0?i.value=u.toFixed(c):i.value=Number(i.value).toFixed(c),this.state(Number(i.value),a,o,l,u),this.customEvent(i,i.value)},{signal:e})})}ripple(e){e.closest(`.ui-no-ripple`)||(e.classList.remove(`ui-ripple`),e.offsetWidth,e.classList.add(`ui-ripple`),e.addEventListener(`animationend`,()=>e.classList.remove(`ui-ripple`),{once:!0}))}customEvent(e,t){let n={detail:{id:e.id,value:t},bubbles:!0};this.debug&&console.log(`CustomEvent: data.detail `,n.detail),e.dispatchEvent(new CustomEvent(`ui-spinbox-change`,n))}},t=class{selectors;main=null;abortController=new AbortController;debug;root;observer=null;rescanTimer=null;constructor(e={},t=!1,n={}){this.debug=t,this.root=n.root??document;let r={main:`UIsw`,label:`UIsw-label`};this.selectors={...r,...e},this.scan(),n.observe&&this.observe()}observe(){let e=this.root===document?document.body:this.root;this.observer=new MutationObserver(()=>{this.rescanTimer===null&&(this.rescanTimer=window.setTimeout(()=>{this.rescanTimer=null,this.scan()},50))}),this.observer.observe(e,{childList:!0,subtree:!0})}destroy(){this.observer?.disconnect(),this.observer=null,this.rescanTimer!==null&&(clearTimeout(this.rescanTimer),this.rescanTimer=null),this.abortController.abort(),this.main?.forEach(e=>delete e.dataset.uiswBound),this.main=null,this.abortController=new AbortController}scan(){this.main=this.root.querySelectorAll(`.${this.selectors.main}`);let e=this.abortController.signal;this.main.forEach(t=>{if(t.dataset.uiswBound)return;t.dataset.uiswBound=`1`;let n=t.querySelector(`.${this.selectors.label}`),r=t.querySelector(`input`);n&&n.id&&t.setAttribute(`aria-labelledby`,n.id),t.hasAttribute(`data-originally-disabled`)||t.setAttribute(`data-originally-disabled`,String(r?.disabled??!1));let i=t.getAttribute(`data-originally-disabled`)===`true`;r&&(r.disabled=!1),t.setAttribute(`tabindex`,`0`),t.removeAttribute(`aria-disabled`),i&&(r&&(r.disabled=!0),t.setAttribute(`tabindex`,`-1`),t.setAttribute(`aria-disabled`,`true`),t.addEventListener(`click`,e=>{e.preventDefault(),e.stopImmediatePropagation()},{capture:!0,signal:e})),r&&(r.checked?t.setAttribute(`aria-checked`,`true`):t.setAttribute(`aria-checked`,`false`),r.addEventListener(`change`,()=>{t.setAttribute(`aria-checked`,String(r.checked)),this.customEvent(r,String(r.checked))},{signal:e}),t.addEventListener(`click`,e=>{if(e.target.tagName===`INPUT`)return;let n=e.target.closest(`label`);n||(r.checked=!r.checked),n||r.dispatchEvent(new Event(`change`));let i=t.querySelector(`.UIsw-slider`);i&&this.ripple(i)},{signal:e}),t.addEventListener(`keydown`,e=>{if(r.disabled)return;let n=null;if(e.key===`ArrowRight`?n=!0:e.key===`ArrowLeft`&&(n=!1),n!==null&&(e.preventDefault(),r.checked!==n)){r.checked=n,r.dispatchEvent(new Event(`change`));let e=t.querySelector(`.UIsw-slider`);e&&this.ripple(e)}},{signal:e}))})}setValue(e,t){this.main?.forEach(n=>{let r=n.querySelector(`input#${e}`);if(r){r.checked=t,this.debug&&console.log(`SetValue:`,r.checked),n.setAttribute(`aria-checked`,String(t)),this.customEvent(r,String(t));let e=n.querySelector(`.UIsw-slider`);e&&!n.closest(`.ui-no-flash`)&&(n.classList.remove(`UIsw--flash`),n.offsetWidth,n.classList.add(`UIsw--flash`),e.addEventListener(`animationend`,()=>n.classList.remove(`UIsw--flash`),{once:!0}))}})}ripple(e){e.closest(`.ui-no-ripple`)||(e.classList.remove(`ui-ripple`),e.offsetWidth,e.classList.add(`ui-ripple`),e.addEventListener(`animationend`,()=>e.classList.remove(`ui-ripple`),{once:!0}))}customEvent(e,t){let n={detail:{id:e.id,value:t},bubbles:!0};this.debug&&console.log(`CustomEvent:`,n.detail),e.dispatchEvent(new CustomEvent(`ui-switch-change`,n))}},n=class e{selectors;main=null;itemArrowInitialized=new WeakSet;abortController=new AbortController;globalAbortController=new AbortController;debug;root;observer=null;rescanTimer=null;selectMap=new Map;constructor(e={},t=!1,n={}){this.debug=t,this.root=n.root??document;let r={idPrefix:`UI-option-`,main:`UIselect`,selected:`UIselect-selected`,arrow:`UIselect-arrow`,optionsList:`UIselect-options`,search:`UIselect-options__search`,items:`UIselect-options__items`,flash:`UIselect--flash`,excludedItems:[`divider`,`test`]};this.selectors={...r,...e},this.scan(),this.initGlobalListener(this.selectors),n.observe&&this.observe()}observe(){let e=this.root===document?document.body:this.root;this.observer=new MutationObserver(()=>{this.rescanTimer===null&&(this.rescanTimer=window.setTimeout(()=>{this.rescanTimer=null,this.scan()},50))}),this.observer.observe(e,{childList:!0,subtree:!0})}filterExcluded(e,t){return Array.from(e).filter(e=>!t.some(t=>typeof t==`string`?e.classList.contains(t)||e.id===t:e===t))}filterSearch(e,t){let n=t.trim().toLowerCase();return e.filter(e=>{let t=e.dataset.value?.toLowerCase()||``,r=e.textContent?.toLowerCase()||``;return t.includes(n)||r.includes(n)})}destroy(){this.observer?.disconnect(),this.observer=null,this.rescanTimer!==null&&(clearTimeout(this.rescanTimer),this.rescanTimer=null),e.closeAll(this.selectors),this.abortController.abort(),this.main?.forEach(e=>delete e.dataset.uiselBound),this.selectMap.clear(),this.itemArrowInitialized=new WeakSet,this.main=null,this.abortController=new AbortController}dispose(){this.destroy(),this.globalAbortController.abort()}disableEl(e){e.setAttribute(`tabindex`,`-1`),e.setAttribute(`aria-disabled`,`true`)}setValue(e,t){let n=this.selectMap.get(e);if(!n){this.debug&&console.warn(`UISelect: element not registered`);return}let{input:r,selected:i}=n,a=e.querySelector(`.${this.selectors.optionsList}`);if(!a)return;let o=Array.from(a.querySelectorAll(`.${this.selectors.items} ul li`)),s=this.filterExcluded(o,this.selectors.excludedItems),c=s.find(e=>String(e.dataset.value)===String(t));if(!c){this.debug&&console.warn(`UISelect: value "${t}" not found`);return}s.forEach(e=>e.removeAttribute(`aria-selected`)),c.setAttribute(`aria-selected`,`true`),i.textContent=c.textContent??``,r.value=String(t),r.setAttribute(`value`,String(t)),e.setAttribute(`aria-activedescendant`,c.id||`${this.selectors.idPrefix}${s.indexOf(c)}`),this.customEvent(e,String(t)),e.closest(`.ui-no-flash`)||(e.classList.remove(this.selectors.flash),e.offsetWidth,e.classList.add(this.selectors.flash),e.addEventListener(`animationend`,()=>e.classList.remove(this.selectors.flash),{once:!0}))}scan(){this.main=this.root.querySelectorAll(`.${this.selectors.main}`);let e=this.abortController.signal;this.main.forEach(t=>{if(t.dataset.uiselBound)return;let n=t.querySelector(`input[type='hidden']`);try{if(!n)throw Error(`<input type="hidden" name="YourUniqueId">`)}catch(e){return console.warn(`Not found:`,e.message)}t.dataset.uiselBound=`1`;let r=t.querySelector(`.${this.selectors.selected}`),i=t.querySelector(`.${this.selectors.arrow}`),a=t.querySelector(`.${this.selectors.optionsList}`),o=t.querySelector(`.${this.selectors.search} input`);if(t.setAttribute(`tabindex`,`0`),t.removeAttribute(`aria-disabled`),t.hasAttribute(`data-disabled`)){this.disableEl(t),t.addEventListener(`click`,e=>{e.preventDefault(),e.stopImmediatePropagation()},{capture:!0,signal:e});return}this.selectMap.set(t,{input:n,selected:r}),i&&i.addEventListener(`click`,()=>{this.toggle(t,a)},{signal:e}),r.addEventListener(`click`,()=>{this.toggle(t,a)},{signal:e}),t.addEventListener(`click`,()=>{this.itemsPosition(a)},{signal:e});let s=a.querySelectorAll(`.${this.selectors.items} ul li`),c=this.filterExcluded(s,this.selectors.excludedItems),l=t.querySelector(`[aria-selected='true']`);l&&this.defaultSelect(t,l,r,n),o&&o.addEventListener(`input`,i=>{let o=i.target.value.trim(),l=o?new Set(this.filterSearch(c,o)):null;s.forEach(e=>{e.hidden=l?!l.has(e):!1}),this.itemArrow(t,a,r,n,e)},{signal:e}),this.itemArrow(t,a,r,n,e),this.items(t,a,c,r,n,e)})}itemArrow(e,t,n,r,i){if(this.itemArrowInitialized.has(e))return;this.itemArrowInitialized.add(e);let a=-1,o=n.textContent?n.textContent:``,s=e.querySelector(`.${this.selectors.search} input`);e.addEventListener(`keydown`,i=>{if(i.key===`Tab`){this.close(e,t);return}s&&s.focus();let c=Array.from(t.querySelectorAll(`.${this.selectors.optionsList} ul li`)),l=this.filterExcluded(c,this.selectors.excludedItems),u=l.length;if(u!==0)if(i.key===`ArrowDown`){i.preventDefault(),e.getAttribute(`aria-expanded`)===`false`&&this.toggle(e,t),a=(a+1)%u,n.textContent=l[a].textContent,l.forEach(e=>e.removeAttribute(`aria-selected`)),l[a].setAttribute(`aria-selected`,`true`);let r=l[a].id||`${this.selectors.idPrefix}${a}`;e.setAttribute(`aria-activedescendant`,r),l[a].scrollIntoView({block:`nearest`})}else if(i.key===`ArrowUp`){i.preventDefault(),a=(a-1+u)%u,n.textContent=l[a].textContent,l.forEach(e=>e.removeAttribute(`aria-selected`)),l[a].setAttribute(`aria-selected`,`true`);let t=l[a].id||`${this.selectors.idPrefix}${a}`;e.setAttribute(`aria-activedescendant`,t),l[a].scrollIntoView({block:`nearest`})}else if(i.key===`Enter`)if(i.preventDefault(),a>=0){n.textContent=l[a].textContent,l.forEach(e=>e.removeAttribute(`aria-selected`)),l[a].setAttribute(`aria-selected`,`true`);let i=l[a].id||`${this.selectors.idPrefix}${a}`;e.setAttribute(`aria-activedescendant`,i),r.value=String(l[a].dataset.value),this.customEvent(e,r.value),this.close(e,t)}else this.toggle(e,t);else i.key===`Escape`&&(e.getAttribute(`aria-activedescendant`)||(n.textContent=o),this.close(e,t))},{signal:i})}itemsPosition(e){let t=e.querySelector(`[aria-selected="true"]`);t&&t.scrollIntoView({block:`nearest`})}items(e,t,n,r,i,a){n.forEach((o,s)=>{o.addEventListener(`click`,()=>{let a=n[s];if(a){r.textContent=a.textContent,n.forEach(e=>e.removeAttribute(`aria-selected`)),a.setAttribute(`aria-selected`,`true`);let o=a.id||`${this.selectors.idPrefix}${s}`;e.setAttribute(`aria-expanded`,`false`),e.setAttribute(`aria-activedescendant`,o),i.value=String(n[s].dataset.value),this.customEvent(e,i.value),this.close(e,t)}},{signal:a})})}defaultSelect(e,t,n,r){t&&(r.setAttribute(`value`,t.dataset.value??``),n.textContent=t.textContent??``,e.setAttribute(`aria-activedescendant`,t.id||``))}customEvent(e,t){let n={detail:{id:e.id,value:t},bubbles:!0};this.debug&&console.log(`CustomEvent:`,n.detail),e.dispatchEvent(new CustomEvent(`ui-select-change`,n))}toggle(t,n){e.closeAll(this.selectors),n.hidden?(n.hidden=!1,t.setAttribute(`aria-expanded`,`true`)):this.close(t,n)}close(e,t){t.hidden=!0,e.setAttribute(`aria-expanded`,`false`)}static closeAll(e){document.querySelectorAll(`.${e.main}`).forEach(t=>{let n=t.querySelector(`.${e.optionsList}`);n.hidden=!0,t.setAttribute(`aria-expanded`,`false`)})}initGlobalListener(t){document.addEventListener(`click`,n=>{let r=n.target;[...document.querySelectorAll(`.${t.main}`)].some(e=>e.contains(r))||e.closeAll(t)},{signal:this.globalAbortController.signal})}},r=class{selectors;main=null;abortController=new AbortController;debug;root;observer=null;rescanTimer=null;constructor(e={},t=!1,n={}){this.debug=t,this.root=n.root??document;let r={main:`UIbg`,btn:`UIbg-btn`,input:`UIbg-input`};this.selectors={...r,...e},this.scan(),n.observe&&this.observe()}observe(){let e=this.root===document?document.body:this.root;this.observer=new MutationObserver(()=>{this.rescanTimer===null&&(this.rescanTimer=window.setTimeout(()=>{this.rescanTimer=null,this.scan()},50))}),this.observer.observe(e,{childList:!0,subtree:!0})}destroy(){this.observer?.disconnect(),this.observer=null,this.rescanTimer!==null&&(clearTimeout(this.rescanTimer),this.rescanTimer=null),this.abortController.abort(),this.main?.forEach(e=>delete e.dataset.uibgBound),this.main=null,this.abortController=new AbortController}setValue(e,t){let n=e.querySelectorAll(`.${this.selectors.input}`),r=e.querySelectorAll(`.${this.selectors.btn}`),i=Array.from(n).findIndex(e=>e.value===t&&!e.disabled);if(i===-1){this.debug&&console.warn(`UIButtonGroup: value "${t}" not found or disabled`);return}n.forEach((e,t)=>{e.checked=t===i,t===i?e.setAttribute(`checked`,``):e.removeAttribute(`checked`)}),r.forEach((e,t)=>{e.setAttribute(`aria-checked`,String(t===i)),e.setAttribute(`tabindex`,t===i?`0`:`-1`)}),this.customEvent(n[i]);let a=r[i];a&&!e.closest(`.ui-no-flash`)&&(a.classList.remove(`UIbg--flash`),a.offsetWidth,a.classList.add(`UIbg--flash`),a.addEventListener(`animationend`,()=>a.classList.remove(`UIbg--flash`),{once:!0}))}scan(){this.main=this.root.querySelectorAll(`.${this.selectors.main}`);let e=this.abortController.signal;this.main.forEach(t=>{if(t.dataset.uibgBound)return;t.dataset.uibgBound=`1`,t.querySelectorAll(`.${this.selectors.input}`).forEach(e=>{e.hasAttribute(`data-originally-disabled`)||e.setAttribute(`data-originally-disabled`,String(e.disabled)),e.disabled=e.getAttribute(`data-originally-disabled`)===`true`}),t.removeAttribute(`aria-disabled`);let n=t.querySelector(`.${this.selectors.input}:checked`);n&&this.customEvent(n);let r=t.querySelectorAll(`.${this.selectors.btn}`);r.forEach(t=>{t.addEventListener(`click`,()=>{r.forEach(e=>{e.setAttribute(`aria-checked`,`false`),e.setAttribute(`tabindex`,`-1`)}),t.setAttribute(`aria-checked`,`true`),t.setAttribute(`tabindex`,`0`),t.focus(),this.ripple(t)},{signal:e}),t.addEventListener(`keydown`,e=>{let n=Array.from(r).indexOf(t);if(e.key===`ArrowRight`&&n++,e.key===`ArrowLeft`&&n--,n<0&&(n=r.length-1),n>=r.length&&(n=0),e.key===`Enter`){let t=i[n];t&&!t.disabled&&(i.forEach(e=>{e.checked=!1,e.removeAttribute(`checked`)}),t.checked=!0,t.setAttribute(`checked`,``),this.customEvent(t)),e.preventDefault();return}let a=r[n];a&&(r.forEach(e=>e.setAttribute(`tabindex`,`-1`)),a.setAttribute(`tabindex`,`0`),a.focus())},{signal:e})});let i=t.querySelectorAll(`.${this.selectors.input}`);i.forEach((t,n)=>{this.debug&&(t.id||console.error(`Input #${n} in group has no ID!`),(!t.value||t.value===`on`)&&console.warn(`Input #${t.id} does not have a value specified (currently "${t.value}")`));let a=r[n];a&&(t.tabIndex=-1,a.setAttribute(`role`,`radio`),a.setAttribute(`aria-checked`,String(t.checked)),a.setAttribute(`tabindex`,t.checked?`0`:`-1`),t.disabled?a.setAttribute(`aria-disabled`,`true`):a.removeAttribute(`aria-disabled`),t.addEventListener(`click`,()=>{i.forEach(e=>{e.checked=!1,e.removeAttribute(`checked`)}),i[n].checked=!0,i[n].setAttribute(`checked`,``),this.customEvent(t)},{signal:e}))});let a=Array.from(i).find(e=>e.checked&&!e.disabled)||Array.from(i).find(e=>!e.disabled);if(a){let e=t.querySelector(`label[for="${a.id}"]`);e&&e.setAttribute(`tabindex`,`0`)}})}ripple(e){e.closest(`.ui-no-ripple`)||(e.classList.remove(`ui-ripple`),e.offsetWidth,e.classList.add(`ui-ripple`),e.addEventListener(`animationend`,()=>e.classList.remove(`ui-ripple`),{once:!0}))}customEvent(e){let t={detail:{id:e.id,value:e.value},bubbles:!0};this.debug&&console.log(`CustomEvent:`,t.detail),e.dispatchEvent(new CustomEvent(`ui-button-group-change`,t))}},i=class{selectors;buttons=null;abortController=new AbortController;debug;root;observer=null;rescanTimer=null;constructor(e={},t=!1,n={}){this.debug=t,this.root=n.root??document;let r={main:`UIb`};this.selectors={...r,...e},this.scan(),n.observe&&this.observe()}observe(){let e=this.root===document?document.body:this.root;this.observer=new MutationObserver(()=>{this.rescanTimer===null&&(this.rescanTimer=window.setTimeout(()=>{this.rescanTimer=null,this.scan()},50))}),this.observer.observe(e,{childList:!0,subtree:!0})}setValue(e,t,n){e.dataset.value=t,e.tagName===`A`&&(e.href=t),n!==void 0&&(e.textContent=n),!e.closest(`.ui-no-flash`)&&(e.classList.remove(`UIb--flash`),e.offsetWidth,e.classList.add(`UIb--flash`),e.addEventListener(`animationend`,()=>e.classList.remove(`UIb--flash`),{once:!0}))}destroy(){this.observer?.disconnect(),this.observer=null,this.rescanTimer!==null&&(clearTimeout(this.rescanTimer),this.rescanTimer=null),this.abortController.abort(),this.buttons?.forEach(e=>delete e.dataset.uibBound),this.buttons=null,this.abortController=new AbortController}disableEl(e){e.tagName===`BUTTON`?e.disabled=!0:(e.setAttribute(`aria-disabled`,`true`),e.setAttribute(`tabindex`,`-1`))}enableEl(e){e.tagName===`BUTTON`?e.disabled=!1:(e.removeAttribute(`aria-disabled`),e.setAttribute(`tabindex`,`0`))}isDisabled(e){return e.tagName===`BUTTON`?e.disabled:e.getAttribute(`aria-disabled`)===`true`}setDisabled(e,t){e.setAttribute(`data-originally-disabled`,String(t)),t?this.disableEl(e):this.enableEl(e)}scan(){this.buttons=this.root.querySelectorAll(`.${this.selectors.main}`);let e=this.abortController.signal;this.buttons.forEach(t=>{t.dataset.uibBound||(t.dataset.uibBound=`1`,t.hasAttribute(`data-originally-disabled`)||t.setAttribute(`data-originally-disabled`,String(this.isDisabled(t))),t.getAttribute(`data-originally-disabled`)===`true`?this.disableEl(t):this.enableEl(t),t.addEventListener(`click`,e=>{if(this.isDisabled(t)){e.preventDefault(),e.stopImmediatePropagation();return}t.tagName===`A`&&e.preventDefault(),this.ripple(t),this.customEvent(t,String(t.dataset.value))},{signal:e}))})}ripple(e){e.closest(`.ui-no-ripple`)||(e.classList.remove(`UIb--ripple`),e.offsetWidth,e.classList.add(`UIb--ripple`),e.addEventListener(`animationend`,()=>e.classList.remove(`UIb--ripple`),{once:!0}))}customEvent(e,t){if(!t||t===`undefined`||t.trim()===``){console.warn(`Button data-value="" Not set!`);return}let n={detail:{id:e.id,value:t},bubbles:!0};this.debug&&console.info(`Button CustomEvent:`,n.detail),e.dispatchEvent(new CustomEvent(`ui-button-change`,n))}},a=null,o=null,s=null,c=null,l=null;function u(...e){return a??=new i(...e)}function d(...e){return l??=new r(...e)}function f(...e){return o??=new n(...e)}function p(...t){return s??=new e(...t)}function m(...e){return c??=new t(...e)}function h(){a=null,o=null,s=null,c=null,l=null}exports.Button=i,exports.ButtonGroup=r,exports.Select=n,exports.SpinBox=e,exports.Switch=t,exports.getButtonGroupManager=d,exports.getButtonManager=u,exports.getSelectManager=f,exports.getSpinBoxManager=p,exports.getSwitchManager=m,exports.resetManagers=h;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=class{selectors;spinBoxes=null;abortController=new AbortController;debug;root;observer=null;rescanTimer=null;valueControls=new WeakMap;constructor(e={},t=!1,n={}){this.debug=t,this.root=n.root??document;let r={main:`UIsp`,btn:`UIsp__btn`,input:`UIsp__input`,disabledBtn:`disabled`};this.selectors={...r,...e},this.scan(),n.observe&&this.observe()}observe(){let e=this.root===document?document.body:this.root;this.observer=new MutationObserver(()=>{this.rescanTimer===null&&(this.rescanTimer=window.setTimeout(()=>{this.rescanTimer=null,this.scan()},50))}),this.observer.observe(e,{childList:!0,subtree:!0})}state=(e,t,n,r=0,i=0)=>{e==r||e<r?(t.classList.add(this.selectors.disabledBtn),t.disabled=!0):(t.classList.remove(this.selectors.disabledBtn),t.disabled=!1),i!==0&&(e==i||e>i?(n.classList.add(this.selectors.disabledBtn),n.disabled=!0):(n.classList.remove(this.selectors.disabledBtn),n.disabled=!1))};destroy(){this.observer?.disconnect(),this.observer=null,this.rescanTimer!==null&&(clearTimeout(this.rescanTimer),this.rescanTimer=null),this.abortController.abort(),this.spinBoxes?.forEach(e=>{delete e.dataset.uispBound,this.valueControls.delete(e)}),this.spinBoxes=null,this.abortController=new AbortController}disableEl(e){let t=e.querySelector(`.${this.selectors.input}`),n=e.querySelectorAll(`.${this.selectors.btn}`);t&&(t.disabled=!0),n.forEach(e=>{e.classList.add(this.selectors.disabledBtn),e.disabled=!0}),e.setAttribute(`tabindex`,`-1`),e.setAttribute(`aria-disabled`,`true`)}setValue(e,t,{silent:n=!1,flash:r=!0}={}){let i=e.querySelector(`.${this.selectors.input}`);if(!i){this.debug&&console.warn(`UISpinBox: input not found`);return}if(n){let n=this.valueControls.get(e);n?n(t,!0):i.value=String(t)}else i.value=String(t),i.dispatchEvent(new Event(`change`));r&&this.playFlash(e,i)}playFlash(e,t){e.closest(`.ui-no-flash`)||(e.classList.remove(`UIsp--flash`),e.offsetWidth,e.classList.add(`UIsp--flash`),t.addEventListener(`animationend`,()=>e.classList.remove(`UIsp--flash`),{once:!0}))}refresh(e){let t=this.valueControls.get(e);if(!t){this.debug&&console.warn(`UISpinBox: element not bound`);return}let n=e.querySelector(`.${this.selectors.input}`);if(!n){this.debug&&console.warn(`UISpinBox: input not found`);return}t(n.value,!0)}getValidDataNumber=(e,t)=>{let n=e.getAttribute(`data-${t}`);return n===null||n.trim()===``||isNaN(Number(n))?0:Number(n)};scan(){this.spinBoxes=this.root.querySelectorAll(`.${this.selectors.main}`);let e=this.abortController.signal;this.spinBoxes.forEach(t=>{if(t.dataset.uispBound)return;t.dataset.uispBound=`1`;let n,r=t.querySelectorAll(`.${this.selectors.btn}`),i=t.querySelector(`.${this.selectors.input}`);this.debug&&(r||console.log(`Buttons (${this.selectors.btn}) not found in container`),i||console.log(`Input (${this.selectors.input}) not found in container`));let a=r[0],o=r[1];i.disabled=!1,[a,o].forEach(e=>{e.classList.remove(this.selectors.disabledBtn),e.disabled=!1}),t.setAttribute(`tabindex`,`0`),t.removeAttribute(`aria-disabled`);let s=t.hasAttribute(`data-decimals`)?this.getValidDataNumber(t,`decimals`):this.getValidDataNumber(t,`step`),c=Math.min(Math.max(Math.trunc(s),0),100),l=this.getValidDataNumber(t,`min`),u=this.getValidDataNumber(t,`max`);if(t.hasAttribute(`data-disabled`)){Number(i.value)<=l&&(i.value=l.toFixed(c)),u===0?i.value=Number(i.value).toFixed(c):Number(i.value)>=u&&(i.value=u.toFixed(c)),this.disableEl(t),t.addEventListener(`click`,e=>{e.preventDefault(),e.stopImmediatePropagation()},{capture:!0,signal:e});return}let d=e=>{t.setAttribute(`aria-valuenow`,String(e)),t.setAttribute(`aria-valuetext`,`${e} items`)},f=(e,t)=>{let n=Number(e);n<l&&(n=l),u!==0&&n>u&&(n=u),i.value=n.toFixed(c),this.state(n,a,o,l,u),d(i.value),t||this.customEvent(i,i.value)};this.valueControls.set(t,f),Number(i.value)<=l&&(i.value=l.toFixed(c)),u===0?i.value=Number(i.value).toFixed(c):(Number(i.value)>=u&&(i.value=u.toFixed(c)),u&&t.setAttribute(`aria-valuemax`,u.toFixed(c))),l&&t.setAttribute(`aria-valuemin`,l.toFixed(c)),this.state(Number(i.value),a,o,l,u),d(i.value);let p=null,m=(e,t=1)=>{i.value=String(Math.abs(Number(i.value)));let n=parseFloat(i.value)||0;return n+=e*t/10**c,e===1&&u!==0&&n>u&&(n=u),e===-1&&n<l&&(n=l),i.value=n.toFixed(c),this.state(Number(i.value),a,o,l,u),d(i.value),i.value},h=(e,t=150)=>{p===null&&(p=window.setInterval(e,t))},g=()=>{p!==null&&(clearInterval(p),p=null)};o.addEventListener(`mousedown`,e=>{let t=e.shiftKey?3:1;h(()=>m(1,t))},{signal:e}),o.addEventListener(`touchstart`,()=>h(()=>m(1)),{signal:e}),[`mouseup`,`mouseleave`,`mouseout`,`touchend`,`touchcancel`].forEach(t=>{o.addEventListener(t,g,{signal:e})}),o.addEventListener(`click`,e=>{let t=e.shiftKey?3:1;p===null&&(n=m(1,t),this.ripple(o),this.customEvent(i,n))},{signal:e}),a.addEventListener(`click`,e=>{let t=e.shiftKey?3:1;p===null&&(n=m(-1,t),this.ripple(a),this.customEvent(i,n))},{signal:e}),a.addEventListener(`mousedown`,e=>{let t=e.shiftKey?3:1;h(()=>m(-1,t),100)},{signal:e}),a.addEventListener(`touchstart`,()=>h(()=>m(-1),100),{signal:e}),[`mouseup`,`mouseleave`,`mouseout`,`touchend`,`touchcancel`].forEach(t=>{a.addEventListener(t,g,{signal:e})}),i.addEventListener(`keydown`,e=>{let t=e.key,n=e.shiftKey?5:1;if([`Backspace`,`Delete`,`ArrowLeft`,`ArrowRight`,`Tab`,`Enter`,`Home`,`End`].includes(t)||(e.ctrlKey||e.metaKey)&&[`a`,`c`,`v`,`x`].includes(t.toLowerCase()))return;if([`e`,`+`,`-`].includes(t)){e.preventDefault();return}if(t===`ArrowUp`||t===`ArrowDown`){e.preventDefault(),m(t===`ArrowUp`?1:-1,n);return}let r=t===`,`?`.`:t,a=/^[0-9]$/.test(r),o=r===`.`,s=i.value.includes(`.`);(c===0&&!a||c>0&&!(a||o)||o&&s)&&e.preventDefault()},{signal:e}),i.addEventListener(`keyup`,e=>{(e.key===`ArrowUp`||e.key===`ArrowDown`)&&this.customEvent(i,i.value)},{signal:e}),i.addEventListener(`change`,()=>f(i.value,!1),{signal:e})})}ripple(e){e.closest(`.ui-no-ripple`)||(e.classList.remove(`ui-ripple`),e.offsetWidth,e.classList.add(`ui-ripple`),e.addEventListener(`animationend`,()=>e.classList.remove(`ui-ripple`),{once:!0}))}customEvent(e,t){let n={detail:{id:e.id,value:t},bubbles:!0};this.debug&&console.log(`CustomEvent: data.detail `,n.detail),e.dispatchEvent(new CustomEvent(`ui-spinbox-change`,n))}},t=class{selectors;main=null;abortController=new AbortController;debug;root;observer=null;rescanTimer=null;constructor(e={},t=!1,n={}){this.debug=t,this.root=n.root??document;let r={main:`UIsw`,label:`UIsw-label`};this.selectors={...r,...e},this.scan(),n.observe&&this.observe()}observe(){let e=this.root===document?document.body:this.root;this.observer=new MutationObserver(()=>{this.rescanTimer===null&&(this.rescanTimer=window.setTimeout(()=>{this.rescanTimer=null,this.scan()},50))}),this.observer.observe(e,{childList:!0,subtree:!0})}destroy(){this.observer?.disconnect(),this.observer=null,this.rescanTimer!==null&&(clearTimeout(this.rescanTimer),this.rescanTimer=null),this.abortController.abort(),this.main?.forEach(e=>delete e.dataset.uiswBound),this.main=null,this.abortController=new AbortController}scan(){this.main=this.root.querySelectorAll(`.${this.selectors.main}`);let e=this.abortController.signal;this.main.forEach(t=>{if(t.dataset.uiswBound)return;t.dataset.uiswBound=`1`;let n=t.querySelector(`.${this.selectors.label}`),r=t.querySelector(`input`);n&&n.id&&t.setAttribute(`aria-labelledby`,n.id),t.hasAttribute(`data-originally-disabled`)||t.setAttribute(`data-originally-disabled`,String(r?.disabled??!1));let i=t.getAttribute(`data-originally-disabled`)===`true`;r&&(r.disabled=!1),t.setAttribute(`tabindex`,`0`),t.removeAttribute(`aria-disabled`),i&&(r&&(r.disabled=!0),t.setAttribute(`tabindex`,`-1`),t.setAttribute(`aria-disabled`,`true`),t.addEventListener(`click`,e=>{e.preventDefault(),e.stopImmediatePropagation()},{capture:!0,signal:e})),r&&(r.checked?t.setAttribute(`aria-checked`,`true`):t.setAttribute(`aria-checked`,`false`),r.addEventListener(`change`,()=>{t.setAttribute(`aria-checked`,String(r.checked)),this.customEvent(r,String(r.checked))},{signal:e}),t.addEventListener(`click`,e=>{if(e.target.tagName===`INPUT`)return;let n=e.target.closest(`label`);n||(r.checked=!r.checked),n||r.dispatchEvent(new Event(`change`));let i=t.querySelector(`.UIsw-slider`);i&&this.ripple(i)},{signal:e}),t.addEventListener(`keydown`,e=>{if(r.disabled)return;let n=null;if(e.key===`ArrowRight`?n=!0:e.key===`ArrowLeft`&&(n=!1),n!==null&&(e.preventDefault(),r.checked!==n)){r.checked=n,r.dispatchEvent(new Event(`change`));let e=t.querySelector(`.UIsw-slider`);e&&this.ripple(e)}},{signal:e}))})}setValue(e,t){this.main?.forEach(n=>{let r=n.querySelector(`input#${e}`);if(r){r.checked=t,this.debug&&console.log(`SetValue:`,r.checked),n.setAttribute(`aria-checked`,String(t)),this.customEvent(r,String(t));let e=n.querySelector(`.UIsw-slider`);e&&!n.closest(`.ui-no-flash`)&&(n.classList.remove(`UIsw--flash`),n.offsetWidth,n.classList.add(`UIsw--flash`),e.addEventListener(`animationend`,()=>n.classList.remove(`UIsw--flash`),{once:!0}))}})}ripple(e){e.closest(`.ui-no-ripple`)||(e.classList.remove(`ui-ripple`),e.offsetWidth,e.classList.add(`ui-ripple`),e.addEventListener(`animationend`,()=>e.classList.remove(`ui-ripple`),{once:!0}))}customEvent(e,t){let n={detail:{id:e.id,value:t},bubbles:!0};this.debug&&console.log(`CustomEvent:`,n.detail),e.dispatchEvent(new CustomEvent(`ui-switch-change`,n))}},n=class e{selectors;main=null;itemArrowInitialized=new WeakSet;abortController=new AbortController;globalAbortController=new AbortController;debug;root;observer=null;rescanTimer=null;selectMap=new Map;constructor(e={},t=!1,n={}){this.debug=t,this.root=n.root??document;let r={idPrefix:`UI-option-`,main:`UIselect`,selected:`UIselect-selected`,arrow:`UIselect-arrow`,optionsList:`UIselect-options`,search:`UIselect-options__search`,items:`UIselect-options__items`,flash:`UIselect--flash`,excludedItems:[`divider`,`test`]};this.selectors={...r,...e},this.scan(),this.initGlobalListener(this.selectors),n.observe&&this.observe()}observe(){let e=this.root===document?document.body:this.root;this.observer=new MutationObserver(()=>{this.rescanTimer===null&&(this.rescanTimer=window.setTimeout(()=>{this.rescanTimer=null,this.scan()},50))}),this.observer.observe(e,{childList:!0,subtree:!0})}filterExcluded(e,t){return Array.from(e).filter(e=>!t.some(t=>typeof t==`string`?e.classList.contains(t)||e.id===t:e===t))}filterSearch(e,t){let n=t.trim().toLowerCase();return e.filter(e=>{let t=e.dataset.value?.toLowerCase()||``,r=e.textContent?.toLowerCase()||``;return t.includes(n)||r.includes(n)})}destroy(){this.observer?.disconnect(),this.observer=null,this.rescanTimer!==null&&(clearTimeout(this.rescanTimer),this.rescanTimer=null),e.closeAll(this.selectors),this.abortController.abort(),this.main?.forEach(e=>delete e.dataset.uiselBound),this.selectMap.clear(),this.itemArrowInitialized=new WeakSet,this.main=null,this.abortController=new AbortController}dispose(){this.destroy(),this.globalAbortController.abort()}disableEl(e){e.setAttribute(`tabindex`,`-1`),e.setAttribute(`aria-disabled`,`true`)}setValue(e,t){let n=this.selectMap.get(e);if(!n){this.debug&&console.warn(`UISelect: element not registered`);return}let{input:r,selected:i}=n,a=e.querySelector(`.${this.selectors.optionsList}`);if(!a)return;let o=Array.from(a.querySelectorAll(`.${this.selectors.items} ul li`)),s=this.filterExcluded(o,this.selectors.excludedItems),c=s.find(e=>String(e.dataset.value)===String(t));if(!c){this.debug&&console.warn(`UISelect: value "${t}" not found`);return}s.forEach(e=>e.removeAttribute(`aria-selected`)),c.setAttribute(`aria-selected`,`true`),i.textContent=c.textContent??``,r.value=String(t),r.setAttribute(`value`,String(t)),e.setAttribute(`aria-activedescendant`,c.id||`${this.selectors.idPrefix}${s.indexOf(c)}`),this.customEvent(e,String(t)),e.closest(`.ui-no-flash`)||(e.classList.remove(this.selectors.flash),e.offsetWidth,e.classList.add(this.selectors.flash),e.addEventListener(`animationend`,()=>e.classList.remove(this.selectors.flash),{once:!0}))}scan(){this.main=this.root.querySelectorAll(`.${this.selectors.main}`);let e=this.abortController.signal;this.main.forEach(t=>{if(t.dataset.uiselBound)return;let n=t.querySelector(`input[type='hidden']`);try{if(!n)throw Error(`<input type="hidden" name="YourUniqueId">`)}catch(e){return console.warn(`Not found:`,e.message)}t.dataset.uiselBound=`1`;let r=t.querySelector(`.${this.selectors.selected}`),i=t.querySelector(`.${this.selectors.arrow}`),a=t.querySelector(`.${this.selectors.optionsList}`),o=t.querySelector(`.${this.selectors.search} input`);if(t.setAttribute(`tabindex`,`0`),t.removeAttribute(`aria-disabled`),t.hasAttribute(`data-disabled`)){this.disableEl(t),t.addEventListener(`click`,e=>{e.preventDefault(),e.stopImmediatePropagation()},{capture:!0,signal:e});return}this.selectMap.set(t,{input:n,selected:r}),i&&i.addEventListener(`click`,()=>{this.toggle(t,a)},{signal:e}),r.addEventListener(`click`,()=>{this.toggle(t,a)},{signal:e}),t.addEventListener(`click`,()=>{this.itemsPosition(a)},{signal:e});let s=a.querySelectorAll(`.${this.selectors.items} ul li`),c=this.filterExcluded(s,this.selectors.excludedItems),l=t.querySelector(`[aria-selected='true']`);l&&this.defaultSelect(t,l,r,n),o&&o.addEventListener(`input`,i=>{let o=i.target.value.trim(),l=o?new Set(this.filterSearch(c,o)):null;s.forEach(e=>{e.hidden=l?!l.has(e):!1}),this.itemArrow(t,a,r,n,e)},{signal:e}),this.itemArrow(t,a,r,n,e),this.items(t,a,c,r,n,e)})}itemArrow(e,t,n,r,i){if(this.itemArrowInitialized.has(e))return;this.itemArrowInitialized.add(e);let a=-1,o=n.textContent?n.textContent:``,s=e.querySelector(`.${this.selectors.search} input`);e.addEventListener(`keydown`,i=>{if(i.key===`Tab`){this.close(e,t);return}s&&s.focus();let c=Array.from(t.querySelectorAll(`.${this.selectors.optionsList} ul li`)),l=this.filterExcluded(c,this.selectors.excludedItems),u=l.length;if(u!==0)if(i.key===`ArrowDown`){i.preventDefault(),e.getAttribute(`aria-expanded`)===`false`&&this.toggle(e,t),a=(a+1)%u,n.textContent=l[a].textContent,l.forEach(e=>e.removeAttribute(`aria-selected`)),l[a].setAttribute(`aria-selected`,`true`);let r=l[a].id||`${this.selectors.idPrefix}${a}`;e.setAttribute(`aria-activedescendant`,r),l[a].scrollIntoView({block:`nearest`})}else if(i.key===`ArrowUp`){i.preventDefault(),a=(a-1+u)%u,n.textContent=l[a].textContent,l.forEach(e=>e.removeAttribute(`aria-selected`)),l[a].setAttribute(`aria-selected`,`true`);let t=l[a].id||`${this.selectors.idPrefix}${a}`;e.setAttribute(`aria-activedescendant`,t),l[a].scrollIntoView({block:`nearest`})}else if(i.key===`Enter`)if(i.preventDefault(),a>=0){n.textContent=l[a].textContent,l.forEach(e=>e.removeAttribute(`aria-selected`)),l[a].setAttribute(`aria-selected`,`true`);let i=l[a].id||`${this.selectors.idPrefix}${a}`;e.setAttribute(`aria-activedescendant`,i),r.value=String(l[a].dataset.value),this.customEvent(e,r.value),this.close(e,t)}else this.toggle(e,t);else i.key===`Escape`&&(e.getAttribute(`aria-activedescendant`)||(n.textContent=o),this.close(e,t))},{signal:i})}itemsPosition(e){let t=e.querySelector(`[aria-selected="true"]`);t&&t.scrollIntoView({block:`nearest`})}items(e,t,n,r,i,a){n.forEach((o,s)=>{o.addEventListener(`click`,()=>{let a=n[s];if(a){r.textContent=a.textContent,n.forEach(e=>e.removeAttribute(`aria-selected`)),a.setAttribute(`aria-selected`,`true`);let o=a.id||`${this.selectors.idPrefix}${s}`;e.setAttribute(`aria-expanded`,`false`),e.setAttribute(`aria-activedescendant`,o),i.value=String(n[s].dataset.value),this.customEvent(e,i.value),this.close(e,t)}},{signal:a})})}defaultSelect(e,t,n,r){t&&(r.setAttribute(`value`,t.dataset.value??``),n.textContent=t.textContent??``,e.setAttribute(`aria-activedescendant`,t.id||``))}customEvent(e,t){let n={detail:{id:e.id,value:t},bubbles:!0};this.debug&&console.log(`CustomEvent:`,n.detail),e.dispatchEvent(new CustomEvent(`ui-select-change`,n))}toggle(t,n){e.closeAll(this.selectors),n.hidden?(n.hidden=!1,t.setAttribute(`aria-expanded`,`true`)):this.close(t,n)}close(e,t){t.hidden=!0,e.setAttribute(`aria-expanded`,`false`)}static closeAll(e){document.querySelectorAll(`.${e.main}`).forEach(t=>{let n=t.querySelector(`.${e.optionsList}`);n.hidden=!0,t.setAttribute(`aria-expanded`,`false`)})}initGlobalListener(t){document.addEventListener(`click`,n=>{let r=n.target;[...document.querySelectorAll(`.${t.main}`)].some(e=>e.contains(r))||e.closeAll(t)},{signal:this.globalAbortController.signal})}},r=class{selectors;main=null;abortController=new AbortController;debug;root;observer=null;rescanTimer=null;constructor(e={},t=!1,n={}){this.debug=t,this.root=n.root??document;let r={main:`UIbg`,btn:`UIbg-btn`,input:`UIbg-input`};this.selectors={...r,...e},this.scan(),n.observe&&this.observe()}observe(){let e=this.root===document?document.body:this.root;this.observer=new MutationObserver(()=>{this.rescanTimer===null&&(this.rescanTimer=window.setTimeout(()=>{this.rescanTimer=null,this.scan()},50))}),this.observer.observe(e,{childList:!0,subtree:!0})}destroy(){this.observer?.disconnect(),this.observer=null,this.rescanTimer!==null&&(clearTimeout(this.rescanTimer),this.rescanTimer=null),this.abortController.abort(),this.main?.forEach(e=>delete e.dataset.uibgBound),this.main=null,this.abortController=new AbortController}setValue(e,t){let n=e.querySelectorAll(`.${this.selectors.input}`),r=e.querySelectorAll(`.${this.selectors.btn}`),i=Array.from(n).findIndex(e=>e.value===t&&!e.disabled);if(i===-1){this.debug&&console.warn(`UIButtonGroup: value "${t}" not found or disabled`);return}n.forEach((e,t)=>{e.checked=t===i,t===i?e.setAttribute(`checked`,``):e.removeAttribute(`checked`)}),r.forEach((e,t)=>{e.setAttribute(`aria-checked`,String(t===i)),e.setAttribute(`tabindex`,t===i?`0`:`-1`)}),this.customEvent(n[i]);let a=r[i];a&&!e.closest(`.ui-no-flash`)&&(a.classList.remove(`UIbg--flash`),a.offsetWidth,a.classList.add(`UIbg--flash`),a.addEventListener(`animationend`,()=>a.classList.remove(`UIbg--flash`),{once:!0}))}scan(){this.main=this.root.querySelectorAll(`.${this.selectors.main}`);let e=this.abortController.signal;this.main.forEach(t=>{if(t.dataset.uibgBound)return;t.dataset.uibgBound=`1`,t.querySelectorAll(`.${this.selectors.input}`).forEach(e=>{e.hasAttribute(`data-originally-disabled`)||e.setAttribute(`data-originally-disabled`,String(e.disabled)),e.disabled=e.getAttribute(`data-originally-disabled`)===`true`}),t.removeAttribute(`aria-disabled`);let n=t.querySelector(`.${this.selectors.input}:checked`);n&&this.customEvent(n);let r=t.querySelectorAll(`.${this.selectors.btn}`);r.forEach(t=>{t.addEventListener(`click`,()=>{r.forEach(e=>{e.setAttribute(`aria-checked`,`false`),e.setAttribute(`tabindex`,`-1`)}),t.setAttribute(`aria-checked`,`true`),t.setAttribute(`tabindex`,`0`),t.focus(),this.ripple(t)},{signal:e}),t.addEventListener(`keydown`,e=>{let n=Array.from(r).indexOf(t);if(e.key===`ArrowRight`&&n++,e.key===`ArrowLeft`&&n--,n<0&&(n=r.length-1),n>=r.length&&(n=0),e.key===`Enter`){let t=i[n];t&&!t.disabled&&(i.forEach(e=>{e.checked=!1,e.removeAttribute(`checked`)}),t.checked=!0,t.setAttribute(`checked`,``),this.customEvent(t)),e.preventDefault();return}let a=r[n];a&&(r.forEach(e=>e.setAttribute(`tabindex`,`-1`)),a.setAttribute(`tabindex`,`0`),a.focus())},{signal:e})});let i=t.querySelectorAll(`.${this.selectors.input}`);i.forEach((t,n)=>{this.debug&&(t.id||console.error(`Input #${n} in group has no ID!`),(!t.value||t.value===`on`)&&console.warn(`Input #${t.id} does not have a value specified (currently "${t.value}")`));let a=r[n];a&&(t.tabIndex=-1,a.setAttribute(`role`,`radio`),a.setAttribute(`aria-checked`,String(t.checked)),a.setAttribute(`tabindex`,t.checked?`0`:`-1`),t.disabled?a.setAttribute(`aria-disabled`,`true`):a.removeAttribute(`aria-disabled`),t.addEventListener(`click`,()=>{i.forEach(e=>{e.checked=!1,e.removeAttribute(`checked`)}),i[n].checked=!0,i[n].setAttribute(`checked`,``),this.customEvent(t)},{signal:e}))});let a=Array.from(i).find(e=>e.checked&&!e.disabled)||Array.from(i).find(e=>!e.disabled);if(a){let e=t.querySelector(`label[for="${a.id}"]`);e&&e.setAttribute(`tabindex`,`0`)}})}ripple(e){e.closest(`.ui-no-ripple`)||(e.classList.remove(`ui-ripple`),e.offsetWidth,e.classList.add(`ui-ripple`),e.addEventListener(`animationend`,()=>e.classList.remove(`ui-ripple`),{once:!0}))}customEvent(e){let t={detail:{id:e.id,value:e.value},bubbles:!0};this.debug&&console.log(`CustomEvent:`,t.detail),e.dispatchEvent(new CustomEvent(`ui-button-group-change`,t))}},i=class{selectors;buttons=null;abortController=new AbortController;debug;root;observer=null;rescanTimer=null;constructor(e={},t=!1,n={}){this.debug=t,this.root=n.root??document;let r={main:`UIb`};this.selectors={...r,...e},this.scan(),n.observe&&this.observe()}observe(){let e=this.root===document?document.body:this.root;this.observer=new MutationObserver(()=>{this.rescanTimer===null&&(this.rescanTimer=window.setTimeout(()=>{this.rescanTimer=null,this.scan()},50))}),this.observer.observe(e,{childList:!0,subtree:!0})}setValue(e,t,n){e.dataset.value=t,e.tagName===`A`&&(e.href=t),n!==void 0&&(e.textContent=n),!e.closest(`.ui-no-flash`)&&(e.classList.remove(`UIb--flash`),e.offsetWidth,e.classList.add(`UIb--flash`),e.addEventListener(`animationend`,()=>e.classList.remove(`UIb--flash`),{once:!0}))}destroy(){this.observer?.disconnect(),this.observer=null,this.rescanTimer!==null&&(clearTimeout(this.rescanTimer),this.rescanTimer=null),this.abortController.abort(),this.buttons?.forEach(e=>delete e.dataset.uibBound),this.buttons=null,this.abortController=new AbortController}disableEl(e){e.tagName===`BUTTON`?e.disabled=!0:(e.setAttribute(`aria-disabled`,`true`),e.setAttribute(`tabindex`,`-1`))}enableEl(e){e.tagName===`BUTTON`?e.disabled=!1:(e.removeAttribute(`aria-disabled`),e.setAttribute(`tabindex`,`0`))}isDisabled(e){return e.tagName===`BUTTON`?e.disabled:e.getAttribute(`aria-disabled`)===`true`}setDisabled(e,t){e.setAttribute(`data-originally-disabled`,String(t)),t?this.disableEl(e):this.enableEl(e)}scan(){this.buttons=this.root.querySelectorAll(`.${this.selectors.main}`);let e=this.abortController.signal;this.buttons.forEach(t=>{t.dataset.uibBound||(t.dataset.uibBound=`1`,t.hasAttribute(`data-originally-disabled`)||t.setAttribute(`data-originally-disabled`,String(this.isDisabled(t))),t.getAttribute(`data-originally-disabled`)===`true`?this.disableEl(t):this.enableEl(t),t.addEventListener(`click`,e=>{if(this.isDisabled(t)){e.preventDefault(),e.stopImmediatePropagation();return}t.tagName===`A`&&e.preventDefault(),this.ripple(t),this.customEvent(t,String(t.dataset.value))},{signal:e}))})}ripple(e){e.closest(`.ui-no-ripple`)||(e.classList.remove(`UIb--ripple`),e.offsetWidth,e.classList.add(`UIb--ripple`),e.addEventListener(`animationend`,()=>e.classList.remove(`UIb--ripple`),{once:!0}))}customEvent(e,t){if(!t||t===`undefined`||t.trim()===``){console.warn(`Button data-value="" Not set!`);return}let n={detail:{id:e.id,value:t},bubbles:!0};this.debug&&console.info(`Button CustomEvent:`,n.detail),e.dispatchEvent(new CustomEvent(`ui-button-change`,n))}};function a(e=document){let t=new AbortController,n=()=>15*(parseFloat(getComputedStyle(document.documentElement).fontSize)||16),r=e=>{let t=e.querySelector(`.UIql__text`);if(!t)return;let r=e.getBoundingClientRect(),i=r.left+r.width/2,a=document.documentElement.clientWidth,o=n(),s=i-8,c=a-i-8;e.classList.remove(`UIql--left`,`UIql--right`),i-o/2>=8&&i+o/2<=a-8?t.style.maxWidth=``:c>=s?(e.classList.add(`UIql--right`),t.style.maxWidth=`${Math.min(o,c)}px`):(e.classList.add(`UIql--left`),t.style.maxWidth=`${Math.min(o,s)}px`)},i=e=>{let t=e.target?.closest?.(`.UIql`);t&&r(t)};return e.addEventListener(`pointerover`,i,{signal:t.signal}),e.addEventListener(`focusin`,i,{signal:t.signal}),window.addEventListener(`resize`,()=>{e.querySelectorAll(`.UIql:hover, .UIql:focus`).forEach(r)},{signal:t.signal}),()=>t.abort()}var o=null,s=null,c=null,l=null,u=null;function d(...e){return o??=new i(...e)}function f(...e){return u??=new r(...e)}function p(...e){return s??=new n(...e)}function m(...t){return c??=new e(...t)}function h(...e){return l??=new t(...e)}function g(){o=null,s=null,c=null,l=null,u=null}exports.Button=i,exports.ButtonGroup=r,exports.Select=n,exports.SpinBox=e,exports.Switch=t,exports.getButtonGroupManager=f,exports.getButtonManager=d,exports.getSelectManager=p,exports.getSpinBoxManager=m,exports.getSwitchManager=h,exports.initQuestionTooltips=a,exports.resetManagers=g;
|
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export { Switch } from './Switch';
|
|
|
8
8
|
export { Select } from './Select';
|
|
9
9
|
export { ButtonGroup } from './ButtonGroup';
|
|
10
10
|
export { Button } from './Button';
|
|
11
|
+
export { initQuestionTooltips } from './questionLabel';
|
|
11
12
|
export declare function getButtonManager(...args: ConstructorParameters<typeof Button>): Button;
|
|
12
13
|
export declare function getButtonGroupManager(...args: ConstructorParameters<typeof ButtonGroup>): ButtonGroup;
|
|
13
14
|
export declare function getSelectManager(...args: ConstructorParameters<typeof Select>): Select;
|
package/dist/index.es.js
CHANGED
|
@@ -7,6 +7,7 @@ var e = class {
|
|
|
7
7
|
root;
|
|
8
8
|
observer = null;
|
|
9
9
|
rescanTimer = null;
|
|
10
|
+
valueControls = /* @__PURE__ */ new WeakMap();
|
|
10
11
|
constructor(e = {}, t = !1, n = {}) {
|
|
11
12
|
this.debug = t, this.root = n.root ?? document;
|
|
12
13
|
let r = {
|
|
@@ -35,7 +36,9 @@ var e = class {
|
|
|
35
36
|
e == r || e < r ? (t.classList.add(this.selectors.disabledBtn), t.disabled = !0) : (t.classList.remove(this.selectors.disabledBtn), t.disabled = !1), i !== 0 && (e == i || e > i ? (n.classList.add(this.selectors.disabledBtn), n.disabled = !0) : (n.classList.remove(this.selectors.disabledBtn), n.disabled = !1));
|
|
36
37
|
};
|
|
37
38
|
destroy() {
|
|
38
|
-
this.observer?.disconnect(), this.observer = null, this.rescanTimer !== null && (clearTimeout(this.rescanTimer), this.rescanTimer = null), this.abortController.abort(), this.spinBoxes?.forEach((e) =>
|
|
39
|
+
this.observer?.disconnect(), this.observer = null, this.rescanTimer !== null && (clearTimeout(this.rescanTimer), this.rescanTimer = null), this.abortController.abort(), this.spinBoxes?.forEach((e) => {
|
|
40
|
+
delete e.dataset.uispBound, this.valueControls.delete(e);
|
|
41
|
+
}), this.spinBoxes = null, this.abortController = new AbortController();
|
|
39
42
|
}
|
|
40
43
|
disableEl(e) {
|
|
41
44
|
let t = e.querySelector(`.${this.selectors.input}`), n = e.querySelectorAll(`.${this.selectors.btn}`);
|
|
@@ -43,13 +46,33 @@ var e = class {
|
|
|
43
46
|
e.classList.add(this.selectors.disabledBtn), e.disabled = !0;
|
|
44
47
|
}), e.setAttribute("tabindex", "-1"), e.setAttribute("aria-disabled", "true");
|
|
45
48
|
}
|
|
46
|
-
setValue(e, t) {
|
|
49
|
+
setValue(e, t, { silent: n = !1, flash: r = !0 } = {}) {
|
|
50
|
+
let i = e.querySelector(`.${this.selectors.input}`);
|
|
51
|
+
if (!i) {
|
|
52
|
+
this.debug && console.warn("UISpinBox: input not found");
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (n) {
|
|
56
|
+
let n = this.valueControls.get(e);
|
|
57
|
+
n ? n(t, !0) : i.value = String(t);
|
|
58
|
+
} else i.value = String(t), i.dispatchEvent(new Event("change"));
|
|
59
|
+
r && this.playFlash(e, i);
|
|
60
|
+
}
|
|
61
|
+
playFlash(e, t) {
|
|
62
|
+
e.closest(".ui-no-flash") || (e.classList.remove("UIsp--flash"), e.offsetWidth, e.classList.add("UIsp--flash"), t.addEventListener("animationend", () => e.classList.remove("UIsp--flash"), { once: !0 }));
|
|
63
|
+
}
|
|
64
|
+
refresh(e) {
|
|
65
|
+
let t = this.valueControls.get(e);
|
|
66
|
+
if (!t) {
|
|
67
|
+
this.debug && console.warn("UISpinBox: element not bound");
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
47
70
|
let n = e.querySelector(`.${this.selectors.input}`);
|
|
48
71
|
if (!n) {
|
|
49
72
|
this.debug && console.warn("UISpinBox: input not found");
|
|
50
73
|
return;
|
|
51
74
|
}
|
|
52
|
-
|
|
75
|
+
t(n.value, !0);
|
|
53
76
|
}
|
|
54
77
|
getValidDataNumber = (e, t) => {
|
|
55
78
|
let n = e.getAttribute(`data-${t}`);
|
|
@@ -79,45 +102,48 @@ var e = class {
|
|
|
79
102
|
}
|
|
80
103
|
let d = (e) => {
|
|
81
104
|
t.setAttribute("aria-valuenow", String(e)), t.setAttribute("aria-valuetext", `${e} items`);
|
|
105
|
+
}, f = (e, t) => {
|
|
106
|
+
let n = Number(e);
|
|
107
|
+
n < l && (n = l), u !== 0 && n > u && (n = u), i.value = n.toFixed(c), this.state(n, a, o, l, u), d(i.value), t || this.customEvent(i, i.value);
|
|
82
108
|
};
|
|
83
|
-
Number(i.value) <= l && (i.value = l.toFixed(c)), u === 0 ? i.value = Number(i.value).toFixed(c) : (Number(i.value) >= u && (i.value = u.toFixed(c)), u && t.setAttribute("aria-valuemax", u.toFixed(c))), l && t.setAttribute("aria-valuemin", l.toFixed(c)), this.state(Number(i.value), a, o, l, u), d(i.value);
|
|
84
|
-
let
|
|
109
|
+
this.valueControls.set(t, f), Number(i.value) <= l && (i.value = l.toFixed(c)), u === 0 ? i.value = Number(i.value).toFixed(c) : (Number(i.value) >= u && (i.value = u.toFixed(c)), u && t.setAttribute("aria-valuemax", u.toFixed(c))), l && t.setAttribute("aria-valuemin", l.toFixed(c)), this.state(Number(i.value), a, o, l, u), d(i.value);
|
|
110
|
+
let p = null, m = (e, t = 1) => {
|
|
85
111
|
i.value = String(Math.abs(Number(i.value)));
|
|
86
112
|
let n = parseFloat(i.value) || 0;
|
|
87
113
|
return n += e * t / 10 ** c, e === 1 && u !== 0 && n > u && (n = u), e === -1 && n < l && (n = l), i.value = n.toFixed(c), this.state(Number(i.value), a, o, l, u), d(i.value), i.value;
|
|
88
|
-
},
|
|
89
|
-
|
|
90
|
-
},
|
|
91
|
-
|
|
114
|
+
}, h = (e, t = 150) => {
|
|
115
|
+
p === null && (p = window.setInterval(e, t));
|
|
116
|
+
}, g = () => {
|
|
117
|
+
p !== null && (clearInterval(p), p = null);
|
|
92
118
|
};
|
|
93
119
|
o.addEventListener("mousedown", (e) => {
|
|
94
120
|
let t = e.shiftKey ? 3 : 1;
|
|
95
|
-
|
|
96
|
-
}, { signal: e }), o.addEventListener("touchstart", () =>
|
|
121
|
+
h(() => m(1, t));
|
|
122
|
+
}, { signal: e }), o.addEventListener("touchstart", () => h(() => m(1)), { signal: e }), [
|
|
97
123
|
"mouseup",
|
|
98
124
|
"mouseleave",
|
|
99
125
|
"mouseout",
|
|
100
126
|
"touchend",
|
|
101
127
|
"touchcancel"
|
|
102
128
|
].forEach((t) => {
|
|
103
|
-
o.addEventListener(t,
|
|
129
|
+
o.addEventListener(t, g, { signal: e });
|
|
104
130
|
}), o.addEventListener("click", (e) => {
|
|
105
131
|
let t = e.shiftKey ? 3 : 1;
|
|
106
|
-
|
|
132
|
+
p === null && (n = m(1, t), this.ripple(o), this.customEvent(i, n));
|
|
107
133
|
}, { signal: e }), a.addEventListener("click", (e) => {
|
|
108
134
|
let t = e.shiftKey ? 3 : 1;
|
|
109
|
-
|
|
135
|
+
p === null && (n = m(-1, t), this.ripple(a), this.customEvent(i, n));
|
|
110
136
|
}, { signal: e }), a.addEventListener("mousedown", (e) => {
|
|
111
137
|
let t = e.shiftKey ? 3 : 1;
|
|
112
|
-
|
|
113
|
-
}, { signal: e }), a.addEventListener("touchstart", () =>
|
|
138
|
+
h(() => m(-1, t), 100);
|
|
139
|
+
}, { signal: e }), a.addEventListener("touchstart", () => h(() => m(-1), 100), { signal: e }), [
|
|
114
140
|
"mouseup",
|
|
115
141
|
"mouseleave",
|
|
116
142
|
"mouseout",
|
|
117
143
|
"touchend",
|
|
118
144
|
"touchcancel"
|
|
119
145
|
].forEach((t) => {
|
|
120
|
-
a.addEventListener(t,
|
|
146
|
+
a.addEventListener(t, g, { signal: e });
|
|
121
147
|
}), i.addEventListener("keydown", (e) => {
|
|
122
148
|
let t = e.key, n = e.shiftKey ? 5 : 1;
|
|
123
149
|
if ([
|
|
@@ -144,16 +170,14 @@ var e = class {
|
|
|
144
170
|
return;
|
|
145
171
|
}
|
|
146
172
|
if (t === "ArrowUp" || t === "ArrowDown") {
|
|
147
|
-
e.preventDefault(),
|
|
173
|
+
e.preventDefault(), m(t === "ArrowUp" ? 1 : -1, n);
|
|
148
174
|
return;
|
|
149
175
|
}
|
|
150
176
|
let r = t === "," ? "." : t, a = /^[0-9]$/.test(r), o = r === ".", s = i.value.includes(".");
|
|
151
177
|
(c === 0 && !a || c > 0 && !(a || o) || o && s) && e.preventDefault();
|
|
152
178
|
}, { signal: e }), i.addEventListener("keyup", (e) => {
|
|
153
179
|
(e.key === "ArrowUp" || e.key === "ArrowDown") && this.customEvent(i, i.value);
|
|
154
|
-
}, { signal: e }), i.addEventListener("change", () => {
|
|
155
|
-
Number(i.value) < l && (i.value = l.toFixed(c)), Number(i.value) > u && u !== 0 ? i.value = u.toFixed(c) : i.value = Number(i.value).toFixed(c), this.state(Number(i.value), a, o, l, u), this.customEvent(i, i.value);
|
|
156
|
-
}, { signal: e });
|
|
180
|
+
}, { signal: e }), i.addEventListener("change", () => f(i.value, !1), { signal: e });
|
|
157
181
|
});
|
|
158
182
|
}
|
|
159
183
|
ripple(e) {
|
|
@@ -629,24 +653,43 @@ var e = class {
|
|
|
629
653
|
};
|
|
630
654
|
this.debug && console.info("Button CustomEvent:", n.detail), e.dispatchEvent(new CustomEvent("ui-button-change", n));
|
|
631
655
|
}
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
|
|
656
|
+
};
|
|
657
|
+
//#endregion
|
|
658
|
+
//#region src/questionLabel.ts
|
|
659
|
+
function a(e = document) {
|
|
660
|
+
let t = new AbortController(), n = () => 15 * (parseFloat(getComputedStyle(document.documentElement).fontSize) || 16), r = (e) => {
|
|
661
|
+
let t = e.querySelector(".UIql__text");
|
|
662
|
+
if (!t) return;
|
|
663
|
+
let r = e.getBoundingClientRect(), i = r.left + r.width / 2, a = document.documentElement.clientWidth, o = n(), s = i - 8, c = a - i - 8;
|
|
664
|
+
e.classList.remove("UIql--left", "UIql--right"), i - o / 2 >= 8 && i + o / 2 <= a - 8 ? t.style.maxWidth = "" : c >= s ? (e.classList.add("UIql--right"), t.style.maxWidth = `${Math.min(o, c)}px`) : (e.classList.add("UIql--left"), t.style.maxWidth = `${Math.min(o, s)}px`);
|
|
665
|
+
}, i = (e) => {
|
|
666
|
+
let t = e.target?.closest?.(".UIql");
|
|
667
|
+
t && r(t);
|
|
668
|
+
};
|
|
669
|
+
return e.addEventListener("pointerover", i, { signal: t.signal }), e.addEventListener("focusin", i, { signal: t.signal }), window.addEventListener("resize", () => {
|
|
670
|
+
e.querySelectorAll(".UIql:hover, .UIql:focus").forEach(r);
|
|
671
|
+
}, { signal: t.signal }), () => t.abort();
|
|
635
672
|
}
|
|
673
|
+
//#endregion
|
|
674
|
+
//#region src/index.ts
|
|
675
|
+
var o = null, s = null, c = null, l = null, u = null;
|
|
636
676
|
function d(...e) {
|
|
637
|
-
return
|
|
677
|
+
return o ??= new i(...e);
|
|
638
678
|
}
|
|
639
679
|
function f(...e) {
|
|
640
|
-
return
|
|
680
|
+
return u ??= new r(...e);
|
|
681
|
+
}
|
|
682
|
+
function p(...e) {
|
|
683
|
+
return s ??= new n(...e);
|
|
641
684
|
}
|
|
642
|
-
function
|
|
643
|
-
return
|
|
685
|
+
function m(...t) {
|
|
686
|
+
return c ??= new e(...t);
|
|
644
687
|
}
|
|
645
|
-
function
|
|
646
|
-
return
|
|
688
|
+
function h(...e) {
|
|
689
|
+
return l ??= new t(...e);
|
|
647
690
|
}
|
|
648
|
-
function
|
|
649
|
-
|
|
691
|
+
function g() {
|
|
692
|
+
o = null, s = null, c = null, l = null, u = null;
|
|
650
693
|
}
|
|
651
694
|
//#endregion
|
|
652
|
-
export { i as Button, r as ButtonGroup, n as Select, e as SpinBox, t as Switch,
|
|
695
|
+
export { i as Button, r as ButtonGroup, n as Select, e as SpinBox, t as Switch, f as getButtonGroupManager, d as getButtonManager, p as getSelectManager, m as getSpinBoxManager, h as getSwitchManager, a as initQuestionTooltips, g as resetManagers };
|
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UiElements={}))})(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=class{selectors;spinBoxes=null;abortController=new AbortController;debug;root;observer=null;rescanTimer=null;constructor(e={},t=!1,n={}){this.debug=t,this.root=n.root??document;let r={main:`UIsp`,btn:`UIsp__btn`,input:`UIsp__input`,disabledBtn:`disabled`};this.selectors={...r,...e},this.scan(),n.observe&&this.observe()}observe(){let e=this.root===document?document.body:this.root;this.observer=new MutationObserver(()=>{this.rescanTimer===null&&(this.rescanTimer=window.setTimeout(()=>{this.rescanTimer=null,this.scan()},50))}),this.observer.observe(e,{childList:!0,subtree:!0})}state=(e,t,n,r=0,i=0)=>{e==r||e<r?(t.classList.add(this.selectors.disabledBtn),t.disabled=!0):(t.classList.remove(this.selectors.disabledBtn),t.disabled=!1),i!==0&&(e==i||e>i?(n.classList.add(this.selectors.disabledBtn),n.disabled=!0):(n.classList.remove(this.selectors.disabledBtn),n.disabled=!1))};destroy(){this.observer?.disconnect(),this.observer=null,this.rescanTimer!==null&&(clearTimeout(this.rescanTimer),this.rescanTimer=null),this.abortController.abort(),this.spinBoxes?.forEach(e=>delete e.dataset.uispBound),this.spinBoxes=null,this.abortController=new AbortController}disableEl(e){let t=e.querySelector(`.${this.selectors.input}`),n=e.querySelectorAll(`.${this.selectors.btn}`);t&&(t.disabled=!0),n.forEach(e=>{e.classList.add(this.selectors.disabledBtn),e.disabled=!0}),e.setAttribute(`tabindex`,`-1`),e.setAttribute(`aria-disabled`,`true`)}setValue(e,t){let n=e.querySelector(`.${this.selectors.input}`);if(!n){this.debug&&console.warn(`UISpinBox: input not found`);return}n.value=String(t),n.dispatchEvent(new Event(`change`)),!e.closest(`.ui-no-flash`)&&(e.classList.remove(`UIsp--flash`),e.offsetWidth,e.classList.add(`UIsp--flash`),n.addEventListener(`animationend`,()=>e.classList.remove(`UIsp--flash`),{once:!0}))}getValidDataNumber=(e,t)=>{let n=e.getAttribute(`data-${t}`);return n===null||n.trim()===``||isNaN(Number(n))?0:Number(n)};scan(){this.spinBoxes=this.root.querySelectorAll(`.${this.selectors.main}`);let e=this.abortController.signal;this.spinBoxes.forEach(t=>{if(t.dataset.uispBound)return;t.dataset.uispBound=`1`;let n,r=t.querySelectorAll(`.${this.selectors.btn}`),i=t.querySelector(`.${this.selectors.input}`);this.debug&&(r||console.log(`Buttons (${this.selectors.btn}) not found in container`),i||console.log(`Input (${this.selectors.input}) not found in container`));let a=r[0],o=r[1];i.disabled=!1,[a,o].forEach(e=>{e.classList.remove(this.selectors.disabledBtn),e.disabled=!1}),t.setAttribute(`tabindex`,`0`),t.removeAttribute(`aria-disabled`);let s=t.hasAttribute(`data-decimals`)?this.getValidDataNumber(t,`decimals`):this.getValidDataNumber(t,`step`),c=Math.min(Math.max(Math.trunc(s),0),100),l=this.getValidDataNumber(t,`min`),u=this.getValidDataNumber(t,`max`);if(t.hasAttribute(`data-disabled`)){Number(i.value)<=l&&(i.value=l.toFixed(c)),u===0?i.value=Number(i.value).toFixed(c):Number(i.value)>=u&&(i.value=u.toFixed(c)),this.disableEl(t),t.addEventListener(`click`,e=>{e.preventDefault(),e.stopImmediatePropagation()},{capture:!0,signal:e});return}let d=e=>{t.setAttribute(`aria-valuenow`,String(e)),t.setAttribute(`aria-valuetext`,`${e} items`)};Number(i.value)<=l&&(i.value=l.toFixed(c)),u===0?i.value=Number(i.value).toFixed(c):(Number(i.value)>=u&&(i.value=u.toFixed(c)),u&&t.setAttribute(`aria-valuemax`,u.toFixed(c))),l&&t.setAttribute(`aria-valuemin`,l.toFixed(c)),this.state(Number(i.value),a,o,l,u),d(i.value);let f=null,p=(e,t=1)=>{i.value=String(Math.abs(Number(i.value)));let n=parseFloat(i.value)||0;return n+=e*t/10**c,e===1&&u!==0&&n>u&&(n=u),e===-1&&n<l&&(n=l),i.value=n.toFixed(c),this.state(Number(i.value),a,o,l,u),d(i.value),i.value},m=(e,t=150)=>{f===null&&(f=window.setInterval(e,t))},h=()=>{f!==null&&(clearInterval(f),f=null)};o.addEventListener(`mousedown`,e=>{let t=e.shiftKey?3:1;m(()=>p(1,t))},{signal:e}),o.addEventListener(`touchstart`,()=>m(()=>p(1)),{signal:e}),[`mouseup`,`mouseleave`,`mouseout`,`touchend`,`touchcancel`].forEach(t=>{o.addEventListener(t,h,{signal:e})}),o.addEventListener(`click`,e=>{let t=e.shiftKey?3:1;f===null&&(n=p(1,t),this.ripple(o),this.customEvent(i,n))},{signal:e}),a.addEventListener(`click`,e=>{let t=e.shiftKey?3:1;f===null&&(n=p(-1,t),this.ripple(a),this.customEvent(i,n))},{signal:e}),a.addEventListener(`mousedown`,e=>{let t=e.shiftKey?3:1;m(()=>p(-1,t),100)},{signal:e}),a.addEventListener(`touchstart`,()=>m(()=>p(-1),100),{signal:e}),[`mouseup`,`mouseleave`,`mouseout`,`touchend`,`touchcancel`].forEach(t=>{a.addEventListener(t,h,{signal:e})}),i.addEventListener(`keydown`,e=>{let t=e.key,n=e.shiftKey?5:1;if([`Backspace`,`Delete`,`ArrowLeft`,`ArrowRight`,`Tab`,`Enter`,`Home`,`End`].includes(t)||(e.ctrlKey||e.metaKey)&&[`a`,`c`,`v`,`x`].includes(t.toLowerCase()))return;if([`e`,`+`,`-`].includes(t)){e.preventDefault();return}if(t===`ArrowUp`||t===`ArrowDown`){e.preventDefault(),p(t===`ArrowUp`?1:-1,n);return}let r=t===`,`?`.`:t,a=/^[0-9]$/.test(r),o=r===`.`,s=i.value.includes(`.`);(c===0&&!a||c>0&&!(a||o)||o&&s)&&e.preventDefault()},{signal:e}),i.addEventListener(`keyup`,e=>{(e.key===`ArrowUp`||e.key===`ArrowDown`)&&this.customEvent(i,i.value)},{signal:e}),i.addEventListener(`change`,()=>{Number(i.value)<l&&(i.value=l.toFixed(c)),Number(i.value)>u&&u!==0?i.value=u.toFixed(c):i.value=Number(i.value).toFixed(c),this.state(Number(i.value),a,o,l,u),this.customEvent(i,i.value)},{signal:e})})}ripple(e){e.closest(`.ui-no-ripple`)||(e.classList.remove(`ui-ripple`),e.offsetWidth,e.classList.add(`ui-ripple`),e.addEventListener(`animationend`,()=>e.classList.remove(`ui-ripple`),{once:!0}))}customEvent(e,t){let n={detail:{id:e.id,value:t},bubbles:!0};this.debug&&console.log(`CustomEvent: data.detail `,n.detail),e.dispatchEvent(new CustomEvent(`ui-spinbox-change`,n))}},n=class{selectors;main=null;abortController=new AbortController;debug;root;observer=null;rescanTimer=null;constructor(e={},t=!1,n={}){this.debug=t,this.root=n.root??document;let r={main:`UIsw`,label:`UIsw-label`};this.selectors={...r,...e},this.scan(),n.observe&&this.observe()}observe(){let e=this.root===document?document.body:this.root;this.observer=new MutationObserver(()=>{this.rescanTimer===null&&(this.rescanTimer=window.setTimeout(()=>{this.rescanTimer=null,this.scan()},50))}),this.observer.observe(e,{childList:!0,subtree:!0})}destroy(){this.observer?.disconnect(),this.observer=null,this.rescanTimer!==null&&(clearTimeout(this.rescanTimer),this.rescanTimer=null),this.abortController.abort(),this.main?.forEach(e=>delete e.dataset.uiswBound),this.main=null,this.abortController=new AbortController}scan(){this.main=this.root.querySelectorAll(`.${this.selectors.main}`);let e=this.abortController.signal;this.main.forEach(t=>{if(t.dataset.uiswBound)return;t.dataset.uiswBound=`1`;let n=t.querySelector(`.${this.selectors.label}`),r=t.querySelector(`input`);n&&n.id&&t.setAttribute(`aria-labelledby`,n.id),t.hasAttribute(`data-originally-disabled`)||t.setAttribute(`data-originally-disabled`,String(r?.disabled??!1));let i=t.getAttribute(`data-originally-disabled`)===`true`;r&&(r.disabled=!1),t.setAttribute(`tabindex`,`0`),t.removeAttribute(`aria-disabled`),i&&(r&&(r.disabled=!0),t.setAttribute(`tabindex`,`-1`),t.setAttribute(`aria-disabled`,`true`),t.addEventListener(`click`,e=>{e.preventDefault(),e.stopImmediatePropagation()},{capture:!0,signal:e})),r&&(r.checked?t.setAttribute(`aria-checked`,`true`):t.setAttribute(`aria-checked`,`false`),r.addEventListener(`change`,()=>{t.setAttribute(`aria-checked`,String(r.checked)),this.customEvent(r,String(r.checked))},{signal:e}),t.addEventListener(`click`,e=>{if(e.target.tagName===`INPUT`)return;let n=e.target.closest(`label`);n||(r.checked=!r.checked),n||r.dispatchEvent(new Event(`change`));let i=t.querySelector(`.UIsw-slider`);i&&this.ripple(i)},{signal:e}),t.addEventListener(`keydown`,e=>{if(r.disabled)return;let n=null;if(e.key===`ArrowRight`?n=!0:e.key===`ArrowLeft`&&(n=!1),n!==null&&(e.preventDefault(),r.checked!==n)){r.checked=n,r.dispatchEvent(new Event(`change`));let e=t.querySelector(`.UIsw-slider`);e&&this.ripple(e)}},{signal:e}))})}setValue(e,t){this.main?.forEach(n=>{let r=n.querySelector(`input#${e}`);if(r){r.checked=t,this.debug&&console.log(`SetValue:`,r.checked),n.setAttribute(`aria-checked`,String(t)),this.customEvent(r,String(t));let e=n.querySelector(`.UIsw-slider`);e&&!n.closest(`.ui-no-flash`)&&(n.classList.remove(`UIsw--flash`),n.offsetWidth,n.classList.add(`UIsw--flash`),e.addEventListener(`animationend`,()=>n.classList.remove(`UIsw--flash`),{once:!0}))}})}ripple(e){e.closest(`.ui-no-ripple`)||(e.classList.remove(`ui-ripple`),e.offsetWidth,e.classList.add(`ui-ripple`),e.addEventListener(`animationend`,()=>e.classList.remove(`ui-ripple`),{once:!0}))}customEvent(e,t){let n={detail:{id:e.id,value:t},bubbles:!0};this.debug&&console.log(`CustomEvent:`,n.detail),e.dispatchEvent(new CustomEvent(`ui-switch-change`,n))}},r=class e{selectors;main=null;itemArrowInitialized=new WeakSet;abortController=new AbortController;globalAbortController=new AbortController;debug;root;observer=null;rescanTimer=null;selectMap=new Map;constructor(e={},t=!1,n={}){this.debug=t,this.root=n.root??document;let r={idPrefix:`UI-option-`,main:`UIselect`,selected:`UIselect-selected`,arrow:`UIselect-arrow`,optionsList:`UIselect-options`,search:`UIselect-options__search`,items:`UIselect-options__items`,flash:`UIselect--flash`,excludedItems:[`divider`,`test`]};this.selectors={...r,...e},this.scan(),this.initGlobalListener(this.selectors),n.observe&&this.observe()}observe(){let e=this.root===document?document.body:this.root;this.observer=new MutationObserver(()=>{this.rescanTimer===null&&(this.rescanTimer=window.setTimeout(()=>{this.rescanTimer=null,this.scan()},50))}),this.observer.observe(e,{childList:!0,subtree:!0})}filterExcluded(e,t){return Array.from(e).filter(e=>!t.some(t=>typeof t==`string`?e.classList.contains(t)||e.id===t:e===t))}filterSearch(e,t){let n=t.trim().toLowerCase();return e.filter(e=>{let t=e.dataset.value?.toLowerCase()||``,r=e.textContent?.toLowerCase()||``;return t.includes(n)||r.includes(n)})}destroy(){this.observer?.disconnect(),this.observer=null,this.rescanTimer!==null&&(clearTimeout(this.rescanTimer),this.rescanTimer=null),e.closeAll(this.selectors),this.abortController.abort(),this.main?.forEach(e=>delete e.dataset.uiselBound),this.selectMap.clear(),this.itemArrowInitialized=new WeakSet,this.main=null,this.abortController=new AbortController}dispose(){this.destroy(),this.globalAbortController.abort()}disableEl(e){e.setAttribute(`tabindex`,`-1`),e.setAttribute(`aria-disabled`,`true`)}setValue(e,t){let n=this.selectMap.get(e);if(!n){this.debug&&console.warn(`UISelect: element not registered`);return}let{input:r,selected:i}=n,a=e.querySelector(`.${this.selectors.optionsList}`);if(!a)return;let o=Array.from(a.querySelectorAll(`.${this.selectors.items} ul li`)),s=this.filterExcluded(o,this.selectors.excludedItems),c=s.find(e=>String(e.dataset.value)===String(t));if(!c){this.debug&&console.warn(`UISelect: value "${t}" not found`);return}s.forEach(e=>e.removeAttribute(`aria-selected`)),c.setAttribute(`aria-selected`,`true`),i.textContent=c.textContent??``,r.value=String(t),r.setAttribute(`value`,String(t)),e.setAttribute(`aria-activedescendant`,c.id||`${this.selectors.idPrefix}${s.indexOf(c)}`),this.customEvent(e,String(t)),e.closest(`.ui-no-flash`)||(e.classList.remove(this.selectors.flash),e.offsetWidth,e.classList.add(this.selectors.flash),e.addEventListener(`animationend`,()=>e.classList.remove(this.selectors.flash),{once:!0}))}scan(){this.main=this.root.querySelectorAll(`.${this.selectors.main}`);let e=this.abortController.signal;this.main.forEach(t=>{if(t.dataset.uiselBound)return;let n=t.querySelector(`input[type='hidden']`);try{if(!n)throw Error(`<input type="hidden" name="YourUniqueId">`)}catch(e){return console.warn(`Not found:`,e.message)}t.dataset.uiselBound=`1`;let r=t.querySelector(`.${this.selectors.selected}`),i=t.querySelector(`.${this.selectors.arrow}`),a=t.querySelector(`.${this.selectors.optionsList}`),o=t.querySelector(`.${this.selectors.search} input`);if(t.setAttribute(`tabindex`,`0`),t.removeAttribute(`aria-disabled`),t.hasAttribute(`data-disabled`)){this.disableEl(t),t.addEventListener(`click`,e=>{e.preventDefault(),e.stopImmediatePropagation()},{capture:!0,signal:e});return}this.selectMap.set(t,{input:n,selected:r}),i&&i.addEventListener(`click`,()=>{this.toggle(t,a)},{signal:e}),r.addEventListener(`click`,()=>{this.toggle(t,a)},{signal:e}),t.addEventListener(`click`,()=>{this.itemsPosition(a)},{signal:e});let s=a.querySelectorAll(`.${this.selectors.items} ul li`),c=this.filterExcluded(s,this.selectors.excludedItems),l=t.querySelector(`[aria-selected='true']`);l&&this.defaultSelect(t,l,r,n),o&&o.addEventListener(`input`,i=>{let o=i.target.value.trim(),l=o?new Set(this.filterSearch(c,o)):null;s.forEach(e=>{e.hidden=l?!l.has(e):!1}),this.itemArrow(t,a,r,n,e)},{signal:e}),this.itemArrow(t,a,r,n,e),this.items(t,a,c,r,n,e)})}itemArrow(e,t,n,r,i){if(this.itemArrowInitialized.has(e))return;this.itemArrowInitialized.add(e);let a=-1,o=n.textContent?n.textContent:``,s=e.querySelector(`.${this.selectors.search} input`);e.addEventListener(`keydown`,i=>{if(i.key===`Tab`){this.close(e,t);return}s&&s.focus();let c=Array.from(t.querySelectorAll(`.${this.selectors.optionsList} ul li`)),l=this.filterExcluded(c,this.selectors.excludedItems),u=l.length;if(u!==0)if(i.key===`ArrowDown`){i.preventDefault(),e.getAttribute(`aria-expanded`)===`false`&&this.toggle(e,t),a=(a+1)%u,n.textContent=l[a].textContent,l.forEach(e=>e.removeAttribute(`aria-selected`)),l[a].setAttribute(`aria-selected`,`true`);let r=l[a].id||`${this.selectors.idPrefix}${a}`;e.setAttribute(`aria-activedescendant`,r),l[a].scrollIntoView({block:`nearest`})}else if(i.key===`ArrowUp`){i.preventDefault(),a=(a-1+u)%u,n.textContent=l[a].textContent,l.forEach(e=>e.removeAttribute(`aria-selected`)),l[a].setAttribute(`aria-selected`,`true`);let t=l[a].id||`${this.selectors.idPrefix}${a}`;e.setAttribute(`aria-activedescendant`,t),l[a].scrollIntoView({block:`nearest`})}else if(i.key===`Enter`)if(i.preventDefault(),a>=0){n.textContent=l[a].textContent,l.forEach(e=>e.removeAttribute(`aria-selected`)),l[a].setAttribute(`aria-selected`,`true`);let i=l[a].id||`${this.selectors.idPrefix}${a}`;e.setAttribute(`aria-activedescendant`,i),r.value=String(l[a].dataset.value),this.customEvent(e,r.value),this.close(e,t)}else this.toggle(e,t);else i.key===`Escape`&&(e.getAttribute(`aria-activedescendant`)||(n.textContent=o),this.close(e,t))},{signal:i})}itemsPosition(e){let t=e.querySelector(`[aria-selected="true"]`);t&&t.scrollIntoView({block:`nearest`})}items(e,t,n,r,i,a){n.forEach((o,s)=>{o.addEventListener(`click`,()=>{let a=n[s];if(a){r.textContent=a.textContent,n.forEach(e=>e.removeAttribute(`aria-selected`)),a.setAttribute(`aria-selected`,`true`);let o=a.id||`${this.selectors.idPrefix}${s}`;e.setAttribute(`aria-expanded`,`false`),e.setAttribute(`aria-activedescendant`,o),i.value=String(n[s].dataset.value),this.customEvent(e,i.value),this.close(e,t)}},{signal:a})})}defaultSelect(e,t,n,r){t&&(r.setAttribute(`value`,t.dataset.value??``),n.textContent=t.textContent??``,e.setAttribute(`aria-activedescendant`,t.id||``))}customEvent(e,t){let n={detail:{id:e.id,value:t},bubbles:!0};this.debug&&console.log(`CustomEvent:`,n.detail),e.dispatchEvent(new CustomEvent(`ui-select-change`,n))}toggle(t,n){e.closeAll(this.selectors),n.hidden?(n.hidden=!1,t.setAttribute(`aria-expanded`,`true`)):this.close(t,n)}close(e,t){t.hidden=!0,e.setAttribute(`aria-expanded`,`false`)}static closeAll(e){document.querySelectorAll(`.${e.main}`).forEach(t=>{let n=t.querySelector(`.${e.optionsList}`);n.hidden=!0,t.setAttribute(`aria-expanded`,`false`)})}initGlobalListener(t){document.addEventListener(`click`,n=>{let r=n.target;[...document.querySelectorAll(`.${t.main}`)].some(e=>e.contains(r))||e.closeAll(t)},{signal:this.globalAbortController.signal})}},i=class{selectors;main=null;abortController=new AbortController;debug;root;observer=null;rescanTimer=null;constructor(e={},t=!1,n={}){this.debug=t,this.root=n.root??document;let r={main:`UIbg`,btn:`UIbg-btn`,input:`UIbg-input`};this.selectors={...r,...e},this.scan(),n.observe&&this.observe()}observe(){let e=this.root===document?document.body:this.root;this.observer=new MutationObserver(()=>{this.rescanTimer===null&&(this.rescanTimer=window.setTimeout(()=>{this.rescanTimer=null,this.scan()},50))}),this.observer.observe(e,{childList:!0,subtree:!0})}destroy(){this.observer?.disconnect(),this.observer=null,this.rescanTimer!==null&&(clearTimeout(this.rescanTimer),this.rescanTimer=null),this.abortController.abort(),this.main?.forEach(e=>delete e.dataset.uibgBound),this.main=null,this.abortController=new AbortController}setValue(e,t){let n=e.querySelectorAll(`.${this.selectors.input}`),r=e.querySelectorAll(`.${this.selectors.btn}`),i=Array.from(n).findIndex(e=>e.value===t&&!e.disabled);if(i===-1){this.debug&&console.warn(`UIButtonGroup: value "${t}" not found or disabled`);return}n.forEach((e,t)=>{e.checked=t===i,t===i?e.setAttribute(`checked`,``):e.removeAttribute(`checked`)}),r.forEach((e,t)=>{e.setAttribute(`aria-checked`,String(t===i)),e.setAttribute(`tabindex`,t===i?`0`:`-1`)}),this.customEvent(n[i]);let a=r[i];a&&!e.closest(`.ui-no-flash`)&&(a.classList.remove(`UIbg--flash`),a.offsetWidth,a.classList.add(`UIbg--flash`),a.addEventListener(`animationend`,()=>a.classList.remove(`UIbg--flash`),{once:!0}))}scan(){this.main=this.root.querySelectorAll(`.${this.selectors.main}`);let e=this.abortController.signal;this.main.forEach(t=>{if(t.dataset.uibgBound)return;t.dataset.uibgBound=`1`,t.querySelectorAll(`.${this.selectors.input}`).forEach(e=>{e.hasAttribute(`data-originally-disabled`)||e.setAttribute(`data-originally-disabled`,String(e.disabled)),e.disabled=e.getAttribute(`data-originally-disabled`)===`true`}),t.removeAttribute(`aria-disabled`);let n=t.querySelector(`.${this.selectors.input}:checked`);n&&this.customEvent(n);let r=t.querySelectorAll(`.${this.selectors.btn}`);r.forEach(t=>{t.addEventListener(`click`,()=>{r.forEach(e=>{e.setAttribute(`aria-checked`,`false`),e.setAttribute(`tabindex`,`-1`)}),t.setAttribute(`aria-checked`,`true`),t.setAttribute(`tabindex`,`0`),t.focus(),this.ripple(t)},{signal:e}),t.addEventListener(`keydown`,e=>{let n=Array.from(r).indexOf(t);if(e.key===`ArrowRight`&&n++,e.key===`ArrowLeft`&&n--,n<0&&(n=r.length-1),n>=r.length&&(n=0),e.key===`Enter`){let t=i[n];t&&!t.disabled&&(i.forEach(e=>{e.checked=!1,e.removeAttribute(`checked`)}),t.checked=!0,t.setAttribute(`checked`,``),this.customEvent(t)),e.preventDefault();return}let a=r[n];a&&(r.forEach(e=>e.setAttribute(`tabindex`,`-1`)),a.setAttribute(`tabindex`,`0`),a.focus())},{signal:e})});let i=t.querySelectorAll(`.${this.selectors.input}`);i.forEach((t,n)=>{this.debug&&(t.id||console.error(`Input #${n} in group has no ID!`),(!t.value||t.value===`on`)&&console.warn(`Input #${t.id} does not have a value specified (currently "${t.value}")`));let a=r[n];a&&(t.tabIndex=-1,a.setAttribute(`role`,`radio`),a.setAttribute(`aria-checked`,String(t.checked)),a.setAttribute(`tabindex`,t.checked?`0`:`-1`),t.disabled?a.setAttribute(`aria-disabled`,`true`):a.removeAttribute(`aria-disabled`),t.addEventListener(`click`,()=>{i.forEach(e=>{e.checked=!1,e.removeAttribute(`checked`)}),i[n].checked=!0,i[n].setAttribute(`checked`,``),this.customEvent(t)},{signal:e}))});let a=Array.from(i).find(e=>e.checked&&!e.disabled)||Array.from(i).find(e=>!e.disabled);if(a){let e=t.querySelector(`label[for="${a.id}"]`);e&&e.setAttribute(`tabindex`,`0`)}})}ripple(e){e.closest(`.ui-no-ripple`)||(e.classList.remove(`ui-ripple`),e.offsetWidth,e.classList.add(`ui-ripple`),e.addEventListener(`animationend`,()=>e.classList.remove(`ui-ripple`),{once:!0}))}customEvent(e){let t={detail:{id:e.id,value:e.value},bubbles:!0};this.debug&&console.log(`CustomEvent:`,t.detail),e.dispatchEvent(new CustomEvent(`ui-button-group-change`,t))}},a=class{selectors;buttons=null;abortController=new AbortController;debug;root;observer=null;rescanTimer=null;constructor(e={},t=!1,n={}){this.debug=t,this.root=n.root??document;let r={main:`UIb`};this.selectors={...r,...e},this.scan(),n.observe&&this.observe()}observe(){let e=this.root===document?document.body:this.root;this.observer=new MutationObserver(()=>{this.rescanTimer===null&&(this.rescanTimer=window.setTimeout(()=>{this.rescanTimer=null,this.scan()},50))}),this.observer.observe(e,{childList:!0,subtree:!0})}setValue(e,t,n){e.dataset.value=t,e.tagName===`A`&&(e.href=t),n!==void 0&&(e.textContent=n),!e.closest(`.ui-no-flash`)&&(e.classList.remove(`UIb--flash`),e.offsetWidth,e.classList.add(`UIb--flash`),e.addEventListener(`animationend`,()=>e.classList.remove(`UIb--flash`),{once:!0}))}destroy(){this.observer?.disconnect(),this.observer=null,this.rescanTimer!==null&&(clearTimeout(this.rescanTimer),this.rescanTimer=null),this.abortController.abort(),this.buttons?.forEach(e=>delete e.dataset.uibBound),this.buttons=null,this.abortController=new AbortController}disableEl(e){e.tagName===`BUTTON`?e.disabled=!0:(e.setAttribute(`aria-disabled`,`true`),e.setAttribute(`tabindex`,`-1`))}enableEl(e){e.tagName===`BUTTON`?e.disabled=!1:(e.removeAttribute(`aria-disabled`),e.setAttribute(`tabindex`,`0`))}isDisabled(e){return e.tagName===`BUTTON`?e.disabled:e.getAttribute(`aria-disabled`)===`true`}setDisabled(e,t){e.setAttribute(`data-originally-disabled`,String(t)),t?this.disableEl(e):this.enableEl(e)}scan(){this.buttons=this.root.querySelectorAll(`.${this.selectors.main}`);let e=this.abortController.signal;this.buttons.forEach(t=>{t.dataset.uibBound||(t.dataset.uibBound=`1`,t.hasAttribute(`data-originally-disabled`)||t.setAttribute(`data-originally-disabled`,String(this.isDisabled(t))),t.getAttribute(`data-originally-disabled`)===`true`?this.disableEl(t):this.enableEl(t),t.addEventListener(`click`,e=>{if(this.isDisabled(t)){e.preventDefault(),e.stopImmediatePropagation();return}t.tagName===`A`&&e.preventDefault(),this.ripple(t),this.customEvent(t,String(t.dataset.value))},{signal:e}))})}ripple(e){e.closest(`.ui-no-ripple`)||(e.classList.remove(`UIb--ripple`),e.offsetWidth,e.classList.add(`UIb--ripple`),e.addEventListener(`animationend`,()=>e.classList.remove(`UIb--ripple`),{once:!0}))}customEvent(e,t){if(!t||t===`undefined`||t.trim()===``){console.warn(`Button data-value="" Not set!`);return}let n={detail:{id:e.id,value:t},bubbles:!0};this.debug&&console.info(`Button CustomEvent:`,n.detail),e.dispatchEvent(new CustomEvent(`ui-button-change`,n))}},o=null,s=null,c=null,l=null,u=null;function d(...e){return o??=new a(...e)}function f(...e){return u??=new i(...e)}function p(...e){return s??=new r(...e)}function m(...e){return c??=new t(...e)}function h(...e){return l??=new n(...e)}function g(){o=null,s=null,c=null,l=null,u=null}e.Button=a,e.ButtonGroup=i,e.Select=r,e.SpinBox=t,e.Switch=n,e.getButtonGroupManager=f,e.getButtonManager=d,e.getSelectManager=p,e.getSpinBoxManager=m,e.getSwitchManager=h,e.resetManagers=g});
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UiElements={}))})(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=class{selectors;spinBoxes=null;abortController=new AbortController;debug;root;observer=null;rescanTimer=null;valueControls=new WeakMap;constructor(e={},t=!1,n={}){this.debug=t,this.root=n.root??document;let r={main:`UIsp`,btn:`UIsp__btn`,input:`UIsp__input`,disabledBtn:`disabled`};this.selectors={...r,...e},this.scan(),n.observe&&this.observe()}observe(){let e=this.root===document?document.body:this.root;this.observer=new MutationObserver(()=>{this.rescanTimer===null&&(this.rescanTimer=window.setTimeout(()=>{this.rescanTimer=null,this.scan()},50))}),this.observer.observe(e,{childList:!0,subtree:!0})}state=(e,t,n,r=0,i=0)=>{e==r||e<r?(t.classList.add(this.selectors.disabledBtn),t.disabled=!0):(t.classList.remove(this.selectors.disabledBtn),t.disabled=!1),i!==0&&(e==i||e>i?(n.classList.add(this.selectors.disabledBtn),n.disabled=!0):(n.classList.remove(this.selectors.disabledBtn),n.disabled=!1))};destroy(){this.observer?.disconnect(),this.observer=null,this.rescanTimer!==null&&(clearTimeout(this.rescanTimer),this.rescanTimer=null),this.abortController.abort(),this.spinBoxes?.forEach(e=>{delete e.dataset.uispBound,this.valueControls.delete(e)}),this.spinBoxes=null,this.abortController=new AbortController}disableEl(e){let t=e.querySelector(`.${this.selectors.input}`),n=e.querySelectorAll(`.${this.selectors.btn}`);t&&(t.disabled=!0),n.forEach(e=>{e.classList.add(this.selectors.disabledBtn),e.disabled=!0}),e.setAttribute(`tabindex`,`-1`),e.setAttribute(`aria-disabled`,`true`)}setValue(e,t,{silent:n=!1,flash:r=!0}={}){let i=e.querySelector(`.${this.selectors.input}`);if(!i){this.debug&&console.warn(`UISpinBox: input not found`);return}if(n){let n=this.valueControls.get(e);n?n(t,!0):i.value=String(t)}else i.value=String(t),i.dispatchEvent(new Event(`change`));r&&this.playFlash(e,i)}playFlash(e,t){e.closest(`.ui-no-flash`)||(e.classList.remove(`UIsp--flash`),e.offsetWidth,e.classList.add(`UIsp--flash`),t.addEventListener(`animationend`,()=>e.classList.remove(`UIsp--flash`),{once:!0}))}refresh(e){let t=this.valueControls.get(e);if(!t){this.debug&&console.warn(`UISpinBox: element not bound`);return}let n=e.querySelector(`.${this.selectors.input}`);if(!n){this.debug&&console.warn(`UISpinBox: input not found`);return}t(n.value,!0)}getValidDataNumber=(e,t)=>{let n=e.getAttribute(`data-${t}`);return n===null||n.trim()===``||isNaN(Number(n))?0:Number(n)};scan(){this.spinBoxes=this.root.querySelectorAll(`.${this.selectors.main}`);let e=this.abortController.signal;this.spinBoxes.forEach(t=>{if(t.dataset.uispBound)return;t.dataset.uispBound=`1`;let n,r=t.querySelectorAll(`.${this.selectors.btn}`),i=t.querySelector(`.${this.selectors.input}`);this.debug&&(r||console.log(`Buttons (${this.selectors.btn}) not found in container`),i||console.log(`Input (${this.selectors.input}) not found in container`));let a=r[0],o=r[1];i.disabled=!1,[a,o].forEach(e=>{e.classList.remove(this.selectors.disabledBtn),e.disabled=!1}),t.setAttribute(`tabindex`,`0`),t.removeAttribute(`aria-disabled`);let s=t.hasAttribute(`data-decimals`)?this.getValidDataNumber(t,`decimals`):this.getValidDataNumber(t,`step`),c=Math.min(Math.max(Math.trunc(s),0),100),l=this.getValidDataNumber(t,`min`),u=this.getValidDataNumber(t,`max`);if(t.hasAttribute(`data-disabled`)){Number(i.value)<=l&&(i.value=l.toFixed(c)),u===0?i.value=Number(i.value).toFixed(c):Number(i.value)>=u&&(i.value=u.toFixed(c)),this.disableEl(t),t.addEventListener(`click`,e=>{e.preventDefault(),e.stopImmediatePropagation()},{capture:!0,signal:e});return}let d=e=>{t.setAttribute(`aria-valuenow`,String(e)),t.setAttribute(`aria-valuetext`,`${e} items`)},f=(e,t)=>{let n=Number(e);n<l&&(n=l),u!==0&&n>u&&(n=u),i.value=n.toFixed(c),this.state(n,a,o,l,u),d(i.value),t||this.customEvent(i,i.value)};this.valueControls.set(t,f),Number(i.value)<=l&&(i.value=l.toFixed(c)),u===0?i.value=Number(i.value).toFixed(c):(Number(i.value)>=u&&(i.value=u.toFixed(c)),u&&t.setAttribute(`aria-valuemax`,u.toFixed(c))),l&&t.setAttribute(`aria-valuemin`,l.toFixed(c)),this.state(Number(i.value),a,o,l,u),d(i.value);let p=null,m=(e,t=1)=>{i.value=String(Math.abs(Number(i.value)));let n=parseFloat(i.value)||0;return n+=e*t/10**c,e===1&&u!==0&&n>u&&(n=u),e===-1&&n<l&&(n=l),i.value=n.toFixed(c),this.state(Number(i.value),a,o,l,u),d(i.value),i.value},h=(e,t=150)=>{p===null&&(p=window.setInterval(e,t))},g=()=>{p!==null&&(clearInterval(p),p=null)};o.addEventListener(`mousedown`,e=>{let t=e.shiftKey?3:1;h(()=>m(1,t))},{signal:e}),o.addEventListener(`touchstart`,()=>h(()=>m(1)),{signal:e}),[`mouseup`,`mouseleave`,`mouseout`,`touchend`,`touchcancel`].forEach(t=>{o.addEventListener(t,g,{signal:e})}),o.addEventListener(`click`,e=>{let t=e.shiftKey?3:1;p===null&&(n=m(1,t),this.ripple(o),this.customEvent(i,n))},{signal:e}),a.addEventListener(`click`,e=>{let t=e.shiftKey?3:1;p===null&&(n=m(-1,t),this.ripple(a),this.customEvent(i,n))},{signal:e}),a.addEventListener(`mousedown`,e=>{let t=e.shiftKey?3:1;h(()=>m(-1,t),100)},{signal:e}),a.addEventListener(`touchstart`,()=>h(()=>m(-1),100),{signal:e}),[`mouseup`,`mouseleave`,`mouseout`,`touchend`,`touchcancel`].forEach(t=>{a.addEventListener(t,g,{signal:e})}),i.addEventListener(`keydown`,e=>{let t=e.key,n=e.shiftKey?5:1;if([`Backspace`,`Delete`,`ArrowLeft`,`ArrowRight`,`Tab`,`Enter`,`Home`,`End`].includes(t)||(e.ctrlKey||e.metaKey)&&[`a`,`c`,`v`,`x`].includes(t.toLowerCase()))return;if([`e`,`+`,`-`].includes(t)){e.preventDefault();return}if(t===`ArrowUp`||t===`ArrowDown`){e.preventDefault(),m(t===`ArrowUp`?1:-1,n);return}let r=t===`,`?`.`:t,a=/^[0-9]$/.test(r),o=r===`.`,s=i.value.includes(`.`);(c===0&&!a||c>0&&!(a||o)||o&&s)&&e.preventDefault()},{signal:e}),i.addEventListener(`keyup`,e=>{(e.key===`ArrowUp`||e.key===`ArrowDown`)&&this.customEvent(i,i.value)},{signal:e}),i.addEventListener(`change`,()=>f(i.value,!1),{signal:e})})}ripple(e){e.closest(`.ui-no-ripple`)||(e.classList.remove(`ui-ripple`),e.offsetWidth,e.classList.add(`ui-ripple`),e.addEventListener(`animationend`,()=>e.classList.remove(`ui-ripple`),{once:!0}))}customEvent(e,t){let n={detail:{id:e.id,value:t},bubbles:!0};this.debug&&console.log(`CustomEvent: data.detail `,n.detail),e.dispatchEvent(new CustomEvent(`ui-spinbox-change`,n))}},n=class{selectors;main=null;abortController=new AbortController;debug;root;observer=null;rescanTimer=null;constructor(e={},t=!1,n={}){this.debug=t,this.root=n.root??document;let r={main:`UIsw`,label:`UIsw-label`};this.selectors={...r,...e},this.scan(),n.observe&&this.observe()}observe(){let e=this.root===document?document.body:this.root;this.observer=new MutationObserver(()=>{this.rescanTimer===null&&(this.rescanTimer=window.setTimeout(()=>{this.rescanTimer=null,this.scan()},50))}),this.observer.observe(e,{childList:!0,subtree:!0})}destroy(){this.observer?.disconnect(),this.observer=null,this.rescanTimer!==null&&(clearTimeout(this.rescanTimer),this.rescanTimer=null),this.abortController.abort(),this.main?.forEach(e=>delete e.dataset.uiswBound),this.main=null,this.abortController=new AbortController}scan(){this.main=this.root.querySelectorAll(`.${this.selectors.main}`);let e=this.abortController.signal;this.main.forEach(t=>{if(t.dataset.uiswBound)return;t.dataset.uiswBound=`1`;let n=t.querySelector(`.${this.selectors.label}`),r=t.querySelector(`input`);n&&n.id&&t.setAttribute(`aria-labelledby`,n.id),t.hasAttribute(`data-originally-disabled`)||t.setAttribute(`data-originally-disabled`,String(r?.disabled??!1));let i=t.getAttribute(`data-originally-disabled`)===`true`;r&&(r.disabled=!1),t.setAttribute(`tabindex`,`0`),t.removeAttribute(`aria-disabled`),i&&(r&&(r.disabled=!0),t.setAttribute(`tabindex`,`-1`),t.setAttribute(`aria-disabled`,`true`),t.addEventListener(`click`,e=>{e.preventDefault(),e.stopImmediatePropagation()},{capture:!0,signal:e})),r&&(r.checked?t.setAttribute(`aria-checked`,`true`):t.setAttribute(`aria-checked`,`false`),r.addEventListener(`change`,()=>{t.setAttribute(`aria-checked`,String(r.checked)),this.customEvent(r,String(r.checked))},{signal:e}),t.addEventListener(`click`,e=>{if(e.target.tagName===`INPUT`)return;let n=e.target.closest(`label`);n||(r.checked=!r.checked),n||r.dispatchEvent(new Event(`change`));let i=t.querySelector(`.UIsw-slider`);i&&this.ripple(i)},{signal:e}),t.addEventListener(`keydown`,e=>{if(r.disabled)return;let n=null;if(e.key===`ArrowRight`?n=!0:e.key===`ArrowLeft`&&(n=!1),n!==null&&(e.preventDefault(),r.checked!==n)){r.checked=n,r.dispatchEvent(new Event(`change`));let e=t.querySelector(`.UIsw-slider`);e&&this.ripple(e)}},{signal:e}))})}setValue(e,t){this.main?.forEach(n=>{let r=n.querySelector(`input#${e}`);if(r){r.checked=t,this.debug&&console.log(`SetValue:`,r.checked),n.setAttribute(`aria-checked`,String(t)),this.customEvent(r,String(t));let e=n.querySelector(`.UIsw-slider`);e&&!n.closest(`.ui-no-flash`)&&(n.classList.remove(`UIsw--flash`),n.offsetWidth,n.classList.add(`UIsw--flash`),e.addEventListener(`animationend`,()=>n.classList.remove(`UIsw--flash`),{once:!0}))}})}ripple(e){e.closest(`.ui-no-ripple`)||(e.classList.remove(`ui-ripple`),e.offsetWidth,e.classList.add(`ui-ripple`),e.addEventListener(`animationend`,()=>e.classList.remove(`ui-ripple`),{once:!0}))}customEvent(e,t){let n={detail:{id:e.id,value:t},bubbles:!0};this.debug&&console.log(`CustomEvent:`,n.detail),e.dispatchEvent(new CustomEvent(`ui-switch-change`,n))}},r=class e{selectors;main=null;itemArrowInitialized=new WeakSet;abortController=new AbortController;globalAbortController=new AbortController;debug;root;observer=null;rescanTimer=null;selectMap=new Map;constructor(e={},t=!1,n={}){this.debug=t,this.root=n.root??document;let r={idPrefix:`UI-option-`,main:`UIselect`,selected:`UIselect-selected`,arrow:`UIselect-arrow`,optionsList:`UIselect-options`,search:`UIselect-options__search`,items:`UIselect-options__items`,flash:`UIselect--flash`,excludedItems:[`divider`,`test`]};this.selectors={...r,...e},this.scan(),this.initGlobalListener(this.selectors),n.observe&&this.observe()}observe(){let e=this.root===document?document.body:this.root;this.observer=new MutationObserver(()=>{this.rescanTimer===null&&(this.rescanTimer=window.setTimeout(()=>{this.rescanTimer=null,this.scan()},50))}),this.observer.observe(e,{childList:!0,subtree:!0})}filterExcluded(e,t){return Array.from(e).filter(e=>!t.some(t=>typeof t==`string`?e.classList.contains(t)||e.id===t:e===t))}filterSearch(e,t){let n=t.trim().toLowerCase();return e.filter(e=>{let t=e.dataset.value?.toLowerCase()||``,r=e.textContent?.toLowerCase()||``;return t.includes(n)||r.includes(n)})}destroy(){this.observer?.disconnect(),this.observer=null,this.rescanTimer!==null&&(clearTimeout(this.rescanTimer),this.rescanTimer=null),e.closeAll(this.selectors),this.abortController.abort(),this.main?.forEach(e=>delete e.dataset.uiselBound),this.selectMap.clear(),this.itemArrowInitialized=new WeakSet,this.main=null,this.abortController=new AbortController}dispose(){this.destroy(),this.globalAbortController.abort()}disableEl(e){e.setAttribute(`tabindex`,`-1`),e.setAttribute(`aria-disabled`,`true`)}setValue(e,t){let n=this.selectMap.get(e);if(!n){this.debug&&console.warn(`UISelect: element not registered`);return}let{input:r,selected:i}=n,a=e.querySelector(`.${this.selectors.optionsList}`);if(!a)return;let o=Array.from(a.querySelectorAll(`.${this.selectors.items} ul li`)),s=this.filterExcluded(o,this.selectors.excludedItems),c=s.find(e=>String(e.dataset.value)===String(t));if(!c){this.debug&&console.warn(`UISelect: value "${t}" not found`);return}s.forEach(e=>e.removeAttribute(`aria-selected`)),c.setAttribute(`aria-selected`,`true`),i.textContent=c.textContent??``,r.value=String(t),r.setAttribute(`value`,String(t)),e.setAttribute(`aria-activedescendant`,c.id||`${this.selectors.idPrefix}${s.indexOf(c)}`),this.customEvent(e,String(t)),e.closest(`.ui-no-flash`)||(e.classList.remove(this.selectors.flash),e.offsetWidth,e.classList.add(this.selectors.flash),e.addEventListener(`animationend`,()=>e.classList.remove(this.selectors.flash),{once:!0}))}scan(){this.main=this.root.querySelectorAll(`.${this.selectors.main}`);let e=this.abortController.signal;this.main.forEach(t=>{if(t.dataset.uiselBound)return;let n=t.querySelector(`input[type='hidden']`);try{if(!n)throw Error(`<input type="hidden" name="YourUniqueId">`)}catch(e){return console.warn(`Not found:`,e.message)}t.dataset.uiselBound=`1`;let r=t.querySelector(`.${this.selectors.selected}`),i=t.querySelector(`.${this.selectors.arrow}`),a=t.querySelector(`.${this.selectors.optionsList}`),o=t.querySelector(`.${this.selectors.search} input`);if(t.setAttribute(`tabindex`,`0`),t.removeAttribute(`aria-disabled`),t.hasAttribute(`data-disabled`)){this.disableEl(t),t.addEventListener(`click`,e=>{e.preventDefault(),e.stopImmediatePropagation()},{capture:!0,signal:e});return}this.selectMap.set(t,{input:n,selected:r}),i&&i.addEventListener(`click`,()=>{this.toggle(t,a)},{signal:e}),r.addEventListener(`click`,()=>{this.toggle(t,a)},{signal:e}),t.addEventListener(`click`,()=>{this.itemsPosition(a)},{signal:e});let s=a.querySelectorAll(`.${this.selectors.items} ul li`),c=this.filterExcluded(s,this.selectors.excludedItems),l=t.querySelector(`[aria-selected='true']`);l&&this.defaultSelect(t,l,r,n),o&&o.addEventListener(`input`,i=>{let o=i.target.value.trim(),l=o?new Set(this.filterSearch(c,o)):null;s.forEach(e=>{e.hidden=l?!l.has(e):!1}),this.itemArrow(t,a,r,n,e)},{signal:e}),this.itemArrow(t,a,r,n,e),this.items(t,a,c,r,n,e)})}itemArrow(e,t,n,r,i){if(this.itemArrowInitialized.has(e))return;this.itemArrowInitialized.add(e);let a=-1,o=n.textContent?n.textContent:``,s=e.querySelector(`.${this.selectors.search} input`);e.addEventListener(`keydown`,i=>{if(i.key===`Tab`){this.close(e,t);return}s&&s.focus();let c=Array.from(t.querySelectorAll(`.${this.selectors.optionsList} ul li`)),l=this.filterExcluded(c,this.selectors.excludedItems),u=l.length;if(u!==0)if(i.key===`ArrowDown`){i.preventDefault(),e.getAttribute(`aria-expanded`)===`false`&&this.toggle(e,t),a=(a+1)%u,n.textContent=l[a].textContent,l.forEach(e=>e.removeAttribute(`aria-selected`)),l[a].setAttribute(`aria-selected`,`true`);let r=l[a].id||`${this.selectors.idPrefix}${a}`;e.setAttribute(`aria-activedescendant`,r),l[a].scrollIntoView({block:`nearest`})}else if(i.key===`ArrowUp`){i.preventDefault(),a=(a-1+u)%u,n.textContent=l[a].textContent,l.forEach(e=>e.removeAttribute(`aria-selected`)),l[a].setAttribute(`aria-selected`,`true`);let t=l[a].id||`${this.selectors.idPrefix}${a}`;e.setAttribute(`aria-activedescendant`,t),l[a].scrollIntoView({block:`nearest`})}else if(i.key===`Enter`)if(i.preventDefault(),a>=0){n.textContent=l[a].textContent,l.forEach(e=>e.removeAttribute(`aria-selected`)),l[a].setAttribute(`aria-selected`,`true`);let i=l[a].id||`${this.selectors.idPrefix}${a}`;e.setAttribute(`aria-activedescendant`,i),r.value=String(l[a].dataset.value),this.customEvent(e,r.value),this.close(e,t)}else this.toggle(e,t);else i.key===`Escape`&&(e.getAttribute(`aria-activedescendant`)||(n.textContent=o),this.close(e,t))},{signal:i})}itemsPosition(e){let t=e.querySelector(`[aria-selected="true"]`);t&&t.scrollIntoView({block:`nearest`})}items(e,t,n,r,i,a){n.forEach((o,s)=>{o.addEventListener(`click`,()=>{let a=n[s];if(a){r.textContent=a.textContent,n.forEach(e=>e.removeAttribute(`aria-selected`)),a.setAttribute(`aria-selected`,`true`);let o=a.id||`${this.selectors.idPrefix}${s}`;e.setAttribute(`aria-expanded`,`false`),e.setAttribute(`aria-activedescendant`,o),i.value=String(n[s].dataset.value),this.customEvent(e,i.value),this.close(e,t)}},{signal:a})})}defaultSelect(e,t,n,r){t&&(r.setAttribute(`value`,t.dataset.value??``),n.textContent=t.textContent??``,e.setAttribute(`aria-activedescendant`,t.id||``))}customEvent(e,t){let n={detail:{id:e.id,value:t},bubbles:!0};this.debug&&console.log(`CustomEvent:`,n.detail),e.dispatchEvent(new CustomEvent(`ui-select-change`,n))}toggle(t,n){e.closeAll(this.selectors),n.hidden?(n.hidden=!1,t.setAttribute(`aria-expanded`,`true`)):this.close(t,n)}close(e,t){t.hidden=!0,e.setAttribute(`aria-expanded`,`false`)}static closeAll(e){document.querySelectorAll(`.${e.main}`).forEach(t=>{let n=t.querySelector(`.${e.optionsList}`);n.hidden=!0,t.setAttribute(`aria-expanded`,`false`)})}initGlobalListener(t){document.addEventListener(`click`,n=>{let r=n.target;[...document.querySelectorAll(`.${t.main}`)].some(e=>e.contains(r))||e.closeAll(t)},{signal:this.globalAbortController.signal})}},i=class{selectors;main=null;abortController=new AbortController;debug;root;observer=null;rescanTimer=null;constructor(e={},t=!1,n={}){this.debug=t,this.root=n.root??document;let r={main:`UIbg`,btn:`UIbg-btn`,input:`UIbg-input`};this.selectors={...r,...e},this.scan(),n.observe&&this.observe()}observe(){let e=this.root===document?document.body:this.root;this.observer=new MutationObserver(()=>{this.rescanTimer===null&&(this.rescanTimer=window.setTimeout(()=>{this.rescanTimer=null,this.scan()},50))}),this.observer.observe(e,{childList:!0,subtree:!0})}destroy(){this.observer?.disconnect(),this.observer=null,this.rescanTimer!==null&&(clearTimeout(this.rescanTimer),this.rescanTimer=null),this.abortController.abort(),this.main?.forEach(e=>delete e.dataset.uibgBound),this.main=null,this.abortController=new AbortController}setValue(e,t){let n=e.querySelectorAll(`.${this.selectors.input}`),r=e.querySelectorAll(`.${this.selectors.btn}`),i=Array.from(n).findIndex(e=>e.value===t&&!e.disabled);if(i===-1){this.debug&&console.warn(`UIButtonGroup: value "${t}" not found or disabled`);return}n.forEach((e,t)=>{e.checked=t===i,t===i?e.setAttribute(`checked`,``):e.removeAttribute(`checked`)}),r.forEach((e,t)=>{e.setAttribute(`aria-checked`,String(t===i)),e.setAttribute(`tabindex`,t===i?`0`:`-1`)}),this.customEvent(n[i]);let a=r[i];a&&!e.closest(`.ui-no-flash`)&&(a.classList.remove(`UIbg--flash`),a.offsetWidth,a.classList.add(`UIbg--flash`),a.addEventListener(`animationend`,()=>a.classList.remove(`UIbg--flash`),{once:!0}))}scan(){this.main=this.root.querySelectorAll(`.${this.selectors.main}`);let e=this.abortController.signal;this.main.forEach(t=>{if(t.dataset.uibgBound)return;t.dataset.uibgBound=`1`,t.querySelectorAll(`.${this.selectors.input}`).forEach(e=>{e.hasAttribute(`data-originally-disabled`)||e.setAttribute(`data-originally-disabled`,String(e.disabled)),e.disabled=e.getAttribute(`data-originally-disabled`)===`true`}),t.removeAttribute(`aria-disabled`);let n=t.querySelector(`.${this.selectors.input}:checked`);n&&this.customEvent(n);let r=t.querySelectorAll(`.${this.selectors.btn}`);r.forEach(t=>{t.addEventListener(`click`,()=>{r.forEach(e=>{e.setAttribute(`aria-checked`,`false`),e.setAttribute(`tabindex`,`-1`)}),t.setAttribute(`aria-checked`,`true`),t.setAttribute(`tabindex`,`0`),t.focus(),this.ripple(t)},{signal:e}),t.addEventListener(`keydown`,e=>{let n=Array.from(r).indexOf(t);if(e.key===`ArrowRight`&&n++,e.key===`ArrowLeft`&&n--,n<0&&(n=r.length-1),n>=r.length&&(n=0),e.key===`Enter`){let t=i[n];t&&!t.disabled&&(i.forEach(e=>{e.checked=!1,e.removeAttribute(`checked`)}),t.checked=!0,t.setAttribute(`checked`,``),this.customEvent(t)),e.preventDefault();return}let a=r[n];a&&(r.forEach(e=>e.setAttribute(`tabindex`,`-1`)),a.setAttribute(`tabindex`,`0`),a.focus())},{signal:e})});let i=t.querySelectorAll(`.${this.selectors.input}`);i.forEach((t,n)=>{this.debug&&(t.id||console.error(`Input #${n} in group has no ID!`),(!t.value||t.value===`on`)&&console.warn(`Input #${t.id} does not have a value specified (currently "${t.value}")`));let a=r[n];a&&(t.tabIndex=-1,a.setAttribute(`role`,`radio`),a.setAttribute(`aria-checked`,String(t.checked)),a.setAttribute(`tabindex`,t.checked?`0`:`-1`),t.disabled?a.setAttribute(`aria-disabled`,`true`):a.removeAttribute(`aria-disabled`),t.addEventListener(`click`,()=>{i.forEach(e=>{e.checked=!1,e.removeAttribute(`checked`)}),i[n].checked=!0,i[n].setAttribute(`checked`,``),this.customEvent(t)},{signal:e}))});let a=Array.from(i).find(e=>e.checked&&!e.disabled)||Array.from(i).find(e=>!e.disabled);if(a){let e=t.querySelector(`label[for="${a.id}"]`);e&&e.setAttribute(`tabindex`,`0`)}})}ripple(e){e.closest(`.ui-no-ripple`)||(e.classList.remove(`ui-ripple`),e.offsetWidth,e.classList.add(`ui-ripple`),e.addEventListener(`animationend`,()=>e.classList.remove(`ui-ripple`),{once:!0}))}customEvent(e){let t={detail:{id:e.id,value:e.value},bubbles:!0};this.debug&&console.log(`CustomEvent:`,t.detail),e.dispatchEvent(new CustomEvent(`ui-button-group-change`,t))}},a=class{selectors;buttons=null;abortController=new AbortController;debug;root;observer=null;rescanTimer=null;constructor(e={},t=!1,n={}){this.debug=t,this.root=n.root??document;let r={main:`UIb`};this.selectors={...r,...e},this.scan(),n.observe&&this.observe()}observe(){let e=this.root===document?document.body:this.root;this.observer=new MutationObserver(()=>{this.rescanTimer===null&&(this.rescanTimer=window.setTimeout(()=>{this.rescanTimer=null,this.scan()},50))}),this.observer.observe(e,{childList:!0,subtree:!0})}setValue(e,t,n){e.dataset.value=t,e.tagName===`A`&&(e.href=t),n!==void 0&&(e.textContent=n),!e.closest(`.ui-no-flash`)&&(e.classList.remove(`UIb--flash`),e.offsetWidth,e.classList.add(`UIb--flash`),e.addEventListener(`animationend`,()=>e.classList.remove(`UIb--flash`),{once:!0}))}destroy(){this.observer?.disconnect(),this.observer=null,this.rescanTimer!==null&&(clearTimeout(this.rescanTimer),this.rescanTimer=null),this.abortController.abort(),this.buttons?.forEach(e=>delete e.dataset.uibBound),this.buttons=null,this.abortController=new AbortController}disableEl(e){e.tagName===`BUTTON`?e.disabled=!0:(e.setAttribute(`aria-disabled`,`true`),e.setAttribute(`tabindex`,`-1`))}enableEl(e){e.tagName===`BUTTON`?e.disabled=!1:(e.removeAttribute(`aria-disabled`),e.setAttribute(`tabindex`,`0`))}isDisabled(e){return e.tagName===`BUTTON`?e.disabled:e.getAttribute(`aria-disabled`)===`true`}setDisabled(e,t){e.setAttribute(`data-originally-disabled`,String(t)),t?this.disableEl(e):this.enableEl(e)}scan(){this.buttons=this.root.querySelectorAll(`.${this.selectors.main}`);let e=this.abortController.signal;this.buttons.forEach(t=>{t.dataset.uibBound||(t.dataset.uibBound=`1`,t.hasAttribute(`data-originally-disabled`)||t.setAttribute(`data-originally-disabled`,String(this.isDisabled(t))),t.getAttribute(`data-originally-disabled`)===`true`?this.disableEl(t):this.enableEl(t),t.addEventListener(`click`,e=>{if(this.isDisabled(t)){e.preventDefault(),e.stopImmediatePropagation();return}t.tagName===`A`&&e.preventDefault(),this.ripple(t),this.customEvent(t,String(t.dataset.value))},{signal:e}))})}ripple(e){e.closest(`.ui-no-ripple`)||(e.classList.remove(`UIb--ripple`),e.offsetWidth,e.classList.add(`UIb--ripple`),e.addEventListener(`animationend`,()=>e.classList.remove(`UIb--ripple`),{once:!0}))}customEvent(e,t){if(!t||t===`undefined`||t.trim()===``){console.warn(`Button data-value="" Not set!`);return}let n={detail:{id:e.id,value:t},bubbles:!0};this.debug&&console.info(`Button CustomEvent:`,n.detail),e.dispatchEvent(new CustomEvent(`ui-button-change`,n))}};function o(e=document){let t=new AbortController,n=()=>15*(parseFloat(getComputedStyle(document.documentElement).fontSize)||16),r=e=>{let t=e.querySelector(`.UIql__text`);if(!t)return;let r=e.getBoundingClientRect(),i=r.left+r.width/2,a=document.documentElement.clientWidth,o=n(),s=i-8,c=a-i-8;e.classList.remove(`UIql--left`,`UIql--right`),i-o/2>=8&&i+o/2<=a-8?t.style.maxWidth=``:c>=s?(e.classList.add(`UIql--right`),t.style.maxWidth=`${Math.min(o,c)}px`):(e.classList.add(`UIql--left`),t.style.maxWidth=`${Math.min(o,s)}px`)},i=e=>{let t=e.target?.closest?.(`.UIql`);t&&r(t)};return e.addEventListener(`pointerover`,i,{signal:t.signal}),e.addEventListener(`focusin`,i,{signal:t.signal}),window.addEventListener(`resize`,()=>{e.querySelectorAll(`.UIql:hover, .UIql:focus`).forEach(r)},{signal:t.signal}),()=>t.abort()}var s=null,c=null,l=null,u=null,d=null;function f(...e){return s??=new a(...e)}function p(...e){return d??=new i(...e)}function m(...e){return c??=new r(...e)}function h(...e){return l??=new t(...e)}function g(...e){return u??=new n(...e)}function _(){s=null,c=null,l=null,u=null,d=null}e.Button=a,e.ButtonGroup=i,e.Select=r,e.SpinBox=t,e.Switch=n,e.getButtonGroupManager=p,e.getButtonManager=f,e.getSelectManager=m,e.getSpinBoxManager=h,e.getSwitchManager=g,e.initQuestionTooltips=o,e.resetManagers=_});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-flip `.UIql` tooltips that would overflow the viewport.
|
|
3
|
+
*
|
|
4
|
+
* You call this **once**, not per element. A single pair of delegated listeners
|
|
5
|
+
* is attached to `root` (the whole document by default), so every `.UIql` —
|
|
6
|
+
* including ones added to the DOM later — is handled without any per-element
|
|
7
|
+
* wiring. Just before a tooltip opens (pointer over / keyboard focus) its
|
|
8
|
+
* bubble is measured and, if it would run past the left/right viewport edge,
|
|
9
|
+
* the `.UIql--right` / `.UIql--left` alignment modifier is toggled so it opens
|
|
10
|
+
* inward instead.
|
|
11
|
+
*
|
|
12
|
+
* The CSS modifiers still work on their own; this just sets them automatically.
|
|
13
|
+
*
|
|
14
|
+
* @param root Subtree to watch. Defaults to `document`.
|
|
15
|
+
* @returns A teardown function that removes the listeners.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* import { initQuestionTooltips } from "@popovandrii/ui-elements";
|
|
19
|
+
* const teardown = initQuestionTooltips(); // whole page
|
|
20
|
+
* // initQuestionTooltips(myDialog); // or scope to a container
|
|
21
|
+
* // teardown(); // when you tear the UI down
|
|
22
|
+
*/
|
|
23
|
+
export declare function initQuestionTooltips(root?: Document | HTMLElement): () => void;
|
package/dist/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.UIbg{--bg-50:var(--c-g-50);--bg-100:var(--c-g-100);--bg-300:var(--c-g-300);--bg-500:var(--c-g-500);--bg-700:var(--c-g-700);--bg-950:var(--c-g-950);grid-auto-columns:minmax(min-content,1fr);grid-auto-flow:column;align-content:center;gap:.5rem;display:grid}.UIbg.vertical{grid-auto-rows:min-content;grid-auto-flow:row}.UIbg-input{opacity:0;pointer-events:none;position:absolute}.UIbg-input:checked+.UIbg-btn{background-color:var(--bg-700);border-color:var(--bg-950);color:var(--bg-50)}.UIbg-input:disabled+.UIbg-btn{background-color:var(--bg-100);border-color:var(--bg-100);color:var(--bg-300);cursor:not-allowed}.UIbg-input:not(:disabled)+.UIbg-btn:hover{background-color:var(--bg-700);border-color:var(--bg-700);color:var(--bg-50)}.UIbg>.UIbg-btn{cursor:pointer;background-color:var(--bg-100);border:1px solid var(--bg-500);height:2.5rem;color:var(--bg-950);border-radius:.5rem;justify-content:center;align-items:center;padding:.125rem;font-size:1rem;transition:all .4s,color .4s;display:flex;position:relative;overflow:hidden}.UIbg>.UIbg-btn:after{content:"";border-radius:inherit;background:radial-gradient(circle at center, var(--bg-500) 0%, transparent 60%);opacity:0;pointer-events:none;position:absolute;inset:0;transform:scale(0)}.UIbg>.UIbg-btn.ui-ripple:after{animation:1s ease-out forwards ui-ripple}.UIbg>.UIbg-btn:hover:not([aria-disabled=true]){background-color:var(--bg-700);border-color:var(--bg-700);color:var(--bg-950)}.UIbg>.UIbg-btn.UIbg--flash{--flash-start:var(--bg-50);--flash-mid:var(--bg-700);--flash-end:var(--bg-950);animation:.4s ease-out ui-flash}.UIbg.r-0>.UIbg-btn{border-radius:0}.UIbg.r-round>.UIbg-btn{border-radius:2.5rem}.UIbg.r-round.g-0>.UIbg-btn:first-of-type{border-radius:2.5rem 0 0 2.5rem}.UIbg.r-round.g-0>.UIbg-btn:last-of-type{border-radius:0 2.5rem 2.5rem 0}.UIbg.g-0{gap:0}.UIbg.g-0>.UIbg-btn{border:0;border-radius:0}.UIbg.g-1{gap:1rem}.UIbg.sm>.UIbg-btn{height:2rem;font-size:.9rem}.UIbg.lg>.UIbg-btn{height:3rem;font-size:1.1rem}.UIbg[aria-disabled=true]{opacity:.5;pointer-events:none;cursor:not-allowed}.UIbg.border{border:1px solid var(--bg-100);border-radius:.5rem;padding:5px}.UIbg.border:hover:not([aria-disabled=true]){border-color:var(--bg-700)}.UIbg.border.r-0{border-radius:0}.UIbg.border.r-round{border-radius:2.5rem}.UIbg.danger{--bg-50:var(--c-d-50);--bg-100:var(--c-d-100);--bg-300:var(--c-d-300);--bg-500:var(--c-d-500);--bg-700:var(--c-d-700);--bg-950:var(--c-d-950)}.UIbg.info{--bg-50:var(--c-i-50);--bg-100:var(--c-i-100);--bg-300:var(--c-i-300);--bg-500:var(--c-i-500);--bg-700:var(--c-i-700);--bg-950:var(--c-i-950)}.UIbg.primary{--bg-50:var(--c-p-50);--bg-100:var(--c-p-100);--bg-300:var(--c-p-300);--bg-500:var(--c-p-500);--bg-700:var(--c-p-700);--bg-950:var(--c-p-950)}.UIbg.success{--bg-50:var(--c-s-50);--bg-100:var(--c-s-100);--bg-300:var(--c-s-300);--bg-500:var(--c-s-500);--bg-700:var(--c-s-700);--bg-950:var(--c-s-950)}.UIbg.warning{--bg-50:var(--c-w-50);--bg-100:var(--c-w-100);--bg-300:var(--c-w-300);--bg-500:var(--c-w-500);--bg-700:var(--c-w-700);--bg-950:var(--c-w-950)}.UIb{--b-50:var(--c-g-50);--b-100:var(--c-g-100);--b-300:var(--c-g-300);--b-500:var(--c-g-500);--b-700:var(--c-g-700);--b-950:var(--c-g-950);grid-auto-flow:column;grid-auto-columns:minmax(min-content);cursor:pointer;background-color:var(--b-100);border:1px solid var(--b-500);height:2.5rem;color:var(--b-950);border-radius:.5rem;justify-content:center;align-items:center;gap:.5rem;padding:.125rem .75rem;font-size:1rem;transition:background-color .4s,color .1s;display:flex;position:relative;overflow:hidden}.UIb:after{content:"";border-radius:inherit;background:radial-gradient(circle at center, var(--b-500) 0%, transparent 60%);opacity:0;pointer-events:none;position:absolute;inset:0;transform:scale(0)}.UIb.UIb--ripple:after{animation:1s ease-out forwards ui-ripple}.UIb.UIb--flash{--flash-start:var(--b-50);--flash-mid:var(--b-700);--flash-end:var(--b-950);animation:.4s ease-out ui-flash}.UIb:hover:not(:disabled){background-color:var(--b-700);border-color:var(--b-700);color:var(--b-50)}.UIb:disabled,.UIb[aria-disabled=true]{background-color:var(--b-100);border-color:var(--b-100);color:var(--b-300);cursor:not-allowed;pointer-events:none}.UIb.expand{width:100%}.UIb.between{justify-content:space-between}.UIb.around{justify-content:space-around}.UIb.r-0{border-radius:0}.UIb.r-round{border-radius:2.5rem}.UIb.g-0{gap:0}.UIb.g-1{gap:1rem}.UIb.sm{height:2rem;font-size:.9rem}.UIb.lg{height:3rem;font-size:1.1rem}.UIb.danger{--b-50:var(--c-d-50);--b-100:var(--c-d-100);--b-300:var(--c-d-300);--b-500:var(--c-d-500);--b-700:var(--c-d-700);--b-950:var(--c-d-950)}.UIb.info{--b-50:var(--c-i-50);--b-100:var(--c-i-100);--b-300:var(--c-i-300);--b-500:var(--c-i-500);--b-700:var(--c-i-700);--b-950:var(--c-i-950)}.UIb.primary{--b-50:var(--c-p-50);--b-100:var(--c-p-100);--b-300:var(--c-p-300);--b-500:var(--c-p-500);--b-700:var(--c-p-700);--b-950:var(--c-p-950)}.UIb.success{--b-50:var(--c-s-50);--b-100:var(--c-s-100);--b-300:var(--c-s-300);--b-500:var(--c-s-500);--b-700:var(--c-s-700);--b-950:var(--c-s-950)}.UIb.warning{--b-50:var(--c-w-50);--b-100:var(--c-w-100);--b-300:var(--c-w-300);--b-500:var(--c-w-500);--b-700:var(--c-w-700);--b-950:var(--c-w-950)}.UIsp{--sp-50:var(--c-g-50);--sp-100:var(--c-g-100);--sp-300:var(--c-g-300);--sp-500:var(--c-g-500);--sp-700:var(--c-g-700);--sp-950:var(--c-g-950);grid-template-columns:min-content 1fr min-content;align-self:end;align-items:end;width:13rem;display:grid}.UIsp.UIsp--flash>.UIsp__btn,.UIsp.UIsp--flash>.UIsp__input{--flash-start:var(--sp-50);--flash-mid:var(--sp-700);--flash-end:var(--sp-950);animation:.4s ease-out ui-flash}.UIsp>.UIsp-label{grid-column:1/-1;padding:0 0 .075rem .25rem;font-size:1rem}.UIsp>.UIsp__input{text-align:center;background-color:var(--sp-50);height:2.5rem;color:var(--sp-700);border:none;border-top:1px solid var(--sp-500);border-bottom:1px solid var(--sp-500);box-sizing:border-box;outline:none;width:100%;min-width:3rem;padding:0;font-size:1.5rem;font-weight:700}.UIsp>.UIsp__input:focus{background-color:var(--sp-50);color:var(--sp-950)}.UIsp>.UIsp__input:disabled{opacity:.5;cursor:not-allowed}.UIsp__txt{font-weight:400}.UIsp>.UIsp__btn{cursor:pointer;background-color:var(--sp-100);border:none;border:1px solid var(--sp-500);width:3rem;height:2.5rem;color:var(--sp-950);border-radius:.5rem 0 0 .5rem;justify-content:center;align-items:center;padding:0;font-size:2rem;transition:background-color .4s,color .1s;display:flex;position:relative;overflow:hidden}.UIsp>.UIsp__btn:after{content:"";border-radius:inherit;background:radial-gradient(circle at center, var(--sp-500) 0%, transparent 60%);opacity:0;pointer-events:none;position:absolute;inset:0;transform:scale(0)}.UIsp>.UIsp__btn.ui-ripple:after{animation:1s ease-out forwards ui-ripple}.UIsp>.UIsp__btn:hover{background-color:var(--sp-700);color:var(--sp-50)}.UIsp>.disabled{background-color:var(--sp-100);border-color:var(--sp-500);color:var(--sp-300);pointer-events:none}.UIsp[aria-disabled=true]{opacity:.5;pointer-events:none;cursor:not-allowed}.UIsp>.UIsp__btn:first-of-type{border-radius:.5rem 0 0 .5rem}.UIsp>.UIsp__btn:last-of-type{border-radius:0 .5rem .5rem 0}.UIsp.r-0>.UIsp__btn{border-radius:0}.UIsp.r-round>.UIsp__btn:first-of-type{border-radius:1.5rem 0 0 1.5rem}.UIsp.r-round>.UIsp__btn:last-of-type{border-radius:0 1.5rem 1.5rem 0}.UIsp.sm{width:10rem}.UIsp.sm>.UIsp-label{padding:0 0 0 .125rem;font-size:.8rem}.UIsp.sm>.UIsp__input,.UIsp.sm>.UIsp__btn{height:2rem;font-size:1rem}.UIsp.sm>.UIsp__btn{width:2rem}.UIsp.lg{width:16rem}.UIsp.lg>.UIsp__input,.UIsp.lg>.UIsp__btn{height:3rem;font-size:2rem}.UIsp.lg>.UIsp__btn{width:3rem}.UIsp.danger{--sp-50:var(--c-d-50);--sp-100:var(--c-d-100);--sp-300:var(--c-d-300);--sp-500:var(--c-d-500);--sp-700:var(--c-d-700);--sp-950:var(--c-d-950)}.UIsp.info{--sp-50:var(--c-i-50);--sp-100:var(--c-i-100);--sp-300:var(--c-i-300);--sp-500:var(--c-i-500);--sp-700:var(--c-i-700);--sp-950:var(--c-i-950)}.UIsp.primary{--sp-50:var(--c-p-50);--sp-100:var(--c-p-100);--sp-300:var(--c-p-300);--sp-500:var(--c-p-500);--sp-700:var(--c-p-700);--sp-950:var(--c-p-950)}.UIsp.success{--sp-50:var(--c-s-50);--sp-100:var(--c-s-100);--sp-300:var(--c-s-300);--sp-500:var(--c-s-500);--sp-700:var(--c-s-700);--sp-950:var(--c-s-950)}.UIsp.warning{--sp-50:var(--c-w-50);--sp-100:var(--c-w-100);--sp-300:var(--c-w-300);--sp-500:var(--c-w-500);--sp-700:var(--c-w-700);--sp-950:var(--c-w-950)}.UIselect{--sl-50:var(--c-g-50);--sl-100:var(--c-g-100);--sl-300:var(--c-g-300);--sl-500:var(--c-g-500);--sl-700:var(--c-g-700);--sl-900:var(--c-g-900);--sl-950:var(--c-g-950);--sl-item-hover-bg:var(--sl-500);--sl-item-hover-color:var(--sl-50);--sl-item-sel-bg:var(--sl-300);--sl-item-sel-color:var(--sl-950);background-color:var(--sl-500);cursor:pointer;box-sizing:border-box;white-space:nowrap;border-radius:.5rem;align-self:end;width:12rem;min-width:10rem;height:2.5rem;display:flex;position:relative}.UIselect:hover{background-color:var(--sl-700)}.UIselect:hover .UIselect-selected,.UIselect:hover .UIselect-arrow{background-color:var(--sl-700);color:var(--sl-50)}.UIselect-selected{background-color:var(--sl-100);color:var(--sl-900);border-radius:.5rem;align-items:center;width:100%;height:calc(100% - 2px);margin:1px;padding:0 .5rem;display:flex;overflow:hidden}.UIselect-selected>span{white-space:nowrap;text-align:center;max-width:100%;display:inline-block;overflow:hidden}.UIselect-selected.center>span{text-align:left;max-width:100%;margin:0 auto}.UIselect-arrow{background-color:var(--sl-100);width:2rem;height:calc(100% - 4px);color:var(--sl-700);border-radius:.5rem;place-content:center;align-items:center;margin:2px 5px;font-size:.8rem;position:absolute;top:0;right:0}.UIselect-arrow>svg{margin:0 auto;display:flex}.UIselect-options{width:inherit;background-color:var(--sl-100);color:var(--sl-950);z-index:2;box-sizing:border-box;border:1px solid var(--sl-500);border-radius:.5rem;margin:0;padding:0;list-style:none;position:absolute;left:0;overflow:hidden}.UIselect-options__search{padding:1px 2px;position:sticky;top:1px}.UIselect-options__search>input{width:100%;height:inherit;border:1px solid var(--sl-300);box-shadow:none;background-color:var(--sl-50);color:var(--sl-950);border-radius:.5rem;padding:0 7px;font-size:1.5rem}.UIselect-options__search>input:focus-visible{outline:none}.UIselect-options__items{max-height:20rem;overflow-y:auto}.UIselect-options__items>ul{margin:0;padding:0;list-style:none}.UIselect-options__items>ul>li{border-radius:.5rem;align-items:center;height:2.5rem;margin:1px;padding:0 .5rem;display:flex}.UIselect-options__items>ul>li[hidden]{display:none}.UIselect-options__items>ul>li:hover{background-color:var(--sl-item-hover-bg);color:var(--sl-item-hover-color)}.UIselect-options__items>ul>li[aria-selected=true]{background-color:var(--sl-item-sel-bg);color:var(--sl-item-sel-color)}.UIselect-options__items>ul>li.divider{background-color:var(--sl-300);height:1px;margin:0 .25rem}.UIselect.r-0,.UIselect.r-0>.UIselect-selected,.UIselect.r-0>.UIselect-options,.UIselect.r-0>.UIselect-options>li.UIselect-options__search,.UIselect.r-0>.UIselect-options>li.UIselect-options__search>input,.UIselect.r-0>.UIselect-options>li>ul>li{border-radius:0}.UIselect.r-1,.UIselect.r-1>.UIselect-selected,.UIselect.r-1>.UIselect-arrow{border-radius:1.5rem}.UIselect.lg{width:16rem;min-width:12rem;height:3rem;font-size:1.1rem}.UIselect.lg>.UIselect-selected{overflow:hidden}.UIselect.lg .UIselect-options__search>input{height:3rem;font-size:1.7rem}.UIselect.lg .UIselect-options__items{max-height:25rem}.UIselect.lg .UIselect-options__items>ul>li{height:3rem}.UIselect.lg .UIselect-options__items>ul>li.divider{height:1px;margin:0 .5rem}.UIselect.sm{width:10rem;min-width:8rem;height:2rem;font-size:.9rem}.UIselect.sm .UIselect-options__search>input{height:2rem;font-size:1rem}.UIselect.sm .UIselect-options__items{max-height:15rem}.UIselect.sm .UIselect-options__items>ul>li{height:2rem}.UIselect.sm .UIselect-options__items>ul>li.divider{height:1px;margin:0 .25rem}.UIselect.expand{width:100%}.UIselect.UIselect--flash{--flash-start:var(--sl-50);--flash-mid:var(--sl-700);--flash-end:var(--sl-950);animation:.4s ease-out ui-flash}.UIselect[aria-disabled=true]{pointer-events:none;opacity:.5;cursor:not-allowed}.UIselect.danger{--sl-50:var(--c-d-50);--sl-100:var(--c-d-100);--sl-300:var(--c-d-300);--sl-500:var(--c-d-500);--sl-700:var(--c-d-700);--sl-900:var(--c-d-900);--sl-950:var(--c-d-950);--sl-item-hover-bg:var(--sl-300);--sl-item-hover-color:var(--sl-950);--sl-item-sel-bg:var(--sl-700);--sl-item-sel-color:var(--sl-50)}.UIselect.info{--sl-50:var(--c-i-50);--sl-100:var(--c-i-100);--sl-300:var(--c-i-300);--sl-500:var(--c-i-500);--sl-700:var(--c-i-700);--sl-900:var(--c-i-900);--sl-950:var(--c-i-950);--sl-item-hover-bg:var(--sl-300);--sl-item-hover-color:var(--sl-950);--sl-item-sel-bg:var(--sl-700);--sl-item-sel-color:var(--sl-50)}.UIselect.primary{--sl-50:var(--c-p-50);--sl-100:var(--c-p-100);--sl-300:var(--c-p-300);--sl-500:var(--c-p-500);--sl-700:var(--c-p-700);--sl-900:var(--c-p-900);--sl-950:var(--c-p-950);--sl-item-hover-bg:var(--sl-300);--sl-item-hover-color:var(--sl-950);--sl-item-sel-bg:var(--sl-700);--sl-item-sel-color:var(--sl-50)}.UIselect.success{--sl-50:var(--c-s-50);--sl-100:var(--c-s-100);--sl-300:var(--c-s-300);--sl-500:var(--c-s-500);--sl-700:var(--c-s-700);--sl-900:var(--c-s-900);--sl-950:var(--c-s-950);--sl-item-hover-bg:var(--sl-300);--sl-item-hover-color:var(--sl-950);--sl-item-sel-bg:var(--sl-700);--sl-item-sel-color:var(--sl-50)}.UIselect.warning{--sl-50:var(--c-w-50);--sl-100:var(--c-w-100);--sl-300:var(--c-w-300);--sl-500:var(--c-w-500);--sl-700:var(--c-w-700);--sl-900:var(--c-w-900);--sl-950:var(--c-w-950);--sl-item-hover-bg:var(--sl-300);--sl-item-hover-color:var(--sl-950);--sl-item-sel-bg:var(--sl-700);--sl-item-sel-color:var(--sl-50)}.UIsw{--sw-50:var(--c-g-50);--sw-100:var(--c-g-100);--sw-300:var(--c-g-300);--sw-700:var(--c-g-700);--sw-950:var(--c-g-950);align-items:center;gap:1.5rem;display:inline-flex;position:relative}.UIsw-label{cursor:pointer;-webkit-user-select:none;user-select:none}.UIsw-label:hover{color:var(--sw-700)}.UIsw>input[type=checkbox]{display:none}.UIsw-slider{background-color:var(--sw-100);cursor:pointer;border:1px solid var(--sw-300);border-radius:1.5rem;width:5rem;height:2.5rem;transition:background-color .4s,border-color .4s;position:relative;overflow:hidden}.UIsw-slider:after{content:"";border-radius:inherit;background:radial-gradient(circle at center, var(--sw-700) 0%, transparent 60%);opacity:0;pointer-events:none;position:absolute;inset:0;transform:scale(0)}.UIsw-slider.ui-ripple:after{animation:1s ease-out forwards ui-ripple}.UIsw-slider:before{z-index:1;content:"";background-color:var(--sw-300);border-radius:1.5rem;width:2.5rem;height:2.5rem;transition:transform .1s;position:absolute;left:0}.UIsw-slider:hover{border-color:var(--sw-50);color:var(--sw-300)}.UIsw-slider:hover~.UIsw-slider__on,.UIsw-slider:hover~.UIsw-slider__off{color:var(--sw-300);transition:color .4s}.UIsw-slider__on,.UIsw-slider__off{color:var(--sw-950);cursor:pointer;transition:color .4s;position:absolute;right:3rem}.UIsw-slider__on:hover,.UIsw-slider__off:hover{color:var(--sw-300)}.UIsw-slider__off{color:var(--sw-700);right:.7rem}.UIsw.UIsw--flash>.UIsw-slider{--flash-start:var(--sw-50);--flash-mid:var(--sw-700);--flash-end:var(--sw-950);animation:.4s ease-out ui-flash}.UIsw[aria-disabled=true]{opacity:.5;pointer-events:none;cursor:not-allowed}.UIsw:has(>input:disabled){opacity:.5;pointer-events:none;cursor:not-allowed}.UIsw>input[type=checkbox]:checked~.UIsw-slider{background-color:var(--sw-100);border-color:var(--sw-700)}.UIsw>input[type=checkbox]:checked~.UIsw-slider:before{background-color:var(--sw-700);transform:translate(2.5rem)}.UIsw>input[type=checkbox]:checked~.UIsw-slider:hover{border-color:var(--sw-50)}.UIsw:has(.UIsw-slider__on:hover,.UIsw-slider__off:hover) .UIsw-slider{border-color:var(--sw-50)}.UIsw>input[type=checkbox]:checked:has(~.UIsw-slider__on:hover,~.UIsw-slider__off:hover)~.UIsw-slider{border-color:var(--sw-50)}.UIsw.lg>.UIsw-slider{width:6rem;height:3rem}.UIsw.lg>.UIsw-slider:before{border-radius:1.5rem;width:3rem;height:3rem}.UIsw.lg>.UIsw-slider__on{font-size:1.2rem;right:3.8rem}.UIsw.lg>.UIsw-slider__off{font-size:1.2rem;right:1rem}.UIsw.lg>input[type=checkbox]:checked~.UIsw-slider:before{transform:translate(3rem)}.UIsw.sm{gap:1rem}.UIsw.sm>.UIsw-slider{width:4rem;height:2rem}.UIsw.sm>.UIsw-slider:before{border-radius:1.5rem;width:2rem;height:2rem}.UIsw.sm>.UIsw-slider__on,.UIsw.sm>.UIsw-slider__off{font-size:.9rem;right:2.5rem}.UIsw.sm>.UIsw-slider__off{right:.6rem}.UIsw.sm>input[type=checkbox]:checked~.UIsw-slider:before{transform:translate(2rem)}.UIsw.xsm{gap:.5rem}.UIsw.xsm>.UIsw-slider{width:2rem;height:1rem}.UIsw.xsm>.UIsw-slider:before{border-radius:1.5rem;width:1rem;height:1rem}.UIsw.xsm>.UIsw-slider__on,.UIsw.xsm>.UIsw-slider__off{font-size:.6rem;right:1.2rem}.UIsw.xsm>.UIsw-slider__off{right:.3rem}.UIsw.xsm>input[type=checkbox]:checked~.UIsw-slider:before{transform:translate(1rem)}.UIsw.r-0>.UIsw-slider,.UIsw.r-0>.UIsw-slider:before{border-radius:0}.UIsw.r-1>.UIsw-slider,.UIsw.r-1>.UIsw-slider:before{border-radius:.5rem}.UIsw.danger{--sw-50:var(--c-d-50);--sw-100:var(--c-d-100);--sw-300:var(--c-d-300);--sw-700:var(--c-d-700);--sw-950:var(--c-d-950)}.UIsw.info{--sw-50:var(--c-i-50);--sw-100:var(--c-i-100);--sw-300:var(--c-i-300);--sw-700:var(--c-i-700);--sw-950:var(--c-i-950)}.UIsw.success{--sw-50:var(--c-s-50);--sw-100:var(--c-s-100);--sw-300:var(--c-s-300);--sw-700:var(--c-s-700);--sw-950:var(--c-s-950)}.UIsw.primary{--sw-50:var(--c-p-50);--sw-100:var(--c-p-100);--sw-300:var(--c-p-300);--sw-700:var(--c-p-700);--sw-950:var(--c-p-950)}.UIsw.warning{--sw-50:var(--c-w-50);--sw-100:var(--c-w-100);--sw-300:var(--c-w-300);--sw-700:var(--c-w-700);--sw-950:var(--c-w-950)}.UIsw.warning>.UIsw-slider__off{color:var(--sw-300)}:root{--g-50:#f2f2f2;--g-100:#e6e6e6;--g-300:#b3b3b3;--g-500:gray;--g-700:#4d4d4d;--g-900:#1a1a1a;--g-950:#0d0d0d;--d-50:#ffe6ea;--d-100:#ffccd5;--d-300:#ff6680;--d-500:#ff002b;--d-700:#99001a;--d-900:#330009;--d-950:#1a0004;--i-50:#e7f8fe;--i-100:#cff1fc;--i-300:#6ed5f7;--i-500:#0db9f2;--i-700:#086f91;--i-900:#032530;--i-950:#011218;--p-50:#ececf9;--p-100:#d9d9f2;--p-300:#8c8cd9;--p-500:#4040bf;--p-700:#262673;--p-900:#0d0d26;--p-950:#060613;--s-50:#e9fbf2;--s-100:#d4f7e6;--s-300:#7de8b3;--s-500:#26d980;--s-700:#17824d;--s-900:#082b1a;--s-950:#04160d;--w-50:#fcf7e9;--w-100:#f9efd2;--w-300:#eccf79;--w-500:#dfaf20;--w-700:#866913;--w-900:#2d2306;--w-950:#161203;--c-d-50:var(--d-50);--c-d-100:var(--d-100);--c-d-300:var(--d-300);--c-d-500:var(--d-500);--c-d-700:var(--d-700);--c-d-900:var(--d-900);--c-d-950:var(--d-950);--c-i-50:var(--i-50);--c-i-100:var(--i-100);--c-i-300:var(--i-300);--c-i-500:var(--i-500);--c-i-700:var(--i-700);--c-i-900:var(--i-900);--c-i-950:var(--i-950);--c-p-50:var(--p-50);--c-p-100:var(--p-100);--c-p-300:var(--p-300);--c-p-500:var(--p-500);--c-p-700:var(--p-700);--c-p-900:var(--p-900);--c-p-950:var(--p-950);--c-s-50:var(--s-50);--c-s-100:var(--s-100);--c-s-300:var(--s-300);--c-s-500:var(--s-500);--c-s-700:var(--s-700);--c-s-900:var(--s-900);--c-s-950:var(--s-950);--c-g-50:var(--g-50);--c-g-100:var(--g-100);--c-g-300:var(--g-300);--c-g-500:var(--g-500);--c-g-700:var(--g-700);--c-g-900:var(--g-900);--c-g-950:var(--g-950);--c-w-50:var(--w-50);--c-w-100:var(--w-100);--c-w-300:var(--w-300);--c-w-500:var(--w-500);--c-w-700:var(--w-700);--c-w-900:var(--w-900);--c-w-950:var(--w-950)}body{background-color:var(--c-g-50);color:var(--c-g-950);padding:0;transition:background .4s}html{-webkit-text-size-adjust:100%;line-height:1.15}body{margin:0}main{display:block}h1{margin:.67em 0;font-size:2em}hr{box-sizing:content-box;height:0;overflow:visible}pre{font-family:monospace;font-size:1em}a{color:inherit;background-color:#0000;text-decoration:none}img{border-style:none}button,input,optgroup,select,textarea{margin:0;font-family:inherit;font-size:100%}button,input{overflow:visible}button,select{text-transform:none}button,[type=button],[type=reset],[type=submit]{-webkit-appearance:button}fieldset{border:1px solid silver;margin:0;padding:.35em .75em .625em}legend{padding:0}progress{vertical-align:baseline}textarea{overflow:auto}[type=checkbox],[type=radio]{box-sizing:border-box;padding:0}table{border-collapse:collapse;border-spacing:0}@keyframes ui-ripple{0%{opacity:1;transform:scale(0)}to{opacity:0;transform:scale(5)}}@keyframes ui-flash{0%{box-shadow:0 0 0 0 var(--flash-start)}50%{box-shadow:0 0 5px 1px var(--flash-mid)}to{box-shadow:0 0 0 0 var(--flash-end)}}.UIFlash{--flash-start:var(--c-g-50);--flash-mid:var(--c-g-700);--flash-end:var(--c-g-950);animation:.4s ease-out ui-flash}
|
|
1
|
+
.UIbg{--bg-50:var(--c-g-50);--bg-100:var(--c-g-100);--bg-300:var(--c-g-300);--bg-500:var(--c-g-500);--bg-700:var(--c-g-700);--bg-950:var(--c-g-950);grid-auto-columns:minmax(min-content,1fr);grid-auto-flow:column;align-content:center;gap:.5rem;display:grid}.UIbg.vertical{grid-auto-rows:min-content;grid-auto-flow:row}.UIbg-input{opacity:0;pointer-events:none;position:absolute}.UIbg-input:checked+.UIbg-btn{background-color:var(--bg-700);border-color:var(--bg-950);color:var(--bg-50)}.UIbg-input:disabled+.UIbg-btn{background-color:var(--bg-100);border-color:var(--bg-100);color:var(--bg-300);cursor:not-allowed}.UIbg-input:not(:disabled)+.UIbg-btn:hover{background-color:var(--bg-700);border-color:var(--bg-700);color:var(--bg-50)}.UIbg>.UIbg-btn{cursor:pointer;background-color:var(--bg-100);border:1px solid var(--bg-500);height:2.5rem;color:var(--bg-950);border-radius:.5rem;justify-content:center;align-items:center;padding:.125rem;font-size:1rem;transition:all .4s,color .4s;display:flex;position:relative;overflow:hidden}.UIbg>.UIbg-btn:after{content:"";border-radius:inherit;background:radial-gradient(circle at center, var(--bg-500) 0%, transparent 60%);opacity:0;pointer-events:none;position:absolute;inset:0;transform:scale(0)}.UIbg>.UIbg-btn.ui-ripple:after{animation:1s ease-out forwards ui-ripple}.UIbg>.UIbg-btn:hover:not([aria-disabled=true]){background-color:var(--bg-700);border-color:var(--bg-700);color:var(--bg-950)}.UIbg>.UIbg-btn.UIbg--flash{--flash-start:var(--bg-50);--flash-mid:var(--bg-700);--flash-end:var(--bg-950);animation:.4s ease-out ui-flash}.UIbg.r-0>.UIbg-btn{border-radius:0}.UIbg.r-round>.UIbg-btn{border-radius:2.5rem}.UIbg.r-round.g-0>.UIbg-btn:first-of-type{border-radius:2.5rem 0 0 2.5rem}.UIbg.r-round.g-0>.UIbg-btn:last-of-type{border-radius:0 2.5rem 2.5rem 0}.UIbg.g-0{gap:0}.UIbg.g-0>.UIbg-btn{border:0;border-radius:0}.UIbg.g-1{gap:1rem}.UIbg.sm>.UIbg-btn{height:2rem;font-size:.9rem}.UIbg.lg>.UIbg-btn{height:3rem;font-size:1.1rem}.UIbg[aria-disabled=true]{opacity:.5;pointer-events:none;cursor:not-allowed}.UIbg.border{border:1px solid var(--bg-100);border-radius:.5rem;padding:5px}.UIbg.border:hover:not([aria-disabled=true]){border-color:var(--bg-700)}.UIbg.border.r-0{border-radius:0}.UIbg.border.r-round{border-radius:2.5rem}.UIbg.danger{--bg-50:var(--c-d-50);--bg-100:var(--c-d-100);--bg-300:var(--c-d-300);--bg-500:var(--c-d-500);--bg-700:var(--c-d-700);--bg-950:var(--c-d-950)}.UIbg.info{--bg-50:var(--c-i-50);--bg-100:var(--c-i-100);--bg-300:var(--c-i-300);--bg-500:var(--c-i-500);--bg-700:var(--c-i-700);--bg-950:var(--c-i-950)}.UIbg.primary{--bg-50:var(--c-p-50);--bg-100:var(--c-p-100);--bg-300:var(--c-p-300);--bg-500:var(--c-p-500);--bg-700:var(--c-p-700);--bg-950:var(--c-p-950)}.UIbg.success{--bg-50:var(--c-s-50);--bg-100:var(--c-s-100);--bg-300:var(--c-s-300);--bg-500:var(--c-s-500);--bg-700:var(--c-s-700);--bg-950:var(--c-s-950)}.UIbg.warning{--bg-50:var(--c-w-50);--bg-100:var(--c-w-100);--bg-300:var(--c-w-300);--bg-500:var(--c-w-500);--bg-700:var(--c-w-700);--bg-950:var(--c-w-950)}.UIb{--b-50:var(--c-g-50);--b-100:var(--c-g-100);--b-300:var(--c-g-300);--b-500:var(--c-g-500);--b-700:var(--c-g-700);--b-950:var(--c-g-950);grid-auto-flow:column;grid-auto-columns:minmax(min-content);cursor:pointer;background-color:var(--b-100);border:1px solid var(--b-500);height:2.5rem;color:var(--b-950);border-radius:.5rem;justify-content:center;align-items:center;gap:.5rem;padding:.125rem .75rem;font-size:1rem;transition:background-color .4s,color .1s;display:flex;position:relative;overflow:hidden}.UIb:after{content:"";border-radius:inherit;background:radial-gradient(circle at center, var(--b-500) 0%, transparent 60%);opacity:0;pointer-events:none;position:absolute;inset:0;transform:scale(0)}.UIb.UIb--ripple:after{animation:1s ease-out forwards ui-ripple}.UIb.UIb--flash{--flash-start:var(--b-50);--flash-mid:var(--b-700);--flash-end:var(--b-950);animation:.4s ease-out ui-flash}.UIb:hover:not(:disabled){background-color:var(--b-700);border-color:var(--b-700);color:var(--b-50)}.UIb:disabled,.UIb[aria-disabled=true]{background-color:var(--b-100);border-color:var(--b-100);color:var(--b-300);cursor:not-allowed;pointer-events:none}.UIb.expand{width:100%}.UIb.between{justify-content:space-between}.UIb.around{justify-content:space-around}.UIb.r-0{border-radius:0}.UIb.r-round{border-radius:2.5rem}.UIb.g-0{gap:0}.UIb.g-1{gap:1rem}.UIb.sm{height:2rem;font-size:.9rem}.UIb.lg{height:3rem;font-size:1.1rem}.UIb.danger{--b-50:var(--c-d-50);--b-100:var(--c-d-100);--b-300:var(--c-d-300);--b-500:var(--c-d-500);--b-700:var(--c-d-700);--b-950:var(--c-d-950)}.UIb.info{--b-50:var(--c-i-50);--b-100:var(--c-i-100);--b-300:var(--c-i-300);--b-500:var(--c-i-500);--b-700:var(--c-i-700);--b-950:var(--c-i-950)}.UIb.primary{--b-50:var(--c-p-50);--b-100:var(--c-p-100);--b-300:var(--c-p-300);--b-500:var(--c-p-500);--b-700:var(--c-p-700);--b-950:var(--c-p-950)}.UIb.success{--b-50:var(--c-s-50);--b-100:var(--c-s-100);--b-300:var(--c-s-300);--b-500:var(--c-s-500);--b-700:var(--c-s-700);--b-950:var(--c-s-950)}.UIb.warning{--b-50:var(--c-w-50);--b-100:var(--c-w-100);--b-300:var(--c-w-300);--b-500:var(--c-w-500);--b-700:var(--c-w-700);--b-950:var(--c-w-950)}.UIsp{--sp-50:var(--c-g-50);--sp-100:var(--c-g-100);--sp-300:var(--c-g-300);--sp-500:var(--c-g-500);--sp-700:var(--c-g-700);--sp-950:var(--c-g-950);grid-template-columns:min-content 1fr min-content;align-self:end;align-items:end;width:13rem;display:grid}.UIsp.UIsp--flash>.UIsp__btn,.UIsp.UIsp--flash>.UIsp__input{--flash-start:var(--sp-50);--flash-mid:var(--sp-700);--flash-end:var(--sp-950);animation:.4s ease-out ui-flash}.UIsp>.UIsp-label{grid-column:1/-1;padding:0 0 .075rem .25rem;font-size:1rem}.UIsp>.UIsp__input{text-align:center;background-color:var(--sp-50);height:2.5rem;color:var(--sp-700);border:none;border-top:1px solid var(--sp-500);border-bottom:1px solid var(--sp-500);box-sizing:border-box;outline:none;width:100%;min-width:3rem;padding:0;font-size:1.5rem;font-weight:700}.UIsp>.UIsp__input:focus{background-color:var(--sp-50);color:var(--sp-950)}.UIsp>.UIsp__input:disabled{opacity:.5;cursor:not-allowed}.UIsp__txt{font-weight:400}.UIsp>.UIsp__btn{cursor:pointer;background-color:var(--sp-100);border:none;border:1px solid var(--sp-500);width:3rem;height:2.5rem;color:var(--sp-950);border-radius:.5rem 0 0 .5rem;justify-content:center;align-items:center;padding:0;font-size:2rem;transition:background-color .4s,color .1s;display:flex;position:relative;overflow:hidden}.UIsp>.UIsp__btn:after{content:"";border-radius:inherit;background:radial-gradient(circle at center, var(--sp-500) 0%, transparent 60%);opacity:0;pointer-events:none;position:absolute;inset:0;transform:scale(0)}.UIsp>.UIsp__btn.ui-ripple:after{animation:1s ease-out forwards ui-ripple}.UIsp>.UIsp__btn:hover{background-color:var(--sp-700);color:var(--sp-50)}.UIsp>.disabled{background-color:var(--sp-100);border-color:var(--sp-500);color:var(--sp-300);pointer-events:none}.UIsp[aria-disabled=true]{pointer-events:none;cursor:not-allowed}.UIsp[aria-disabled=true]>button,.UIsp[aria-disabled=true]>input{border-color:var(--sp-100)}.UIsp[aria-disabled=true]>.UIsp-label{color:var(--sp-300)}.UIsp>.UIsp__btn:first-of-type{border-radius:.5rem 0 0 .5rem}.UIsp>.UIsp__btn:last-of-type{border-radius:0 .5rem .5rem 0}.UIsp.r-0>.UIsp__btn{border-radius:0}.UIsp.r-round>.UIsp__btn:first-of-type{border-radius:1.5rem 0 0 1.5rem}.UIsp.r-round>.UIsp__btn:last-of-type{border-radius:0 1.5rem 1.5rem 0}.UIsp.sm{width:10rem}.UIsp.sm>.UIsp-label{padding:0 0 0 .125rem;font-size:.8rem}.UIsp.sm>.UIsp__input,.UIsp.sm>.UIsp__btn{height:2rem;font-size:1rem}.UIsp.sm>.UIsp__btn{width:2rem}.UIsp.lg{width:16rem}.UIsp.lg>.UIsp__input,.UIsp.lg>.UIsp__btn{height:3rem;font-size:2rem}.UIsp.lg>.UIsp__btn{width:3rem}.UIsp.danger{--sp-50:var(--c-d-50);--sp-100:var(--c-d-100);--sp-300:var(--c-d-300);--sp-500:var(--c-d-500);--sp-700:var(--c-d-700);--sp-950:var(--c-d-950)}.UIsp.info{--sp-50:var(--c-i-50);--sp-100:var(--c-i-100);--sp-300:var(--c-i-300);--sp-500:var(--c-i-500);--sp-700:var(--c-i-700);--sp-950:var(--c-i-950)}.UIsp.primary{--sp-50:var(--c-p-50);--sp-100:var(--c-p-100);--sp-300:var(--c-p-300);--sp-500:var(--c-p-500);--sp-700:var(--c-p-700);--sp-950:var(--c-p-950)}.UIsp.success{--sp-50:var(--c-s-50);--sp-100:var(--c-s-100);--sp-300:var(--c-s-300);--sp-500:var(--c-s-500);--sp-700:var(--c-s-700);--sp-950:var(--c-s-950)}.UIsp.warning{--sp-50:var(--c-w-50);--sp-100:var(--c-w-100);--sp-300:var(--c-w-300);--sp-500:var(--c-w-500);--sp-700:var(--c-w-700);--sp-950:var(--c-w-950)}.UIselect{--sl-50:var(--c-g-50);--sl-100:var(--c-g-100);--sl-300:var(--c-g-300);--sl-500:var(--c-g-500);--sl-700:var(--c-g-700);--sl-900:var(--c-g-900);--sl-950:var(--c-g-950);--sl-item-hover-bg:var(--sl-500);--sl-item-hover-color:var(--sl-50);--sl-item-sel-bg:var(--sl-300);--sl-item-sel-color:var(--sl-950);background-color:var(--sl-500);cursor:pointer;box-sizing:border-box;white-space:nowrap;border-radius:.5rem;align-self:end;width:12rem;min-width:10rem;height:2.5rem;display:flex;position:relative}.UIselect:hover{background-color:var(--sl-700)}.UIselect:hover .UIselect-selected,.UIselect:hover .UIselect-arrow{background-color:var(--sl-700);color:var(--sl-50)}.UIselect-selected{background-color:var(--sl-100);color:var(--sl-900);border-radius:.5rem;align-items:center;width:100%;height:calc(100% - 2px);margin:1px;padding:0 .5rem;display:flex;overflow:hidden}.UIselect-selected>span{white-space:nowrap;text-align:center;max-width:100%;display:inline-block;overflow:hidden}.UIselect-selected.center>span{text-align:left;max-width:100%;margin:0 auto}.UIselect-arrow{background-color:var(--sl-100);width:2rem;height:calc(100% - 4px);color:var(--sl-700);border-radius:.5rem;place-content:center;align-items:center;margin:2px 5px;font-size:.8rem;position:absolute;top:0;right:0}.UIselect-arrow>svg{margin:0 auto;display:flex}.UIselect-options{width:inherit;background-color:var(--sl-100);color:var(--sl-950);z-index:2;box-sizing:border-box;border:1px solid var(--sl-500);border-radius:.5rem;margin:0;padding:0;list-style:none;position:absolute;left:0;overflow:hidden}.UIselect-options__search{padding:1px 2px;position:sticky;top:1px}.UIselect-options__search>input{width:100%;height:inherit;border:1px solid var(--sl-300);box-shadow:none;background-color:var(--sl-50);color:var(--sl-950);border-radius:.5rem;padding:0 7px;font-size:1.5rem}.UIselect-options__search>input:focus-visible{outline:none}.UIselect-options__items{max-height:20rem;overflow-y:auto}.UIselect-options__items>ul{margin:0;padding:0;list-style:none}.UIselect-options__items>ul>li{border-radius:.5rem;align-items:center;height:2.5rem;margin:1px;padding:0 .5rem;display:flex}.UIselect-options__items>ul>li[hidden]{display:none}.UIselect-options__items>ul>li:hover{background-color:var(--sl-item-hover-bg);color:var(--sl-item-hover-color)}.UIselect-options__items>ul>li[aria-selected=true]{background-color:var(--sl-item-sel-bg);color:var(--sl-item-sel-color)}.UIselect-options__items>ul>li.divider{background-color:var(--sl-300);height:1px;margin:0 .25rem}.UIselect.r-0,.UIselect.r-0>.UIselect-selected,.UIselect.r-0>.UIselect-options,.UIselect.r-0>.UIselect-options>li.UIselect-options__search,.UIselect.r-0>.UIselect-options>li.UIselect-options__search>input,.UIselect.r-0>.UIselect-options>li>ul>li{border-radius:0}.UIselect.r-1,.UIselect.r-1>.UIselect-selected,.UIselect.r-1>.UIselect-arrow{border-radius:1.5rem}.UIselect.lg{width:16rem;min-width:12rem;height:3rem;font-size:1.1rem}.UIselect.lg>.UIselect-selected{overflow:hidden}.UIselect.lg .UIselect-options__search>input{height:3rem;font-size:1.7rem}.UIselect.lg .UIselect-options__items{max-height:25rem}.UIselect.lg .UIselect-options__items>ul>li{height:3rem}.UIselect.lg .UIselect-options__items>ul>li.divider{height:1px;margin:0 .5rem}.UIselect.sm{width:10rem;min-width:8rem;height:2rem;font-size:.9rem}.UIselect.sm .UIselect-options__search>input{height:2rem;font-size:1rem}.UIselect.sm .UIselect-options__items{max-height:15rem}.UIselect.sm .UIselect-options__items>ul>li{height:2rem}.UIselect.sm .UIselect-options__items>ul>li.divider{height:1px;margin:0 .25rem}.UIselect.expand{width:100%}.UIselect.UIselect--flash{--flash-start:var(--sl-50);--flash-mid:var(--sl-700);--flash-end:var(--sl-950);animation:.4s ease-out ui-flash}.UIselect[aria-disabled=true]{pointer-events:none;opacity:.5;cursor:not-allowed}.UIselect.danger{--sl-50:var(--c-d-50);--sl-100:var(--c-d-100);--sl-300:var(--c-d-300);--sl-500:var(--c-d-500);--sl-700:var(--c-d-700);--sl-900:var(--c-d-900);--sl-950:var(--c-d-950);--sl-item-hover-bg:var(--sl-300);--sl-item-hover-color:var(--sl-950);--sl-item-sel-bg:var(--sl-700);--sl-item-sel-color:var(--sl-50)}.UIselect.info{--sl-50:var(--c-i-50);--sl-100:var(--c-i-100);--sl-300:var(--c-i-300);--sl-500:var(--c-i-500);--sl-700:var(--c-i-700);--sl-900:var(--c-i-900);--sl-950:var(--c-i-950);--sl-item-hover-bg:var(--sl-300);--sl-item-hover-color:var(--sl-950);--sl-item-sel-bg:var(--sl-700);--sl-item-sel-color:var(--sl-50)}.UIselect.primary{--sl-50:var(--c-p-50);--sl-100:var(--c-p-100);--sl-300:var(--c-p-300);--sl-500:var(--c-p-500);--sl-700:var(--c-p-700);--sl-900:var(--c-p-900);--sl-950:var(--c-p-950);--sl-item-hover-bg:var(--sl-300);--sl-item-hover-color:var(--sl-950);--sl-item-sel-bg:var(--sl-700);--sl-item-sel-color:var(--sl-50)}.UIselect.success{--sl-50:var(--c-s-50);--sl-100:var(--c-s-100);--sl-300:var(--c-s-300);--sl-500:var(--c-s-500);--sl-700:var(--c-s-700);--sl-900:var(--c-s-900);--sl-950:var(--c-s-950);--sl-item-hover-bg:var(--sl-300);--sl-item-hover-color:var(--sl-950);--sl-item-sel-bg:var(--sl-700);--sl-item-sel-color:var(--sl-50)}.UIselect.warning{--sl-50:var(--c-w-50);--sl-100:var(--c-w-100);--sl-300:var(--c-w-300);--sl-500:var(--c-w-500);--sl-700:var(--c-w-700);--sl-900:var(--c-w-900);--sl-950:var(--c-w-950);--sl-item-hover-bg:var(--sl-300);--sl-item-hover-color:var(--sl-950);--sl-item-sel-bg:var(--sl-700);--sl-item-sel-color:var(--sl-50)}.UIsw{--sw-50:var(--c-g-50);--sw-100:var(--c-g-100);--sw-300:var(--c-g-300);--sw-500:var(--c-g-500);--sw-700:var(--c-g-700);--sw-950:var(--c-g-950);align-items:center;gap:1.5rem;display:inline-flex;position:relative}.UIsw-label{cursor:pointer;-webkit-user-select:none;user-select:none}.UIsw-label:hover{color:var(--sw-700)}.UIsw>input[type=checkbox]{display:none}.UIsw-slider{background-color:var(--sw-100);cursor:pointer;border:1px solid var(--sw-300);border-radius:1.5rem;width:5rem;height:2.5rem;transition:background-color .4s,border-color .4s;position:relative;overflow:hidden}.UIsw-slider:after{content:"";border-radius:inherit;background:radial-gradient(circle at center, var(--sw-700) 0%, transparent 60%);opacity:0;pointer-events:none;position:absolute;inset:0;transform:scale(0)}.UIsw-slider.ui-ripple:after{animation:1s ease-out forwards ui-ripple}.UIsw-slider:before{z-index:1;content:"";background-color:var(--sw-300);border-radius:1.5rem;width:2.5rem;height:2.5rem;transition:transform .1s;position:absolute;left:0}.UIsw-slider:hover{border-color:var(--sw-50);color:var(--sw-300)}.UIsw-slider:hover~.UIsw-slider__on,.UIsw-slider:hover~.UIsw-slider__off{color:var(--sw-300);transition:color .4s}.UIsw-slider__on,.UIsw-slider__off{color:var(--sw-950);cursor:pointer;transition:color .4s;position:absolute;right:3rem}.UIsw-slider__on:hover,.UIsw-slider__off:hover{color:var(--sw-300)}.UIsw-slider__off{color:var(--sw-700);right:.7rem}.UIsw.UIsw--flash>.UIsw-slider{--flash-start:var(--sw-50);--flash-mid:var(--sw-700);--flash-end:var(--sw-950);animation:.4s ease-out ui-flash}.UIsw[aria-disabled=true]{pointer-events:none;cursor:not-allowed}.UIsw[aria-disabled=true]>input[type=checkbox]:checked~.UIsw-slider:before{background-color:var(--sw-300)}.UIsw[aria-disabled=true]>input[type=checkbox]:checked~.UIsw-slider{border-color:var(--sw-50)}.UIsw:has(>input:disabled){pointer-events:none;cursor:not-allowed}.UIsw:has(>input:disabled)>.UIsw-label{color:var(--sw-300)}.UIsw:has(>input:disabled)>span{color:var(--sw-300);border-color:var(--sw-50);background-color:var(--sw-50)}.UIsw:has(>input:disabled)>span:before{background-color:var(--sw-100)}:is(.UIsw:has(>input:disabled)>.UIsw-slider__on,.UIsw:has(>input:disabled)>.UIsw-slider__off){background-color:#0000}.UIsw>input[type=checkbox]:checked~.UIsw-slider{background-color:var(--sw-100);border-color:var(--sw-700)}.UIsw>input[type=checkbox]:checked~.UIsw-slider:before{background-color:var(--sw-700);transform:translate(2.5rem)}.UIsw>input[type=checkbox]:checked~.UIsw-slider:hover{border-color:var(--sw-50)}.UIsw:has(.UIsw-slider__on:hover,.UIsw-slider__off:hover) .UIsw-slider{border-color:var(--sw-50)}.UIsw>input[type=checkbox]:checked:has(~.UIsw-slider__on:hover,~.UIsw-slider__off:hover)~.UIsw-slider{border-color:var(--sw-50)}.UIsw.lg>.UIsw-slider{width:6rem;height:3rem}.UIsw.lg>.UIsw-slider:before{border-radius:1.5rem;width:3rem;height:3rem}.UIsw.lg>.UIsw-slider__on{font-size:1.2rem;right:3.8rem}.UIsw.lg>.UIsw-slider__off{font-size:1.2rem;right:1rem}.UIsw.lg>input[type=checkbox]:checked~.UIsw-slider:before{transform:translate(3rem)}.UIsw.sm{gap:1rem}.UIsw.sm>.UIsw-slider{width:4rem;height:2rem}.UIsw.sm>.UIsw-slider:before{border-radius:1.5rem;width:2rem;height:2rem}.UIsw.sm>.UIsw-slider__on,.UIsw.sm>.UIsw-slider__off{font-size:.9rem;right:2.5rem}.UIsw.sm>.UIsw-slider__off{right:.6rem}.UIsw.sm>input[type=checkbox]:checked~.UIsw-slider:before{transform:translate(2rem)}.UIsw.xsm{gap:.5rem}.UIsw.xsm>.UIsw-slider{width:2rem;height:1rem}.UIsw.xsm>.UIsw-slider:before{border-radius:1.5rem;width:1rem;height:1rem}.UIsw.xsm>.UIsw-slider__on,.UIsw.xsm>.UIsw-slider__off{font-size:.6rem;right:1.2rem}.UIsw.xsm>.UIsw-slider__off{right:.3rem}.UIsw.xsm>input[type=checkbox]:checked~.UIsw-slider:before{transform:translate(1rem)}.UIsw.r-0>.UIsw-slider,.UIsw.r-0>.UIsw-slider:before{border-radius:0}.UIsw.r-1>.UIsw-slider,.UIsw.r-1>.UIsw-slider:before{border-radius:.5rem}.UIsw.label-top{margin-top:1.5rem}.UIsw.label-top>.UIsw-label{white-space:nowrap;position:absolute;bottom:calc(100% + .25rem);left:0}.UIsw.danger{--sw-50:var(--c-d-50);--sw-100:var(--c-d-100);--sw-300:var(--c-d-300);--sw-700:var(--c-d-700);--sw-950:var(--c-d-950)}.UIsw.info{--sw-50:var(--c-i-50);--sw-100:var(--c-i-100);--sw-300:var(--c-i-300);--sw-700:var(--c-i-700);--sw-950:var(--c-i-950)}.UIsw.success{--sw-50:var(--c-s-50);--sw-100:var(--c-s-100);--sw-300:var(--c-s-300);--sw-700:var(--c-s-700);--sw-950:var(--c-s-950)}.UIsw.primary{--sw-50:var(--c-p-50);--sw-100:var(--c-p-100);--sw-300:var(--c-p-300);--sw-700:var(--c-p-700);--sw-950:var(--c-p-950)}.UIsw.warning{--sw-50:var(--c-w-50);--sw-100:var(--c-w-100);--sw-300:var(--c-w-300);--sw-700:var(--c-w-700);--sw-950:var(--c-w-950)}.UIsw.warning>.UIsw-slider__off{color:var(--sw-300)}.UIql{--ql-bg:var(--sp-100,var(--sw-100,var(--sl-100,var(--b-100,var(--bg-100,var(--c-g-100))))));--ql-fg:var(--sp-700,var(--sw-700,var(--sl-700,var(--b-700,var(--bg-700,var(--c-g-700))))));--ql-border:var(--sp-300,var(--sw-300,var(--sl-300,var(--b-300,var(--bg-300,var(--c-g-300))))));--ql-tip-bg:var(--sp-700,var(--sw-700,var(--sl-700,var(--b-700,var(--bg-700,var(--c-g-700))))));--ql-tip-fg:var(--sp-50,var(--sw-50,var(--sl-50,var(--b-50,var(--bg-50,var(--c-g-50))))));box-sizing:border-box;background-color:var(--ql-bg);width:1.15em;height:1.15em;color:var(--ql-fg);vertical-align:middle;cursor:help;-webkit-user-select:none;user-select:none;border-radius:50%;justify-content:center;align-items:center;margin-left:.35em;font-size:.8em;font-weight:700;line-height:1;transition:background-color .2s,color .2s;display:inline-flex;position:relative;top:-.2rem}.UIql:before{content:"?"}.UIql:hover,.UIql:focus{background-color:var(--ql-tip-bg);color:var(--ql-tip-fg);outline:none}.UIql>.UIql__text{--ql-shift-x:-50%;--ql-arrow-inset:.9rem;z-index:10;box-sizing:border-box;background-color:var(--ql-tip-bg);width:max-content;max-width:min(15rem,100vw - 1rem);color:var(--ql-tip-fg);text-align:left;white-space:normal;opacity:0;visibility:hidden;pointer-events:none;transform:translate(var(--ql-shift-x), .25em);border-radius:.5rem;padding:.4rem .6rem;font-size:.85rem;font-weight:400;line-height:1.35;transition:opacity .18s,transform .18s,visibility 0s linear .18s;position:absolute;bottom:calc(100% + .5em);left:50%;box-shadow:0 2px 8px #00000080}.UIql>.UIql__text:after{content:"";border:.35rem solid #0000;border-top-color:var(--ql-tip-bg);margin-left:-.35rem;position:absolute;top:100%;left:50%}.UIql.UIql--right>.UIql__text{--ql-shift-x:0;left:0;right:auto}.UIql.UIql--right>.UIql__text:after{left:var(--ql-arrow-inset);margin-left:-.35rem}.UIql.UIql--left>.UIql__text{--ql-shift-x:0;left:auto;right:0}.UIql.UIql--left>.UIql__text:after{left:auto;right:var(--ql-arrow-inset);margin-left:0;margin-right:-.35rem}.UIql:hover>.UIql__text,.UIql:focus>.UIql__text{opacity:1;visibility:visible;transform:translate(var(--ql-shift-x), 0);transition:opacity .18s,transform .18s,visibility}:root{--g-50:#f2f2f2;--g-100:#e6e6e6;--g-300:#b3b3b3;--g-500:gray;--g-700:#4d4d4d;--g-900:#1a1a1a;--g-950:#0d0d0d;--d-50:#ffe6ea;--d-100:#ffccd5;--d-300:#ff6680;--d-500:#ff002b;--d-700:#99001a;--d-900:#330009;--d-950:#1a0004;--i-50:#e7f8fe;--i-100:#cff1fc;--i-300:#6ed5f7;--i-500:#0db9f2;--i-700:#086f91;--i-900:#032530;--i-950:#011218;--p-50:#ececf9;--p-100:#d9d9f2;--p-300:#8c8cd9;--p-500:#4040bf;--p-700:#262673;--p-900:#0d0d26;--p-950:#060613;--s-50:#e9fbf2;--s-100:#d4f7e6;--s-300:#7de8b3;--s-500:#26d980;--s-700:#17824d;--s-900:#082b1a;--s-950:#04160d;--w-50:#fcf7e9;--w-100:#f9efd2;--w-300:#eccf79;--w-500:#dfaf20;--w-700:#866913;--w-900:#2d2306;--w-950:#161203;--c-d-50:var(--d-50);--c-d-100:var(--d-100);--c-d-300:var(--d-300);--c-d-500:var(--d-500);--c-d-700:var(--d-700);--c-d-900:var(--d-900);--c-d-950:var(--d-950);--c-i-50:var(--i-50);--c-i-100:var(--i-100);--c-i-300:var(--i-300);--c-i-500:var(--i-500);--c-i-700:var(--i-700);--c-i-900:var(--i-900);--c-i-950:var(--i-950);--c-p-50:var(--p-50);--c-p-100:var(--p-100);--c-p-300:var(--p-300);--c-p-500:var(--p-500);--c-p-700:var(--p-700);--c-p-900:var(--p-900);--c-p-950:var(--p-950);--c-s-50:var(--s-50);--c-s-100:var(--s-100);--c-s-300:var(--s-300);--c-s-500:var(--s-500);--c-s-700:var(--s-700);--c-s-900:var(--s-900);--c-s-950:var(--s-950);--c-g-50:var(--g-50);--c-g-100:var(--g-100);--c-g-300:var(--g-300);--c-g-500:var(--g-500);--c-g-700:var(--g-700);--c-g-900:var(--g-900);--c-g-950:var(--g-950);--c-w-50:var(--w-50);--c-w-100:var(--w-100);--c-w-300:var(--w-300);--c-w-500:var(--w-500);--c-w-700:var(--w-700);--c-w-900:var(--w-900);--c-w-950:var(--w-950)}body{background-color:var(--c-g-50);color:var(--c-g-950);padding:0;transition:background .4s}html{-webkit-text-size-adjust:100%;line-height:1.15}body{margin:0}main{display:block}h1{margin:.67em 0;font-size:2em}hr{box-sizing:content-box;height:0;overflow:visible}pre{font-family:monospace;font-size:1em}a{color:inherit;background-color:#0000;text-decoration:none}img{border-style:none}button,input,optgroup,select,textarea{margin:0;font-family:inherit;font-size:100%}button,input{overflow:visible}button,select{text-transform:none}button,[type=button],[type=reset],[type=submit]{-webkit-appearance:button}fieldset{border:1px solid silver;margin:0;padding:.35em .75em .625em}legend{padding:0}progress{vertical-align:baseline}textarea{overflow:auto}[type=checkbox],[type=radio]{box-sizing:border-box;padding:0}table{border-collapse:collapse;border-spacing:0}@keyframes ui-ripple{0%{opacity:1;transform:scale(0)}to{opacity:0;transform:scale(5)}}@keyframes ui-flash{0%{box-shadow:0 0 0 0 var(--flash-start)}50%{box-shadow:0 0 5px 1px var(--flash-mid)}to{box-shadow:0 0 0 0 var(--flash-end)}}.UIFlash{--flash-start:var(--c-g-50);--flash-mid:var(--c-g-700);--flash-end:var(--c-g-950);animation:.4s ease-out ui-flash}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"author": "Andrii Popov",
|
|
3
3
|
"name": "@popovandrii/ui-elements",
|
|
4
4
|
"description": "Lightweight TypeScript UI component library — SpinBox, Select with search, Switch, ButtonGroup (radio), Button. Zero dependencies, accessible (ARIA), themeable via CSS custom properties, supports destroy/reinitialize lifecycle.",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.3.0",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"ui",
|
|
@@ -71,4 +71,4 @@
|
|
|
71
71
|
"vite-plugin-dts": "^5.0.0",
|
|
72
72
|
"vitest": "^4.1.5"
|
|
73
73
|
}
|
|
74
|
-
}
|
|
74
|
+
}
|