UNPKG

@public-ui/components

Version:

Contains all web components that belong to KoliBri - The accessible HTML-Standard.

5 lines 16.9 kB
/*! * KoliBri - The accessible HTML-Standard */ import{r as n,h as e,H as o,g as t}from"./index-BQlHOxik.js";import{d as i}from"./component-names-Dy77vq43.js";import{s as l}from"./common-Cx_AGO_M.js";import{v as r}from"./align-DxZmRFcp.js";import{v as a}from"./has-closer-B8w7bVjx.js";import{v as s}from"./label-Fyi30H9j.js";import{v as d}from"./open-Dw4Y2dzo.js";import{c}from"./clsx-COFh-Vc8.js";import{c as h}from"./dev.utils-02Sl9bQo.js";import{d as f,K as p}from"./events-VVvk1win.js";import{h as m}from"./tooltip-open-tracking-D3tCiiGP.js";import{w as u}from"./validation-D6nATCh8.js";import"./level-1jyaYIAE.js";import"./normalizers-m3s9sgmq.js";import"./_Uint8Array-kJHDjtoP.js";import"./isArray-CcrBs4JM.js";const b='@charset "UTF-8";\n/*\n* This file defines the layer order for all CSS layers used in KoliBri.\n* The order is important as it determines the cascade priority.\n*\n* Layer order (lowest to highest priority):\n* 1. kol-a11y - Accessibility defaults and requirements\n* 2. kol-global - Global component styles and resets\n* 3. kol-component - Component-specific styles\n* 4. kol-theme-global - Theme-specific global styles\n* 5. kol-theme-component - Theme-specific component styles\n*/\n@layer kol-a11y, kol-global, kol-component, kol-theme-global, kol-theme-component;\n/* forward the rem function */\n/*\n * This file contains all rules for accessibility.\n */\n@layer kol-a11y {\n :host {\n /*\n * Minimum size of interactive elements.\n */\n --a11y-min-size: calc(44 * 1rem / var(--kolibri-root-font-size, 16));\n /*\n * No element should be used without verifying the contrast ratio of its background and font colors.\n * By initially setting the background color to white and the font color to black,\n * the contrast ratio is ensured and explicit adjustment is forced.\n */\n color: black;\n background-color: white;\n /*\n * Verdana is an accessible font that can be used without requiring additional loading time.\n */\n font-family: Verdana;\n /*\n * Letter spacing is required for all texts.\n */\n letter-spacing: inherit;\n /*\n * Word spacing is required for all texts.\n */\n word-spacing: inherit;\n /*\n * Text should be aligned left by default to provide a predictable starting point.\n */\n text-align: left;\n }\n * {\n /*\n * This rule enables the word dividing for all texts. That is important for high zoom levels.\n */\n hyphens: auto;\n /*\n * This rule enables the word dividing for all texts. That is important for high zoom levels.\n */\n word-break: break-word;\n }\n /*\n * All interactive elements should have a minimum size of to-rem(44).\n */\n /* input:not([type=\'checkbox\'], [type=\'radio\'], [type=\'range\']), */\n /* option, */\n /* select, */\n /* textarea, */\n button,\n .kol-input .input {\n min-width: var(--a11y-min-size);\n min-height: var(--a11y-min-size);\n }\n /*\n * Some interactive elements should not inherit the font-family and font-size.\n */\n a,\n button,\n h1,\n h2,\n h3,\n h4,\n h5,\n h6,\n input,\n option,\n select,\n textarea {\n /*\n * All elements should inherit the text color from his parent element.\n */\n color: inherit;\n /*\n * All elements should inherit the font family from his parent element.\n */\n font-family: inherit;\n /*\n * All elements should inherit the font size from his parent element.\n */\n font-size: inherit;\n /*\n * Letter spacing is required for all texts.\n */\n letter-spacing: inherit;\n /*\n * Word spacing is required for all texts.\n */\n word-spacing: inherit;\n }\n /**\n * Sometimes we need the semantic element for accessibility reasons,\n * but we don\'t want to show it.\n *\n * - https://www.a11yproject.com/posts/how-to-hide-content/\n */\n .visually-hidden {\n position: fixed;\n top: 0;\n left: 0;\n width: 1px;\n height: 1px;\n overflow: hidden;\n white-space: nowrap;\n clip-path: inset(50%);\n }\n}\n@layer kol-global {\n /*\n * Dieses CSS stellt sicher, dass der Standard-Style\n * von A und Button resettet werden.\n */\n :is(a, button) {\n background-color: transparent;\n width: 100%;\n margin: 0;\n padding: 0;\n border: none;\n /* 100% needed for custom width from outside */\n }\n /*\n * Ensure elements with hidden attribute to be actually not visible\n * @see https://meowni.ca/hidden.is.a.lie.html\n */\n [hidden] {\n display: none !important;\n }\n .badge-text-hint {\n color: black;\n background-color: white;\n }\n}\n@layer kol-global {\n :host {\n /*\n * The max-width is needed to prevent the table from overflowing the\n * parent node, if the table is wider than the parent node.\n */\n max-width: 100%;\n font-size: calc(16 * 1rem / var(--kolibri-root-font-size, 16));\n }\n * {\n /*\n * We prefer to box-sizing: border-box for all elements.\n */\n box-sizing: border-box;\n }\n .kol-span {\n /* KolSpan is a layout component with icons in all directions and a label text in the middle. */\n display: flex;\n flex-flow: column;\n align-items: center;\n justify-content: center;\n /* The sub span in KolSpan is the horizontal span with icon left and right and the label text in the middle. */\n }\n .kol-span__container {\n display: flex;\n align-items: center;\n }\n a,\n button {\n cursor: pointer;\n }\n .kol-span .kol-span__label--hide-label .kol-span__label {\n display: none;\n }\n /* Reset browser agent style. */\n button:disabled {\n color: unset;\n }\n .disabled label,\n .disabled:focus-within label,\n [aria-disabled=true],\n [aria-disabled=true]:focus,\n [disabled],\n [disabled]:focus {\n outline: none;\n cursor: not-allowed;\n }\n [aria-disabled=true]:focus .kol-span,\n [disabled]:focus .kol-span {\n outline: none !important;\n }\n .hastooltip {\n z-index: 900 !important;\n }\n}\n@font-face {\n font-family: "kolicons";\n src: url("kolicons.eot?t=1780571516250"); /* IE9*/\n src: url("kolicons.eot?t=1780571516250#iefix") format("embedded-opentype"), url("kolicons.woff2?t=1780571516250") format("woff2"), url("kolicons.woff?t=1780571516250") format("woff"), url("kolicons.ttf?t=1780571516250") format("truetype"), url("kolicons.svg?t=1780571516250#kolicons") format("svg"); /* iOS 4.1- */\n}\n@layer kol-component {\n [class^=kolicon-], [class*=" kolicon-"] {\n font-family: "kolicons";\n font-style: normal;\n font-weight: 400;\n line-height: 1em;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n }\n .kolicon-alert-error::before {\n content: "\\ea01";\n }\n .kolicon-alert-info::before {\n content: "\\ea02";\n }\n .kolicon-alert-success::before {\n content: "\\ea03";\n }\n .kolicon-alert-warning::before {\n content: "\\ea04";\n }\n .kolicon-check::before {\n content: "\\ea05";\n }\n .kolicon-chevron-double-left::before {\n content: "\\ea06";\n }\n .kolicon-chevron-double-right::before {\n content: "\\ea07";\n }\n .kolicon-chevron-down::before {\n content: "\\ea08";\n }\n .kolicon-chevron-left::before {\n content: "\\ea09";\n }\n .kolicon-chevron-right::before {\n content: "\\ea0a";\n }\n .kolicon-chevron-up::before {\n content: "\\ea0b";\n }\n .kolicon-cogwheel::before {\n content: "\\ea0c";\n }\n .kolicon-cross::before {\n content: "\\ea0d";\n }\n .kolicon-eye-closed::before {\n content: "\\ea0e";\n }\n .kolicon-eye::before {\n content: "\\ea0f";\n }\n .kolicon-house::before {\n content: "\\ea10";\n }\n .kolicon-kolibri::before {\n content: "\\ea11";\n }\n .kolicon-link-external::before {\n content: "\\ea12";\n }\n .kolicon-link::before {\n content: "\\ea13";\n }\n .kolicon-minus::before {\n content: "\\ea14";\n }\n .kolicon-plus::before {\n content: "\\ea15";\n }\n .kolicon-settings::before {\n content: "\\ea16";\n }\n .kolicon-sort-asc::before {\n content: "\\ea17";\n }\n .kolicon-sort-desc::before {\n content: "\\ea18";\n }\n .kolicon-sort-neutral::before {\n content: "\\ea19";\n }\n .kolicon-up::before {\n content: "\\ea1a";\n }\n .kolicon-version::before {\n content: "\\ea1b";\n }\n}\n@layer kol-component {\n .kol-icon {\n color: inherit;\n display: inline-block;\n font-size: inherit;\n font-weight: inherit;\n line-height: inherit;\n }\n .kol-tooltip {\n display: contents;\n }\n .kol-tooltip__floating {\n opacity: 0;\n display: none;\n position: fixed;\n /* Avoid layout interference - see https://floating-ui.com/docs/computePosition */\n top: 0;\n left: 0;\n /* Can be used to specify the tooltip-width from the outside. Unset by default. */\n width: var(--kol-tooltip-width, max-content);\n min-width: calc(8 * 1rem / var(--kolibri-root-font-size, 16));\n max-width: 90vw;\n max-height: 90vh;\n animation-direction: normal;\n /* Can be used to specify the animation duration from the outside. 250ms by default. */\n animation-duration: var(--kolibri-tooltip-animation-duration, 250ms);\n animation-fill-mode: forwards;\n animation-iteration-count: 1;\n animation-timing-function: ease-in;\n }\n .kol-tooltip__floating.hide {\n animation-name: hideTooltip;\n }\n .kol-tooltip__floating.show {\n animation-name: showTooltip;\n }\n .kol-tooltip__arrow {\n transform: rotate(45deg);\n color: black;\n background-color: white;\n position: absolute;\n z-index: 999;\n width: calc(10 * 1rem / var(--kolibri-root-font-size, 16));\n height: calc(10 * 1rem / var(--kolibri-root-font-size, 16));\n }\n .kol-tooltip__content {\n color: black;\n background-color: white;\n position: relative;\n z-index: 1000;\n }\n @keyframes hideTooltip {\n 0% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n display: none;\n }\n }\n @keyframes showTooltip {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n }\n}\n@layer kol-component {\n .kol-icon {\n color: inherit;\n display: inline-block;\n font-size: inherit;\n font-weight: inherit;\n line-height: inherit;\n }\n .kol-card .kol-icon {\n color: inherit;\n display: inline-block;\n font-size: inherit;\n font-weight: inherit;\n line-height: inherit;\n }\n .kol-card :host {\n display: inline-block;\n }\n .kol-card .kol-button {\n display: flex;\n min-height: var(--a11y-min-size);\n font-style: calc(16 * 1rem / var(--kolibri-root-font-size, 16));\n text-decoration-line: none;\n }\n .kol-card .kol-button::before {\n /* Render zero-width character as first element to set the baseline correctly. */\n content: "​";\n }\n .kol-card .kol-button__text {\n flex: 1 0 100%;\n }\n .kol-card {\n /* Visible with forced colors */\n outline: transparent solid calc(1 * 1rem / var(--kolibri-root-font-size, 16));\n display: grid;\n height: 100%;\n overflow: visible;\n grid-template-areas: "header close" "content content";\n grid-template-columns: 1fr min-content;\n grid-template-rows: min-content 1fr;\n }\n .kol-card__header {\n align-self: start;\n grid-area: header;\n }\n .kol-card__content {\n align-self: stretch;\n grid-area: content;\n }\n .kol-card__close-button {\n grid-area: close;\n }\n .kol-drawer__dialog {\n padding: 0;\n border: none;\n }\n .kol-drawer__wrapper {\n position: fixed;\n overflow: auto;\n }\n .kol-drawer__wrapper--left, .kol-drawer__wrapper--right {\n top: 0;\n max-width: 100vw;\n height: 100vh;\n }\n .kol-drawer__wrapper--left .kol-drawer__content, .kol-drawer__wrapper--right .kol-drawer__content {\n height: 100%;\n }\n .kol-drawer__wrapper--left {\n left: 0;\n }\n .kol-drawer__wrapper--right {\n right: 0;\n }\n .kol-drawer__wrapper--bottom, .kol-drawer__wrapper--top {\n left: 0;\n width: 100vw;\n max-height: 100vh;\n }\n .kol-drawer__wrapper--bottom .kol-drawer__content, .kol-drawer__wrapper--top .kol-drawer__content {\n width: 100%;\n }\n .kol-drawer__wrapper--bottom {\n bottom: 0;\n }\n .kol-drawer__wrapper--top {\n top: 0;\n }\n .kol-drawer__content {\n position: relative;\n }\n .kol-drawer__dialog .kol-card__content {\n overflow-y: auto;\n }\n}';const k=class{constructor(e){n(this,e);this.cardHeadingId=h("drawer-heading");this.isModal=true;this._cardOn={onClose:()=>void this.close()};this.getWrapperRef=n=>this.dialogWrapperElement=n;this.getRef=n=>{this.dialogElement=n;setTimeout((()=>{void this.openOrCloseBasedOnState()}))};this._hasCloser=false;this._level=0;this.state={_label:"",_open:false,_align:"left"};this.handleCancelEvent=n=>{var e,o;m(n);if(n.defaultPrevented)return;(o=(e=this.state._on)===null||e===void 0?void 0:e.onCancel)===null||o===void 0?void 0:o.call(e,n);if(n.defaultPrevented)return;if(this.host&&!f(this.host,p.cancel)){n.preventDefault()}};this.handleClose=()=>{void(async()=>{await this.close();this.handleCloseDialog()})()};this.handleAnimationEnd=n=>{var e,o;const t=n;if(t.animationName.includes("slideOut")){(o=(e=this.dialogElement)===null||e===void 0?void 0:e.close)===null||o===void 0?void 0:o.call(e)}}}async show(n=false){var e,o,t,i,l,r,a;if((e=this.dialogElement)===null||e===void 0?void 0:e.open){return}this.isModal=n;this.state=Object.assign(Object.assign({},this.state),{_open:true});if(n){(t=(o=this.dialogElement)===null||o===void 0?void 0:o.showModal)===null||t===void 0?void 0:t.call(o)}else{(l=(i=this.dialogElement)===null||i===void 0?void 0:i.show)===null||l===void 0?void 0:l.call(i)}(a=(r=this._on)===null||r===void 0?void 0:r.onToggle)===null||a===void 0?void 0:a.call(r,true);if(this.host){f(this.host,p.toggle)}}showModal(){return this.show(true)}open(){return this.show(false)}async close(){var n,e;this.state=Object.assign(Object.assign({},this.state),{_open:false});const o=this.dialogWrapperElement;if(!o){return}if(window.getComputedStyle(o).animationName==="none"){(e=(n=this.dialogElement)===null||n===void 0?void 0:n.close)===null||e===void 0?void 0:e.call(n)}}renderDialogContent(){const n=this.state._align;return e(i,{ref:this.getWrapperRef,class:c(`kol-drawer__wrapper`,`kol-drawer__wrapper--${n}`,{"kol-drawer__wrapper--open":this.state._open,"kol-drawer__wrapper--is-closing":this.state._open===false}),_hasCloser:this.state._hasCloser,_headingId:this.cardHeadingId,_label:this.state._label,_level:this._level,_on:this._cardOn},e("div",{class:"kol-drawer__content"},e("slot",null)))}render(){return e(o,{key:"9ddd7432cb3f0a79b4020144378e951d76d6429b",class:"kol-drawer"},e("dialog",{key:"4187cc6a21ca4471a30f1db9f860d5a141372157","aria-labelledby":this.cardHeadingId,"aria-modal":this.isModal?"true":"false",class:"kol-drawer__dialog",onCancel:this.handleCancelEvent,ref:this.getRef},this.renderDialogContent()))}validateLabel(n){s(this,n,{required:true})}validateAlign(n){r(this,n)}validateHasCloser(n){a(this,n)}validateLevel(n){u(this,n)}validateOpen(n){if(typeof n==="boolean"){d(this,n);if(this.dialogElement){void this.openOrCloseBasedOnState()}}}async openOrCloseBasedOnState(){if(this.state._open){await this.show(this.isModal)}else{await this.close()}}validateOn(n){if(typeof n==="object"&&n!==null){const e={};if(typeof n.onCancel==="function"){e.onCancel=n.onCancel}if(typeof n.onClose==="function"){e.onClose=n.onClose}if(typeof n.onToggle==="function"){e.onToggle=n.onToggle}l(this,"_on",e)}}handleCloseDialog(){var n,e,o,t;(e=(n=this._on)===null||n===void 0?void 0:n.onClose)===null||e===void 0?void 0:e.call(n);(t=(o=this._on)===null||o===void 0?void 0:o.onToggle)===null||t===void 0?void 0:t.call(o,false);if(this.host){f(this.host,p.close);f(this.host,p.toggle)}}componentDidLoad(){var n,e;(n=this.dialogElement)===null||n===void 0?void 0:n.addEventListener("animationend",this.handleAnimationEnd);(e=this.dialogElement)===null||e===void 0?void 0:e.addEventListener("close",this.handleClose)}disconnectedCallback(){var n,e;(n=this.dialogElement)===null||n===void 0?void 0:n.removeEventListener("animationend",this.handleAnimationEnd);(e=this.dialogElement)===null||e===void 0?void 0:e.removeEventListener("close",this.handleClose)}componentWillLoad(){this.validateAlign(this._align);this.validateHasCloser(this._hasCloser);this.validateLabel(this._label);this.validateOpen(this._open);this.validateLevel(this._level);this.validateOn(this._on)}get host(){return t(this)}static get watchers(){return{_label:["validateLabel"],_align:["validateAlign"],_hasCloser:["validateHasCloser"],_level:["validateLevel"],_open:["validateOpen"],_on:["validateOn"]}}};k.style={default:b};export{k as kol_drawer}; //# sourceMappingURL=kol-drawer.entry.js.map