@nordhealth/components 2.9.0 → 2.10.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/custom-elements.json +3778 -3433
- package/lib/Badge.js +1 -1
- package/lib/Badge.js.map +1 -1
- package/lib/Banner.js +1 -1
- package/lib/Banner.js.map +1 -1
- package/lib/Button.js +1 -1
- package/lib/Button.js.map +1 -1
- package/lib/{Calendar-1904bf2f.js → Calendar-29123404.js} +1 -1
- package/lib/{Calendar-1904bf2f.js.map → Calendar-29123404.js.map} +1 -1
- package/lib/Calendar.js +1 -1
- package/lib/Checkbox.js +1 -1
- package/lib/Checkbox.js.map +1 -1
- package/lib/CommandMenu.js +1 -1
- package/lib/CommandMenu.js.map +1 -1
- package/lib/CommandMenuAction.js +1 -1
- package/lib/CommandMenuAction.js.map +1 -1
- package/lib/DatePicker.js +1 -1
- package/lib/DatePicker.js.map +1 -1
- package/lib/Dropdown.js +1 -1
- package/lib/Dropdown.js.map +1 -1
- package/lib/Fieldset.js +1 -1
- package/lib/Fieldset.js.map +1 -1
- package/lib/FormAssociatedMixin-aa74901e.js +2 -0
- package/lib/FormAssociatedMixin-aa74901e.js.map +1 -0
- package/lib/FormField-ae3570d2.js +2 -0
- package/lib/FormField-ae3570d2.js.map +1 -0
- package/lib/Icon.js +6 -1
- package/lib/Icon.js.map +1 -1
- package/lib/Input.js +1 -1
- package/lib/Input.js.map +1 -1
- package/lib/Layout.js +1 -1
- package/lib/Layout.js.map +1 -1
- package/lib/Modal.js +1 -1
- package/lib/Modal.js.map +1 -1
- package/lib/ModalController.js +1 -1
- package/lib/ModalController.js.map +1 -1
- package/lib/NavGroup.js +1 -1
- package/lib/NavGroup.js.map +1 -1
- package/lib/NavToggle.js +1 -1
- package/lib/NavToggle.js.map +1 -1
- package/lib/Popout-4aa0cc87.js +2 -0
- package/lib/Popout-4aa0cc87.js.map +1 -0
- package/lib/Popout.js +1 -1
- package/lib/Radio.js +1 -1
- package/lib/Radio.js.map +1 -1
- package/lib/Range.js +1 -1
- package/lib/Range.js.map +1 -1
- package/lib/ScrollbarController-773c79f4.js +2 -0
- package/lib/ScrollbarController-773c79f4.js.map +1 -0
- package/lib/Select.js +1 -1
- package/lib/Select.js.map +1 -1
- package/lib/TextField-db22898b.js +2 -0
- package/lib/{TextField-a7382912.js.map → TextField-db22898b.js.map} +1 -1
- package/lib/Textarea.js +1 -1
- package/lib/Toast.js +1 -1
- package/lib/Toast.js.map +1 -1
- package/lib/Toggle.js +1 -1
- package/lib/Toggle.js.map +1 -1
- package/lib/bundle.js +11 -11
- package/lib/bundle.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/src/button/Button.d.ts +1 -0
- package/lib/src/common/controllers/ScrollbarController.d.ts +23 -7
- package/lib/src/common/mixins/FormAssociatedMixin.d.ts +1 -1
- package/lib/src/date-picker/DatePicker.d.ts +23 -13
- package/lib/src/dropdown/Dropdown.d.ts +9 -2
- package/lib/src/fieldset/Fieldset.d.ts +11 -0
- package/lib/src/input/Input.d.ts +6 -0
- package/lib/src/input/Input.test.d.ts +3 -0
- package/package.json +2 -2
- package/lib/FormAssociatedMixin-252fb0e9.js +0 -2
- package/lib/FormAssociatedMixin-252fb0e9.js.map +0 -1
- package/lib/FormField-081da729.js +0 -2
- package/lib/FormField-081da729.js.map +0 -1
- package/lib/Popout-08f11a8d.js +0 -2
- package/lib/Popout-08f11a8d.js.map +0 -1
- package/lib/ScrollbarController-680392c9.js +0 -2
- package/lib/ScrollbarController-680392c9.js.map +0 -1
- package/lib/TextField-a7382912.js +0 -2
- package/lib/unsafe-html-6be42999.js +0 -7
- package/lib/unsafe-html-6be42999.js.map +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{_ as t,e}from"./query-assigned-elements-e6cbac30.js";import{i as o,y as i,s}from"./lit-element-9178eae5.js";import{e as n}from"./property-03f59dce.js";import{t as r}from"./state-70f38ceb.js";import{i as a}from"./query-2d22378e.js";import{c as l,l as p,o as h,f as d,s as c,h as m,a as u}from"./positioning-3bbd3548.js";import{L as f}from"./LightDismissController-a2645ae6.js";import{S as v}from"./ScrollbarController-773c79f4.js";import{N as g}from"./events-731d0007.js";import{s as b}from"./Component-92eb6234.js";import{D as y}from"./DirectionController-8b298382.js";import{o as w}from"./observe-a9c6dfb6.js";import{E as x}from"./EventController-d99ebeef.js";function E(e){class o extends e{constructor(){super(...arguments),this.open=!1,this.align="start",this.position="block-end"}}return t([n({type:Boolean,reflect:!0})],o.prototype,"open",void 0),t([n({reflect:!0})],o.prototype,"align",void 0),t([n({reflect:!0})],o.prototype,"position",void 0),o}const k=o`:host{position:fixed;pointer-events:none;z-index:var(--n-index-popout);left:var(--_n-popout-position-x);top:var(--_n-popout-position-y);color:var(--n-color-text);opacity:0;transition:opacity var(--n-transition-slowly)}.n-popout{pointer-events:none;transform:translateY(-10px) scale(.97);visibility:hidden;transition:transform var(--n-transition-slowly),visibility var(--n-transition-slowly);transform-origin:top left;will-change:transform,opacity,visibility;background:var(--n-color-surface);box-shadow:var(--n-box-shadow-popout);border-radius:var(--n-border-radius-s)}:host([open]){opacity:1}:host([open]) .n-popout{transition-property:transform;visibility:visible;pointer-events:auto;transform:translateY(0) translateX(0) scale(1)}@media (max-width:35.9375em){:host{position:fixed;inset:0;overflow-y:auto;opacity:1;background:0 0;transition:background var(--n-transition-mobile)}:host([open]){pointer-events:auto;background:var(--n-color-overlay)}:host .n-popout{position:fixed;inset:0;inset-block-start:auto;transform:translateY(100%);transition:transform var(--n-transition-mobile),visibility var(--n-transition-mobile);transform-origin:bottom center;border-radius:0}}.top-end,.top-start{transform:translateY(10px) scale(.97)}.left-end,.left-start{transform:translateX(10px) scale(.97)}.right-end,.right-start{transform:translateX(-10px) scale(.97)}.bottom-start.is-rtl,.left-end,.top-end{transform-origin:bottom right}.bottom-end,.left-start,.top-start.is-rtl{transform-origin:top right}.bottom-end.is-rtl,.right-end,.right-start{transform-origin:bottom left}.right-start,.top-end.is-rtl{transform-origin:top left}`,C=matchMedia("(max-width: 35.9375em)");let j=class extends(E(s)){constructor(){super(...arguments),this.scrollBar=new v(this),this.dismiss=new f(this,{isOpen:()=>this.open,onDismiss:t=>this.hide("click"!==t.type),isDismissible:t=>t!==this.popout&&t!==this.targetElement}),this.events=new x(this),this.direction=new y(this),this.smallViewport=C.matches,this.id="",this.enableScroll=()=>{this.open||this.scrollBar.unlockScroll()},this.updatePosition=async()=>{var t;const{x:e,y:o,placement:i,middlewareData:s}=await l(this.anchorElement,this,{strategy:"fixed",placement:p(this.position,this.align,this.direction.dir),middleware:[h(8),d(),c({padding:8}),m()]});this.computedPosition=i,this.style.setProperty("--_n-popout-position-x",`${e}px`),this.style.setProperty("--_n-popout-position-y",`${o}px`),(null===(t=s.hide)||void 0===t?void 0:t.referenceHidden)&&this.hide()},this.toggleOpen=t=>{t.preventDefault(),this.open?this.hide(!1):this.smallViewport?this.show():this.updatePosition().then((()=>this.show()))},this.handleMediaQueryChange=()=>{var t;this.smallViewport=C.matches,null===(t=this.cleanupAutoUpdate)||void 0===t||t.call(this),!this.smallViewport&&this.open?(this.cleanupAutoUpdate=u(this.anchorElement,this,this.updatePosition),this.scrollBar.unlockScroll()):this.open&&this.scrollBar.lockScroll()}}show(){this.open||(this.open=!0,this.updateComplete.then((()=>{this.dispatchEvent(new g("open"))})))}hide(t=!0){var e;this.open&&(this.open=!1,null===(e=this.cleanupAutoUpdate)||void 0===e||e.call(this),this.dispatchEvent(new g("close")),t&&this.targetElement.focus({preventScroll:!0}))}firstUpdated(){this.smallViewport||this.updatePosition()}connectedCallback(){super.connectedCallback(),this.targetElement=this.getToggle(),this.anchorElement=this.anchor?this.getAnchor():this.targetElement,this.events.listen(this.targetElement,"click",this.toggleOpen),this.events.listen(C,"change",this.handleMediaQueryChange)}disconnectedCallback(){var t;super.disconnectedCallback(),null===(t=this.cleanupAutoUpdate)||void 0===t||t.call(this),this.targetElement.removeAttribute("aria-expanded")}render(){return i`<div class="n-popout ${this.computedPosition} is-${this.direction.dir}" aria-hidden="${this.open?"false":"true"}" @transitionend="${this.enableScroll}"><slot></slot></div>`}handleIdChange(){this.id||console.warn("NORD: popout requires an id attribute and value")}handleOpenChange(){var t;this.targetElement.setAttribute("aria-expanded",`${this.open}`),this.open?this.smallViewport?this.scrollBar.lockScroll():this.cleanupAutoUpdate=u(this.anchorElement,this,this.updatePosition):null===(t=this.cleanupAutoUpdate)||void 0===t||t.call(this)}getToggle(){const t=this.getRootNode().querySelector(`[aria-controls='${this.id}']`);return t instanceof HTMLSlotElement?t.assignedElements()[0]:t}getAnchor(){const t=this.getRootNode().querySelector(`#${this.anchor}`);return t instanceof HTMLSlotElement?t.assignedElements()[0]:t}};j.styles=[b,k],t([a(".n-popout",!0)],j.prototype,"popout",void 0),t([r()],j.prototype,"computedPosition",void 0),t([r()],j.prototype,"smallViewport",void 0),t([n({reflect:!0})],j.prototype,"id",void 0),t([n({reflect:!0})],j.prototype,"anchor",void 0),t([w("id")],j.prototype,"handleIdChange",null),t([w("open")],j.prototype,"handleOpenChange",null),j=t([e("nord-popout")],j);var S=j;export{E as F,S as P};
|
|
2
|
+
//# sourceMappingURL=Popout-4aa0cc87.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Popout-4aa0cc87.js","sources":["../src/common/mixins/FloatingComponentMixin.ts","../src/popout/Popout.ts"],"sourcesContent":["/* eslint-disable max-classes-per-file */\nimport { LitElement } from \"lit\"\nimport { property } from \"lit/decorators.js\"\nimport { Alignment } from \"@floating-ui/dom\"\nimport { LogicalSide } from \"../positioning.js\"\n\ntype Constructor<T = Record<string, unknown>> = new (...args: any[]) => T\n\nexport declare class FloatingMixinInterface {\n open: boolean\n align: Alignment\n position: LogicalSide\n}\n\nexport function FloatingMixin<T extends Constructor<LitElement>>(\n superClass: T\n): Constructor<FloatingMixinInterface> & T {\n class FloatingElement extends superClass {\n /**\n * Controls whether the component is open or not.\n */\n @property({ type: Boolean, reflect: true }) open = false\n\n /**\n * Set the alignment in relation to the toggle (or anchor) depending on the position.\n * `start` will align it to the left of the toggle (or anchor).\n * `end` will align it to the right of the toggle (or anchor).\n * Setting the `position` to `inline-start` or `inline-end` will switch\n * `start` and `end` to the top and bottom respectively.\n */\n @property({ reflect: true }) align: \"start\" | \"end\" = \"start\"\n\n /**\n * Set the position in relation to the toggle (or anchor).\n * Options follow logical properties.\n * `block-start` and `block-end` referring to top and bottom respectively,\n * `inline-start` and `inline-end` referring to left and right respectively.\n */\n @property({ reflect: true }) position: \"block-end\" | \"block-start\" | \"inline-start\" | \"inline-end\" = \"block-end\"\n }\n\n return FloatingElement\n}\n","import { LitElement, html } from \"lit\"\nimport { customElement, property, query, state } from \"lit/decorators.js\"\nimport { computePosition, shift, offset, flip, hide, autoUpdate, Placement } from \"@floating-ui/dom\"\nimport { LightDismissController } from \"../common/controllers/LightDismissController.js\"\nimport { ScrollbarController } from \"../common/controllers/ScrollbarController.js\"\nimport { NordEvent } from \"../common/events.js\"\nimport { FloatingMixin } from \"../common/mixins/FloatingComponentMixin.js\"\n\nimport componentStyle from \"../common/styles/Component.css\"\nimport style from \"./Popout.css\"\nimport { logicalToPhysical } from \"../common/positioning.js\"\nimport { DirectionController } from \"../common/controllers/DirectionController.js\"\nimport { observe } from \"../common/decorators/observe.js\"\nimport { EventController } from \"../common/controllers/EventController.js\"\n\n/*\n * The breakpoint width to switch between \"sheet\" design and floating design\n */\nconst mediaQuery = matchMedia(\"(max-width: 35.9375em)\")\n\n/**\n * Popouts are small overlays that open on demand. They let users access additional content and actions without cluttering the page.\n *\n * @status ready\n * @category overlay\n * @slot - The popout content.\n */\n@customElement(\"nord-popout\")\nexport default class Popout extends FloatingMixin(LitElement) {\n static styles = [componentStyle, style]\n\n private targetElement!: HTMLElement\n private anchorElement!: Element\n private cleanupAutoUpdate?: ReturnType<typeof autoUpdate>\n\n @query(\".n-popout\", true) private popout!: HTMLDivElement\n\n private scrollBar = new ScrollbarController(this)\n\n /**\n * Handle dismissal of the popout, clicking outside the target button and popout.\n */\n private dismiss = new LightDismissController(this, {\n isOpen: () => this.open,\n onDismiss: e => this.hide(e.type !== \"click\"),\n isDismissible: node => node !== this.popout && node !== this.targetElement,\n })\n\n private events = new EventController(this)\n private direction = new DirectionController(this)\n\n @state() private computedPosition?: Placement\n\n @state() private smallViewport = mediaQuery.matches\n\n /**\n * The id for the active element to reference via aria-controls.\n */\n @property({ reflect: true }) id: string = \"\"\n\n /**\n * Set an optional anchor element to align against, replacing the triggering element.\n */\n @property({ reflect: true }) anchor?: string\n\n /**\n * Show the popout, moving focus to the calendar inside.\n */\n show() {\n if (this.open) {\n return\n }\n\n this.open = true\n\n // we should only focus once the popout is visible after render is complete\n this.updateComplete.then(() => {\n /**\n * Dispatched when the popout is opened.\n */\n this.dispatchEvent(new NordEvent(\"open\"))\n })\n }\n\n /**\n * Hide the popout.\n * @param {boolean} moveFocusToButton prevent focus returning to the target\n * button. Default is true.\n */\n hide(moveFocusToButton = true) {\n if (!this.open) {\n return\n }\n\n this.open = false\n\n this.cleanupAutoUpdate?.()\n\n /**\n * Dispatched when the popout is closed.\n */\n this.dispatchEvent(new NordEvent(\"close\"))\n\n if (moveFocusToButton) {\n this.targetElement.focus({ preventScroll: true })\n }\n }\n\n /**\n * Position the popout on load.\n */\n firstUpdated() {\n if (!this.smallViewport) {\n this.updatePosition()\n }\n }\n\n connectedCallback() {\n super.connectedCallback()\n\n this.targetElement = this.getToggle()\n this.anchorElement = this.anchor ? this.getAnchor() : this.targetElement\n\n this.events.listen(this.targetElement, \"click\", this.toggleOpen)\n this.events.listen(mediaQuery, \"change\", this.handleMediaQueryChange)\n }\n\n disconnectedCallback() {\n super.disconnectedCallback()\n\n this.cleanupAutoUpdate?.()\n this.targetElement.removeAttribute(\"aria-expanded\")\n }\n\n render() {\n return html`\n <div\n class=\"n-popout ${this.computedPosition} is-${this.direction.dir}\"\n aria-hidden=${this.open ? \"false\" : \"true\"}\n @transitionend=${this.enableScroll}\n >\n <slot></slot>\n </div>\n `\n }\n\n @observe(\"id\")\n protected handleIdChange() {\n if (!this.id) {\n // eslint-disable-next-line no-console\n console.warn(\"NORD: popout requires an id attribute and value\")\n }\n }\n\n @observe(\"open\")\n protected handleOpenChange() {\n this.targetElement.setAttribute(\"aria-expanded\", `${this.open}`)\n\n if (this.open) {\n if (this.smallViewport) {\n // hide scrollbar and prevent scroll on body\n this.scrollBar.lockScroll()\n } else {\n this.cleanupAutoUpdate = autoUpdate(this.anchorElement, this, this.updatePosition)\n }\n } else {\n this.cleanupAutoUpdate?.()\n }\n }\n\n private enableScroll = () => {\n // scrollbar should only be restored when the backdrop has transitioned\n // that way we avoid awkward double scrollbars.\n if (!this.open) {\n this.scrollBar.unlockScroll()\n }\n }\n\n /**\n * Get the position of the element toggling the popout\n * and position the popout underneath it, taking into account the optional placement.\n */\n private updatePosition = async () => {\n const { x, y, placement, middlewareData } = await computePosition(this.anchorElement, this, {\n strategy: \"fixed\",\n placement: logicalToPhysical(this.position, this.align, this.direction.dir),\n middleware: [\n offset(8),\n flip(),\n shift({\n padding: 8,\n }),\n hide(),\n ],\n })\n\n this.computedPosition = placement\n\n // use physical properties here since floating-ui\n // works exclusively in physical dimensions\n // we do all the mapping in logicalToPhysical\n this.style.setProperty(\"--_n-popout-position-x\", `${x}px`)\n this.style.setProperty(\"--_n-popout-position-y\", `${y}px`)\n\n if (middlewareData.hide?.referenceHidden) {\n this.hide()\n }\n }\n\n /**\n * Toggle the popout open or closed using state.\n * Updating the position to underneath the target button before the popout is opened.\n */\n private toggleOpen = (e: Event) => {\n e.preventDefault()\n if (this.open) {\n this.hide(false)\n } else if (!this.smallViewport) {\n this.updatePosition().then(() => this.show())\n } else {\n this.show()\n }\n }\n\n private getToggle() {\n const rootNode = this.getRootNode() as Document | ShadowRoot\n const toggle = <HTMLElement>rootNode.querySelector(`[aria-controls='${this.id}']`)\n\n if (toggle instanceof HTMLSlotElement) {\n return toggle.assignedElements()[0] as HTMLElement\n }\n\n return toggle\n }\n\n private getAnchor() {\n const rootNode = this.getRootNode() as Document | ShadowRoot\n const anchor = <HTMLElement>rootNode.querySelector(`#${this.anchor}`)\n\n if (anchor instanceof HTMLSlotElement) {\n return anchor.assignedElements()[0] as HTMLElement\n }\n\n return anchor\n }\n\n /**\n * Update the smallViewport flag to switch between \"sheet\" and \"floating\".\n * autoUpdate is needed when a viewport gets larger and the popout is open.\n */\n private handleMediaQueryChange = () => {\n this.smallViewport = mediaQuery.matches\n\n this.cleanupAutoUpdate?.()\n\n if (!this.smallViewport && this.open) {\n this.cleanupAutoUpdate = autoUpdate(this.anchorElement, this, this.updatePosition)\n this.scrollBar.unlockScroll()\n } else if (this.open) {\n this.scrollBar.lockScroll()\n }\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"nord-popout\": Popout\n }\n}\n"],"names":["FloatingMixin","superClass","FloatingElement","constructor","this","open","align","position","__decorate","property","type","Boolean","reflect","prototype","mediaQuery","matchMedia","Popout","LitElement","scrollBar","ScrollbarController","dismiss","LightDismissController","isOpen","onDismiss","e","hide","isDismissible","node","popout","targetElement","events","EventController","direction","DirectionController","smallViewport","matches","id","enableScroll","unlockScroll","updatePosition","async","x","y","placement","middlewareData","computePosition","anchorElement","strategy","logicalToPhysical","dir","middleware","offset","flip","shift","padding","computedPosition","style","setProperty","_a","referenceHidden","toggleOpen","preventDefault","show","then","handleMediaQueryChange","cleanupAutoUpdate","call","autoUpdate","lockScroll","updateComplete","dispatchEvent","NordEvent","moveFocusToButton","focus","preventScroll","firstUpdated","connectedCallback","super","getToggle","anchor","getAnchor","listen","disconnectedCallback","removeAttribute","render","html","handleIdChange","console","warn","handleOpenChange","setAttribute","toggle","getRootNode","querySelector","HTMLSlotElement","assignedElements","styles","componentStyle","query","state","observe","customElement"],"mappings":"4pBAcM,SAAUA,EACdC,GAEA,MAAMC,UAAwBD,EAA9BE,kCAI8CC,KAAIC,MAAG,EAStBD,KAAKE,MAAoB,QAQzBF,KAAQG,SAAgE,WACtG,EAED,OApB8CC,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"}
|
package/lib/Popout.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"./query-assigned-elements-e6cbac30.js";import"./lit-element-9178eae5.js";import"./property-03f59dce.js";import"./state-70f38ceb.js";import"./query-2d22378e.js";import"./positioning-3bbd3548.js";import"./LightDismissController-a2645ae6.js";import"./ScrollbarController-
|
|
1
|
+
import"./query-assigned-elements-e6cbac30.js";import"./lit-element-9178eae5.js";import"./property-03f59dce.js";import"./state-70f38ceb.js";import"./query-2d22378e.js";import"./positioning-3bbd3548.js";import"./LightDismissController-a2645ae6.js";import"./ScrollbarController-773c79f4.js";import"./events-731d0007.js";export{P as default}from"./Popout-4aa0cc87.js";import"./Component-92eb6234.js";import"./DirectionController-8b298382.js";import"./observe-a9c6dfb6.js";import"./EventController-d99ebeef.js";import"./ShortcutController-87615e31.js";import"./tinykeys.module-84e6cc41.js";
|
|
2
2
|
//# sourceMappingURL=Popout.js.map
|
package/lib/Radio.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{_ as e,e as t}from"./query-assigned-elements-e6cbac30.js";import{b as o,i as n,y as i,s as r}from"./lit-element-9178eae5.js";import{e as a}from"./property-03f59dce.js";import{n as s}from"./ref-0e619221.js";import{L as l}from"./LightDomController-3c726b20.js";import{S as d}from"./SlotController-89834aef.js";import{o as c}from"./observe-a9c6dfb6.js";import{c as h}from"./cond-338158e9.js";import{F as p}from"./FocusableMixin-34870ed3.js";import{F as m}from"./FormAssociatedMixin-
|
|
1
|
+
import{_ as e,e as t}from"./query-assigned-elements-e6cbac30.js";import{b as o,i as n,y as i,s as r}from"./lit-element-9178eae5.js";import{e as a}from"./property-03f59dce.js";import{n as s}from"./ref-0e619221.js";import{L as l}from"./LightDomController-3c726b20.js";import{S as d}from"./SlotController-89834aef.js";import{o as c}from"./observe-a9c6dfb6.js";import{c as h}from"./cond-338158e9.js";import{F as p}from"./FocusableMixin-34870ed3.js";import{F as m}from"./FormAssociatedMixin-aa74901e.js";import{I as u}from"./InputMixin-158f63fb.js";import{s as v}from"./Component-92eb6234.js";import{s as b}from"./FormField-ae3570d2.js";import"./directive-de55b00a.js";import"./EventController-d99ebeef.js";import"./events-731d0007.js";import"./VisuallyHidden.js";class g extends d{constructor(e,t){super(e,t.slotName),this.options=t,this.onChange=()=>{this.syncLightDom()},this.renderHook=document.createComment(this.slotName),this.lightDom=new l(e,{render:()=>this.hasContent?o:this.options.render(),renderOptions:{renderBefore:this.renderHook}})}hostConnected(){super.hostConnected(),this.host.appendChild(this.renderHook),this.syncLightDom()}hostDisconnected(){this.renderHook.remove()}syncLightDom(){const e=this.content;e&&this.options.syncLightDom(e)}}const f=n`:host{--_n-radio-size:calc(var(--n-space-m) * 1.25);display:inline-block;line-height:var(--n-line-height)}.n-flex{display:flex}.n-expand{flex:1}.n-input-container{position:relative}::slotted(input){--_n-radio-accent-color:var(--n-color-accent);-moz-appearance:none;-webkit-appearance:none;appearance:none;margin:0!important;padding:0!important;border:1px solid var(--_n-radio-border-color,var(--n-color-border-hover))!important;border-radius:var(--n-border-radius-circle)!important;transition:none!important;display:block!important;inline-size:var(--_n-radio-size)!important;block-size:var(--_n-radio-size)!important;cursor:pointer}::slotted(input:checked){--_n-radio-border-color:var(--n-color-accent);background:var(--_n-radio-accent-color)!important}::slotted(input[aria-invalid]){--_n-radio-accent-color:var(--n-color-status-danger);--_n-radio-border-color:var(--_n-radio-accent-color)}::slotted(input:active){opacity:.8}::slotted(input:focus-visible){outline:0!important}::slotted(input:focus){outline:0!important;box-shadow:0 0 0 1px var(--n-color-surface),0 0 0 3px var(--n-color-accent)!important}:host([disabled]) ::slotted(input){--_n-radio-accent-color:var(--n-color-border-strong);--_n-radio-border-color:var(--_n-radio-accent-color);background:var(--_n-radio-accent-color);cursor:default;opacity:1}:host([disabled]) ::slotted(label){color:var(--n-color-text-weaker);cursor:default}.n-dot{--_n-radio-dot-size:var(--n-space-s);--_n-radio-dot-inset:calc((var(--_n-radio-size) - var(--_n-radio-dot-size)) / 2);position:absolute;border-radius:var(--n-border-radius-circle);inline-size:var(--_n-radio-dot-size);block-size:var(--_n-radio-dot-size);background-color:var(--n-color-text-on-accent);inset-inline-start:var(--_n-radio-dot-inset);inset-block-start:var(--_n-radio-dot-inset);z-index:var(--n-index-default);pointer-events:none}.n-label-container{margin-block-end:0}::slotted(label){-webkit-user-select:none;user-select:none;font-weight:var(--n-font-weight)!important;line-height:var(--n-line-height-l)!important;padding-inline-start:var(--n-space-s)!important;cursor:pointer}.n-hint{padding-inline-start:var(--n-space-s)}.n-error{margin-block-start:calc(var(--n-space-s)/ 2);padding-inline-start:var(--n-space-s)}`;let k=0;const $=e=>`nord-radio-${e}-${k++}`;let y=class extends(m(u(p(r)))){constructor(){super(...arguments),this.inputId=$("input"),this.hintId=$("hint"),this.errorId=$("error"),this.hintSlot=new g(this,{slotName:"hint",render:()=>this.hint?i`<div slot="hint-internal" id="${this.hintId}">${this.hint}</div>`:o,syncLightDom:e=>{e.id=this.hintId}}),this.labelSlot=new g(this,{slotName:"label",render:()=>this.label?i`<label slot="label-internal" for="${this.inputId}">${this.label}</label>`:o,syncLightDom:e=>{!function(e){return"label"===e.localName}(e)?console.warn('NORD: Only <label> elements should be placed in radio\'s "label" slot'):e.htmlFor=this.inputId}}),this.errorSlot=new g(this,{slotName:"error",render:()=>this.error?i`<div slot="error-internal" id="${this.errorId}">${this.error}</div>`:o,syncLightDom:e=>{e.id=this.hintId}}),this.inputSlot=new l(this,{render:()=>i`<input slot="input" @blur="${this.handleBlur}" @focus="${this.handleFocus}" ${s(this.focusableRef)} class="n-input" id="${this.inputId}" type="radio" name="${h(this.name)}" .value="${h(this.value)}" .checked="${this.checked}" ?disabled="${this.disabled}" ?required="${this.required}" aria-describedby="${h(this.getDescribedBy())}" aria-invalid="${h(this.getInvalid())}" form="${h(this.getAttribute("form")||void 0)}">`}),this.checked=!1,this.handleBlur=e=>{e.stopPropagation(),this.dispatchEvent(new Event("blur",{bubbles:!1,cancelable:!0}))},this.handleFocus=e=>{e.stopPropagation(),this.dispatchEvent(new Event("focus",{bubbles:!1,cancelable:!0}))}}get formValue(){}render(){return i`<div class="n-flex"><div class="n-input-container" @change="${this.handleChange}"><slot name="input"></slot>${this.checked?i`<div class="n-dot"></div>`:o}</div><div class="n-expand"><div class="n-label-container">${e=this.hideLabel,t=()=>i`<slot name="label"></slot><slot name="label-internal"></slot>`,n=e=>i`<nord-visually-hidden>${e}</nord-visually-hidden>`,e?n(t()):t()}<div class="n-caption n-hint" ?hidden="${!this.hasHint}"><slot name="hint"></slot><slot name="hint-internal"></slot></div></div><div class="n-caption n-error" role="alert" ?hidden="${!this.hasError}"><slot name="error"></slot><slot name="error-internal"></slot></div></div></div>`;var e,t,n}handleCheckedChange(e){!e&&this.checked&&this.uncheckSiblings()}uncheckSiblings(){this.getRootNode().querySelectorAll(`nord-radio[name="${this.name}"]`).forEach((e=>{e!==this&&(e.checked=!1)}))}handleChange(e){e.stopPropagation();const t=e.target;this.checked=t.checked,super.handleChange(e)}};y.styles=[v,b,f],e([a({type:Boolean,reflect:!0})],y.prototype,"checked",void 0),e([c("checked")],y.prototype,"handleCheckedChange",null),y=e([t("nord-radio")],y);var _=y;export{_ as default};
|
|
2
2
|
//# sourceMappingURL=Radio.js.map
|
package/lib/Radio.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Radio.js","sources":["../src/common/controllers/LightSlotController.ts","../src/radio/Radio.ts","../src/common/directives/wrapIf.ts"],"sourcesContent":["import { nothing, ReactiveControllerHost } from \"lit\"\nimport { LightDomController } from \"./LightDomController.js\"\nimport { SlotController } from \"./SlotController.js\"\n\ntype LightSlotOptions = {\n slotName: string\n render: () => unknown\n syncLightDom: (element: Element) => void\n}\n\n/**\n * Handles cases where a component needs to render to light DOM,\n * and potentially sync component properties to user-supplied content.\n */\nexport class LightSlotController extends SlotController {\n private renderHook: Comment\n private lightDom: LightDomController\n\n constructor(host: ReactiveControllerHost & HTMLElement, private options: LightSlotOptions) {\n super(host, options.slotName)\n\n // we need a node to hook onto for rendering\n // without this, multiple controllers rendering to the light DOM\n // will overwrite each others' content\n this.renderHook = document.createComment(this.slotName)\n\n this.lightDom = new LightDomController(host, {\n render: () => (this.hasContent ? nothing : this.options.render()),\n renderOptions: { renderBefore: this.renderHook },\n })\n }\n\n hostConnected() {\n super.hostConnected()\n this.host.appendChild(this.renderHook)\n this.syncLightDom()\n }\n\n hostDisconnected() {\n this.renderHook.remove()\n }\n\n protected override onChange = () => {\n this.syncLightDom()\n }\n\n private syncLightDom() {\n const node = this.content\n\n if (node) {\n this.options.syncLightDom(node)\n }\n }\n}\n","import { html, LitElement, nothing } from \"lit\"\nimport { customElement, property } from \"lit/decorators.js\"\nimport { ref } from \"lit/directives/ref.js\"\nimport { LightDomController } from \"../common/controllers/LightDomController.js\"\nimport { LightSlotController } from \"../common/controllers/LightSlotController.js\"\nimport { observe } from \"../common/decorators/observe.js\"\nimport { cond } from \"../common/directives/cond.js\"\nimport { wrapIf } from \"../common/directives/wrapIf.js\"\n\nimport { FocusableMixin } from \"../common/mixins/FocusableMixin.js\"\nimport { FormAssociatedMixin } from \"../common/mixins/FormAssociatedMixin.js\"\nimport { InputMixin } from \"../common/mixins/InputMixin.js\"\n\nimport componentStyle from \"../common/styles/Component.css\"\nimport formFieldStyle from \"../common/styles/FormField.css\"\nimport style from \"./Radio.css\"\n\nlet id = 0\nconst createId = (suffix: string) => `nord-radio-${suffix}-${id++}`\n\nfunction isLabel(element: Element): element is HTMLLabelElement {\n return element.localName === \"label\"\n}\n\n/**\n * Radio buttons are graphical user interface elements that allow user to choose only one option from\n * a predefined set of mutually exclusive options.\n *\n * @status ready\n * @category form\n * @slot label - Use when a label requires more than plain text.\n * @slot hint - Optional slot that holds hint text for the input.\n * @slot error - Optional slot that holds error text for the input.\n */\n@customElement(\"nord-radio\")\nexport default class Radio extends FormAssociatedMixin(InputMixin(FocusableMixin(LitElement))) {\n static styles = [componentStyle, formFieldStyle, style]\n\n protected override inputId = createId(\"input\")\n protected override hintId = createId(\"hint\")\n protected override errorId = createId(\"error\")\n\n /**\n * For accessibility reasons, we render some parts of the component to the light DOM.\n */\n protected override hintSlot = new LightSlotController(this, {\n slotName: \"hint\",\n render: () => (this.hint ? html`<div slot=\"hint-internal\" id=${this.hintId}>${this.hint}</div>` : nothing),\n syncLightDom: element => {\n element.id = this.hintId\n },\n })\n\n protected override labelSlot = new LightSlotController(this, {\n slotName: \"label\",\n render: () => (this.label ? html`<label slot=\"label-internal\" for=${this.inputId}>${this.label}</label>` : nothing),\n syncLightDom: element => {\n if (!isLabel(element)) {\n // eslint-disable-next-line no-console\n console.warn(`NORD: Only <label> elements should be placed in radio's \"label\" slot`)\n } else {\n element.htmlFor = this.inputId\n }\n },\n })\n\n protected override errorSlot = new LightSlotController(this, {\n slotName: \"error\",\n render: () => (this.error ? html`<div slot=\"error-internal\" id=${this.errorId}>${this.error}</div>` : nothing),\n syncLightDom: element => {\n element.id = this.hintId\n },\n })\n\n protected inputSlot = new LightDomController(this, {\n render: () =>\n html`\n <input\n slot=\"input\"\n @blur=${this.handleBlur}\n @focus=${this.handleFocus}\n ${ref(this.focusableRef)}\n class=\"n-input\"\n id=${this.inputId}\n type=\"radio\"\n name=${cond(this.name)}\n .value=${cond(this.value)}\n .checked=${this.checked}\n ?disabled=${this.disabled}\n ?required=${this.required}\n aria-describedby=${cond(this.getDescribedBy())}\n aria-invalid=${cond(this.getInvalid())}\n form=${cond(this.getAttribute(\"form\") || undefined)}\n />\n `,\n })\n\n // eslint-disable-next-line class-methods-use-this\n protected override get formValue() {\n // opt out of formdata event, since radio button is in light dom\n return undefined\n }\n\n /**\n * Controls whether the checkbox is checked or not.\n */\n @property({ type: Boolean, reflect: true }) checked: boolean = false\n\n render() {\n return html`\n <div class=\"n-flex\">\n <div class=\"n-input-container\" @change=${this.handleChange}>\n <slot name=\"input\"></slot>\n ${this.checked ? html`<div class=\"n-dot\"></div>` : nothing}\n </div>\n <div class=\"n-expand\">\n <div class=\"n-label-container\">\n ${wrapIf(\n this.hideLabel,\n () => html`\n <slot name=\"label\"></slot>\n <slot name=\"label-internal\"></slot>\n `,\n content => html`<nord-visually-hidden>${content}</nord-visually-hidden>`\n )}\n <div class=\"n-caption n-hint\" ?hidden=${!this.hasHint}>\n <slot name=\"hint\"></slot>\n <slot name=\"hint-internal\"></slot>\n </div>\n </div>\n <div class=\"n-caption n-error\" role=\"alert\" ?hidden=${!this.hasError}>\n <slot name=\"error\"></slot>\n <slot name=\"error-internal\"></slot>\n </div>\n </div>\n </div>\n `\n }\n\n @observe(\"checked\")\n protected handleCheckedChange(previousChecked: boolean) {\n // if this component was previous unchecked but is now checked,\n // then we need to uncheck any radios in the same group\n if (!previousChecked && this.checked) {\n this.uncheckSiblings()\n }\n }\n\n private uncheckSiblings() {\n const root = this.getRootNode() as Document | ShadowRoot\n\n root.querySelectorAll<Radio>(`nord-radio[name=\"${this.name}\"]`).forEach(radio => {\n if (radio !== this) {\n radio.checked = false\n }\n })\n }\n\n protected handleChange(e: Event): void {\n e.stopPropagation()\n const target = e.target as HTMLInputElement\n\n this.checked = target.checked\n super.handleChange(e)\n }\n\n private handleBlur = (e: Event) => {\n e.stopPropagation()\n this.dispatchEvent(new Event(\"blur\", { bubbles: false, cancelable: true }))\n }\n\n private handleFocus = (e: Event) => {\n e.stopPropagation()\n this.dispatchEvent(new Event(\"focus\", { bubbles: false, cancelable: true }))\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"nord-radio\": Radio\n }\n}\n","// some clever typing so that TS knows what happens if you pass true/false values\nexport function wrapIf<TInner, TWrapper>(\n condition: false,\n inner: () => TInner,\n wrapper: (inner: TInner) => TWrapper\n): TInner\nexport function wrapIf<TInner, TWrapper>(\n condition: true,\n inner: () => TInner,\n wrapper: (inner: TInner) => TWrapper\n): TWrapper\nexport function wrapIf<TInner, TWrapper>(\n condition: unknown,\n inner: () => TInner,\n wrapper: (inner: TInner) => TWrapper\n): TInner | TWrapper\n\n/**\n * @returns if condition is truthy, return result of wrapper, passing result of inner as arg. if falsy, return result of inner\n */\nexport function wrapIf<TInner, TWrapper>(condition: any, inner: () => TInner, wrapper: (innards: TInner) => TWrapper) {\n return condition ? wrapper(inner()) : inner()\n}\n"],"names":["LightSlotController","SlotController","constructor","host","options","super","slotName","this","onChange","syncLightDom","renderHook","document","createComment","lightDom","LightDomController","render","hasContent","nothing","renderOptions","renderBefore","hostConnected","appendChild","hostDisconnected","remove","node","content","id","createId","suffix","Radio","FormAssociatedMixin","InputMixin","FocusableMixin","LitElement","inputId","hintId","errorId","hintSlot","hint","html","element","labelSlot","label","localName","isLabel","console","warn","htmlFor","errorSlot","error","inputSlot","handleBlur","handleFocus","ref","focusableRef","cond","name","value","checked","disabled","required","getDescribedBy","getInvalid","getAttribute","undefined","e","stopPropagation","dispatchEvent","Event","bubbles","cancelable","formValue","handleChange","condition","hideLabel","inner","wrapper","hasHint","hasError","handleCheckedChange","previousChecked","uncheckSiblings","getRootNode","querySelectorAll","forEach","radio","target","styles","componentStyle","formFieldStyle","style","__decorate","property","type","Boolean","reflect","prototype","observe","customElement"],"mappings":"uvBAcM,MAAOA,UAA4BC,EAIvCC,YAAYC,EAAoDC,GAC9DC,MAAMF,EAAMC,EAAQE,UAD0CC,KAAOH,QAAPA,EAwB7CG,KAAQC,SAAG,KAC5BD,KAAKE,cAAc,EAnBnBF,KAAKG,WAAaC,SAASC,cAAcL,KAAKD,UAE9CC,KAAKM,SAAW,IAAIC,EAAmBX,EAAM,CAC3CY,OAAQ,IAAOR,KAAKS,WAAaC,EAAUV,KAAKH,QAAQW,SACxDG,cAAe,CAAEC,aAAcZ,KAAKG,aAEvC,CAEDU,gBACEf,MAAMe,gBACNb,KAAKJ,KAAKkB,YAAYd,KAAKG,YAC3BH,KAAKE,cACN,CAEDa,mBACEf,KAAKG,WAAWa,QACjB,CAMOd,eACN,MAAMe,EAAOjB,KAAKkB,QAEdD,GACFjB,KAAKH,QAAQK,aAAae,EAE7B,ksEC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cAAWC,SAcLzD,KAAOmD,SAAY,EA4DvDnD,KAAA4C,WAAcc,IACpBA,EAAEC,kBACF3D,KAAK4D,cAAc,IAAIC,MAAM,OAAQ,CAAEC,SAAS,EAAOC,YAAY,IAAQ,EAGrE/D,KAAA6C,YAAea,IACrBA,EAAEC,kBACF3D,KAAK4D,cAAc,IAAIC,MAAM,QAAS,CAAEC,SAAS,EAAOC,YAAY,IAAQ,CAE/E,CA7EwBC,gBAGtB,CAODxD,SACE,OAAOwB,CAAI,+DAEkChC,KAAKiE,2CAE1CjE,KAAKmD,QAAUnB,CAAI,4BAA8BtB,+DC7FpBwD,EDkG3BlE,KAAKmE,UClGsCC,EDmG3C,IAAMpC,CAAI,gECnGsDqC,EDuGhEnD,GAAWc,CAAI,yBAAyBd,2BCtG7CgD,EAAYG,EAAQD,KAAWA,8CDwGapE,KAAKsE,yIAKOtE,KAAKuE,gGC9G7BL,EAAgBE,EAAqBC,CDqH3E,CAGSG,oBAAoBC,IAGvBA,GAAmBzE,KAAKmD,SAC3BnD,KAAK0E,iBAER,CAEOA,kBACO1E,KAAK2E,cAEbC,iBAAwB,oBAAoB5E,KAAKiD,UAAU4B,SAAQC,IAClEA,IAAU9E,OACZ8E,EAAM3B,SAAU,EACjB,GAEJ,CAESc,aAAaP,GACrBA,EAAEC,kBACF,MAAMoB,EAASrB,EAAEqB,OAEjB/E,KAAKmD,QAAU4B,EAAO5B,QACtBrD,MAAMmE,aAAaP,EACpB,GAhIMpC,EAAM0D,OAAG,CAACC,EAAgBC,EAAgBC,GAsELC,EAAA,CAA3CC,EAAS,CAAEC,KAAMC,QAASC,SAAS,KAAgClE,EAAAmE,UAAA,eAAA,GAkCpEL,EAAA,CADCM,EAAQ,YAORpE,EAAAmE,UAAA,sBAAA,MA/GkBnE,EAAK8D,EAAA,CADzBO,EAAc,eACMrE,SAAAA"}
|
|
1
|
+
{"version":3,"file":"Radio.js","sources":["../src/common/controllers/LightSlotController.ts","../src/radio/Radio.ts","../src/common/directives/wrapIf.ts"],"sourcesContent":["import { nothing, ReactiveControllerHost } from \"lit\"\nimport { LightDomController } from \"./LightDomController.js\"\nimport { SlotController } from \"./SlotController.js\"\n\ntype LightSlotOptions = {\n slotName: string\n render: () => unknown\n syncLightDom: (element: Element) => void\n}\n\n/**\n * Handles cases where a component needs to render to light DOM,\n * and potentially sync component properties to user-supplied content.\n */\nexport class LightSlotController extends SlotController {\n private renderHook: Comment\n private lightDom: LightDomController\n\n constructor(host: ReactiveControllerHost & HTMLElement, private options: LightSlotOptions) {\n super(host, options.slotName)\n\n // we need a node to hook onto for rendering\n // without this, multiple controllers rendering to the light DOM\n // will overwrite each others' content\n this.renderHook = document.createComment(this.slotName)\n\n this.lightDom = new LightDomController(host, {\n render: () => (this.hasContent ? nothing : this.options.render()),\n renderOptions: { renderBefore: this.renderHook },\n })\n }\n\n hostConnected() {\n super.hostConnected()\n this.host.appendChild(this.renderHook)\n this.syncLightDom()\n }\n\n hostDisconnected() {\n this.renderHook.remove()\n }\n\n protected override onChange = () => {\n this.syncLightDom()\n }\n\n private syncLightDom() {\n const node = this.content\n\n if (node) {\n this.options.syncLightDom(node)\n }\n }\n}\n","import { html, LitElement, nothing } from \"lit\"\nimport { customElement, property } from \"lit/decorators.js\"\nimport { ref } from \"lit/directives/ref.js\"\nimport { LightDomController } from \"../common/controllers/LightDomController.js\"\nimport { LightSlotController } from \"../common/controllers/LightSlotController.js\"\nimport { observe } from \"../common/decorators/observe.js\"\nimport { cond } from \"../common/directives/cond.js\"\nimport { wrapIf } from \"../common/directives/wrapIf.js\"\n\nimport { FocusableMixin } from \"../common/mixins/FocusableMixin.js\"\nimport { FormAssociatedMixin } from \"../common/mixins/FormAssociatedMixin.js\"\nimport { InputMixin } from \"../common/mixins/InputMixin.js\"\n\nimport componentStyle from \"../common/styles/Component.css\"\nimport formFieldStyle from \"../common/styles/FormField.css\"\nimport style from \"./Radio.css\"\n\nlet id = 0\nconst createId = (suffix: string) => `nord-radio-${suffix}-${id++}`\n\nfunction isLabel(element: Element): element is HTMLLabelElement {\n return element.localName === \"label\"\n}\n\n/**\n * Radio buttons are graphical user interface elements that allow user to choose only one option from\n * a predefined set of mutually exclusive options.\n *\n * @status ready\n * @category form\n * @slot label - Use when a label requires more than plain text.\n * @slot hint - Optional slot that holds hint text for the input.\n * @slot error - Optional slot that holds error text for the input.\n */\n@customElement(\"nord-radio\")\nexport default class Radio extends FormAssociatedMixin(InputMixin(FocusableMixin(LitElement))) {\n static styles = [componentStyle, formFieldStyle, style]\n\n protected override inputId = createId(\"input\")\n protected override hintId = createId(\"hint\")\n protected override errorId = createId(\"error\")\n\n /**\n * For accessibility reasons, we render some parts of the component to the light DOM.\n */\n protected override hintSlot = new LightSlotController(this, {\n slotName: \"hint\",\n render: () => (this.hint ? html`<div slot=\"hint-internal\" id=${this.hintId}>${this.hint}</div>` : nothing),\n syncLightDom: element => {\n element.id = this.hintId\n },\n })\n\n protected override labelSlot = new LightSlotController(this, {\n slotName: \"label\",\n render: () => (this.label ? html`<label slot=\"label-internal\" for=${this.inputId}>${this.label}</label>` : nothing),\n syncLightDom: element => {\n if (!isLabel(element)) {\n // eslint-disable-next-line no-console\n console.warn(`NORD: Only <label> elements should be placed in radio's \"label\" slot`)\n } else {\n element.htmlFor = this.inputId\n }\n },\n })\n\n protected override errorSlot = new LightSlotController(this, {\n slotName: \"error\",\n render: () => (this.error ? html`<div slot=\"error-internal\" id=${this.errorId}>${this.error}</div>` : nothing),\n syncLightDom: element => {\n element.id = this.hintId\n },\n })\n\n protected inputSlot = new LightDomController(this, {\n render: () =>\n html`\n <input\n slot=\"input\"\n @blur=${this.handleBlur}\n @focus=${this.handleFocus}\n ${ref(this.focusableRef)}\n class=\"n-input\"\n id=${this.inputId}\n type=\"radio\"\n name=${cond(this.name)}\n .value=${cond(this.value)}\n .checked=${this.checked}\n ?disabled=${this.disabled}\n ?required=${this.required}\n aria-describedby=${cond(this.getDescribedBy())}\n aria-invalid=${cond(this.getInvalid())}\n form=${cond(this.getAttribute(\"form\") || undefined)}\n />\n `,\n })\n\n // eslint-disable-next-line class-methods-use-this\n protected override get formValue() {\n // opt out of formdata event, since radio button is in light dom\n return undefined\n }\n\n /**\n * Controls whether the checkbox is checked or not.\n */\n @property({ type: Boolean, reflect: true }) checked: boolean = false\n\n render() {\n return html`\n <div class=\"n-flex\">\n <div class=\"n-input-container\" @change=${this.handleChange}>\n <slot name=\"input\"></slot>\n ${this.checked ? html`<div class=\"n-dot\"></div>` : nothing}\n </div>\n <div class=\"n-expand\">\n <div class=\"n-label-container\">\n ${wrapIf(\n this.hideLabel,\n () => html`\n <slot name=\"label\"></slot>\n <slot name=\"label-internal\"></slot>\n `,\n content => html`<nord-visually-hidden>${content}</nord-visually-hidden>`\n )}\n <div class=\"n-caption n-hint\" ?hidden=${!this.hasHint}>\n <slot name=\"hint\"></slot>\n <slot name=\"hint-internal\"></slot>\n </div>\n </div>\n <div class=\"n-caption n-error\" role=\"alert\" ?hidden=${!this.hasError}>\n <slot name=\"error\"></slot>\n <slot name=\"error-internal\"></slot>\n </div>\n </div>\n </div>\n `\n }\n\n @observe(\"checked\")\n protected handleCheckedChange(previousChecked: boolean) {\n // if this component was previous unchecked but is now checked,\n // then we need to uncheck any radios in the same group\n if (!previousChecked && this.checked) {\n this.uncheckSiblings()\n }\n }\n\n private uncheckSiblings() {\n const root = this.getRootNode() as Document | ShadowRoot\n\n root.querySelectorAll<Radio>(`nord-radio[name=\"${this.name}\"]`).forEach(radio => {\n if (radio !== this) {\n radio.checked = false\n }\n })\n }\n\n protected handleChange(e: Event): void {\n e.stopPropagation()\n const target = e.target as HTMLInputElement\n\n this.checked = target.checked\n super.handleChange(e)\n }\n\n private handleBlur = (e: Event) => {\n e.stopPropagation()\n this.dispatchEvent(new Event(\"blur\", { bubbles: false, cancelable: true }))\n }\n\n private handleFocus = (e: Event) => {\n e.stopPropagation()\n this.dispatchEvent(new Event(\"focus\", { bubbles: false, cancelable: true }))\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"nord-radio\": Radio\n }\n}\n","// some clever typing so that TS knows what happens if you pass true/false values\nexport function wrapIf<TInner, TWrapper>(\n condition: false,\n inner: () => TInner,\n wrapper: (inner: TInner) => TWrapper\n): TInner\nexport function wrapIf<TInner, TWrapper>(\n condition: true,\n inner: () => TInner,\n wrapper: (inner: TInner) => TWrapper\n): TWrapper\nexport function wrapIf<TInner, TWrapper>(\n condition: unknown,\n inner: () => TInner,\n wrapper: (inner: TInner) => TWrapper\n): TInner | TWrapper\n\n/**\n * @returns if condition is truthy, return result of wrapper, passing result of inner as arg. if falsy, return result of inner\n */\nexport function wrapIf<TInner, TWrapper>(condition: any, inner: () => TInner, wrapper: (innards: TInner) => TWrapper) {\n return condition ? wrapper(inner()) : inner()\n}\n"],"names":["LightSlotController","SlotController","constructor","host","options","super","slotName","this","onChange","syncLightDom","renderHook","document","createComment","lightDom","LightDomController","render","hasContent","nothing","renderOptions","renderBefore","hostConnected","appendChild","hostDisconnected","remove","node","content","id","createId","suffix","Radio","FormAssociatedMixin","InputMixin","FocusableMixin","LitElement","inputId","hintId","errorId","hintSlot","hint","html","element","labelSlot","label","localName","isLabel","console","warn","htmlFor","errorSlot","error","inputSlot","handleBlur","handleFocus","ref","focusableRef","cond","name","value","checked","disabled","required","getDescribedBy","getInvalid","getAttribute","undefined","e","stopPropagation","dispatchEvent","Event","bubbles","cancelable","formValue","handleChange","condition","hideLabel","inner","wrapper","hasHint","hasError","handleCheckedChange","previousChecked","uncheckSiblings","getRootNode","querySelectorAll","forEach","radio","target","styles","componentStyle","formFieldStyle","style","__decorate","property","type","Boolean","reflect","prototype","observe","customElement"],"mappings":"uvBAcM,MAAOA,UAA4BC,EAIvCC,YAAYC,EAAoDC,GAC9DC,MAAMF,EAAMC,EAAQE,UAD0CC,KAAOH,QAAPA,EAwB7CG,KAAQC,SAAG,KAC5BD,KAAKE,cAAc,EAnBnBF,KAAKG,WAAaC,SAASC,cAAcL,KAAKD,UAE9CC,KAAKM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,GAhIMpC,EAAM0D,OAAG,CAACC,EAAgBC,EAAgBC,GAsELC,EAAA,CAA3CC,EAAS,CAAEC,KAAMC,QAASC,SAAS,KAAgClE,EAAAmE,UAAA,eAAA,GAkCpEL,EAAA,CADCM,EAAQ,YAORpE,EAAAmE,UAAA,sBAAA,MA/GkBnE,EAAK8D,EAAA,CADzBO,EAAc,eACMrE,SAAAA"}
|
package/lib/Range.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{_ as r,e}from"./query-assigned-elements-e6cbac30.js";import{i as n,y as a,s as o}from"./lit-element-9178eae5.js";import{n as t}from"./ref-0e619221.js";import{o as i}from"./class-map-949b7d3b.js";import{e as s}from"./property-03f59dce.js";import{l as c}from"./if-defined-4598a996.js";import{N as l}from"./events-731d0007.js";import{D as d}from"./DraftComponentMixin-9e4b7b34.js";import{F as b}from"./FocusableMixin-34870ed3.js";import{F as m}from"./FormAssociatedMixin-
|
|
1
|
+
import{_ as r,e}from"./query-assigned-elements-e6cbac30.js";import{i as n,y as a,s as o}from"./lit-element-9178eae5.js";import{n as t}from"./ref-0e619221.js";import{o as i}from"./class-map-949b7d3b.js";import{e as s}from"./property-03f59dce.js";import{l as c}from"./if-defined-4598a996.js";import{N as l}from"./events-731d0007.js";import{D as d}from"./DraftComponentMixin-9e4b7b34.js";import{F as b}from"./FocusableMixin-34870ed3.js";import{F as m}from"./FormAssociatedMixin-aa74901e.js";import{I as g}from"./InputMixin-158f63fb.js";import{R as u,s as h}from"./TextField-db22898b.js";import{A as p}from"./AutocompleteMixin-370de2be.js";import{D as v}from"./DirectionController-8b298382.js";import{s as f}from"./Component-92eb6234.js";import{s as _}from"./FormField-ae3570d2.js";import"./directive-de55b00a.js";import"./EventController-d99ebeef.js";import"./SlotController-89834aef.js";import"./VisuallyHidden.js";const z=n`:host{--_n-range-progress:0%;--_n-range-thumb-focus-ring:0 0 0 1px var(--n-color-accent);--_n-range-thumb-color:var(--n-color-text-on-accent);--_n-range-thumb-border-size:1px;--_n-range-thumb-border-color:var(--n-color-border-strong);--_n-range-gradient-direction:right;--_n-range-thumb-size:var(--n-range-thumb-size, 20px);--_n-range-track-color-active:var(--n-range-track-color-active, var(--n-color-accent));--_n-range-track-color-inactive:var(--n-range-track-color-inactive, var(--n-color-border-strong));--_n-range-track-size:var(--n-range-track-size, 3px)}.n-range{-webkit-appearance:none;appearance:none;inline-size:100%;background:linear-gradient(to var(--_n-range-gradient-direction),var(--_n-range-track-color-active) 0,var(--_n-range-track-color-active) var(--_n-range-progress),var(--_n-range-track-color-inactive) var(--_n-range-progress));border-radius:var(--n-border-radius-s)}.n-range.is-rtl{--_n-range-gradient-direction:left}.n-range::-webkit-slider-runnable-track{inline-size:100%;block-size:var(--_n-range-track-size)}.n-range::-webkit-slider-thumb{block-size:var(--_n-range-thumb-size);inline-size:var(--_n-range-thumb-size);box-shadow:var(--n-box-shadow),var(--n-box-shadow);border-radius:var(--n-border-radius-circle);background:var(--_n-range-thumb-color);border:var(--_n-range-thumb-border-size) solid var(--_n-range-thumb-border-color);cursor:pointer;-webkit-appearance:none;margin-block-start:calc(calc(var(--_n-range-thumb-size) - var(--_n-range-track-size))/ 2 * -1)}.n-range::-moz-range-track{border:var(--n-space-s) solid var(--n-color-surface);inline-size:100%;block-size:var(--_n-range-track-size)}.n-range::-moz-range-thumb{block-size:var(--_n-range-thumb-size);inline-size:var(--_n-range-thumb-size);box-shadow:var(--n-box-shadow);border-radius:var(--n-border-radius-circle);background:var(--_n-range-thumb-color);border:var(--_n-range-thumb-border-size) solid var(--_n-range-thumb-border-color);cursor:pointer;appearance:none;margin-block-start:calc(calc(var(--_n-range-thumb-size) - var(--_n-range-track-size))/ 2 * -1)}.n-label-container{margin-block-end:0;inline-size:100%}label{display:flex!important}.n-range-output{font-weight:var(--n-font-weight);color:var(--n-color-text-weaker);font-size:var(--n-font-size-m);margin-inline-start:auto}.n-range:focus{outline:0}.n-label-container:hover+.n-input-container .n-input:disabled,.n-range:disabled{opacity:.5}.n-range:disabled::-webkit-slider-thumb,.n-range[readonly]::-webkit-slider-thumb{--_n-range-thumb-color:var(--n-color-border);--_n-range-thumb-border-color:var(--n-color-border);box-shadow:none;cursor:default}.n-range:disabled::-moz-range-thumb,.n-range[readonly]::-moz-range-thumb{--_n-range-thumb-color:var(--n-color-border);--_n-range-thumb-border-color:var(--n-color-border);box-shadow:none;cursor:default}.n-range:focus::-webkit-slider-thumb{--_n-range-thumb-border-color:var(--n-color-accent);box-shadow:var(--_n-range-thumb-focus-ring)}.n-range:focus::-moz-range-thumb{--_n-range-thumb-border-color:var(--n-color-accent);box-shadow:var(--_n-range-thumb-focus-ring)}`;let k=class extends(d(m(p(u(g(b(o))))))){constructor(){super(...arguments),this.direction=new v(this),this.min=0,this.max=10,this.step=1,this.expand=!1}render(){const r=Number(this.value)||0,e=Math.max(0,(r-this.min)/(this.max-this.min));return a`<div class="n-input-container">${this.renderLabel(a`<span class="n-range-output" aria-hidden="true">${r}</span>`)} <input ${t(this.focusableRef)} id="${this.inputId}" type="range" class="${i({"n-range":!0,"is-rtl":this.direction.isRTL})}" name="${c(this.name)}" min="${this.min}" step="${this.step}" max="${this.max}" style="${`--_n-range-progress: ${100*e}%`}" ?disabled="${this.disabled}" ?required="${this.required}" ?readonly="${this.readonly}" .value="${this.value?this.value:0}" @input="${this.handleInput}" @change="${this.handleChange}" aria-describedby="${c(this.getDescribedBy())}" aria-invalid="${c(this.getInvalid())}"></div>${this.renderError()}`}handleInput(r){r.stopPropagation();const e=r.target;if(this.readonly)return r.preventDefault(),void(e.value=this.value);this.value=e.value,this.dispatchEvent(new l("input"))}};k.styles=[f,_,h,z],r([s()],k.prototype,"min",void 0),r([s()],k.prototype,"max",void 0),r([s()],k.prototype,"step",void 0),r([s({reflect:!0,type:Boolean})],k.prototype,"expand",void 0),k=r([e("nord-range")],k);var x=k;export{x as default};
|
|
2
2
|
//# sourceMappingURL=Range.js.map
|
package/lib/Range.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Range.js","sources":["../src/range/Range.ts"],"sourcesContent":["import { LitElement, html } from \"lit\"\nimport { ref } from \"lit/directives/ref.js\"\nimport { classMap } from \"lit/directives/class-map.js\"\nimport { customElement, property } from \"lit/decorators.js\"\nimport { ifDefined } from \"lit/directives/if-defined.js\"\nimport { NordEvent } from \"../common/events.js\"\n\nimport { DraftComponentMixin } from \"../common/mixins/DraftComponentMixin.js\"\nimport { FocusableMixin } from \"../common/mixins/FocusableMixin.js\"\nimport { FormAssociatedMixin } from \"../common/mixins/FormAssociatedMixin.js\"\nimport { InputMixin } from \"../common/mixins/InputMixin.js\"\nimport { ReadonlyMixin } from \"../common/mixins/ReadonlyMixin.js\"\nimport { AutocompleteMixin } from \"../common/mixins/AutocompleteMixin.js\"\nimport { DirectionController } from \"../common/controllers/DirectionController.js\"\n\nimport componentStyle from \"../common/styles/Component.css\"\nimport formFieldStyle from \"../common/styles/FormField.css\"\nimport textFieldStyle from \"../common/styles/TextField.css\"\nimport style from \"./Range.css\"\n\n/**\n * Range input lets user specify a numeric value using a slider which\n * must be no less than a given value, and no more than another given value.\n *\n * @status draft\n * @category form\n * @slot label - Use when a label requires more than plain text.\n * @slot hint - Optional slot that holds hint text for the input.\n * @slot error - Optional slot that holds error text for the input.\n *\n * @cssprop [--n-range-thumb-size=20px] - Controls the size of the thumb.\n * @cssprop [--n-range-track-color-active=var(--n-color-accent)] - Controls the color of the portion of the track that represents the current value.\n * @cssprop [--n-range-track-color-inactive=var(--n-color-border-strong)] - Controls the color of the portion of the track that represents the remaining value.\n * @cssprop [--n-range-track-size=3px] - Controls the height of the track.\n */\n@customElement(\"nord-range\")\nexport default class Range extends DraftComponentMixin(\n FormAssociatedMixin(AutocompleteMixin(ReadonlyMixin(InputMixin(FocusableMixin(LitElement)))))\n) {\n static styles = [componentStyle, formFieldStyle, textFieldStyle, style]\n\n private direction = new DirectionController(this)\n\n /**\n * Minimum value for the range slider.\n */\n @property() min: number = 0\n\n /**\n * Maximum value for the range slider.\n */\n @property() max: number = 10\n\n /**\n * Step amount for the range slider.\n */\n @property() step: number = 1\n\n /**\n * Controls whether the input expands to fill the width of its container.\n */\n @property({ reflect: true, type: Boolean }) expand = false\n\n render() {\n const value = Number(this.value) || 0\n const percent = Math.max(0, (value - this.min) / (this.max - this.min))\n\n return html`\n <div class=\"n-input-container\">\n ${this.renderLabel(html`<span class=\"n-range-output\" aria-hidden=\"true\">${value}</span>`)}\n\n <input\n ${ref(this.focusableRef)}\n id=${this.inputId}\n type=\"range\"\n class=${classMap({\n \"n-range\": true,\n \"is-rtl\": this.direction.isRTL,\n })}\n name=${ifDefined(this.name)}\n min=${this.min}\n step=${this.step}\n max=${this.max}\n style=${`--_n-range-progress: ${percent * 100}%`}\n ?disabled=${this.disabled}\n ?required=${this.required}\n ?readonly=${this.readonly}\n .value=${this.value ? this.value : 0}\n @input=${this.handleInput}\n @change=${this.handleChange}\n aria-describedby=${ifDefined(this.getDescribedBy())}\n aria-invalid=${ifDefined(this.getInvalid())}\n />\n </div>\n\n ${this.renderError()}\n `\n }\n\n protected handleInput(e: Event) {\n e.stopPropagation()\n const target = e.target as HTMLInputElement\n\n if (this.readonly) {\n e.preventDefault()\n target.value = this.value\n return\n }\n\n this.value = target.value\n\n /**\n * Fired as the user types into the input.\n */\n this.dispatchEvent(new NordEvent(\"input\"))\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"nord-range\": Range\n }\n}\n"],"names":["Range","DraftComponentMixin","FormAssociatedMixin","AutocompleteMixin","ReadonlyMixin","InputMixin","FocusableMixin","LitElement","constructor","this","direction","DirectionController","min","max","step","expand","render","value","Number","percent","Math","html","renderLabel","ref","focusableRef","inputId","classMap","isRTL","ifDefined","name","disabled","required","readonly","handleInput","handleChange","getDescribedBy","getInvalid","renderError","e","stopPropagation","target","preventDefault","dispatchEvent","NordEvent","styles","componentStyle","formFieldStyle","textFieldStyle","style","__decorate","property","prototype","reflect","type","Boolean","customElement"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Range.js","sources":["../src/range/Range.ts"],"sourcesContent":["import { LitElement, html } from \"lit\"\nimport { ref } from \"lit/directives/ref.js\"\nimport { classMap } from \"lit/directives/class-map.js\"\nimport { customElement, property } from \"lit/decorators.js\"\nimport { ifDefined } from \"lit/directives/if-defined.js\"\nimport { NordEvent } from \"../common/events.js\"\n\nimport { DraftComponentMixin } from \"../common/mixins/DraftComponentMixin.js\"\nimport { FocusableMixin } from \"../common/mixins/FocusableMixin.js\"\nimport { FormAssociatedMixin } from \"../common/mixins/FormAssociatedMixin.js\"\nimport { InputMixin } from \"../common/mixins/InputMixin.js\"\nimport { ReadonlyMixin } from \"../common/mixins/ReadonlyMixin.js\"\nimport { AutocompleteMixin } from \"../common/mixins/AutocompleteMixin.js\"\nimport { DirectionController } from \"../common/controllers/DirectionController.js\"\n\nimport componentStyle from \"../common/styles/Component.css\"\nimport formFieldStyle from \"../common/styles/FormField.css\"\nimport textFieldStyle from \"../common/styles/TextField.css\"\nimport style from \"./Range.css\"\n\n/**\n * Range input lets user specify a numeric value using a slider which\n * must be no less than a given value, and no more than another given value.\n *\n * @status draft\n * @category form\n * @slot label - Use when a label requires more than plain text.\n * @slot hint - Optional slot that holds hint text for the input.\n * @slot error - Optional slot that holds error text for the input.\n *\n * @cssprop [--n-range-thumb-size=20px] - Controls the size of the thumb.\n * @cssprop [--n-range-track-color-active=var(--n-color-accent)] - Controls the color of the portion of the track that represents the current value.\n * @cssprop [--n-range-track-color-inactive=var(--n-color-border-strong)] - Controls the color of the portion of the track that represents the remaining value.\n * @cssprop [--n-range-track-size=3px] - Controls the height of the track.\n */\n@customElement(\"nord-range\")\nexport default class Range extends DraftComponentMixin(\n FormAssociatedMixin(AutocompleteMixin(ReadonlyMixin(InputMixin(FocusableMixin(LitElement)))))\n) {\n static styles = [componentStyle, formFieldStyle, textFieldStyle, style]\n\n private direction = new DirectionController(this)\n\n /**\n * Minimum value for the range slider.\n */\n @property() min: number = 0\n\n /**\n * Maximum value for the range slider.\n */\n @property() max: number = 10\n\n /**\n * Step amount for the range slider.\n */\n @property() step: number = 1\n\n /**\n * Controls whether the input expands to fill the width of its container.\n */\n @property({ reflect: true, type: Boolean }) expand = false\n\n render() {\n const value = Number(this.value) || 0\n const percent = Math.max(0, (value - this.min) / (this.max - this.min))\n\n return html`\n <div class=\"n-input-container\">\n ${this.renderLabel(html`<span class=\"n-range-output\" aria-hidden=\"true\">${value}</span>`)}\n\n <input\n ${ref(this.focusableRef)}\n id=${this.inputId}\n type=\"range\"\n class=${classMap({\n \"n-range\": true,\n \"is-rtl\": this.direction.isRTL,\n })}\n name=${ifDefined(this.name)}\n min=${this.min}\n step=${this.step}\n max=${this.max}\n style=${`--_n-range-progress: ${percent * 100}%`}\n ?disabled=${this.disabled}\n ?required=${this.required}\n ?readonly=${this.readonly}\n .value=${this.value ? this.value : 0}\n @input=${this.handleInput}\n @change=${this.handleChange}\n aria-describedby=${ifDefined(this.getDescribedBy())}\n aria-invalid=${ifDefined(this.getInvalid())}\n />\n </div>\n\n ${this.renderError()}\n `\n }\n\n protected handleInput(e: Event) {\n e.stopPropagation()\n const target = e.target as HTMLInputElement\n\n if (this.readonly) {\n e.preventDefault()\n target.value = this.value\n return\n }\n\n this.value = target.value\n\n /**\n * Fired as the user types into the input.\n */\n this.dispatchEvent(new NordEvent(\"input\"))\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"nord-range\": Range\n }\n}\n"],"names":["Range","DraftComponentMixin","FormAssociatedMixin","AutocompleteMixin","ReadonlyMixin","InputMixin","FocusableMixin","LitElement","constructor","this","direction","DirectionController","min","max","step","expand","render","value","Number","percent","Math","html","renderLabel","ref","focusableRef","inputId","classMap","isRTL","ifDefined","name","disabled","required","readonly","handleInput","handleChange","getDescribedBy","getInvalid","renderError","e","stopPropagation","target","preventDefault","dispatchEvent","NordEvent","styles","componentStyle","formFieldStyle","textFieldStyle","style","__decorate","property","prototype","reflect","type","Boolean","customElement"],"mappings":"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E,SAAS,EAAMC,KAAMC,WAAyBtD,EAAAmD,UAAA,cAAA,GAzBvCnD,EAAKiD,EAAA,CADzBM,EAAc,eACMvD,SAAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
class t{constructor(t){t.addController(this)}hostDisconnected(){this.unlockScroll()}lockScroll(){if(0===t.locks.size){const e=document.documentElement.clientWidth,s=Math.abs(window.innerWidth-e),o=getComputedStyle(document.body),l=parseInt(o.paddingRight,10)||0;t.setStyle("--n-scrollbar-gutter",`${s+l}px`),t.setStyle("overflow","hidden"),t.setStyle("padding-right","var(--n-scrollbar-gutter)")}t.locks.add(this)}unlockScroll(){t.locks.delete(this),0===t.locks.size&&(t.resets.forEach((t=>t())),t.resets=[])}static setStyle(e,s){const{style:o}=document.body,l=o.getPropertyValue(e);o.setProperty(e,s),t.resets.push((()=>o.setProperty(e,l)))}}t.locks=new Set,t.resets=[];export{t as S};
|
|
2
|
+
//# sourceMappingURL=ScrollbarController-773c79f4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScrollbarController-773c79f4.js","sources":["../src/common/controllers/ScrollbarController.ts"],"sourcesContent":["import { ReactiveController, ReactiveControllerHost } from \"lit\"\n\n/**\n * We can have any number of components open at a time, all of which lock scroll.\n * Consider multiple modals being open, plus some popouts, etc.\n *\n * So we need some bookkeeping to know when to unlock scroll...\n *\n * But we can't simply keep a count of how many components are open,\n * since a misbehaving component may call lockScroll() multiple times.\n *\n * Nor can we rely on the first component to call lockScroll() to be the last to unlockScroll(),\n * since we cannot guarantee order of operations.\n *\n * Therefore, we track instances of ScrollbarController in a Set,\n * and only unlock scroll when the set is empty.\n *\n * We also need to be careful to restore any styles that were there\n * before we locked scroll.\n */\nexport class ScrollbarController implements ReactiveController {\n private static locks = new Set<ScrollbarController>()\n private static resets: Array<() => void> = []\n\n constructor(host: ReactiveControllerHost) {\n host.addController(this)\n }\n\n hostDisconnected() {\n this.unlockScroll()\n }\n\n lockScroll() {\n if (ScrollbarController.locks.size === 0) {\n const documentWidth = document.documentElement.clientWidth\n const width = Math.abs(window.innerWidth - documentWidth)\n\n const computedStyle = getComputedStyle(document.body)\n const paddingRight = parseInt(computedStyle.paddingRight, 10) || 0\n\n // hiding the scrollbar slightly increases the width of the inner viewport.\n // this is fine for the modal, since it is accounted for there. but it causes layout shift for any other fixed position components/elements.\n // so we define a custom property here for the gutter value, since it can be inherited/used by any other component that has a fixed position e.g. toast-group.\n ScrollbarController.setStyle(\"--n-scrollbar-gutter\", `${width + paddingRight}px`)\n ScrollbarController.setStyle(\"overflow\", \"hidden\")\n // use physical padding property rather than the logical equivalent, since the scrollbar is on always right side of the viewport, even in RTL.\n ScrollbarController.setStyle(\"padding-right\", `var(--n-scrollbar-gutter)`)\n }\n\n ScrollbarController.locks.add(this)\n }\n\n unlockScroll() {\n ScrollbarController.locks.delete(this)\n\n if (ScrollbarController.locks.size === 0) {\n ScrollbarController.resets.forEach(reset => reset())\n ScrollbarController.resets = []\n }\n }\n\n private static setStyle(property: string, value: string) {\n const { style } = document.body\n\n const previous = style.getPropertyValue(property)\n style.setProperty(property, value)\n\n ScrollbarController.resets.push(() => style.setProperty(property, previous))\n }\n}\n"],"names":["ScrollbarController","constructor","host","addController","this","hostDisconnected","unlockScroll","lockScroll","locks","size","documentWidth","document","documentElement","clientWidth","width","Math","abs","window","innerWidth","computedStyle","getComputedStyle","body","paddingRight","parseInt","setStyle","add","delete","resets","forEach","reset","static","property","value","style","previous","getPropertyValue","setProperty","push","Set"],"mappings":"MAoBaA,EAIXC,YAAYC,GACVA,EAAKC,cAAcC,KACpB,CAEDC,mBACED,KAAKE,cACN,CAEDC,aACE,GAAuC,IAAnCP,EAAoBQ,MAAMC,KAAY,CACxC,MAAMC,EAAgBC,SAASC,gBAAgBC,YACzCC,EAAQC,KAAKC,IAAIC,OAAOC,WAAaR,GAErCS,EAAgBC,iBAAiBT,SAASU,MAC1CC,EAAeC,SAASJ,EAAcG,aAAc,KAAO,EAKjEtB,EAAoBwB,SAAS,uBAAwB,GAAGV,EAAQQ,OAChEtB,EAAoBwB,SAAS,WAAY,UAEzCxB,EAAoBwB,SAAS,gBAAiB,4BAC/C,CAEDxB,EAAoBQ,MAAMiB,IAAIrB,KAC/B,CAEDE,eACEN,EAAoBQ,MAAMkB,OAAOtB,MAEM,IAAnCJ,EAAoBQ,MAAMC,OAC5BT,EAAoB2B,OAAOC,SAAQC,GAASA,MAC5C7B,EAAoB2B,OAAS,GAEhC,CAEOG,gBAAgBC,EAAkBC,GACxC,MAAMC,MAAEA,GAAUtB,SAASU,KAErBa,EAAWD,EAAME,iBAAiBJ,GACxCE,EAAMG,YAAYL,EAAUC,GAE5BhC,EAAoB2B,OAAOU,MAAK,IAAMJ,EAAMG,YAAYL,EAAUG,IACnE,EA/CclC,EAAAQ,MAAQ,IAAI8B,IACZtC,EAAM2B,OAAsB"}
|
package/lib/Select.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{_ as e,e as t}from"./query-assigned-elements-e6cbac30.js";import{i as o,y as n,s as r}from"./lit-element-9178eae5.js";import{e as i}from"./property-03f59dce.js";import{l as s}from"./if-defined-4598a996.js";import{n as a}from"./ref-0e619221.js";import"./Button.js";import l from"./Icon.js";import{I as d}from"./InputMixin-158f63fb.js";import{F as c}from"./FocusableMixin-34870ed3.js";import{F as p}from"./FormAssociatedMixin-
|
|
1
|
+
import{_ as e,e as t}from"./query-assigned-elements-e6cbac30.js";import{i as o,y as n,s as r}from"./lit-element-9178eae5.js";import{e as i}from"./property-03f59dce.js";import{l as s}from"./if-defined-4598a996.js";import{n as a}from"./ref-0e619221.js";import"./Button.js";import l from"./Icon.js";import{I as d}from"./InputMixin-158f63fb.js";import{F as c}from"./FocusableMixin-34870ed3.js";import{F as p}from"./FormAssociatedMixin-aa74901e.js";import{A as u}from"./AutocompleteMixin-370de2be.js";import{S as b,i as m}from"./SizeMixin-4559b224.js";import{s as h}from"./Component-92eb6234.js";import{s as v}from"./FormField-ae3570d2.js";import{S as f}from"./SlotController-89834aef.js";import"./directive-de55b00a.js";import"./EventController-d99ebeef.js";import"./LightDomController-3c726b20.js";import"./cond-338158e9.js";import"./Spinner.js";import"./state-70f38ceb.js";import"./observe-a9c6dfb6.js";import"./events-731d0007.js";import"./VisuallyHidden.js";var x=Object.freeze({__proto__:null,default:'<svg viewBox="0 0 140 140" xmlns="http://www.w3.org/2000/svg"><g transform="translate(6,6) scale(0.9)"><path fill="currentColor" d="M105 56a10.416 10.416 0 0 1-7.42-3.08L72.478 27.818a3.528 3.528 0 0 0-4.956 0L42.42 52.92a10.5 10.5 0 0 1-14.84-14.84l35-35a10.486 10.486 0 0 1 14.84 0l35 35A10.5 10.5 0 0 1 105 56zm-35 84a10.416 10.416 0 0 1-7.42-3.08l-35-35a10.5 10.5 0 0 1 14.84-14.84l25.102 25.102a3.528 3.528 0 0 0 4.956 0L97.58 87.08a10.5 10.5 0 1 1 14.84 14.84l-35 35A10.416 10.416 0 0 1 70 140z"/></g></svg>',title:"interface-dropdown-small",tags:"nordicon small interface dropdown select arrow up down caret triangle chevron"});const g=o`.n-select-container{position:relative;inline-size:fit-content}:host([expand]){inline-size:100%}:host([expand]) .n-select-container{inline-size:100%}select{-webkit-appearance:none;appearance:none;position:absolute;font-size:var(--n-font-size-m);font-family:var(--n-font-family);color:var(--n-color-text);inline-size:100%;opacity:.0001;cursor:pointer;background:0 0;border:0;block-size:var(--n-space-xl);inset-block-end:0;inset-inline-start:0;z-index:var(--n-index-default)}option{color:initial}nord-button{--n-button-text-align:start}nord-icon{color:var(--n-color-icon)}.n-label-container:hover+.n-select-container nord-button,select:hover+nord-button{--n-button-border-color:var(--n-color-border-hover);--_n-button-background-color:var(--n-color-button-hover)}.n-label-container:hover+.n-select-container nord-button nord-icon,select:hover+nord-button nord-icon{color:var(--n-color-icon-hover)}select:focus+nord-button{--n-button-border-color:var(--n-color-accent);--_n-button-box-shadow:0 0 0 1px var(--n-button-border-color)}:host([disabled]){cursor:auto;pointer-events:none}:host([disabled]) nord-button{--n-input-border-color:var(--n-color-active);--_n-button-color:var(--n-color-text-weakest);--_n-button-background-color:var(--n-color-active);--_n-button-opacity:1}:host([disabled]) nord-icon{color:var(--n-color-text-weakest)}::slotted(:not([slot])){display:none}select[aria-invalid=true]+nord-button{--n-button-border-color:var(--n-color-status-danger)}`;l.registerIcon(x);let j=class extends(b(p(u(d(c(r)))))){constructor(){super(...arguments),this.defaultSlot=new f(this),this.inputId="select",this.expand=!1}get formValue(){return this.value||void 0}render(){const e=this.options,t=this.getButtonText(e),o=m[this.size]||m.m;return n`<slot></slot>${this.renderLabel()}<div class="n-select-container"><select ${a(this.focusableRef)} id="${this.inputId}" ?disabled="${this.disabled}" ?required="${this.required}" name="${s(this.name)}" @change="${this.handleChange}" @input="${this.handleInput}" aria-describedby="${s(this.getDescribedBy())}" aria-invalid="${s(this.getInvalid())}" autocomplete="${this.autocomplete}">${this.placeholder&&n`<option value="" disabled="disabled" ?selected="${!this.value}">${this.placeholder}</option>`} ${e.map((e=>this.renderOption(e)))}</select><nord-button size="${this.size}" tabindex="-1" ?disabled="${this.disabled}" ?expand="${this.expand}" aria-hidden="true" type="button"><slot slot="start" name="icon"></slot>${t}<nord-icon slot="end" size="${o}" name="interface-dropdown-small"></nord-icon></nord-button></div>${this.renderError()}`}get options(){return Array.from(this.querySelectorAll("option"))}getButtonText(e){const t=e.find((e=>e.value===this.value.toString()));return t?t.text:this.placeholder?this.placeholder:e[0]?e[0].text:""}renderOption(e){return n`<option value="${s(e.value)}" ?disabled="${e.disabled}" .selected="${e.value===this.value.toString()}">${e.text}</option>`}};j.styles=[h,v,g],e([i({reflect:!0,type:Boolean})],j.prototype,"expand",void 0),j=e([t("nord-select")],j);var $=j;export{$ as default};
|
|
2
2
|
//# sourceMappingURL=Select.js.map
|
package/lib/Select.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.js","sources":["../../icons/lib/assets/interface-dropdown-small.js","../src/select/Select.ts"],"sourcesContent":["export default '<svg viewBox=\"0 0 140 140\" xmlns=\"http://www.w3.org/2000/svg\"><g transform=\"translate(6,6) scale(0.9)\"><path fill=\"currentColor\" d=\"M105 56a10.416 10.416 0 0 1-7.42-3.08L72.478 27.818a3.528 3.528 0 0 0-4.956 0L42.42 52.92a10.5 10.5 0 0 1-14.84-14.84l35-35a10.486 10.486 0 0 1 14.84 0l35 35A10.5 10.5 0 0 1 105 56zm-35 84a10.416 10.416 0 0 1-7.42-3.08l-35-35a10.5 10.5 0 0 1 14.84-14.84l25.102 25.102a3.528 3.528 0 0 0 4.956 0L97.58 87.08a10.5 10.5 0 1 1 14.84 14.84l-35 35A10.416 10.416 0 0 1 70 140z\"/></g></svg>'\nexport const title = \"interface-dropdown-small\"\nexport const tags = \"nordicon small interface dropdown select arrow up down caret triangle chevron\"\n","/* eslint-disable lit-a11y/no-invalid-change-handler */\nimport { LitElement, html } from \"lit\"\nimport { customElement, property } from \"lit/decorators.js\"\nimport { ifDefined } from \"lit/directives/if-defined.js\"\nimport { ref } from \"lit/directives/ref.js\"\nimport * as dropdownIcon from \"@nordhealth/icons/lib/assets/interface-dropdown-small.js\"\n\nimport \"../button/Button.js\"\nimport Icon from \"../icon/Icon.js\"\n\nimport { InputMixin } from \"../common/mixins/InputMixin.js\"\nimport { FocusableMixin } from \"../common/mixins/FocusableMixin.js\"\nimport { FormAssociatedMixin } from \"../common/mixins/FormAssociatedMixin.js\"\nimport { AutocompleteMixin } from \"../common/mixins/AutocompleteMixin.js\"\nimport { SizeMixin, iconSizeMap } from \"../common/mixins/SizeMixin.js\"\n\nimport componentStyle from \"../common/styles/Component.css\"\nimport formFieldStyle from \"../common/styles/FormField.css\"\nimport style from \"./Select.css\"\nimport { SlotController } from \"../common/controllers/SlotController.js\"\n\nIcon.registerIcon(dropdownIcon)\n\n/**\n * Select lets users choose one option from an options menu.\n * Consider using select when you have 5 or more options to choose from.\n *\n * @status ready\n * @category form\n * @slot - Default slot for holding <option> elements.\n * @slot label - Use when a label requires more than plain text.\n * @slot hint - Use when a hint requires more than plain text.\n * @slot error - Optional slot that holds error text for the input.\n */\n@customElement(\"nord-select\")\nexport default class Select extends SizeMixin(\n FormAssociatedMixin(AutocompleteMixin(InputMixin(FocusableMixin(LitElement))))\n) {\n static styles = [componentStyle, formFieldStyle, style]\n\n protected override get formValue() {\n return this.value || undefined\n }\n\n private defaultSlot = new SlotController(this)\n\n protected inputId = \"select\"\n\n /**\n * Controls whether the select expands to fill the width of its container.\n */\n @property({ reflect: true, type: Boolean }) expand = false\n\n render() {\n const slottedOptions = this.options\n const buttonText = this.getButtonText(slottedOptions)\n const iconSize = iconSizeMap[this.size] || iconSizeMap.m\n\n return html`\n <slot></slot>\n ${this.renderLabel()}\n\n <div class=\"n-select-container\">\n <select\n ${ref(this.focusableRef)}\n id=${this.inputId}\n ?disabled=${this.disabled}\n ?required=${this.required}\n name=${ifDefined(this.name)}\n @change=${this.handleChange}\n @input=${this.handleInput}\n aria-describedby=${ifDefined(this.getDescribedBy())}\n aria-invalid=${ifDefined(this.getInvalid())}\n autocomplete=${this.autocomplete as any}\n >\n ${this.placeholder && html`<option value=\"\" disabled ?selected=${!this.value}>${this.placeholder}</option>`}\n ${slottedOptions.map(option => this.renderOption(option))}\n </select>\n\n <nord-button\n size=${this.size}\n tabindex=\"-1\"\n ?disabled=${this.disabled}\n ?expand=${this.expand}\n aria-hidden=\"true\"\n type=\"button\"\n >\n <slot slot=\"start\" name=\"icon\"></slot>\n ${buttonText}\n <nord-icon slot=\"end\" size=${iconSize} name=\"interface-dropdown-small\"></nord-icon>\n </nord-button>\n </div>\n\n ${this.renderError()}\n `\n }\n\n private get options() {\n return Array.from(this.querySelectorAll(\"option\"))\n }\n\n private getButtonText(options: HTMLOptionElement[]): string {\n const selected = options.find(option => option.value === this.value.toString())\n\n if (selected) {\n return selected.text\n }\n\n if (this.placeholder) {\n return this.placeholder\n }\n\n if (options[0]) {\n return options[0].text\n }\n\n return \"\"\n }\n\n private renderOption(option: HTMLOptionElement) {\n return html`\n <option\n value=${ifDefined(option.value)}\n ?disabled=${option.disabled}\n .selected=${option.value === this.value.toString()}\n >\n ${option.text}\n </option>\n `\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"nord-select\": Select\n }\n}\n"],"names":["Icon","registerIcon","dropdownIcon","Select","SizeMixin","FormAssociatedMixin","AutocompleteMixin","InputMixin","FocusableMixin","LitElement","constructor","this","defaultSlot","SlotController","inputId","expand","formValue","value","undefined","render","slottedOptions","options","buttonText","getButtonText","iconSize","iconSizeMap","size","m","html","renderLabel","ref","focusableRef","disabled","required","ifDefined","name","handleChange","handleInput","getDescribedBy","getInvalid","autocomplete","placeholder","map","option","renderOption","renderError","Array","from","querySelectorAll","selected","find","toString","text","styles","componentStyle","formFieldStyle","style","__decorate","property","reflect","type","Boolean","prototype","customElement"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Select.js","sources":["../../icons/lib/assets/interface-dropdown-small.js","../src/select/Select.ts"],"sourcesContent":["export default '<svg viewBox=\"0 0 140 140\" xmlns=\"http://www.w3.org/2000/svg\"><g transform=\"translate(6,6) scale(0.9)\"><path fill=\"currentColor\" d=\"M105 56a10.416 10.416 0 0 1-7.42-3.08L72.478 27.818a3.528 3.528 0 0 0-4.956 0L42.42 52.92a10.5 10.5 0 0 1-14.84-14.84l35-35a10.486 10.486 0 0 1 14.84 0l35 35A10.5 10.5 0 0 1 105 56zm-35 84a10.416 10.416 0 0 1-7.42-3.08l-35-35a10.5 10.5 0 0 1 14.84-14.84l25.102 25.102a3.528 3.528 0 0 0 4.956 0L97.58 87.08a10.5 10.5 0 1 1 14.84 14.84l-35 35A10.416 10.416 0 0 1 70 140z\"/></g></svg>'\nexport const title = \"interface-dropdown-small\"\nexport const tags = \"nordicon small interface dropdown select arrow up down caret triangle chevron\"\n","/* eslint-disable lit-a11y/no-invalid-change-handler */\nimport { LitElement, html } from \"lit\"\nimport { customElement, property } from \"lit/decorators.js\"\nimport { ifDefined } from \"lit/directives/if-defined.js\"\nimport { ref } from \"lit/directives/ref.js\"\nimport * as dropdownIcon from \"@nordhealth/icons/lib/assets/interface-dropdown-small.js\"\n\nimport \"../button/Button.js\"\nimport Icon from \"../icon/Icon.js\"\n\nimport { InputMixin } from \"../common/mixins/InputMixin.js\"\nimport { FocusableMixin } from \"../common/mixins/FocusableMixin.js\"\nimport { FormAssociatedMixin } from \"../common/mixins/FormAssociatedMixin.js\"\nimport { AutocompleteMixin } from \"../common/mixins/AutocompleteMixin.js\"\nimport { SizeMixin, iconSizeMap } from \"../common/mixins/SizeMixin.js\"\n\nimport componentStyle from \"../common/styles/Component.css\"\nimport formFieldStyle from \"../common/styles/FormField.css\"\nimport style from \"./Select.css\"\nimport { SlotController } from \"../common/controllers/SlotController.js\"\n\nIcon.registerIcon(dropdownIcon)\n\n/**\n * Select lets users choose one option from an options menu.\n * Consider using select when you have 5 or more options to choose from.\n *\n * @status ready\n * @category form\n * @slot - Default slot for holding <option> elements.\n * @slot label - Use when a label requires more than plain text.\n * @slot hint - Use when a hint requires more than plain text.\n * @slot error - Optional slot that holds error text for the input.\n */\n@customElement(\"nord-select\")\nexport default class Select extends SizeMixin(\n FormAssociatedMixin(AutocompleteMixin(InputMixin(FocusableMixin(LitElement))))\n) {\n static styles = [componentStyle, formFieldStyle, style]\n\n protected override get formValue() {\n return this.value || undefined\n }\n\n private defaultSlot = new SlotController(this)\n\n protected inputId = \"select\"\n\n /**\n * Controls whether the select expands to fill the width of its container.\n */\n @property({ reflect: true, type: Boolean }) expand = false\n\n render() {\n const slottedOptions = this.options\n const buttonText = this.getButtonText(slottedOptions)\n const iconSize = iconSizeMap[this.size] || iconSizeMap.m\n\n return html`\n <slot></slot>\n ${this.renderLabel()}\n\n <div class=\"n-select-container\">\n <select\n ${ref(this.focusableRef)}\n id=${this.inputId}\n ?disabled=${this.disabled}\n ?required=${this.required}\n name=${ifDefined(this.name)}\n @change=${this.handleChange}\n @input=${this.handleInput}\n aria-describedby=${ifDefined(this.getDescribedBy())}\n aria-invalid=${ifDefined(this.getInvalid())}\n autocomplete=${this.autocomplete as any}\n >\n ${this.placeholder && html`<option value=\"\" disabled ?selected=${!this.value}>${this.placeholder}</option>`}\n ${slottedOptions.map(option => this.renderOption(option))}\n </select>\n\n <nord-button\n size=${this.size}\n tabindex=\"-1\"\n ?disabled=${this.disabled}\n ?expand=${this.expand}\n aria-hidden=\"true\"\n type=\"button\"\n >\n <slot slot=\"start\" name=\"icon\"></slot>\n ${buttonText}\n <nord-icon slot=\"end\" size=${iconSize} name=\"interface-dropdown-small\"></nord-icon>\n </nord-button>\n </div>\n\n ${this.renderError()}\n `\n }\n\n private get options() {\n return Array.from(this.querySelectorAll(\"option\"))\n }\n\n private getButtonText(options: HTMLOptionElement[]): string {\n const selected = options.find(option => option.value === this.value.toString())\n\n if (selected) {\n return selected.text\n }\n\n if (this.placeholder) {\n return this.placeholder\n }\n\n if (options[0]) {\n return options[0].text\n }\n\n return \"\"\n }\n\n private renderOption(option: HTMLOptionElement) {\n return html`\n <option\n value=${ifDefined(option.value)}\n ?disabled=${option.disabled}\n .selected=${option.value === this.value.toString()}\n >\n ${option.text}\n </option>\n `\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"nord-select\": Select\n }\n}\n"],"names":["Icon","registerIcon","dropdownIcon","Select","SizeMixin","FormAssociatedMixin","AutocompleteMixin","InputMixin","FocusableMixin","LitElement","constructor","this","defaultSlot","SlotController","inputId","expand","formValue","value","undefined","render","slottedOptions","options","buttonText","getButtonText","iconSize","iconSizeMap","size","m","html","renderLabel","ref","focusableRef","disabled","required","ifDefined","name","handleChange","handleInput","getDescribedBy","getInvalid","autocomplete","placeholder","map","option","renderOption","renderError","Array","from","querySelectorAll","selected","find","toString","text","styles","componentStyle","formFieldStyle","style","__decorate","property","reflect","type","Boolean","prototype","customElement"],"mappings":"0+BAAe,0gBACM,gCACD,mhDCmBpBA,EAAKC,aAAaC,GAclB,IAAqBC,EAArB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yB1D,EAAA2D,UAAA,cAAA,GAhBvC3D,EAAMsD,EAAA,CAD1BM,EAAc,gBACM5D,SAAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{_ as n}from"./query-assigned-elements-e6cbac30.js";import{e as r}from"./property-03f59dce.js";import{i as o}from"./lit-element-9178eae5.js";function i(o){class i extends o{constructor(){super(...arguments),this.readonly=!1}}return n([r({type:Boolean,reflect:!0})],i.prototype,"readonly",void 0),i}const t=o`:host{--_n-input-inline-size:var(--n-input-inline-size, 240px);--_n-input-background:var(--n-input-background, var(--n-color-active));--_n-input-color:var(--n-input-color, var(--n-color-text));--_n-input-border-color:var(--n-input-border-color, var(--n-color-border-strong));--_n-input-border-radius:var(--n-input-border-radius, var(--n-border-radius-s))}.n-input-container{position:relative;inline-size:var(--_n-input-inline-size)}.n-input{background:var(--_n-input-background);color:var(--_n-input-color);padding:calc(var(--n-space-s) - 1px) calc(var(--n-space-s) * 1.6);border-radius:var(--_n-input-border-radius);border:1px solid var(--_n-input-border-color);font-family:var(--n-font-family);font-size:var(--n-font-size-m);line-height:var(--n-line-height-form);inline-size:100%;transition:border var(--n-transition-slowly),box-shadow var(--n-transition-slowly),background var(--n-transition-slowly)}@media (max-width:480px){.n-input{font-size:var(--n-font-size-l)}}:host([expand]){--_n-input-inline-size:100%;inline-size:100%}.n-input:hover,.n-label-container:hover+.n-input-container{--_n-input-border-color:var(--n-input-border-color, var(--n-color-border-hover))}.n-input:focus{--_n-input-border-color:var(--n-input-border-color, var(--n-color-accent));--_n-input-background:var(--n-input-background, var(--n-color-surface));outline:0;box-shadow:0 0 0 1px var(--_n-input-border-color)}.n-input::placeholder{color:var(--n-color-text-weakest)}.n-input[aria-invalid=true]{--_n-input-border-color:var(--n-input-border-color, var(--n-color-status-danger))!important}.n-input:disabled,.n-input[readonly],.n-label-container:hover+.n-input-container .n-input:disabled,.n-label-container:hover+.n-input-container .n-input[readonly]{--_n-input-border-color:var(--n-input-border-color, var(--n-color-active));--_n-input-color:var(--n-input-color, var(--n-color-text-weakest))}.n-input[readonly],.n-label-container:hover+.n-input-container .n-input[readonly]{--_n-input-color:var(--n-input-color, var(--n-color-text-weak))}.n-input[readonly]:focus{--_n-input-border-color:var(--n-input-border-color, var(--n-color-accent))}:host([size="s"]) :is(.n-input-container, .n-input){font-size:var(--n-font-size-s)}:host([size="s"]) .n-input{padding:calc((var(--n-space-s)/ 2) - 2px) calc((var(--n-space-s)/ 2) * 1.6)}:host([size="l"]) :is(.n-input-container, .n-input){font-size:var(--n-font-size-l)}:host([size="l"]) .n-input{padding-block-start:calc(var(--n-space-m)/ 1.25);padding-block-end:calc(var(--n-space-m)/ 1.25)}`;export{i as R,t as s};
|
|
2
|
+
//# sourceMappingURL=TextField-db22898b.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextField-
|
|
1
|
+
{"version":3,"file":"TextField-db22898b.js","sources":["../src/common/mixins/ReadonlyMixin.ts"],"sourcesContent":["/* eslint-disable max-classes-per-file */\nimport { LitElement } from \"lit\"\nimport { property } from \"lit/decorators.js\"\n\ntype Constructor<T = Record<string, unknown>> = new (...args: any[]) => T\n\nexport declare class ReadonlyMixinInterface {\n readonly: boolean\n}\n\nexport function ReadonlyMixin<T extends Constructor<LitElement>>(\n superClass: T\n): Constructor<ReadonlyMixinInterface> & T {\n class ReadonlyElement extends superClass {\n /**\n * Makes the component readonly, so that it is not editable.\n * Readonly differs from disabled in that readonly fields are still focusable and will be submitted with a form.\n */\n @property({ type: Boolean, reflect: true }) readonly = false\n }\n\n return ReadonlyElement\n}\n"],"names":["ReadonlyMixin","superClass","ReadonlyElement","constructor","this","readonly","__decorate","property","type","Boolean","reflect","prototype"],"mappings":"mJAUM,SAAUA,EACdC,GAEA,MAAMC,UAAwBD,EAA9BE,kCAK8CC,KAAQC,UAAG,CACxD,EAED,OAH8CC,EAAA,CAA3CC,EAAS,CAAEC,KAAMC,QAASC,SAAS,KAAwBR,EAAAS,UAAA,gBAAA,GAGvDT,CACT"}
|
package/lib/Textarea.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{_ as e,e as r}from"./query-assigned-elements-e6cbac30.js";import{i as t,y as o,s as n}from"./lit-element-9178eae5.js";import{e as a}from"./property-03f59dce.js";import{l as i}from"./if-defined-4598a996.js";import{n as s}from"./ref-0e619221.js";import{o as l}from"./observe-a9c6dfb6.js";import{F as d}from"./FocusableMixin-34870ed3.js";import{F as c}from"./FormAssociatedMixin-
|
|
1
|
+
import{_ as e,e as r}from"./query-assigned-elements-e6cbac30.js";import{i as t,y as o,s as n}from"./lit-element-9178eae5.js";import{e as a}from"./property-03f59dce.js";import{l as i}from"./if-defined-4598a996.js";import{n as s}from"./ref-0e619221.js";import{o as l}from"./observe-a9c6dfb6.js";import{F as d}from"./FocusableMixin-34870ed3.js";import{F as c}from"./FormAssociatedMixin-aa74901e.js";import{I as p}from"./InputMixin-158f63fb.js";import{R as u,s as v}from"./TextField-db22898b.js";import{A as b}from"./AutocompleteMixin-370de2be.js";import{S as m}from"./SizeMixin-4559b224.js";import{s as h}from"./Component-92eb6234.js";import{s as x}from"./FormField-ae3570d2.js";import"./directive-de55b00a.js";import"./EventController-d99ebeef.js";import"./SlotController-89834aef.js";import"./events-731d0007.js";import"./VisuallyHidden.js";const f=t`:host{--_n-textarea-inline-size:var(--n-textarea-inline-size, 240px);--_n-textarea-block-size:var(--n-textarea-block-size, 76px);--_n-input-background:var(--n-textarea-background, var(--n-color-active));--_n-input-color:var(--n-textarea-color, var(--n-color-text));--_n-input-border-color:var(--n-textarea-border-color, var(--n-color-border-strong));--_n-input-border-radius:var(--n-textarea-border-radius, var(--n-border-radius-s))}.n-input-container{position:relative;inline-size:var(--_n-textarea-inline-size)}.n-input{min-block-size:var(--_n-textarea-block-size);transition:border var(--n-transition-slowly),box-shadow var(--n-transition-slowly),background var(--n-transition-slowly);display:block;resize:vertical}:host([resize=auto]) .n-input{resize:none;overflow:hidden}:host([expand]){--_n-textarea-inline-size:100%}.n-input:hover,.n-label-container:hover+.n-input-container .n-input{--_n-input-border-color:var(--n-textarea-border-color, var(--n-color-border-hover))}.n-input:focus{--_n-input-border-color:var(--n-textarea-border-color, var(--n-color-accent));--_n-input-background:var(--n-textarea-background, var(--n-color-surface))}.n-input[aria-invalid=true]{--_n-input-border-color:var(--n-textarea-border-color, var(--n-color-status-danger))!important}.n-input:disabled,.n-input[readonly],.n-label-container:hover+.n-input-container .n-input:disabled,.n-label-container:hover+.n-input-container .n-input[readonly]{--_n-input-border-color:var(--n-textarea-border-color, var(--n-color-active));--_n-input-color:var(--n-textarea-color, var(--n-color-text-weakest))}.n-input[readonly],.n-label-container:hover+.n-input-container .n-input[readonly]{--_n-input-color:var(--n-textarea-color, var(--n-color-text-weak))}.n-input[readonly]:focus{--_n-input-border-color:var(--n-textarea-border-color, var(--n-color-accent))}`;let y=class extends(m(c(b(u(p(d(n))))))){constructor(){super(...arguments),this.inputId="textarea",this.resize="vertical",this.expand=!1}render(){var e;return o`${this.renderLabel()}<div class="n-input-container"><textarea ${s(this.focusableRef)} id="${this.inputId}" class="n-input" ?disabled="${this.disabled}" ?readonly="${this.readonly}" ?required="${this.required}" name="${i(this.name)}" .value="${null!==(e=this.value)&&void 0!==e?e:""}" placeholder="${i(this.placeholder)}" @change="${this.handleChange}" @input="${this.handleInput}" aria-describedby="${i(this.getDescribedBy())}" aria-invalid="${i(this.getInvalid())}" autocomplete="${this.autocomplete}"></textarea></div>${this.renderError()}`}resizeToFitContent(){const e=this.focusableRef.value;e&&("auto"===this.resize?(e.style.height="auto",e.style.height=`${e.scrollHeight}px`):e.style.height=null)}};y.styles=[h,x,v,f],e([a({reflect:!0})],y.prototype,"resize",void 0),e([a({reflect:!0,type:Boolean})],y.prototype,"expand",void 0),e([l("resize","updated"),l("value","updated")],y.prototype,"resizeToFitContent",null),y=e([r("nord-textarea")],y);var j=y;export{j as default};
|
|
2
2
|
//# sourceMappingURL=Textarea.js.map
|
package/lib/Toast.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{_ as s,e as o}from"./query-assigned-elements-e6cbac30.js";import{i as t,s as i,y as e}from"./lit-element-9178eae5.js";import{o as r}from"./class-map-949b7d3b.js";import{e as n}from"./property-03f59dce.js";import{t as a}from"./state-70f38ceb.js";import{i as d}from"./query-2d22378e.js";import c from"./Icon.js";import{s as l}from"./Component-92eb6234.js";import{N as m}from"./events-731d0007.js";import{E as u}from"./EventController-d99ebeef.js";import{o as p}from"./observe-a9c6dfb6.js";import"./directive-de55b00a.js";import"./if-defined-4598a996.js";import"./
|
|
1
|
+
import{_ as s,e as o}from"./query-assigned-elements-e6cbac30.js";import{i as t,s as i,y as e}from"./lit-element-9178eae5.js";import{o as r}from"./class-map-949b7d3b.js";import{e as n}from"./property-03f59dce.js";import{t as a}from"./state-70f38ceb.js";import{i as d}from"./query-2d22378e.js";import c from"./Icon.js";import{s as l}from"./Component-92eb6234.js";import{N as m}from"./events-731d0007.js";import{E as u}from"./EventController-d99ebeef.js";import{o as p}from"./observe-a9c6dfb6.js";import"./directive-de55b00a.js";import"./if-defined-4598a996.js";import"./cond-338158e9.js";var v=Object.freeze({__proto__:null,default:'<svg viewBox="0 0 140 140" xmlns="http://www.w3.org/2000/svg"><path d="M133 7 7 133M7 7l126 126" stroke-width="14" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/></svg>',title:"interface-close",tags:"nordicon interface close cross remove delete erase symbol"});const f=t`:host{--_n-toast-color:var(--n-color-surface);--_n-toast-background-color:var(--n-color-text)}.n-toast{display:flex;gap:var(--n-space-l);align-items:flex-start;background-color:var(--_n-toast-background-color);color:var(--_n-toast-color);border-radius:var(--n-border-radius);animation:n-enter var(--n-transition-slowly) forwards 1;z-index:var(--n-index-toast);box-shadow:var(--n-box-shadow-popout)}.n-dismissed{animation-name:n-exit}@keyframes n-enter{from{transform:translateY(50%);opacity:0}}@keyframes n-exit{to{transform:scale(.97);opacity:0}}.n-toast-inner{padding:var(--n-space-m);flex:1}.n-dismiss{--_n-toast-focus-ring:0 0 0 2px var(--n-color-accent);border:none;display:flex;justify-content:center;align-items:center;block-size:var(--n-space-xl);inline-size:var(--n-space-xl);position:relative;inset-inline-end:var(--n-space-s);inset-block-start:var(--n-space-s);background-color:transparent;border-radius:var(--n-border-radius);cursor:pointer}.n-dismiss::after,.n-dismiss::before{content:"";position:absolute;display:block;border-radius:var(--n-border-radius)}.n-dismiss::before{inset:0;background:var(--_n-toast-color);transition:opacity var(--n-transition-quickly);opacity:0}.n-dismiss:is(:hover,:focus)::before{opacity:.06}.n-dismiss::after{inset:calc(var(--n-space-s) * -1)}.n-dismiss:active{transform:translateY(1px)}.n-dismiss:focus{outline:0;box-shadow:var(--_n-toast-focus-ring)}@supports selector(:focus-visible){.n-dismiss:focus{box-shadow:none}.n-dismiss:focus-visible{box-shadow:var(--_n-toast-focus-ring)}}.n-dismiss nord-icon{opacity:.53;transition:opacity var(--n-transition-quickly);color:var(--_n-toast-color)}.n-dismiss:is(:hover,:focus) nord-icon{opacity:1}:host([variant=danger]){--_n-toast-background-color:var(--n-color-status-danger);--_n-toast-color:var(--n-color-text-on-accent)}`;c.registerIcon(v);let b=class extends i{constructor(){super(...arguments),this.events=new u(this),this.dismissed=!1,this.variant="default",this.autoDismiss=1e4}disconnectedCallback(){super.disconnectedCallback(),clearTimeout(this.timeoutId)}dismiss(){return this.dismissed=!0,clearTimeout(this.timeoutId),new Promise((s=>{this.events.listen(this.toast,"animationend",(()=>{this.dispatchEvent(new m("dismiss")),s()}),{once:!0})}))}render(){return e`<div class="${r({"n-toast":!0,"n-dismissed":this.dismissed})}"><div class="n-toast-inner"><slot></slot></div><button class="n-dismiss" @click="${this.dismiss}" aria-hidden="true"><nord-icon name="interface-close" size="s"></nord-icon></button></div>`}handleAutoDismissChange(){clearTimeout(this.timeoutId),null!=this.autoDismiss&&this.autoDismiss>=0&&setTimeout((()=>this.dismiss()),this.autoDismiss)}};b.styles=[l,f],s([d(".n-toast",!0)],b.prototype,"toast",void 0),s([a()],b.prototype,"dismissed",void 0),s([n({reflect:!0})],b.prototype,"variant",void 0),s([n({type:Number,attribute:"auto-dismiss"})],b.prototype,"autoDismiss",void 0),s([p("autoDismiss")],b.prototype,"handleAutoDismissChange",null),b=s([o("nord-toast")],b);var h=b;export{h as default};
|
|
2
2
|
//# sourceMappingURL=Toast.js.map
|
package/lib/Toast.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toast.js","sources":["../../icons/lib/assets/interface-close.js","../src/toast/Toast.ts"],"sourcesContent":["export default '<svg viewBox=\"0 0 140 140\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M133 7 7 133M7 7l126 126\" stroke-width=\"14\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/></svg>'\nexport const title = \"interface-close\"\nexport const tags = \"nordicon interface close cross remove delete erase symbol\"\n","import { LitElement, html } from \"lit\"\nimport { classMap } from \"lit/directives/class-map.js\"\nimport { customElement, property, query, state } from \"lit/decorators.js\"\nimport * as closeIcon from \"@nordhealth/icons/lib/assets/interface-close.js\"\n\nimport Icon from \"../icon/Icon.js\"\nimport componentStyle from \"../common/styles/Component.css\"\nimport style from \"./Toast.css\"\nimport { NordEvent } from \"../common/events.js\"\nimport { EventController } from \"../common/controllers/EventController.js\"\nimport { observe } from \"../common/decorators/observe.js\"\n\nIcon.registerIcon(closeIcon)\n\n/**\n * Toasts are non-disruptive messages that appear in the interface\n * to provide quick, at-a-glance feedback on the outcome of an action.\n *\n * @status new\n * @category feedback\n * @slot - Default slot used for the toast text/message.\n * @fires dismiss - Fired when the toast is dismissed (via user action or auto-dismiss), and its exit animation has completed. This event should be used to remove the dismissed toast from the DOM.\n */\n@customElement(\"nord-toast\")\nexport default class Toast extends LitElement {\n static styles = [componentStyle, style]\n\n private timeoutId?: ReturnType<typeof setTimeout>\n private events = new EventController(this)\n\n @query(\".n-toast\", true) private toast!: HTMLElement\n @state() private dismissed = false\n\n /**\n * The style variant of the toast.\n */\n @property({ reflect: true }) variant: \"default\" | \"danger\" = \"default\"\n\n /**\n * Timeout in milliseconds before the toast is automatically dismissed.\n */\n @property({ type: Number, attribute: \"auto-dismiss\" }) autoDismiss? = 10000\n\n disconnectedCallback() {\n super.disconnectedCallback()\n clearTimeout(this.timeoutId)\n }\n\n /**\n * Programmatically dismiss the toast.\n * The returned promise resolves when toast's exit animation is complete.\n */\n dismiss() {\n this.dismissed = true\n clearTimeout(this.timeoutId)\n\n return new Promise<void>(resolve => {\n this.events.listen(\n this.toast,\n \"animationend\",\n () => {\n this.dispatchEvent(new NordEvent(\"dismiss\"))\n resolve()\n },\n { once: true }\n )\n })\n }\n\n render() {\n return html`\n <div class=${classMap({ \"n-toast\": true, \"n-dismissed\": this.dismissed })}>\n <div class=\"n-toast-inner\">\n <slot></slot>\n </div>\n\n <button class=\"n-dismiss\" @click=${this.dismiss} aria-hidden=\"true\">\n <nord-icon name=\"interface-close\" size=\"s\"></nord-icon>\n </button>\n </div>\n `\n }\n\n @observe(\"autoDismiss\")\n protected handleAutoDismissChange() {\n clearTimeout(this.timeoutId)\n\n if (this.autoDismiss != null && this.autoDismiss >= 0) {\n setTimeout(() => this.dismiss(), this.autoDismiss)\n }\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"nord-toast\": Toast\n }\n}\n"],"names":["Icon","registerIcon","closeIcon","Toast","LitElement","constructor","this","events","EventController","dismissed","variant","autoDismiss","disconnectedCallback","super","clearTimeout","timeoutId","dismiss","Promise","resolve","listen","toast","dispatchEvent","NordEvent","once","render","html","classMap","handleAutoDismissChange","setTimeout","styles","componentStyle","style","__decorate","query","prototype","state","property","reflect","type","Number","attribute","observe","customElement"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Toast.js","sources":["../../icons/lib/assets/interface-close.js","../src/toast/Toast.ts"],"sourcesContent":["export default '<svg viewBox=\"0 0 140 140\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M133 7 7 133M7 7l126 126\" stroke-width=\"14\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/></svg>'\nexport const title = \"interface-close\"\nexport const tags = \"nordicon interface close cross remove delete erase symbol\"\n","import { LitElement, html } from \"lit\"\nimport { classMap } from \"lit/directives/class-map.js\"\nimport { customElement, property, query, state } from \"lit/decorators.js\"\nimport * as closeIcon from \"@nordhealth/icons/lib/assets/interface-close.js\"\n\nimport Icon from \"../icon/Icon.js\"\nimport componentStyle from \"../common/styles/Component.css\"\nimport style from \"./Toast.css\"\nimport { NordEvent } from \"../common/events.js\"\nimport { EventController } from \"../common/controllers/EventController.js\"\nimport { observe } from \"../common/decorators/observe.js\"\n\nIcon.registerIcon(closeIcon)\n\n/**\n * Toasts are non-disruptive messages that appear in the interface\n * to provide quick, at-a-glance feedback on the outcome of an action.\n *\n * @status new\n * @category feedback\n * @slot - Default slot used for the toast text/message.\n * @fires dismiss - Fired when the toast is dismissed (via user action or auto-dismiss), and its exit animation has completed. This event should be used to remove the dismissed toast from the DOM.\n */\n@customElement(\"nord-toast\")\nexport default class Toast extends LitElement {\n static styles = [componentStyle, style]\n\n private timeoutId?: ReturnType<typeof setTimeout>\n private events = new EventController(this)\n\n @query(\".n-toast\", true) private toast!: HTMLElement\n @state() private dismissed = false\n\n /**\n * The style variant of the toast.\n */\n @property({ reflect: true }) variant: \"default\" | \"danger\" = \"default\"\n\n /**\n * Timeout in milliseconds before the toast is automatically dismissed.\n */\n @property({ type: Number, attribute: \"auto-dismiss\" }) autoDismiss? = 10000\n\n disconnectedCallback() {\n super.disconnectedCallback()\n clearTimeout(this.timeoutId)\n }\n\n /**\n * Programmatically dismiss the toast.\n * The returned promise resolves when toast's exit animation is complete.\n */\n dismiss() {\n this.dismissed = true\n clearTimeout(this.timeoutId)\n\n return new Promise<void>(resolve => {\n this.events.listen(\n this.toast,\n \"animationend\",\n () => {\n this.dispatchEvent(new NordEvent(\"dismiss\"))\n resolve()\n },\n { once: true }\n )\n })\n }\n\n render() {\n return html`\n <div class=${classMap({ \"n-toast\": true, \"n-dismissed\": this.dismissed })}>\n <div class=\"n-toast-inner\">\n <slot></slot>\n </div>\n\n <button class=\"n-dismiss\" @click=${this.dismiss} aria-hidden=\"true\">\n <nord-icon name=\"interface-close\" size=\"s\"></nord-icon>\n </button>\n </div>\n `\n }\n\n @observe(\"autoDismiss\")\n protected handleAutoDismissChange() {\n clearTimeout(this.timeoutId)\n\n if (this.autoDismiss != null && this.autoDismiss >= 0) {\n setTimeout(() => this.dismiss(), this.autoDismiss)\n }\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"nord-toast\": Toast\n }\n}\n"],"names":["Icon","registerIcon","closeIcon","Toast","LitElement","constructor","this","events","EventController","dismissed","variant","autoDismiss","disconnectedCallback","super","clearTimeout","timeoutId","dismiss","Promise","resolve","listen","toast","dispatchEvent","NordEvent","once","render","html","classMap","handleAutoDismissChange","setTimeout","styles","componentStyle","style","__decorate","query","prototype","state","property","reflect","type","Number","attribute","observe","customElement"],"mappings":"snBAAe,oNACM,uBACD,g2DCUpBA,EAAKC,aAAaC,GAYlB,IAAqBC,EAArB,cAAmCC,EAAnCC,kCAIUC,KAAAC,OAAS,IAAIC,EAAgBF,MAGpBA,KAASG,WAAG,EAKAH,KAAOI,QAAyB,UAKNJ,KAAWK,YAAI,GAkDvE,CAhDCC,uBACEC,MAAMD,uBACNE,aAAaR,KAAKS,UACnB,CAMDC,UAIE,OAHAV,KAAKG,WAAY,EACjBK,aAAaR,KAAKS,WAEX,IAAIE,SAAcC,IACvBZ,KAAKC,OAAOY,OACVb,KAAKc,MACL,gBACA,KACEd,KAAKe,cAAc,IAAIC,EAAU,YACjCJ,GAAS,GAEX,CAAEK,MAAM,GACT,GAEJ,CAEDC,SACE,OAAOC,CAAI,eACIC,EAAS,CAAE,WAAW,EAAM,cAAepB,KAAKG,gGAKxBH,KAAKU,oGAK7C,CAGSW,0BACRb,aAAaR,KAAKS,WAEM,MAApBT,KAAKK,aAAuBL,KAAKK,aAAe,GAClDiB,YAAW,IAAMtB,KAAKU,WAAWV,KAAKK,YAEzC,GAjEMR,EAAA0B,OAAS,CAACC,EAAgBC,GAKRC,EAAA,CAAxBC,EAAM,YAAY,IAAiC9B,EAAA+B,UAAA,aAAA,GAC3CF,EAAA,CAARG,KAAiChC,EAAA+B,UAAA,iBAAA,GAKLF,EAAA,CAA5BI,EAAS,CAAEC,SAAS,KAAiDlC,EAAA+B,UAAA,eAAA,GAKfF,EAAA,CAAtDI,EAAS,CAAEE,KAAMC,OAAQC,UAAW,kBAAsCrC,EAAA+B,UAAA,mBAAA,GA2C3EF,EAAA,CADCS,EAAQ,gBAORtC,EAAA+B,UAAA,0BAAA,MAlEkB/B,EAAK6B,EAAA,CADzBU,EAAc,eACMvC,SAAAA"}
|
package/lib/Toggle.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{_ as e,e as n}from"./query-assigned-elements-e6cbac30.js";import{i,y as r,s as t}from"./lit-element-9178eae5.js";import{e as o}from"./property-03f59dce.js";import{l as a}from"./if-defined-4598a996.js";import{n as s}from"./ref-0e619221.js";import{F as l}from"./FocusableMixin-34870ed3.js";import{F as c}from"./FormAssociatedMixin-
|
|
1
|
+
import{_ as e,e as n}from"./query-assigned-elements-e6cbac30.js";import{i,y as r,s as t}from"./lit-element-9178eae5.js";import{e as o}from"./property-03f59dce.js";import{l as a}from"./if-defined-4598a996.js";import{n as s}from"./ref-0e619221.js";import{F as l}from"./FocusableMixin-34870ed3.js";import{F as c}from"./FormAssociatedMixin-aa74901e.js";import{I as d}from"./InputMixin-158f63fb.js";import{s as g}from"./Component-92eb6234.js";import{s as p}from"./FormField-ae3570d2.js";import"./directive-de55b00a.js";import"./EventController-d99ebeef.js";import"./SlotController-89834aef.js";import"./events-731d0007.js";import"./VisuallyHidden.js";const h=i`:host{--_n-toggle-block-size:calc(var(--_n-toggle-inline-size) / 1.6);--_n-toggle-inline-size:3.2143em;--_n-toggle-thumb-margin:0.35em;display:inline-block;font-size:var(--n-font-size-m)}.n-flex{display:flex}.n-expand{flex:1;display:flex;justify-content:center;align-items:flex-start;flex-direction:column;min-block-size:100%}.n-input-container{position:relative}.n-toggle{-webkit-appearance:none;appearance:none;display:inline-flex;align-items:center;inline-size:var(--_n-toggle-inline-size);block-size:var(--_n-toggle-block-size);border-radius:var(--n-border-radius-pill);background:var(--_n-toggle-background,var(--n-color-border-strong));cursor:pointer;transition:background var(--n-transition-slowly);font-size:var(--_n-toggle-size,var(--n-font-size-m))}.n-toggle::before{content:"";display:block;aspect-ratio:1/1;block-size:calc(100% - 2 * var(--_n-toggle-thumb-margin));background:var(--n-color-text-on-accent);border-radius:var(--n-border-radius-circle);transition:margin;transition-duration:inherit;margin-inline-start:var(--_n-toggle-thumb-margin);box-shadow:var(--n-box-shadow)}input:checked{--_n-toggle-background:var(--n-color-text-link)}input:checked::before{margin-inline-start:calc(var(--_n-toggle-inline-size) - var(--_n-toggle-block-size) + var(--_n-toggle-thumb-margin))}input:checked[aria-invalid]{--_n-toggle-background:var(--n-color-status-danger)}input:focus{outline:0;box-shadow:0 0 0 1px var(--n-color-surface),0 0 0 3px var(--n-color-accent)}:host([disabled]) label{color:var(--n-color-text-weaker);cursor:default}:host([disabled]) input{opacity:.3;cursor:not-allowed}.n-label-container{margin-block-end:0}label{-webkit-user-select:none;user-select:none;font-weight:var(--n-font-weight)!important;line-height:var(--n-line-height-l);padding-inline-start:var(--n-space-s);cursor:pointer}.n-hint{padding-inline-start:var(--n-space-s)}.n-error{margin-block-start:calc(var(--n-space-s)/ 2);padding-inline-start:var(--n-space-s)}:host([reverse]) .n-error,:host([reverse]) .n-hint,:host([reverse]) label{padding-inline-start:0;padding-inline-end:var(--n-space-s)}:host([size="s"]) .n-toggle{--_n-toggle-size:var(--n-font-size-xs)}:host([size="l"]) .n-toggle{--_n-toggle-size:var(--n-font-size-xl)}`;let v=class extends(c(d(l(t)))){constructor(){super(...arguments),this.checked=!1,this.reverse=!1,this.size="m"}get formValue(){return this.checked?this.value||"on":void 0}render(){const e=r`<div class="n-expand">${this.renderLabel()} ${this.renderError()}</div>`,n=r`<div class="n-input-container"><input ${s(this.focusableRef)} class="n-toggle" id="${this.inputId}" type="checkbox" role="switch" name="${a(this.name)}" .value="${this.value}" .checked="${this.checked}" ?disabled="${this.disabled}" ?required="${this.required}" aria-describedby="${a(this.getDescribedBy())}" aria-invalid="${a(this.getInvalid())}" @change="${this.handleChange}"></div>`;return r`<div class="n-flex">${this.reverse?[e,n]:[n,e]}</div>`}handleChange(e){const n=e.target;this.checked=n.checked,super.handleChange(e)}};v.styles=[g,p,h],e([o({type:Boolean})],v.prototype,"checked",void 0),e([o({type:Boolean})],v.prototype,"reverse",void 0),e([o({reflect:!0})],v.prototype,"size",void 0),v=e([n("nord-toggle")],v);var m=v;export{m as default};
|
|
2
2
|
//# sourceMappingURL=Toggle.js.map
|
package/lib/Toggle.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toggle.js","sources":["../src/toggle/Toggle.ts"],"sourcesContent":["/* eslint-disable lit-a11y/role-has-required-aria-attrs */\nimport { html, LitElement } from \"lit\"\nimport { customElement, property } from \"lit/decorators.js\"\nimport { ifDefined } from \"lit/directives/if-defined.js\"\nimport { ref } from \"lit/directives/ref.js\"\n\nimport { FocusableMixin } from \"../common/mixins/FocusableMixin.js\"\nimport { FormAssociatedMixin } from \"../common/mixins/FormAssociatedMixin.js\"\nimport { InputMixin } from \"../common/mixins/InputMixin.js\"\n\nimport componentStyle from \"../common/styles/Component.css\"\nimport formFieldStyle from \"../common/styles/FormField.css\"\nimport style from \"./Toggle.css\"\n\n/**\n * Toggle switch gives control over a feature or option that can be\n * turned on or off. If a physical switch would work for the action, a\n * toggle is probably the best component to use.\n *\n * @status new\n * @category form\n * @slot label - Use when a label requires more than plain text.\n * @slot hint - Optional slot that holds hint text for the input.\n * @slot error - Optional slot that holds error text for the input.\n */\n@customElement(\"nord-toggle\")\nexport default class Toggle extends FormAssociatedMixin(InputMixin(FocusableMixin(LitElement))) {\n static styles = [componentStyle, formFieldStyle, style]\n\n protected override get formValue() {\n return this.checked ? this.value || \"on\" : undefined\n }\n\n /**\n * Controls whether the toggle is checked or not.\n */\n @property({ type: Boolean }) checked: boolean = false\n\n /**\n * Controls whether the contents are displayed in reverse order,\n * putting the label before the toggle.\n */\n @property({ type: Boolean }) reverse: boolean = false\n\n /**\n * The size of the toggle switch.\n */\n @property({ reflect: true }) size: \"s\" | \"m\" | \"l\" = \"m\"\n\n render() {\n const label = html`<div class=\"n-expand\">${this.renderLabel()} ${this.renderError()}</div>`\n const input = html`<div class=\"n-input-container\">\n <input\n ${ref(this.focusableRef)}\n class=\"n-toggle\"\n id=${this.inputId}\n type=\"checkbox\"\n role=\"switch\"\n name=${ifDefined(this.name)}\n .value=${this.value}\n .checked=${this.checked}\n ?disabled=${this.disabled}\n ?required=${this.required}\n aria-describedby=${ifDefined(this.getDescribedBy())}\n aria-invalid=${ifDefined(this.getInvalid())}\n @change=${this.handleChange}\n />\n </div>`\n\n return html`<div class=\"n-flex\">${this.reverse ? [label, input] : [input, label]}</div>`\n }\n\n protected handleChange(e: Event): void {\n const target = e.target as HTMLInputElement\n this.checked = target.checked\n super.handleChange(e)\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"nord-toggle\": Toggle\n }\n}\n"],"names":["Toggle","FormAssociatedMixin","InputMixin","FocusableMixin","LitElement","constructor","this","checked","reverse","size","formValue","value","undefined","render","label","html","renderLabel","renderError","input","ref","focusableRef","inputId","ifDefined","name","disabled","required","getDescribedBy","getInvalid","handleChange","e","target","super","styles","componentStyle","formFieldStyle","style","__decorate","property","type","Boolean","prototype","reflect","customElement"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Toggle.js","sources":["../src/toggle/Toggle.ts"],"sourcesContent":["/* eslint-disable lit-a11y/role-has-required-aria-attrs */\nimport { html, LitElement } from \"lit\"\nimport { customElement, property } from \"lit/decorators.js\"\nimport { ifDefined } from \"lit/directives/if-defined.js\"\nimport { ref } from \"lit/directives/ref.js\"\n\nimport { FocusableMixin } from \"../common/mixins/FocusableMixin.js\"\nimport { FormAssociatedMixin } from \"../common/mixins/FormAssociatedMixin.js\"\nimport { InputMixin } from \"../common/mixins/InputMixin.js\"\n\nimport componentStyle from \"../common/styles/Component.css\"\nimport formFieldStyle from \"../common/styles/FormField.css\"\nimport style from \"./Toggle.css\"\n\n/**\n * Toggle switch gives control over a feature or option that can be\n * turned on or off. If a physical switch would work for the action, a\n * toggle is probably the best component to use.\n *\n * @status new\n * @category form\n * @slot label - Use when a label requires more than plain text.\n * @slot hint - Optional slot that holds hint text for the input.\n * @slot error - Optional slot that holds error text for the input.\n */\n@customElement(\"nord-toggle\")\nexport default class Toggle extends FormAssociatedMixin(InputMixin(FocusableMixin(LitElement))) {\n static styles = [componentStyle, formFieldStyle, style]\n\n protected override get formValue() {\n return this.checked ? this.value || \"on\" : undefined\n }\n\n /**\n * Controls whether the toggle is checked or not.\n */\n @property({ type: Boolean }) checked: boolean = false\n\n /**\n * Controls whether the contents are displayed in reverse order,\n * putting the label before the toggle.\n */\n @property({ type: Boolean }) reverse: boolean = false\n\n /**\n * The size of the toggle switch.\n */\n @property({ reflect: true }) size: \"s\" | \"m\" | \"l\" = \"m\"\n\n render() {\n const label = html`<div class=\"n-expand\">${this.renderLabel()} ${this.renderError()}</div>`\n const input = html`<div class=\"n-input-container\">\n <input\n ${ref(this.focusableRef)}\n class=\"n-toggle\"\n id=${this.inputId}\n type=\"checkbox\"\n role=\"switch\"\n name=${ifDefined(this.name)}\n .value=${this.value}\n .checked=${this.checked}\n ?disabled=${this.disabled}\n ?required=${this.required}\n aria-describedby=${ifDefined(this.getDescribedBy())}\n aria-invalid=${ifDefined(this.getInvalid())}\n @change=${this.handleChange}\n />\n </div>`\n\n return html`<div class=\"n-flex\">${this.reverse ? [label, input] : [input, label]}</div>`\n }\n\n protected handleChange(e: Event): void {\n const target = e.target as HTMLInputElement\n this.checked = target.checked\n super.handleChange(e)\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"nord-toggle\": Toggle\n }\n}\n"],"names":["Toggle","FormAssociatedMixin","InputMixin","FocusableMixin","LitElement","constructor","this","checked","reverse","size","formValue","value","undefined","render","label","html","renderLabel","renderError","input","ref","focusableRef","inputId","ifDefined","name","disabled","required","getDescribedBy","getInvalid","handleChange","e","target","super","styles","componentStyle","formFieldStyle","style","__decorate","property","type","Boolean","prototype","reflect","customElement"],"mappings":"0zFA0BA,IAAqBA,EAArB,cAAoCC,EAAoBC,EAAWC,EAAeC,MAAlFC,kCAU+BC,KAAOC,SAAY,EAMnBD,KAAOE,SAAY,EAKnBF,KAAIG,KAAoB,GA8BtD,CAhDwBC,gBACrB,OAAOJ,KAAKC,QAAUD,KAAKK,OAAS,UAAOC,CAC5C,CAkBDC,SACE,MAAMC,EAAQC,CAAI,yBAAyBT,KAAKU,iBAAiBV,KAAKW,sBAChEC,EAAQH,CAAI,yCAEZI,EAAIb,KAAKc,sCAENd,KAAKe,gDAGHC,EAAUhB,KAAKiB,kBACbjB,KAAKK,oBACHL,KAAKC,uBACJD,KAAKkB,wBACLlB,KAAKmB,+BACEH,EAAUhB,KAAKoB,oCACnBJ,EAAUhB,KAAKqB,2BACpBrB,KAAKsB,uBAInB,OAAOb,CAAI,uBAAuBT,KAAKE,QAAU,CAACM,EAAOI,GAAS,CAACA,EAAOJ,UAC3E,CAESc,aAAaC,GACrB,MAAMC,EAASD,EAAEC,OACjBxB,KAAKC,QAAUuB,EAAOvB,QACtBwB,MAAMH,aAAaC,EACpB,GAjDM7B,EAAMgC,OAAG,CAACC,EAAgBC,EAAgBC,GASpBC,EAAA,CAA5BC,EAAS,CAAEC,KAAMC,WAAmCvC,EAAAwC,UAAA,eAAA,GAMxBJ,EAAA,CAA5BC,EAAS,CAAEC,KAAMC,WAAmCvC,EAAAwC,UAAA,eAAA,GAKxBJ,EAAA,CAA5BC,EAAS,CAAEI,SAAS,KAAmCzC,EAAAwC,UAAA,YAAA,GArBrCxC,EAAMoC,EAAA,CAD1BM,EAAc,gBACM1C,SAAAA"}
|