@warp-ds/elements 1.2.1-next.1 → 1.2.1-next.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -4
- package/dist/api.js +52 -1
- package/dist/api.js.map +2 -2
- package/dist/index.js +3357 -3812
- package/dist/index.js.map +7 -0
- package/dist/packages/affix/index.js +1748 -8
- package/dist/packages/affix/index.js.map +4 -4
- package/dist/packages/alert/index.js +1881 -9
- package/dist/packages/alert/index.js.map +4 -4
- package/dist/packages/attention/index.js +2364 -17
- package/dist/packages/attention/index.js.map +4 -4
- package/dist/packages/badge/index.js +289 -2
- package/dist/packages/badge/index.js.map +4 -4
- package/dist/packages/box/index.js +279 -3
- package/dist/packages/box/index.js.map +4 -4
- package/dist/packages/breadcrumbs/index.js +1703 -10
- package/dist/packages/breadcrumbs/index.js.map +4 -4
- package/dist/packages/broadcast/index.js +93 -8
- package/dist/packages/broadcast/index.js.map +2 -2
- package/dist/packages/button/index.js +1778 -8
- package/dist/packages/button/index.js.map +4 -4
- package/dist/packages/card/index.js +318 -9
- package/dist/packages/card/index.js.map +4 -4
- package/dist/packages/expandable/index.d.ts +0 -2
- package/dist/packages/expandable/index.js +1822 -55
- package/dist/packages/expandable/index.js.map +4 -4
- package/dist/packages/select/index.js +1841 -19
- package/dist/packages/select/index.js.map +4 -4
- package/dist/packages/textfield/index.js +383 -17
- package/dist/packages/textfield/index.js.map +4 -4
- package/dist/packages/toast/index.js +2165 -23
- package/dist/packages/toast/index.js.map +4 -4
- package/package.json +17 -19
- package/dist/elements.min.js +0 -5
- package/dist/packages/expandable/locales/en/messages.d.mts +0 -1
- package/dist/packages/expandable/locales/fi/messages.d.mts +0 -1
- package/dist/packages/expandable/locales/nb/messages.d.mts +0 -1
|
@@ -1,22 +1,348 @@
|
|
|
1
|
-
var y=Object.defineProperty;var w=(d,l,n)=>l in d?y(d,l,{enumerable:!0,configurable:!0,writable:!0,value:n}):d[l]=n;var x=(d,l,n)=>(w(d,typeof l!="symbol"?l+"":l,n),n);import{css as L,html as v}from"lit";import k from"@warp-ds/elements-core";var h={box:"group block relative break-words last-child:mb-0 p-16 rounded-8",bleed:"-mx-16 sm:mx-0 rounded-l-0 rounded-r-0 sm:rounded-8",info:"i-bg-$color-box-info-background i-text-$color-box-info-text",neutral:"i-bg-$color-box-neutral-background i-text-$color-box-neutral-text",bordered:"border-2 i-border-$color-box-bordered-border i-bg-$color-box-bordered-background i-text-$color-box-bordered-text",infoClickable:"hover:i-bg-$color-box-info-background-hover active:i-bg-$color-box-info-background-hover",neutralClickable:"hover:i-bg-$color-box-neutral-background-hover active:i-bg-$color-box-neutral-background-hover",borderedClickable:"hover:i-bg-$color-box-bordered-background-hover active:i-bg-$color-box-bordered-background-hover hover:i-border-$color-box-bordered-border-hover active:i-border-$color-box-bordered-border-hover"};var S="focus:outline-none appearance-none cursor-pointer bg-transparent border-0 m-0 p-0 inline-block",_={expandable:"will-change-height",expandableTitle:"font-bold i-text-$color-expandable-title-text",expandableBox:"i-bg-$color-expandable-background hover:i-bg-$color-expandable-background-hover py-0 px-0 "+h.box,expandableBleed:h.bleed,chevron:"inline-block align-middle i-text-$color-expandable-icon",chevronNonBox:"relative left-8",chevronBox:"absolute right-16",chevronTransform:"transform transition-transform transform-gpu ease-in-out",chevronExpand:"-rotate-180",chevronCollapse:"rotate-180",expansion:"overflow-hidden",expansionNotExpanded:"h-0 invisible",button:S+" hover:underline focus:underline",buttonBox:"w-full text-left relative inline-flex items-center "+h.box,paddingTop:"pt-0",title:"flex justify-between items-center",titleType:"h4"},c="font-bold focusable justify-center transition-colors ease-in-out",i={primary:"i-text-$color-button-primary-text hover:i-text-$color-button-primary-text i-bg-$color-button-primary-background hover:i-bg-$color-button-primary-background-hover active:i-bg-$color-button-primary-background-active",secondary:"i-text-$color-button-secondary-text hover:i-text-$color-button-secondary-text i-border-$color-button-secondary-border i-bg-$color-button-secondary-background hover:i-bg-$color-button-secondary-background-hover hover:i-border-$color-button-secondary-border-hover active:i-bg-$color-button-secondary-background-active",utility:"i-text-$color-button-utility-text hover:i-text-$color-button-utility-text i-bg-$color-button-utility-background i-border-$color-button-utility-border hover:i-bg-$color-button-utility-background hover:i-border-$color-button-utility-border-hover active:i-border-$color-button-utility-border-active",destructive:"i-bg-$color-button-negative-background i-text-$color-button-negative-text hover:i-text-$color-button-negative-text hover:i-bg-$color-button-negative-background-hover active:i-bg-$color-button-negative-background-active",pill:"i-text-$color-button-pill-icon hover:i-text-$color-button-pill-icon-hover active:i-text-$color-button-pill-icon-active i-bg-$color-button-pill-background hover:i-bg-$color-button-pill-background-hover active:i-bg-$color-button-pill-background-active",disabled:"i-text-$color-button-disabled-text i-bg-$color-button-disabled-background",quiet:"i-bg-$color-button-quiet-background i-text-$color-button-quiet-text hover:i-bg-$color-button-quiet-background-hover active:i-bg-$color-button-quiet-background-active",utilityQuiet:"i-text-$color-button-utility-quiet-text i-bg-$color-button-utility-quiet-background hover:i-bg-$color-button-utility-quiet-background-hover",negativeQuiet:"i-bg-$color-button-negative-quiet-background i-text-$color-button-negative-quiet-text hover:i-bg-$color-button-negative-quiet-background-hover active:i-bg-$color-button-negative-quiet-background-active",loading:"i-text-$color-button-loading-text i-bg-$color-button-loading-background",link:"i-text-$color-button-link-text"},t={primary:`border-0 rounded-8 ${c}`,secondary:`border-2 rounded-8 ${c}`,utility:`border rounded-4 ${c}`,negative:`border-0 rounded-8 ${c}`,pill:`p-4 rounded-full border-0 inline-flex items-center justify-center hover:bg-clip-padding ${c}`,link:`bg-transparent focusable ease-in-out inline active:underline hover:underline ${i.link}`},r={xsmall:"py-6 px-16",small:"py-8 px-16",medium:"py-10 px-14",large:"py-12 px-16",utility:"py-[11px] px-[15px]",smallUtility:"py-[7px] px-[15px]",pill:"min-h-[44px] min-w-[44px]",pillSmall:"min-h-32 min-w-32",link:"p-0"},o={medium:"text-m leading-[24]",xsmall:"text-xs"},e={inProgress:`border-transparent animate-inprogress pointer-events-none ${i.loading}`,quiet:`border-0 rounded-8 ${c}`,utilityQuiet:`border-0 rounded-4 ${c}`,negativeQuiet:`border-0 rounded-8 ${c}`,isDisabled:`font-bold justify-center transition-colors ease-in-out cursor-default pointer-events-none ${i.disabled}`},q={secondary:`${r.medium} ${o.medium} ${t.secondary} ${i.secondary}`,secondaryHref:`${r.medium} ${o.medium} ${t.secondary} ${i.secondary}`,secondaryDisabled:`${r.medium} ${o.medium} ${t.secondary} ${e.isDisabled}`,secondarySmall:`${o.xsmall} ${r.xsmall} ${t.secondary} ${i.secondary}`,secondarySmallDisabled:`${o.xsmall} ${r.xsmall} ${t.secondary} ${e.isDisabled}`,secondaryQuiet:`${r.medium} ${o.medium} ${e.quiet} ${i.quiet}`,secondaryQuietDisabled:`${r.medium} ${o.medium} ${e.quiet} ${e.isDisabled}`,secondarySmallQuiet:`${o.xsmall} ${r.xsmall} ${e.quiet} ${i.quiet}`,secondarySmallQuietDisabled:`${o.xsmall} ${r.xsmall} ${e.quiet} ${e.isDisabled}`,secondaryLoading:`${r.medium} ${o.medium} ${t.secondary} ${e.inProgress}`,secondarySmallLoading:`${o.xsmall} ${r.xsmall} ${t.secondary} ${e.inProgress}`,secondarySmallQuietLoading:`${o.xsmall} ${r.xsmall} ${e.quiet} ${e.inProgress}`,secondaryQuietLoading:`${r.medium} ${o.medium} ${e.quiet} ${e.inProgress}`,primary:`${r.large} ${o.medium} ${t.primary} ${i.primary}`,primaryDisabled:`${r.large} ${o.medium} ${e.isDisabled} ${t.primary}`,primarySmall:`${r.small} ${o.xsmall} ${t.primary} ${i.primary}`,primarySmallDisabled:`${r.small} ${o.xsmall} ${e.isDisabled} ${t.primary} `,primaryQuiet:`${r.large} ${o.medium} ${e.quiet} ${i.quiet}`,primaryQuietDisabled:`${r.large} ${o.medium} ${e.quiet} ${e.isDisabled}`,primarySmallQuiet:`${r.small} ${o.xsmall} ${e.quiet} ${i.quiet}`,primarySmallQuietDisabled:`${r.small} ${o.xsmall} ${e.quiet} ${e.isDisabled}`,primaryLoading:`${r.large} ${o.medium} ${e.inProgress} ${t.primary}`,primarySmallLoading:`${r.small} ${o.xsmall} ${e.inProgress} ${t.primary}`,primarySmallQuietLoading:`${r.small} ${o.xsmall} ${e.quiet} ${e.inProgress} ${t.primary}`,primaryQuietLoading:`${r.large} ${o.medium} ${e.quiet} ${e.inProgress}`,utility:`${r.utility} ${o.medium} ${t.utility} ${i.utility}`,utilityDisabled:`${r.utility} ${o.medium} ${t.utility} ${e.isDisabled}`,utilityQuiet:`${r.large} ${o.medium} ${e.utilityQuiet} ${i.utilityQuiet}`,utilityQuietDisabled:`${r.large} ${o.medium} ${e.utilityQuiet} ${e.isDisabled}`,utilitySmall:`${r.smallUtility} ${o.xsmall} ${t.utility} ${i.utility}`,utilitySmallDisabled:`${r.smallUtility} ${o.xsmall} ${t.utility} ${e.isDisabled}`,utilitySmallQuiet:`${r.smallUtility} ${o.xsmall} ${e.utilityQuiet} ${i.utilityQuiet}`,utilitySmallQuietDisabled:`${r.smallUtility} ${o.xsmall} ${e.utilityQuiet} ${e.isDisabled}`,utilityLoading:`${r.large} ${o.medium} ${t.utility} ${e.inProgress}`,utilitySmallLoading:`${r.smallUtility} ${o.xsmall} ${t.utility} ${e.inProgress}`,utilityQuietLoading:`${r.large} ${o.medium} ${e.inProgress} ${e.utilityQuiet}`,utilitySmallQuietLoading:`${r.smallUtility} ${o.xsmall} ${e.inProgress} ${e.utilityQuiet}`,negative:`${r.large} ${o.medium} ${t.negative} ${i.destructive}`,negativeDisabled:`${r.large} ${o.medium} ${t.negative} ${e.isDisabled}`,negativeQuiet:`${r.large} ${o.medium} ${e.negativeQuiet} ${i.negativeQuiet}`,negativeQuietDisabled:`${r.large} ${o.medium} ${e.negativeQuiet}${e.isDisabled}`,negativeSmall:`${r.small} ${o.xsmall} ${t.negative} ${i.destructive}`,negativeSmallDisabled:`${r.small} ${o.xsmall} ${t.negative} ${e.isDisabled}`,negativeSmallQuiet:`${r.small} ${o.xsmall} ${e.negativeQuiet} ${i.negativeQuiet}`,negativeSmallQuietDisabled:`${r.small} ${o.xsmall} ${e.negativeQuiet} ${e.isDisabled}`,negativeLoading:`${r.large} ${o.medium} ${t.negative} ${e.inProgress}`,negativeSmallLoading:`${r.small} ${o.xsmall} ${e.inProgress} ${t.negative}`,negativeQuietLoading:`${r.large} ${o.medium} ${e.negativeQuiet} ${t.negative} ${e.inProgress}`,negativeSmallQuietLoading:`${r.small} ${o.xsmall} ${e.negativeQuiet} ${e.inProgress}`,pill:`${r.pill} ${o.medium} ${t.pill} ${i.pill}`,pillSmall:`${r.pillSmall} ${o.xsmall} ${t.pill} ${i.pill}`,pillLoading:`${r.pill} ${o.medium} ${t.pill} ${e.inProgress}`,pillSmallLoading:`${r.pillSmall} ${o.xsmall} ${t.pill} ${e.inProgress}`,link:`${r.link} ${o.medium} ${t.link}`,linkSmall:`${r.link} ${o.xsmall} ${t.link}`,linkAsButton:"inline-block hover:no-underline text-center",a11y:"sr-only",fullWidth:"w-full max-w-full",contentWidth:"max-w-max"};var B={transparentBg:'before:i-bg-$color-modal-backdrop-background before:content-[""] before:absolute before:top-0 before:bottom-0 before:left-0 before:right-0 before:opacity-25',backdrop:"fixed inset-0 flex sm:place-content-center sm:place-items-center items-end z-20 [--w-modal-max-height:80%] [--w-modal-width:640px]",modal:"pb-safe-[32] i-shadow-$shadow-modal max-h-[--w-modal-max-height] min-h-[--w-modal-min-height] w-[--w-modal-width] h-[--w-modal-height] relative transition-300 ease-in-out backface-hidden will-change-height rounded-8 mx-0 sm:mx-16 i-bg-$color-modal-background flex flex-col overflow-hidden outline-none space-y-16 pt-8 sm:pt-32 sm:pb-32 rounded-b-0 sm:rounded-b-8",content:"block overflow-y-auto overflow-x-hidden last-child:mb-0 grow shrink px-16 sm:px-32 relative",footer:"flex justify-end shrink-0 px-16 sm:px-32",transitionTitle:"transition-all duration-300",transitionTitleCenter:"justify-self-center",transitionTitleColSpan:"col-span-2",title:"-mt-4 sm:-mt-8 h-40 sm:h-48 grid gap-8 sm:gap-16 grid-cols-[auto_1fr_auto] items-center px-16 sm:px-32 border-b sm:border-b-0 shrink-0",titleText:"mb-0 h4 sm:h3",titleButton:`${o.medium} ${t.pill} ${i.pill} sm:min-h-[44px] sm:min-w-[44px] min-h-[32px] min-w-[32px]`,titleButtonLeft:"-ml-8 sm:-ml-12 justify-self-start",titleButtonRight:"-mr-8 sm:-mr-12 justify-self-end",titleButtonIcon:"h-16 w-16 sm:h-24 sm:w-24",titleButtonIconRotated:"transform rotate-90"};var b={default:"block text-m mb-0 leading-m i-text-$color-input-text-filled i-bg-$color-input-background i-border-$color-input-border hover:i-border-$color-input-border-hover active:i-border-$color-input-border-active rounded-4 py-12 px-8 block border-1 w-full focusable focus:[--w-outline-offset:-2px] caret-current",textArea:"min-h-[42] sm:min-h-[45]",disabled:"i-bg-$color-input-background-disabled i-border-$color-input-border-disabled hover:i-border-$color-input-border-disabled! i-text-$color-input-text-disabled pointer-events-none",invalid:"i-border-$color-input-border-negative i-text-$color-input-text-negative!",readOnly:"pl-0 bg-transparent border-0 pointer-events-none i-text-$color-input-text-read-only",placeholder:"placeholder:i-text-$color-input-text-placeholder",wrapper:"relative",suffix:"pr-40",prefix:"pl-40"};var g={label:"antialiased block relative text-s font-bold pb-4 cursor-pointer i-text-$color-label-text",labelInvalid:"i-text-$color-label-text-negative",optional:"pl-8 font-normal text-s i-text-$color-label-optional-text"},m={helpText:"text-xs mt-4 block i-text-$color-helptext-text",helpTextValid:"i-text-$color-helptext-text-positive",helpTextInvalid:"i-text-$color-helptext-text-negative"},f="absolute top-0 bottom-0 flex justify-center items-center focusable focus:[--w-outline-offset:-2px] bg-transparent ",T={wrapper:f+"right-0",wrapperWithLabel:"w-max pr-12",wrapperWithIcon:"w-40",label:"antialiased block relative cursor-default pb-0 font-bold text-xs i-text-$color-label-text"},C={wrapper:f+"left-0",wrapperWithLabel:"w-max pl-12",wrapperWithIcon:"w-40",label:"antialiased block relative cursor-default pb-0 font-bold text-xs i-text-$color-label-text"};var I={toggle:"absolute inset-0 h-full w-full appearance-none cursor-pointer focusable focusable-inset",label:`px-12 ${g.label} py-8! cursor-pointer focusable focusable-inset`,buttonOrLink:"bg-transparent focusable",buttonOrLinkStretch:"inset-0 absolute"};var P={base:"border-2 relative flex items-start",tooltip:"i-bg-$color-tooltip-background i-border-$color-tooltip-background i-shadow-$shadow-tooltip i-text-$color-tooltip-text rounded-4 py-6 px-8",callout:"i-bg-$color-callout-background i-border-$color-callout-border i-text-$color-callout-text py-8 px-16 rounded-8",highlight:"i-bg-$color-callout-background i-border-$color-callout-border i-text-$color-callout-text py-8 px-16 rounded-8 drop-shadow-m",popover:"i-bg-$color-popover-background i-border-$color-popover-background i-text-$color-popover-paragraph-text rounded-8 p-16 drop-shadow-m",arrowBase:"absolute h-[14px] w-[14px] border-2 border-b-0 border-r-0 rounded-tl-4 transform",arrowDirectionLeft:"-left-[8px]",arrowDirectionRight:"-right-[8px]",arrowDirectionBottom:"-bottom-[8px]",arrowDirectionTop:"-top-[8px]",arrowTooltip:"i-bg-$color-tooltip-background i-border-$color-tooltip-background",arrowCallout:"i-bg-$color-callout-background i-border-$color-callout-border",arrowPopover:"i-bg-$color-popover-background i-border-$color-popover-background",arrowHighlight:"i-bg-$color-callout-background i-border-$color-callout-border",content:"last-child:mb-0",notCallout:"absolute z-50",closeBtn:`${o.medium} ${t.pill} ${i.pill} justify-self-end -mr-8 ml-8`};import{ifDefined as a}from"lit/directives/if-defined.js";import{classMap as D}from"lit/directives/class-map.js";function p(d){let l={};for(let[n,s]of Object.entries(d))for(let $ of n.split(" "))l[$]=s;return D(l)}var u=class extends k{constructor(){super(),this.type="text"}get _inputStyles(){return p({[b.default]:!0,[b.invalid]:this.invalid,[b.disabled]:this.disabled,[b.readOnly]:this.readOnly,[b.suffix]:this._hasSuffix,[b.prefix]:this._hasPrefix})}get _helpTextStyles(){return p({[m.helpText]:!0,[m.helpTextInvalid]:this.invalid})}get _labelStyles(){return p({[g.label]:!0,[g.labelInvalid]:this.invalid})}get _label(){if(this.label)return v`<label for="${this._id}" class=${this._labelStyles}>${this.label}</label>`}get _helpId(){if(this.helpText)return`${this._id}__hint`}get _id(){return"textfield"}get _error(){if(this.invalid&&this._helpId)return this._helpId}handler(l){let{name:n,value:s}=l.target,$=new CustomEvent(l.type,{detail:{name:n,value:s,target:l.target}});this.dispatchEvent($)}prefixSlotChange(l){this.renderRoot.querySelector("slot[name=prefix]").assignedElements().length&&(this._hasPrefix=!0)}suffixSlotChange(l){this.renderRoot.querySelector("slot[name=suffix]").assignedElements().length&&(this._hasSuffix=!0)}render(){return v`
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => {
|
|
4
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
return value;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
// packages/textfield/index.js
|
|
9
|
+
import { css, html } from "lit";
|
|
10
|
+
import WarpElement from "@warp-ds/elements-core";
|
|
11
|
+
|
|
12
|
+
// node_modules/.pnpm/@warp-ds+css@1.4.2/node_modules/@warp-ds/css/component-classes/index.js
|
|
13
|
+
var box = {
|
|
14
|
+
box: "group block relative break-words last-child:mb-0 p-16 rounded-8",
|
|
15
|
+
// Relative here enables w-clickable
|
|
16
|
+
bleed: "-mx-16 sm:mx-0 rounded-l-0 rounded-r-0 sm:rounded-8",
|
|
17
|
+
// We target L and R to override the default rounded-8
|
|
18
|
+
info: "i-bg-$color-box-info-background i-text-$color-box-info-text",
|
|
19
|
+
neutral: "i-bg-$color-box-neutral-background i-text-$color-box-neutral-text",
|
|
20
|
+
bordered: "border-2 i-border-$color-box-bordered-border i-bg-$color-box-bordered-background i-text-$color-box-bordered-text",
|
|
21
|
+
infoClickable: "hover:i-bg-$color-box-info-background-hover active:i-bg-$color-box-info-background-hover",
|
|
22
|
+
neutralClickable: "hover:i-bg-$color-box-neutral-background-hover active:i-bg-$color-box-neutral-background-hover",
|
|
23
|
+
borderedClickable: "hover:i-bg-$color-box-bordered-background-hover active:i-bg-$color-box-bordered-background-hover hover:i-border-$color-box-bordered-border-hover active:i-border-$color-box-bordered-border-hover"
|
|
24
|
+
};
|
|
25
|
+
var buttonReset = "focus:outline-none appearance-none cursor-pointer bg-transparent border-0 m-0 p-0 inline-block";
|
|
26
|
+
var expandable = {
|
|
27
|
+
expandable: "will-change-height",
|
|
28
|
+
expandableTitle: "font-bold i-text-$color-expandable-title-text",
|
|
29
|
+
expandableBox: "i-bg-$color-expandable-background hover:i-bg-$color-expandable-background-hover py-0 px-0 " + box.box,
|
|
30
|
+
expandableBleed: box.bleed,
|
|
31
|
+
chevron: "inline-block align-middle i-text-$color-expandable-icon",
|
|
32
|
+
chevronNonBox: "ml-8",
|
|
33
|
+
chevronBox: "",
|
|
34
|
+
chevronTransform: "transform transition-transform transform-gpu ease-in-out",
|
|
35
|
+
chevronExpand: "-rotate-180",
|
|
36
|
+
chevronCollapse: "rotate-180",
|
|
37
|
+
elementsTransformChevronDownPart: "part-[w-icon-chevron-down-16-part]:transform part-[w-icon-chevron-down-16-part]:transition-transform part-[w-icon-chevron-down-16-part]:transform-gpu part-[w-icon-chevron-down-16-part]:ease-in-out",
|
|
38
|
+
elementsChevronDownExpandPart: "part-[w-icon-chevron-down-16-part]:-rotate-180",
|
|
39
|
+
elementsTransformChevronUpPart: "part-[w-icon-chevron-up-16-part]:transform part-[w-icon-chevron-up-16-part]:transition-transform part-[w-icon-chevron-up-16-part]:transform-gpu part-[w-icon-chevron-up-16-part]:ease-in-out",
|
|
40
|
+
elementsChevronUpCollapsePart: "part-[w-icon-chevron-up-16-part]:rotate-180",
|
|
41
|
+
expansion: "overflow-hidden",
|
|
42
|
+
expansionNotExpanded: "h-0 invisible",
|
|
43
|
+
button: buttonReset + " hover:underline focus-visible:underline",
|
|
44
|
+
buttonBox: "w-full text-left relative inline-flex items-center justify-between " + box.box,
|
|
45
|
+
paddingTop: "pt-0",
|
|
46
|
+
title: "flex w-full justify-between items-center",
|
|
47
|
+
titleType: "h4"
|
|
48
|
+
};
|
|
49
|
+
var buttonDefaultStyling = "font-bold focusable justify-center transition-colors ease-in-out";
|
|
50
|
+
var buttonColors = {
|
|
51
|
+
primary: "i-text-$color-button-primary-text hover:i-text-$color-button-primary-text i-bg-$color-button-primary-background hover:i-bg-$color-button-primary-background-hover active:i-bg-$color-button-primary-background-active",
|
|
52
|
+
secondary: "i-text-$color-button-secondary-text hover:i-text-$color-button-secondary-text i-border-$color-button-secondary-border i-bg-$color-button-secondary-background hover:i-bg-$color-button-secondary-background-hover hover:i-border-$color-button-secondary-border-hover active:i-bg-$color-button-secondary-background-active",
|
|
53
|
+
utility: "i-text-$color-button-utility-text hover:i-text-$color-button-utility-text i-bg-$color-button-utility-background i-border-$color-button-utility-border hover:i-bg-$color-button-utility-background hover:i-border-$color-button-utility-border-hover active:i-border-$color-button-utility-border-active",
|
|
54
|
+
destructive: "i-bg-$color-button-negative-background i-text-$color-button-negative-text hover:i-text-$color-button-negative-text hover:i-bg-$color-button-negative-background-hover active:i-bg-$color-button-negative-background-active",
|
|
55
|
+
pill: "i-text-$color-button-pill-icon hover:i-text-$color-button-pill-icon-hover active:i-text-$color-button-pill-icon-active i-bg-$color-button-pill-background hover:i-bg-$color-button-pill-background-hover active:i-bg-$color-button-pill-background-active",
|
|
56
|
+
disabled: "i-text-$color-button-disabled-text i-bg-$color-button-disabled-background",
|
|
57
|
+
quiet: "i-bg-$color-button-quiet-background i-text-$color-button-quiet-text hover:i-bg-$color-button-quiet-background-hover active:i-bg-$color-button-quiet-background-active",
|
|
58
|
+
utilityQuiet: "i-text-$color-button-utility-quiet-text i-bg-$color-button-utility-quiet-background hover:i-bg-$color-button-utility-quiet-background-hover",
|
|
59
|
+
negativeQuiet: "i-bg-$color-button-negative-quiet-background i-text-$color-button-negative-quiet-text hover:i-bg-$color-button-negative-quiet-background-hover active:i-bg-$color-button-negative-quiet-background-active",
|
|
60
|
+
loading: "i-text-$color-button-loading-text i-bg-$color-button-loading-background",
|
|
61
|
+
link: "i-text-$color-button-link-text"
|
|
62
|
+
};
|
|
63
|
+
var buttonTypes = {
|
|
64
|
+
primary: `border-0 rounded-8 ${buttonDefaultStyling}`,
|
|
65
|
+
secondary: `border-2 rounded-8 ${buttonDefaultStyling}`,
|
|
66
|
+
utility: `border rounded-4 ${buttonDefaultStyling}`,
|
|
67
|
+
negative: `border-0 rounded-8 ${buttonDefaultStyling}`,
|
|
68
|
+
pill: `p-4 rounded-full border-0 inline-flex items-center justify-center hover:bg-clip-padding ${buttonDefaultStyling}`,
|
|
69
|
+
link: `bg-transparent focusable ease-in-out inline active:underline hover:underline ${buttonColors.link}`
|
|
70
|
+
};
|
|
71
|
+
var buttonSizes = {
|
|
72
|
+
xsmall: "py-6 px-16",
|
|
73
|
+
small: "py-8 px-16",
|
|
74
|
+
medium: "py-10 px-14",
|
|
75
|
+
large: "py-12 px-16",
|
|
76
|
+
utility: "py-[11px] px-[15px]",
|
|
77
|
+
smallUtility: "py-[7px] px-[15px]",
|
|
78
|
+
pill: "min-h-[44px] min-w-[44px]",
|
|
79
|
+
pillSmall: "min-h-32 min-w-32",
|
|
80
|
+
link: "p-0"
|
|
81
|
+
};
|
|
82
|
+
var buttonTextSizes = {
|
|
83
|
+
medium: "text-m leading-[24]",
|
|
84
|
+
xsmall: "text-xs"
|
|
85
|
+
};
|
|
86
|
+
var buttonVariants = {
|
|
87
|
+
inProgress: `border-transparent animate-inprogress pointer-events-none ${buttonColors.loading}`,
|
|
88
|
+
// .button--in-progress, a.button--in-progress:visited
|
|
89
|
+
quiet: `border-0 rounded-8 ${buttonDefaultStyling}`,
|
|
90
|
+
utilityQuiet: `border-0 rounded-4 ${buttonDefaultStyling}`,
|
|
91
|
+
negativeQuiet: `border-0 rounded-8 ${buttonDefaultStyling}`,
|
|
92
|
+
isDisabled: `font-bold justify-center transition-colors ease-in-out cursor-default pointer-events-none ${buttonColors.disabled}`
|
|
93
|
+
// .button:disabled, .button--is-disabled
|
|
94
|
+
};
|
|
95
|
+
var button = {
|
|
96
|
+
// Buttontypes
|
|
97
|
+
secondary: `${buttonSizes.medium} ${buttonTextSizes.medium} ${buttonTypes.secondary} ${buttonColors.secondary}`,
|
|
98
|
+
// .button--secondary, .button--default, .button
|
|
99
|
+
secondaryHref: `${buttonSizes.medium} ${buttonTextSizes.medium} ${buttonTypes.secondary} ${buttonColors.secondary}`,
|
|
100
|
+
secondaryDisabled: `${buttonSizes.medium} ${buttonTextSizes.medium} ${buttonTypes.secondary} ${buttonVariants.isDisabled}`,
|
|
101
|
+
secondarySmall: `${buttonTextSizes.xsmall} ${buttonSizes.xsmall} ${buttonTypes.secondary} ${buttonColors.secondary}`,
|
|
102
|
+
secondarySmallDisabled: `${buttonTextSizes.xsmall} ${buttonSizes.xsmall} ${buttonTypes.secondary} ${buttonVariants.isDisabled}`,
|
|
103
|
+
secondaryQuiet: `${buttonSizes.medium} ${buttonTextSizes.medium} ${buttonVariants.quiet} ${buttonColors.quiet}`,
|
|
104
|
+
secondaryQuietDisabled: `${buttonSizes.medium} ${buttonTextSizes.medium} ${buttonVariants.quiet} ${buttonVariants.isDisabled}`,
|
|
105
|
+
secondarySmallQuiet: `${buttonTextSizes.xsmall} ${buttonSizes.xsmall} ${buttonVariants.quiet} ${buttonColors.quiet}`,
|
|
106
|
+
secondarySmallQuietDisabled: `${buttonTextSizes.xsmall} ${buttonSizes.xsmall} ${buttonVariants.quiet} ${buttonVariants.isDisabled}`,
|
|
107
|
+
secondaryLoading: `${buttonSizes.medium} ${buttonTextSizes.medium} ${buttonTypes.secondary} ${buttonVariants.inProgress}`,
|
|
108
|
+
secondarySmallLoading: `${buttonTextSizes.xsmall} ${buttonSizes.xsmall} ${buttonTypes.secondary} ${buttonVariants.inProgress}`,
|
|
109
|
+
secondarySmallQuietLoading: `${buttonTextSizes.xsmall} ${buttonSizes.xsmall} ${buttonVariants.quiet} ${buttonVariants.inProgress}`,
|
|
110
|
+
secondaryQuietLoading: `${buttonSizes.medium} ${buttonTextSizes.medium} ${buttonVariants.quiet} ${buttonVariants.inProgress}`,
|
|
111
|
+
primary: `${buttonSizes.large} ${buttonTextSizes.medium} ${buttonTypes.primary} ${buttonColors.primary}`,
|
|
112
|
+
// .button--primary, .button--cta
|
|
113
|
+
primaryDisabled: `${buttonSizes.large} ${buttonTextSizes.medium} ${buttonVariants.isDisabled} ${buttonTypes.primary}`,
|
|
114
|
+
primarySmall: `${buttonSizes.small} ${buttonTextSizes.xsmall} ${buttonTypes.primary} ${buttonColors.primary}`,
|
|
115
|
+
primarySmallDisabled: `${buttonSizes.small} ${buttonTextSizes.xsmall} ${buttonVariants.isDisabled} ${buttonTypes.primary} `,
|
|
116
|
+
primaryQuiet: `${buttonSizes.large} ${buttonTextSizes.medium} ${buttonVariants.quiet} ${buttonColors.quiet}`,
|
|
117
|
+
primaryQuietDisabled: `${buttonSizes.large} ${buttonTextSizes.medium} ${buttonVariants.quiet} ${buttonVariants.isDisabled}`,
|
|
118
|
+
primarySmallQuiet: `${buttonSizes.small} ${buttonTextSizes.xsmall} ${buttonVariants.quiet} ${buttonColors.quiet}`,
|
|
119
|
+
primarySmallQuietDisabled: `${buttonSizes.small} ${buttonTextSizes.xsmall} ${buttonVariants.quiet} ${buttonVariants.isDisabled}`,
|
|
120
|
+
primaryLoading: `${buttonSizes.large} ${buttonTextSizes.medium} ${buttonVariants.inProgress} ${buttonTypes.primary}`,
|
|
121
|
+
primarySmallLoading: `${buttonSizes.small} ${buttonTextSizes.xsmall} ${buttonVariants.inProgress} ${buttonTypes.primary}`,
|
|
122
|
+
primarySmallQuietLoading: `${buttonSizes.small} ${buttonTextSizes.xsmall} ${buttonVariants.quiet} ${buttonVariants.inProgress} ${buttonTypes.primary}`,
|
|
123
|
+
primaryQuietLoading: `${buttonSizes.large} ${buttonTextSizes.medium} ${buttonVariants.quiet} ${buttonVariants.inProgress}`,
|
|
124
|
+
utility: `${buttonSizes.utility} ${buttonTextSizes.medium} ${buttonTypes.utility} ${buttonColors.utility}`,
|
|
125
|
+
// .button--utility
|
|
126
|
+
utilityDisabled: `${buttonSizes.utility} ${buttonTextSizes.medium} ${buttonTypes.utility} ${buttonVariants.isDisabled}`,
|
|
127
|
+
utilityQuiet: `${buttonSizes.large} ${buttonTextSizes.medium} ${buttonVariants.utilityQuiet} ${buttonColors.utilityQuiet}`,
|
|
128
|
+
// .button--utility-flat
|
|
129
|
+
utilityQuietDisabled: `${buttonSizes.large} ${buttonTextSizes.medium} ${buttonVariants.utilityQuiet} ${buttonVariants.isDisabled}`,
|
|
130
|
+
utilitySmall: `${buttonSizes.smallUtility} ${buttonTextSizes.xsmall} ${buttonTypes.utility} ${buttonColors.utility}`,
|
|
131
|
+
utilitySmallDisabled: `${buttonSizes.smallUtility} ${buttonTextSizes.xsmall} ${buttonTypes.utility} ${buttonVariants.isDisabled}`,
|
|
132
|
+
utilitySmallQuiet: `${buttonSizes.smallUtility} ${buttonTextSizes.xsmall} ${buttonVariants.utilityQuiet} ${buttonColors.utilityQuiet}`,
|
|
133
|
+
utilitySmallQuietDisabled: `${buttonSizes.smallUtility} ${buttonTextSizes.xsmall} ${buttonVariants.utilityQuiet} ${buttonVariants.isDisabled}`,
|
|
134
|
+
utilityLoading: `${buttonSizes.large} ${buttonTextSizes.medium} ${buttonTypes.utility} ${buttonVariants.inProgress}`,
|
|
135
|
+
utilitySmallLoading: `${buttonSizes.smallUtility} ${buttonTextSizes.xsmall} ${buttonTypes.utility} ${buttonVariants.inProgress}`,
|
|
136
|
+
utilityQuietLoading: `${buttonSizes.large} ${buttonTextSizes.medium} ${buttonVariants.inProgress} ${buttonVariants.utilityQuiet}`,
|
|
137
|
+
utilitySmallQuietLoading: `${buttonSizes.smallUtility} ${buttonTextSizes.xsmall} ${buttonVariants.inProgress} ${buttonVariants.utilityQuiet}`,
|
|
138
|
+
negative: `${buttonSizes.large} ${buttonTextSizes.medium} ${buttonTypes.negative} ${buttonColors.destructive}`,
|
|
139
|
+
// .button--destructive
|
|
140
|
+
negativeDisabled: `${buttonSizes.large} ${buttonTextSizes.medium} ${buttonTypes.negative} ${buttonVariants.isDisabled}`,
|
|
141
|
+
negativeQuiet: `${buttonSizes.large} ${buttonTextSizes.medium} ${buttonVariants.negativeQuiet} ${buttonColors.negativeQuiet}`,
|
|
142
|
+
// .button--destructive-flat
|
|
143
|
+
negativeQuietDisabled: `${buttonSizes.large} ${buttonTextSizes.medium} ${buttonVariants.negativeQuiet}${buttonVariants.isDisabled}`,
|
|
144
|
+
negativeSmall: `${buttonSizes.small} ${buttonTextSizes.xsmall} ${buttonTypes.negative} ${buttonColors.destructive}`,
|
|
145
|
+
negativeSmallDisabled: `${buttonSizes.small} ${buttonTextSizes.xsmall} ${buttonTypes.negative} ${buttonVariants.isDisabled}`,
|
|
146
|
+
negativeSmallQuiet: `${buttonSizes.small} ${buttonTextSizes.xsmall} ${buttonVariants.negativeQuiet} ${buttonColors.negativeQuiet}`,
|
|
147
|
+
negativeSmallQuietDisabled: `${buttonSizes.small} ${buttonTextSizes.xsmall} ${buttonVariants.negativeQuiet} ${buttonVariants.isDisabled}`,
|
|
148
|
+
negativeLoading: `${buttonSizes.large} ${buttonTextSizes.medium} ${buttonTypes.negative} ${buttonVariants.inProgress}`,
|
|
149
|
+
negativeSmallLoading: `${buttonSizes.small} ${buttonTextSizes.xsmall} ${buttonVariants.inProgress} ${buttonTypes.negative}`,
|
|
150
|
+
negativeQuietLoading: `${buttonSizes.large} ${buttonTextSizes.medium} ${buttonVariants.negativeQuiet} ${buttonTypes.negative} ${buttonVariants.inProgress}`,
|
|
151
|
+
negativeSmallQuietLoading: `${buttonSizes.small} ${buttonTextSizes.xsmall} ${buttonVariants.negativeQuiet} ${buttonVariants.inProgress}`,
|
|
152
|
+
pill: `${buttonSizes.pill} ${buttonTextSizes.medium} ${buttonTypes.pill} ${buttonColors.pill}`,
|
|
153
|
+
// .button--pill
|
|
154
|
+
pillSmall: `${buttonSizes.pillSmall} ${buttonTextSizes.xsmall} ${buttonTypes.pill} ${buttonColors.pill}`,
|
|
155
|
+
pillLoading: `${buttonSizes.pill} ${buttonTextSizes.medium} ${buttonTypes.pill} ${buttonVariants.inProgress}`,
|
|
156
|
+
pillSmallLoading: `${buttonSizes.pillSmall} ${buttonTextSizes.xsmall} ${buttonTypes.pill} ${buttonVariants.inProgress}`,
|
|
157
|
+
link: `${buttonSizes.link} ${buttonTextSizes.medium} ${buttonTypes.link}`,
|
|
158
|
+
linkSmall: `${buttonSizes.link} ${buttonTextSizes.xsmall} ${buttonTypes.link}`,
|
|
159
|
+
linkAsButton: "inline-block hover:no-underline text-center",
|
|
160
|
+
a11y: "sr-only",
|
|
161
|
+
fullWidth: "w-full max-w-full",
|
|
162
|
+
contentWidth: "max-w-max"
|
|
163
|
+
};
|
|
164
|
+
var modal = {
|
|
165
|
+
//TODO: this class can be removed when we have the solution for opacity and we can add rgba values to the background of the backdrop
|
|
166
|
+
transparentBg: `before:i-bg-$color-modal-backdrop-background before:content-[""] before:absolute before:top-0 before:bottom-0 before:left-0 before:right-0 before:opacity-25`,
|
|
167
|
+
backdrop: "fixed inset-0 flex sm:place-content-center sm:place-items-center items-end z-30 [--w-modal-max-height:80%] [--w-modal-width:640px]",
|
|
168
|
+
modal: "pb-safe-[32] i-shadow-$shadow-modal max-h-[--w-modal-max-height] min-h-[--w-modal-min-height] w-[--w-modal-width] h-[--w-modal-height] relative transition-300 ease-in-out backface-hidden will-change-height rounded-8 mx-0 sm:mx-16 i-bg-$color-modal-background flex flex-col overflow-hidden outline-none space-y-16 pt-8 sm:pt-32 sm:pb-32 rounded-b-0 sm:rounded-b-8",
|
|
169
|
+
content: "block overflow-y-auto overflow-x-hidden last-child:mb-0 grow shrink px-16 sm:px-32 relative",
|
|
170
|
+
footer: "flex justify-end shrink-0 px-16 sm:px-32",
|
|
171
|
+
transitionTitle: "transition-all duration-300",
|
|
172
|
+
transitionTitleCenter: "justify-self-center",
|
|
173
|
+
transitionTitleColSpan: "col-span-2",
|
|
174
|
+
title: "-mt-4 sm:-mt-8 h-40 sm:h-48 grid gap-8 sm:gap-16 grid-cols-[auto_1fr_auto] items-center px-16 sm:px-32 border-b sm:border-b-0 shrink-0",
|
|
175
|
+
titleText: "mb-0 h4 sm:h3",
|
|
176
|
+
titleButton: `${buttonTextSizes.medium} ${buttonTypes.pill} ${buttonColors.pill} sm:min-h-[44px] sm:min-w-[44px] min-h-[32px] min-w-[32px]`,
|
|
177
|
+
titleButtonLeft: "-ml-8 sm:-ml-12 justify-self-start",
|
|
178
|
+
titleButtonRight: "-mr-8 sm:-mr-12 justify-self-end",
|
|
179
|
+
titleButtonIcon: "h-16 w-16 sm:h-24 sm:w-24",
|
|
180
|
+
titleButtonIconRotated: "transform rotate-90"
|
|
181
|
+
};
|
|
182
|
+
var input = {
|
|
183
|
+
default: "block text-m mb-0 leading-m i-text-$color-input-text-filled i-bg-$color-input-background i-border-$color-input-border hover:i-border-$color-input-border-hover active:i-border-$color-input-border-active rounded-4 py-12 px-8 block border-1 w-full focusable focus:[--w-outline-offset:-2px] caret-current",
|
|
184
|
+
textArea: "min-h-[42] sm:min-h-[45]",
|
|
185
|
+
disabled: "i-bg-$color-input-background-disabled i-border-$color-input-border-disabled hover:i-border-$color-input-border-disabled! i-text-$color-input-text-disabled pointer-events-none",
|
|
186
|
+
invalid: "i-border-$color-input-border-negative i-text-$color-input-text-negative!",
|
|
187
|
+
readOnly: "pl-0 bg-transparent border-0 pointer-events-none i-text-$color-input-text-read-only",
|
|
188
|
+
placeholder: "placeholder:i-text-$color-input-text-placeholder",
|
|
189
|
+
wrapper: "relative",
|
|
190
|
+
suffix: "pr-40",
|
|
191
|
+
prefix: "pl-40"
|
|
192
|
+
};
|
|
193
|
+
var label = {
|
|
194
|
+
label: "antialiased block relative text-s font-bold pb-4 cursor-pointer i-text-$color-label-text",
|
|
195
|
+
labelInvalid: "i-text-$color-label-text-negative",
|
|
196
|
+
optional: "pl-8 font-normal text-s i-text-$color-label-optional-text"
|
|
197
|
+
};
|
|
198
|
+
var helpText = {
|
|
199
|
+
helpText: "text-xs mt-4 block i-text-$color-helptext-text",
|
|
200
|
+
helpTextValid: "i-text-$color-helptext-text-positive",
|
|
201
|
+
helpTextInvalid: "i-text-$color-helptext-text-negative"
|
|
202
|
+
};
|
|
203
|
+
var prefixSuffixWrapperBase = "absolute top-0 bottom-0 flex justify-center items-center focusable focus:[--w-outline-offset:-2px] bg-transparent ";
|
|
204
|
+
var suffix = {
|
|
205
|
+
wrapper: prefixSuffixWrapperBase + "right-0",
|
|
206
|
+
wrapperWithLabel: "w-max pr-12",
|
|
207
|
+
wrapperWithIcon: "w-40",
|
|
208
|
+
label: "antialiased block relative cursor-default pb-0 font-bold text-xs i-text-$color-label-text"
|
|
209
|
+
};
|
|
210
|
+
var prefix = {
|
|
211
|
+
wrapper: prefixSuffixWrapperBase + "left-0",
|
|
212
|
+
wrapperWithLabel: "w-max pl-12",
|
|
213
|
+
wrapperWithIcon: "w-40",
|
|
214
|
+
label: "antialiased block relative cursor-default pb-0 font-bold text-xs i-text-$color-label-text"
|
|
215
|
+
};
|
|
216
|
+
var clickable = {
|
|
217
|
+
toggle: "absolute inset-0 h-full w-full appearance-none cursor-pointer focusable focusable-inset",
|
|
218
|
+
label: `px-12 ${label.label} py-8! cursor-pointer focusable focusable-inset`,
|
|
219
|
+
buttonOrLink: "bg-transparent focusable",
|
|
220
|
+
buttonOrLinkStretch: "inset-0 absolute"
|
|
221
|
+
};
|
|
222
|
+
var attention = {
|
|
223
|
+
base: "border-2 relative flex items-start",
|
|
224
|
+
tooltip: "i-bg-$color-tooltip-background i-border-$color-tooltip-background i-shadow-$shadow-tooltip i-text-$color-tooltip-text rounded-4 py-6 px-8",
|
|
225
|
+
callout: "i-bg-$color-callout-background i-border-$color-callout-border i-text-$color-callout-text py-8 px-16 rounded-8",
|
|
226
|
+
highlight: "i-bg-$color-callout-background i-border-$color-callout-border i-text-$color-callout-text py-8 px-16 rounded-8 drop-shadow-m",
|
|
227
|
+
popover: "i-bg-$color-popover-background i-border-$color-popover-background i-text-$color-popover-paragraph-text rounded-8 p-16 drop-shadow-m",
|
|
228
|
+
arrowBase: "absolute h-[14px] w-[14px] border-2 border-b-0 border-r-0 rounded-tl-4 transform",
|
|
229
|
+
arrowDirectionLeft: "-left-[8px]",
|
|
230
|
+
arrowDirectionRight: "-right-[8px]",
|
|
231
|
+
arrowDirectionBottom: "-bottom-[8px]",
|
|
232
|
+
arrowDirectionTop: "-top-[8px]",
|
|
233
|
+
arrowTooltip: "i-bg-$color-tooltip-background i-border-$color-tooltip-background",
|
|
234
|
+
arrowCallout: "i-bg-$color-callout-background i-border-$color-callout-border",
|
|
235
|
+
arrowPopover: "i-bg-$color-popover-background i-border-$color-popover-background",
|
|
236
|
+
arrowHighlight: "i-bg-$color-callout-background i-border-$color-callout-border",
|
|
237
|
+
content: "last-child:mb-0",
|
|
238
|
+
notCallout: "absolute z-50",
|
|
239
|
+
closeBtn: `${buttonTextSizes.medium} ${buttonTypes.pill} ${buttonColors.pill} justify-self-end -mr-8 ml-8`
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
// packages/textfield/index.js
|
|
243
|
+
import { ifDefined } from "lit/directives/if-defined.js";
|
|
244
|
+
|
|
245
|
+
// packages/utils/index.js
|
|
246
|
+
import { classMap } from "lit/directives/class-map.js";
|
|
247
|
+
function fclasses(definition) {
|
|
248
|
+
const defn = {};
|
|
249
|
+
for (const [key, value] of Object.entries(definition)) {
|
|
250
|
+
for (const className of key.split(" ")) {
|
|
251
|
+
defn[className] = value;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
return classMap(defn);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// packages/textfield/index.js
|
|
258
|
+
var WarpTextField = class extends WarpElement {
|
|
259
|
+
constructor() {
|
|
260
|
+
super();
|
|
261
|
+
this.type = "text";
|
|
262
|
+
}
|
|
263
|
+
get _inputStyles() {
|
|
264
|
+
return fclasses({
|
|
265
|
+
[input.default]: true,
|
|
266
|
+
[input.invalid]: this.invalid,
|
|
267
|
+
[input.disabled]: this.disabled,
|
|
268
|
+
[input.readOnly]: this.readOnly,
|
|
269
|
+
[input.suffix]: this._hasSuffix,
|
|
270
|
+
// we style input with prefix here because we cannot use
|
|
271
|
+
// arbitrary values with commas in UnoCSS like pl-[var(--w-prefix-width, 40px)]
|
|
272
|
+
"warp-input-with-prefix": this._hasPrefix
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
get _helpTextStyles() {
|
|
276
|
+
return fclasses({
|
|
277
|
+
[helpText.helpText]: true,
|
|
278
|
+
[helpText.helpTextInvalid]: this.invalid
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
get _labelStyles() {
|
|
282
|
+
return fclasses({
|
|
283
|
+
[label.label]: true,
|
|
284
|
+
[label.labelInvalid]: this.invalid
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
get _label() {
|
|
288
|
+
if (this.label) {
|
|
289
|
+
return html`<label for="${this._id}" class=${this._labelStyles}>${this.label}</label>`;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
get _helpId() {
|
|
293
|
+
if (this.helpText)
|
|
294
|
+
return `${this._id}__hint`;
|
|
295
|
+
}
|
|
296
|
+
get _id() {
|
|
297
|
+
return "textfield";
|
|
298
|
+
}
|
|
299
|
+
get _error() {
|
|
300
|
+
if (this.invalid && this._helpId)
|
|
301
|
+
return this._helpId;
|
|
302
|
+
}
|
|
303
|
+
handler(e) {
|
|
304
|
+
const { name, value } = e.target;
|
|
305
|
+
const event = new CustomEvent(e.type, {
|
|
306
|
+
detail: {
|
|
307
|
+
name,
|
|
308
|
+
value,
|
|
309
|
+
target: e.target
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
this.dispatchEvent(event);
|
|
313
|
+
}
|
|
314
|
+
prefixSlotChange(e) {
|
|
315
|
+
const el = this.renderRoot.querySelector("slot[name=prefix]");
|
|
316
|
+
const affixes = el.assignedElements();
|
|
317
|
+
if (affixes.length)
|
|
318
|
+
this._hasPrefix = true;
|
|
319
|
+
}
|
|
320
|
+
suffixSlotChange(e) {
|
|
321
|
+
const el = this.renderRoot.querySelector("slot[name=suffix]");
|
|
322
|
+
const affixes = el.assignedElements();
|
|
323
|
+
if (affixes.length)
|
|
324
|
+
this._hasSuffix = true;
|
|
325
|
+
}
|
|
326
|
+
render() {
|
|
327
|
+
return html`
|
|
2
328
|
${this._label}
|
|
3
|
-
<div class="${
|
|
329
|
+
<div class="${input.wrapper}">
|
|
4
330
|
<slot @slotchange="${this.prefixSlotChange}" name="prefix"></slot>
|
|
5
331
|
<input
|
|
6
332
|
class="${this._inputStyles}"
|
|
7
333
|
type="${this.type}"
|
|
8
|
-
min="${
|
|
9
|
-
max="${
|
|
10
|
-
size="${
|
|
11
|
-
minlength="${
|
|
12
|
-
maxlength="${
|
|
13
|
-
name="${
|
|
14
|
-
pattern="${
|
|
15
|
-
placeholder="${
|
|
16
|
-
value="${
|
|
17
|
-
aria-describedby="${
|
|
18
|
-
aria-errormessage="${
|
|
19
|
-
aria-invalid="${
|
|
334
|
+
min="${ifDefined(this.min)}"
|
|
335
|
+
max="${ifDefined(this.max)}"
|
|
336
|
+
size="${ifDefined(this.size)}"
|
|
337
|
+
minlength="${ifDefined(this.minLength)}"
|
|
338
|
+
maxlength="${ifDefined(this.maxLength)}"
|
|
339
|
+
name="${ifDefined(this.name)}"
|
|
340
|
+
pattern="${ifDefined(this.pattern)}"
|
|
341
|
+
placeholder="${ifDefined(this.placeholder)}"
|
|
342
|
+
value="${ifDefined(this.value)}"
|
|
343
|
+
aria-describedby="${ifDefined(this._helpId)}"
|
|
344
|
+
aria-errormessage="${ifDefined(this._error)}"
|
|
345
|
+
aria-invalid="${ifDefined(this.invalid)}"
|
|
20
346
|
id="${this._id}"
|
|
21
347
|
?disabled="${this.disabled}"
|
|
22
348
|
?readonly="${this.readOnly}"
|
|
@@ -27,13 +353,53 @@ var y=Object.defineProperty;var w=(d,l,n)=>l in d?y(d,l,{enumerable:!0,configura
|
|
|
27
353
|
/>
|
|
28
354
|
<slot @slotchange="${this.suffixSlotChange}" name="suffix"></slot>
|
|
29
355
|
</div>
|
|
30
|
-
${this.helpText&&
|
|
31
|
-
|
|
356
|
+
${this.helpText && html`<div class="${this._helpTextStyles}" id="${this._helpId}">${this.helpText}</div>`}
|
|
357
|
+
`;
|
|
358
|
+
}
|
|
359
|
+
};
|
|
360
|
+
__publicField(WarpTextField, "properties", {
|
|
361
|
+
disabled: { type: Boolean },
|
|
362
|
+
invalid: { type: Boolean },
|
|
363
|
+
id: { type: String },
|
|
364
|
+
label: { type: String },
|
|
365
|
+
helpText: { type: String, attribute: "help-text" },
|
|
366
|
+
size: { type: String },
|
|
367
|
+
max: { type: Number },
|
|
368
|
+
min: { type: Number },
|
|
369
|
+
minLength: { type: Number, attribute: "min-length" },
|
|
370
|
+
maxLength: { type: Number, attribute: "max-length" },
|
|
371
|
+
name: { type: String },
|
|
372
|
+
pattern: { type: String },
|
|
373
|
+
placeholder: { type: String },
|
|
374
|
+
readOnly: { type: Boolean, attribute: "read-only" },
|
|
375
|
+
required: { type: Boolean },
|
|
376
|
+
type: { type: String },
|
|
377
|
+
value: { type: String },
|
|
378
|
+
_hasPrefix: { state: true },
|
|
379
|
+
_hasSuffix: { state: true }
|
|
380
|
+
});
|
|
381
|
+
// Slotted elements remain in lightDOM which allows for control of their style outside of shadowDOM.
|
|
382
|
+
// ::slotted([Simple Selector]) confirms to Specificity rules, but (being simple) does not add weight to lightDOM skin selectors,
|
|
383
|
+
// so never gets higher Specificity. Thus in order to overwrite style linked within shadowDOM, we need to use !important.
|
|
384
|
+
// https://stackoverflow.com/a/61631668
|
|
385
|
+
__publicField(WarpTextField, "styles", [
|
|
386
|
+
WarpElement.styles,
|
|
387
|
+
css`
|
|
32
388
|
:host {
|
|
33
389
|
display: block;
|
|
34
390
|
}
|
|
35
391
|
::slotted(:last-child) {
|
|
36
392
|
margin-bottom: 0px !important;
|
|
37
393
|
}
|
|
38
|
-
|
|
394
|
+
.warp-input-with-prefix {
|
|
395
|
+
padding-left:var(--w-prefix-width, 40px);
|
|
396
|
+
}
|
|
397
|
+
`
|
|
398
|
+
]);
|
|
399
|
+
if (!customElements.get("w-textfield")) {
|
|
400
|
+
customElements.define("w-textfield", WarpTextField);
|
|
401
|
+
}
|
|
402
|
+
export {
|
|
403
|
+
WarpTextField
|
|
404
|
+
};
|
|
39
405
|
//# sourceMappingURL=index.js.map
|