dap-design-system 0.61.0 → 0.61.2
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/dist/components/icon-button/icon-button.component.js +32 -29
- package/dist/components/icon-button/icon-button.component.js.map +1 -1
- package/dist/components/textarea/textarea.component.js +2 -2
- package/dist/components/textarea/textarea.component.js.map +1 -1
- package/dist/manifest/types/vue/index.d.ts +138 -138
- package/dist/manifest/vscode.html-custom-data.json +132 -132
- package/dist/manifest/web-types.json +186 -186
- package/dist/react/index.d.ts +5 -5
- package/dist/react-types.ts +5 -5
- package/dist/react.js +60 -60
- package/package.json +1 -1
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import { clsx as
|
|
1
|
+
import { clsx as u } from "../../node_modules/clsx/dist/clsx.js";
|
|
2
2
|
import "../../node_modules/@lit/reactive-element/reactive-element.js";
|
|
3
3
|
import "../../node_modules/lit-html/lit-html.js";
|
|
4
4
|
import "../../node_modules/lit-element/lit-element.js";
|
|
5
5
|
import { property as a } from "../../node_modules/@lit/reactive-element/decorators/property.js";
|
|
6
|
-
import { ifDefined as
|
|
6
|
+
import { ifDefined as p } from "../../node_modules/lit-html/directives/if-defined.js";
|
|
7
7
|
import { html as d } from "../../node_modules/lit-html/static.js";
|
|
8
8
|
import { DdsElement as m } from "../../internal/dds-hu-element.js";
|
|
9
9
|
import { SizedMixin as S } from "../../internal/mixin/sizedMixin.js";
|
|
10
10
|
import b from "../icon/icon.component.js";
|
|
11
11
|
import z from "./icon-button.scss.js";
|
|
12
12
|
import { unsafeCSS as y } from "../../node_modules/@lit/reactive-element/css-tag.js";
|
|
13
|
-
var v = Object.defineProperty, r = (h, t, e,
|
|
14
|
-
for (var n = void 0,
|
|
15
|
-
(l = h[
|
|
13
|
+
var v = Object.defineProperty, r = (h, t, e, i) => {
|
|
14
|
+
for (var n = void 0, s = h.length - 1, l; s >= 0; s--)
|
|
15
|
+
(l = h[s]) && (n = l(t, e, n) || n);
|
|
16
16
|
return n && v(t, e, n), n;
|
|
17
17
|
};
|
|
18
|
-
const
|
|
18
|
+
const g = S(m), c = class c extends g {
|
|
19
19
|
constructor() {
|
|
20
20
|
super(), this.variant = "neutral", this.clean = !1, this.disabled = !1, this.htmlType = "button", this._ariaLabelForButton = null, this.handleSlotChange = () => {
|
|
21
21
|
if (this.shadowRoot) {
|
|
22
22
|
const t = this.shadowRoot.querySelector("slot");
|
|
23
23
|
if (t) {
|
|
24
24
|
const e = t.assignedElements({ flatten: !0 });
|
|
25
|
-
for (const
|
|
26
|
-
|
|
25
|
+
for (const i of e)
|
|
26
|
+
i instanceof HTMLSlotElement && (i.__ddsSlotListenerAdded || (i.addEventListener("slotchange", this.handleSlotChange), i.__ddsSlotListenerAdded = !0));
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
this.applySizeToSlotIcons();
|
|
@@ -38,23 +38,23 @@ const L = S(m), c = class c extends L {
|
|
|
38
38
|
* Recursively finds all icon elements in slots and nested slots
|
|
39
39
|
*/
|
|
40
40
|
findIconElementsInSlot(t) {
|
|
41
|
-
const e = [],
|
|
42
|
-
for (const
|
|
43
|
-
if (
|
|
44
|
-
e.push(
|
|
45
|
-
else if (
|
|
46
|
-
e.push(...this.findIconElementsInSlot(
|
|
47
|
-
else if (
|
|
41
|
+
const e = [], i = t.assignedElements({ flatten: !0 }), n = t.assignedNodes({ flatten: !0 });
|
|
42
|
+
for (const s of i)
|
|
43
|
+
if (s.tagName === "DAP-DS-ICON")
|
|
44
|
+
e.push(s);
|
|
45
|
+
else if (s instanceof HTMLSlotElement)
|
|
46
|
+
e.push(...this.findIconElementsInSlot(s));
|
|
47
|
+
else if (s.children) {
|
|
48
48
|
const l = Array.from(
|
|
49
|
-
|
|
49
|
+
s.querySelectorAll("dap-ds-icon")
|
|
50
50
|
);
|
|
51
51
|
e.push(...l);
|
|
52
52
|
}
|
|
53
|
-
for (const
|
|
54
|
-
if (
|
|
55
|
-
e.includes(
|
|
56
|
-
else if (
|
|
57
|
-
const l = Array.from(
|
|
53
|
+
for (const s of n)
|
|
54
|
+
if (s instanceof Element && s.tagName === "DAP-DS-ICON")
|
|
55
|
+
e.includes(s) || e.push(s);
|
|
56
|
+
else if (s instanceof Element) {
|
|
57
|
+
const l = Array.from(s.querySelectorAll("dap-ds-icon"));
|
|
58
58
|
for (const f of l)
|
|
59
59
|
e.includes(f) || e.push(f);
|
|
60
60
|
}
|
|
@@ -68,8 +68,8 @@ const L = S(m), c = class c extends L {
|
|
|
68
68
|
const t = this.shadowRoot.querySelector("slot");
|
|
69
69
|
if (!t) return;
|
|
70
70
|
const e = this.findIconElementsInSlot(t);
|
|
71
|
-
for (const
|
|
72
|
-
this.iconSize !== void 0 ? (
|
|
71
|
+
for (const i of e)
|
|
72
|
+
this.iconSize !== void 0 ? (i.setAttribute("staticSize", this.iconSize.toString()), i.setAttribute("size", this.iconSize.toString())) : (i.setAttribute("size", this.effectiveSize), i.removeAttribute("staticSize"));
|
|
73
73
|
}
|
|
74
74
|
/**
|
|
75
75
|
* Sets up slotchange listeners for the main slot and any nested slots
|
|
@@ -77,8 +77,8 @@ const L = S(m), c = class c extends L {
|
|
|
77
77
|
setupSlotListeners(t) {
|
|
78
78
|
t.addEventListener("slotchange", this.handleSlotChange);
|
|
79
79
|
const e = t.assignedElements({ flatten: !0 });
|
|
80
|
-
for (const
|
|
81
|
-
|
|
80
|
+
for (const i of e)
|
|
81
|
+
i instanceof HTMLSlotElement && (i.addEventListener("slotchange", this.handleSlotChange), i.__ddsSlotListenerAdded = !0);
|
|
82
82
|
}
|
|
83
83
|
firstUpdated(t) {
|
|
84
84
|
if (super.firstUpdated(t), this.shadowRoot) {
|
|
@@ -90,7 +90,10 @@ const L = S(m), c = class c extends L {
|
|
|
90
90
|
});
|
|
91
91
|
}
|
|
92
92
|
updated(t) {
|
|
93
|
-
|
|
93
|
+
var i;
|
|
94
|
+
super.updated(t);
|
|
95
|
+
const e = (i = this.getAttribute("aria-label")) != null ? i : this.ariaLabel;
|
|
96
|
+
e != null && e !== "" && (this._ariaLabelForButton = e), this.removeAttribute("aria-label"), (t.has("size") || t.has("sizeMap") || t.has("iconSize") || this.sizeMap) && requestAnimationFrame(() => {
|
|
94
97
|
this.applySizeToSlotIcons();
|
|
95
98
|
});
|
|
96
99
|
}
|
|
@@ -104,8 +107,8 @@ const L = S(m), c = class c extends L {
|
|
|
104
107
|
part="base"
|
|
105
108
|
.disabled=${this.disabled}
|
|
106
109
|
type=${this.htmlType}
|
|
107
|
-
aria-label=${
|
|
108
|
-
class=${
|
|
110
|
+
aria-label=${p(this.effectiveAriaLabel) || ""}
|
|
111
|
+
class=${u(
|
|
109
112
|
"icon-button",
|
|
110
113
|
{
|
|
111
114
|
[`icon-button--${this.effectiveSize}`]: this.effectiveSize && this.iconSize === void 0
|
|
@@ -121,7 +124,7 @@ const L = S(m), c = class c extends L {
|
|
|
121
124
|
exportparts="icon, base: icon-base"
|
|
122
125
|
name="${this.icon}"
|
|
123
126
|
aria-hidden="true"
|
|
124
|
-
staticSize=${
|
|
127
|
+
staticSize=${p(this.iconSize)}
|
|
125
128
|
size=${this.effectiveSize === "xxs" ? "xs" : this.effectiveSize}>
|
|
126
129
|
</dap-ds-icon>` : d` <slot></slot> `}
|
|
127
130
|
</button>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icon-button.component.js","sources":["../../../src/components/icon-button/icon-button.component.ts"],"sourcesContent":["import clsx from 'clsx'\nimport { PropertyValueMap, unsafeCSS } from 'lit'\nimport { property } from 'lit/decorators.js'\nimport { ifDefined } from 'lit/directives/if-defined.js'\nimport { html } from 'lit/static-html.js'\n\nimport { Size } from '../../common/types'\nimport { DdsElement } from '../../internal/dds-hu-element'\nimport { SizedMixin } from '../../internal/mixin/sizedMixin'\nimport DapDSIcon from '../icon/icon.component'\nimport styles from './icon-button.scss?inline'\n\nconst IconButtonBaseWithSized = SizedMixin(DdsElement)\n\nexport type ButtonVariant = 'neutral' | 'brand' | 'inverted' | 'inverted-brand'\nexport type HtmlButtonType = 'button' | 'submit' | 'reset'\nexport type ButtonSize = Extract<Size, 'lg' | 'md' | 'sm' | 'xs'>\n\n/**\n * `dap-ds-icon-button`\n * @summary An icon button is a button with an icon.\n * @element dap-ds-icon-button\n * @title - Icon button\n *\n * @property {string} ariaLabel - The aria label of the button.\n *\n * @slot - The icon of the button.\n *\n * @csspart base - The main button container.\n * @csspart content - The icon of the button.\n * @csspart icon - The icon of the icon.\n * @csspart icon-base - The base of the icon.\n *\n * @cssproperty --dds-icon-button-border-width - Border width of the icon button (default: var(--dds-border-width-base))\n * @cssproperty --dds-icon-button-border-color - Border color of the icon button (default: var(--dds-border-neutral-transparent-interactive, #fff500))\n * @cssproperty --dds-icon-button-border-radius - Border radius of the icon button (default: var(--dds-radius-rounded))\n * @cssproperty --dds-icon-button-hover-border-width - Border width on hover (default: var(--dds-border-width-large))\n * @cssproperty --dds-icon-button-active-border-width - Border width when active (default: var(--dds-border-width-xlarge))\n * @cssproperty --dds-icon-button-transition - Transition property for the icon button (default: var(--dds-transition-all))\n * @cssproperty --dds-icon-button-cursor - Cursor style for the button (default: pointer)\n * @cssproperty --dds-icon-button-disabled-cursor - Cursor style for the disabled button (default: not-allowed)\n * @cssproperty --dds-icon-button-column-gap - Column gap between elements (default: var(--dds-spacing-100))\n * @cssproperty --dds-icon-button-padding-lg - Padding for large size (default: var(--dds-spacing-0))\n * @cssproperty --dds-icon-button-padding-md - Padding for medium size (default: var(--dds-spacing-100))\n * @cssproperty --dds-icon-button-padding-sm - Padding for small size (default: var(--dds-spacing-50))\n * @cssproperty --dds-icon-button-padding-xs - Padding for extra small size (default: var(--dds-spacing-25))\n * @cssproperty --dds-icon-button-size-lg - Size for large icon button (default: var(--dds-spacing-800))\n * @cssproperty --dds-icon-button-size-md - Size for medium icon button (default: var(--dds-spacing-600))\n * @cssproperty --dds-icon-button-size-sm - Size for small icon button (default: var(--dds-spacing-400))\n * @cssproperty --dds-icon-button-size-xs - Size for extra small icon button (default: var(--dds-spacing-300))\n * @cssproperty --dds-icon-button-neutral-bg - Background color for neutral variant (default: var(--dds-transparent-black-subtle))\n * @cssproperty --dds-icon-button-neutral-color - Text color for neutral variant (default: var(--dds-icon-neutral-base))\n * @cssproperty --dds-icon-button-neutral-hover-bg - Hover background color for neutral variant (default: var(--dds-transparent-black-base))\n * @cssproperty --dds-icon-button-neutral-active-bg - Active background color for neutral variant (default: var(--dds-transparent-black-medium))\n * @cssproperty --dds-icon-button-brand-bg - Background color for brand variant (default: var(--dds-button-subtle-background-enabled))\n * @cssproperty --dds-icon-button-brand-color - Text color for brand variant (default: var(--dds-button-subtle-icon-enabled))\n * @cssproperty --dds-icon-button-brand-hover-bg - Hover background color for brand variant (default: var(--dds-button-subtle-background-hover))\n * @cssproperty --dds-icon-button-brand-active-bg - Active background color for brand variant (default: var(--dds-button-subtle-background-pressed))\n * @cssproperty --dds-icon-button-inverted-bg - Background color for inverted variant (default: var(--dds-transparent-white-subtle))\n * @cssproperty --dds-icon-button-inverted-color - Text color for inverted variant (default: var(--dds-button-primary-icon-enabled))\n * @cssproperty --dds-icon-button-inverted-hover-bg - Hover background color for inverted variant (default: var(--dds-transparent-white-base))\n * @cssproperty --dds-icon-button-inverted-active-bg - Active background color for inverted variant (default: var(--dds-transparent-white-medium))\n * @cssproperty --dds-icon-button-inverted-brand-bg - Background color for inverted brand variant (default: var(--dds-button-primary-background-enabled))\n * @cssproperty --dds-icon-button-inverted-brand-color - Text color for inverted brand variant (default: var(--dds-button-primary-icon-enabled))\n * @cssproperty --dds-icon-button-inverted-brand-hover-bg - Hover background color for inverted brand variant (default: var(--dds-button-primary-background-enabled))\n * @cssproperty --dds-icon-button-inverted-brand-active-bg - Active background color for inverted brand variant (default: var(--dds-button-primary-background-enabled))\n * @cssproperty --dds-icon-button-disabled-color - Color for disabled state (default: var(--dds-icon-neutral-disabled))\n * @cssproperty --dds-icon-button-disabled-bg - Background color for disabled state (default: transparent)\n */\nexport default class DapDSIconButton extends IconButtonBaseWithSized {\n static tagName = 'dap-ds-icon-button'\n\n static dependencies = {\n 'dap-ds-icon': DapDSIcon,\n }\n\n /** The type of the button.\n * @type {'neutral' | 'brand' | 'inverted' | 'inverted-brand'}\n */\n @property({ reflect: true }) variant?: ButtonVariant = 'neutral'\n\n /** Adds a transparent background to the button */\n @property({ type: Boolean, reflect: true }) clean? = false\n\n /**\n * The size of the icon in pixels. By default the icon gets the size of the button. This property overwrites the size of the icon.\n */\n @property({ type: Number }) iconSize: number\n\n constructor() {\n super()\n this.size = 'md' as ButtonSize\n }\n\n /** The disabled state of the button. */\n @property({ type: Boolean, reflect: true }) disabled = false\n\n /**\n * The type of the button.\n * @type {'button' | 'submit' | 'reset'}\n */\n @property() htmlType: HtmlButtonType = 'button'\n\n /** The icon of the button. You can use the icon names from the icon component */\n @property() icon: string\n\n /** The name of the button */\n @property() name: string\n\n static readonly styles = unsafeCSS(styles)\n\n /** Persisted aria-label for the inner button; host attribute is removed so we keep the value here */\n private _ariaLabelForButton: string | null = null\n\n /** Aria-label for the inner button; survives host attribute removal so Lit does not clear it */\n private get effectiveAriaLabel(): string | null {\n return this.ariaLabel ?? this._ariaLabelForButton\n }\n\n /**\n * Recursively finds all icon elements in slots and nested slots\n */\n private findIconElementsInSlot(slot: HTMLSlotElement): Element[] {\n const iconElements: Element[] = []\n\n // Get both assigned elements and nodes (to catch all content)\n const assignedElements = slot.assignedElements({ flatten: true })\n const assignedNodes = slot.assignedNodes({ flatten: true })\n\n // First, check assigned elements\n for (const element of assignedElements) {\n // If it's an icon element, add it\n if (element.tagName === 'DAP-DS-ICON') {\n iconElements.push(element)\n }\n // If it's a nested slot, recursively find icons in it\n else if (element instanceof HTMLSlotElement) {\n iconElements.push(...this.findIconElementsInSlot(element))\n }\n // If it's a custom element, search for icons in its light DOM children\n // (slot default content appears in light DOM)\n else if (element.children) {\n const lightDomIcons = Array.from(\n element.querySelectorAll('dap-ds-icon'),\n )\n iconElements.push(...lightDomIcons)\n }\n }\n\n // Also check assigned nodes for icon elements (in case they're not in assignedElements)\n for (const node of assignedNodes) {\n if (node instanceof Element && node.tagName === 'DAP-DS-ICON') {\n if (!iconElements.includes(node)) {\n iconElements.push(node)\n }\n }\n // Check children of element nodes\n else if (node instanceof Element) {\n const childIcons = Array.from(node.querySelectorAll('dap-ds-icon'))\n for (const icon of childIcons) {\n if (!iconElements.includes(icon)) {\n iconElements.push(icon)\n }\n }\n }\n }\n\n return iconElements\n }\n\n /**\n * Applies size props to all icon elements in the slot\n */\n private applySizeToSlotIcons(): void {\n if (!this.shadowRoot) return\n\n const iconSlot = this.shadowRoot.querySelector('slot') as HTMLSlotElement\n if (!iconSlot) return\n\n const iconElements = this.findIconElementsInSlot(iconSlot)\n\n for (const iconElement of iconElements) {\n if (this.iconSize !== undefined) {\n iconElement.setAttribute('staticSize', this.iconSize.toString())\n iconElement.setAttribute('size', this.iconSize.toString())\n } else {\n iconElement.setAttribute('size', this.effectiveSize)\n iconElement.removeAttribute('staticSize')\n }\n }\n }\n\n /**\n * Handles slot change events to update icon sizes\n */\n private handleSlotChange = (): void => {\n // Set up listeners on any newly assigned nested slots\n if (this.shadowRoot) {\n const iconSlot = this.shadowRoot.querySelector('slot') as HTMLSlotElement\n if (iconSlot) {\n const assignedElements = iconSlot.assignedElements({ flatten: true })\n for (const element of assignedElements) {\n if (element instanceof HTMLSlotElement) {\n // Check if we already have a listener on this slot\n if (!(element as any).__ddsSlotListenerAdded) {\n element.addEventListener('slotchange', this.handleSlotChange)\n ;(element as any).__ddsSlotListenerAdded = true\n }\n }\n }\n }\n }\n\n // Apply size to icons\n this.applySizeToSlotIcons()\n }\n\n /**\n * Sets up slotchange listeners for the main slot and any nested slots\n */\n private setupSlotListeners(slot: HTMLSlotElement): void {\n slot.addEventListener('slotchange', this.handleSlotChange)\n\n // Also listen to nested slots that are already assigned\n const assignedElements = slot.assignedElements({ flatten: true })\n for (const element of assignedElements) {\n if (element instanceof HTMLSlotElement) {\n element.addEventListener('slotchange', this.handleSlotChange)\n ;(element as any).__ddsSlotListenerAdded = true\n }\n }\n }\n\n protected firstUpdated(\n _changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>,\n ): void {\n super.firstUpdated(_changedProperties)\n\n if (this.shadowRoot) {\n const iconSlot = this.shadowRoot.querySelector('slot') as HTMLSlotElement\n if (iconSlot) {\n this.setupSlotListeners(iconSlot)\n }\n }\n\n // Use requestAnimationFrame to ensure slots are fully assigned\n requestAnimationFrame(() => {\n this.applySizeToSlotIcons()\n })\n }\n\n protected updated(\n changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>,\n ): void {\n super.updated(changedProperties)\n\n // Persist value before removing host attribute so the inner button keeps it\n if (this.ariaLabel != null && this.ariaLabel !== '') {\n this._ariaLabelForButton = this.ariaLabel\n } else if (changedProperties.has('ariaLabel')) {\n this._ariaLabelForButton = null\n }\n this.removeAttribute('aria-label')\n\n // Update slot icons when size, sizeMap, or iconSize changes (sizeMap drives effectiveSize on viewport change)\n if (\n changedProperties.has('size') ||\n changedProperties.has('sizeMap') ||\n changedProperties.has('iconSize') ||\n this.sizeMap\n ) {\n requestAnimationFrame(() => {\n this.applySizeToSlotIcons()\n })\n }\n }\n\n focus() {\n this.shadowRoot?.querySelector('button')?.focus()\n }\n\n render() {\n return html`\n <button\n part=\"base\"\n .disabled=${this.disabled}\n type=${this.htmlType}\n aria-label=${ifDefined(this.effectiveAriaLabel) || ''}\n class=${clsx(\n 'icon-button',\n {\n [`icon-button--${this.effectiveSize}`]:\n this.effectiveSize && this.iconSize === undefined,\n },\n { [`icon-button--${this.size}`]: this.size },\n { 'icon-button--disabled': this.disabled },\n { 'icon-button--clean': this.clean },\n `icon-button--${this.variant}`,\n )}>\n <div part=\"high-contrast\" class=\"button__highcontrast\"></div>\n ${this.icon\n ? html` <dap-ds-icon\n part=\"content\"\n exportparts=\"icon, base: icon-base\"\n name=\"${this.icon}\"\n aria-hidden=\"true\"\n staticSize=${ifDefined(this.iconSize)}\n size=${(this.effectiveSize === 'xxs'\n ? 'xs'\n : this.effectiveSize) as ButtonSize}>\n </dap-ds-icon>`\n : html` <slot></slot> `}\n </button>\n `\n }\n}\n"],"names":["IconButtonBaseWithSized","SizedMixin","DdsElement","_DapDSIconButton","iconSlot","assignedElements","element","_a","slot","iconElements","assignedNodes","lightDomIcons","node","childIcons","icon","iconElement","_changedProperties","changedProperties","_b","html","ifDefined","clsx","DapDSIcon","unsafeCSS","styles","DapDSIconButton","__decorateClass","property"],"mappings":";;;;;;;;;;;;;;;;;AAYA,MAAMA,IAA0BC,EAAWC,CAAU,GAyDhCC,IAArB,MAAqBA,UAAwBH,EAAwB;AAAA,EAoBnE,cAAc;AACN,UAAA,GAX+C,KAAA,UAAA,WAGF,KAAA,QAAA,IAaE,KAAA,WAAA,IAMhB,KAAA,WAAA,UAWvC,KAAQ,sBAAqC,MAmF7C,KAAQ,mBAAmB,MAAY;AAErC,UAAI,KAAK,YAAY;AACnB,cAAMI,IAAW,KAAK,WAAW,cAAc,MAAM;AACrD,YAAIA,GAAU;AACZ,gBAAMC,IAAmBD,EAAS,iBAAiB,EAAE,SAAS,IAAM;AACpE,qBAAWE,KAAWD;AACpB,YAAIC,aAAmB,oBAEfA,EAAgB,2BACZA,EAAA,iBAAiB,cAAc,KAAK,gBAAgB,GAC1DA,EAAgB,yBAAyB;AAAA,QAGjD;AAAA,MACF;AAIF,WAAK,qBAAqB;AAAA,IAC5B,GA5HE,KAAK,OAAO;AAAA,EAAA;AAAA;AAAA,EAwBd,IAAY,qBAAoC;;AACvC,YAAAC,IAAA,KAAK,cAAL,OAAAA,IAAkB,KAAK;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA,EAMxB,uBAAuBC,GAAkC;AAC/D,UAAMC,IAA0B,CAAC,GAG3BJ,IAAmBG,EAAK,iBAAiB,EAAE,SAAS,IAAM,GAC1DE,IAAgBF,EAAK,cAAc,EAAE,SAAS,IAAM;AAG1D,eAAWF,KAAWD;AAEhB,UAAAC,EAAQ,Y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EC,KAAK,OACHF;AAAAA;AAAAA;AAAAA,sBAGU,KAAK,IAAI;AAAA;AAAA,2BAEJC,EAAU,KAAK,QAAQ,CAAC;AAAA,qBAC7B,KAAK,kBAAkB,QAC3B,OACA,KAAK,aAA4B;AAAA,8BAEvCD,kBAAqB;AAAA;AAAA;AAAA,EAAA;AAIjC;AArPEhB,EAAO,UAAU,sBAEjBA,EAAO,eAAe;AAAA,EACpB,eAAemB;AACjB,GAmCgBnB,EAAA,SAASoB,EAAUC,CAAM;AAxC3C,IAAqBC,IAArBtB;AAU+BuB,EAAA;AAAA,EAA5BC,EAAS,EAAE,SAAS,GAAM,CAAA;AAAA,GAVRF,EAUU,WAAA,SAAA;AAGeC,EAAA;AAAA,EAA3CC,EAAS,EAAE,MAAM,SAAS,SAAS,GAAM,CAAA;AAAA,GAbvBF,EAayB,WAAA,OAAA;AAKhBC,EAAA;AAAA,EAA3BC,EAAS,EAAE,MAAM,OAAQ,CAAA;AAAA,GAlBPF,EAkBS,WAAA,UAAA;AAQgBC,EAAA;AAAA,EAA3CC,EAAS,EAAE,MAAM,SAAS,SAAS,GAAM,CAAA;AAAA,GA1BvBF,EA0ByB,WAAA,UAAA;AAMhCC,EAAA;AAAA,EAAXC,EAAS;AAAA,GAhCSF,EAgCP,WAAA,UAAA;AAGAC,EAAA;AAAA,EAAXC,EAAS;AAAA,GAnCSF,EAmCP,WAAA,MAAA;AAGAC,EAAA;AAAA,EAAXC,EAAS;AAAA,GAtCSF,EAsCP,WAAA,MAAA;"}
|
|
1
|
+
{"version":3,"file":"icon-button.component.js","sources":["../../../src/components/icon-button/icon-button.component.ts"],"sourcesContent":["import clsx from 'clsx'\nimport { PropertyValueMap, unsafeCSS } from 'lit'\nimport { property } from 'lit/decorators.js'\nimport { ifDefined } from 'lit/directives/if-defined.js'\nimport { html } from 'lit/static-html.js'\n\nimport { Size } from '../../common/types'\nimport { DdsElement } from '../../internal/dds-hu-element'\nimport { SizedMixin } from '../../internal/mixin/sizedMixin'\nimport DapDSIcon from '../icon/icon.component'\nimport styles from './icon-button.scss?inline'\n\nconst IconButtonBaseWithSized = SizedMixin(DdsElement)\n\nexport type ButtonVariant = 'neutral' | 'brand' | 'inverted' | 'inverted-brand'\nexport type HtmlButtonType = 'button' | 'submit' | 'reset'\nexport type ButtonSize = Extract<Size, 'lg' | 'md' | 'sm' | 'xs'>\n\n/**\n * `dap-ds-icon-button`\n * @summary An icon button is a button with an icon.\n * @element dap-ds-icon-button\n * @title - Icon button\n *\n * @property {string} ariaLabel - The aria label of the button.\n *\n * @slot - The icon of the button.\n *\n * @csspart base - The main button container.\n * @csspart content - The icon of the button.\n * @csspart icon - The icon of the icon.\n * @csspart icon-base - The base of the icon.\n *\n * @cssproperty --dds-icon-button-border-width - Border width of the icon button (default: var(--dds-border-width-base))\n * @cssproperty --dds-icon-button-border-color - Border color of the icon button (default: var(--dds-border-neutral-transparent-interactive, #fff500))\n * @cssproperty --dds-icon-button-border-radius - Border radius of the icon button (default: var(--dds-radius-rounded))\n * @cssproperty --dds-icon-button-hover-border-width - Border width on hover (default: var(--dds-border-width-large))\n * @cssproperty --dds-icon-button-active-border-width - Border width when active (default: var(--dds-border-width-xlarge))\n * @cssproperty --dds-icon-button-transition - Transition property for the icon button (default: var(--dds-transition-all))\n * @cssproperty --dds-icon-button-cursor - Cursor style for the button (default: pointer)\n * @cssproperty --dds-icon-button-disabled-cursor - Cursor style for the disabled button (default: not-allowed)\n * @cssproperty --dds-icon-button-column-gap - Column gap between elements (default: var(--dds-spacing-100))\n * @cssproperty --dds-icon-button-padding-lg - Padding for large size (default: var(--dds-spacing-0))\n * @cssproperty --dds-icon-button-padding-md - Padding for medium size (default: var(--dds-spacing-100))\n * @cssproperty --dds-icon-button-padding-sm - Padding for small size (default: var(--dds-spacing-50))\n * @cssproperty --dds-icon-button-padding-xs - Padding for extra small size (default: var(--dds-spacing-25))\n * @cssproperty --dds-icon-button-size-lg - Size for large icon button (default: var(--dds-spacing-800))\n * @cssproperty --dds-icon-button-size-md - Size for medium icon button (default: var(--dds-spacing-600))\n * @cssproperty --dds-icon-button-size-sm - Size for small icon button (default: var(--dds-spacing-400))\n * @cssproperty --dds-icon-button-size-xs - Size for extra small icon button (default: var(--dds-spacing-300))\n * @cssproperty --dds-icon-button-neutral-bg - Background color for neutral variant (default: var(--dds-transparent-black-subtle))\n * @cssproperty --dds-icon-button-neutral-color - Text color for neutral variant (default: var(--dds-icon-neutral-base))\n * @cssproperty --dds-icon-button-neutral-hover-bg - Hover background color for neutral variant (default: var(--dds-transparent-black-base))\n * @cssproperty --dds-icon-button-neutral-active-bg - Active background color for neutral variant (default: var(--dds-transparent-black-medium))\n * @cssproperty --dds-icon-button-brand-bg - Background color for brand variant (default: var(--dds-button-subtle-background-enabled))\n * @cssproperty --dds-icon-button-brand-color - Text color for brand variant (default: var(--dds-button-subtle-icon-enabled))\n * @cssproperty --dds-icon-button-brand-hover-bg - Hover background color for brand variant (default: var(--dds-button-subtle-background-hover))\n * @cssproperty --dds-icon-button-brand-active-bg - Active background color for brand variant (default: var(--dds-button-subtle-background-pressed))\n * @cssproperty --dds-icon-button-inverted-bg - Background color for inverted variant (default: var(--dds-transparent-white-subtle))\n * @cssproperty --dds-icon-button-inverted-color - Text color for inverted variant (default: var(--dds-button-primary-icon-enabled))\n * @cssproperty --dds-icon-button-inverted-hover-bg - Hover background color for inverted variant (default: var(--dds-transparent-white-base))\n * @cssproperty --dds-icon-button-inverted-active-bg - Active background color for inverted variant (default: var(--dds-transparent-white-medium))\n * @cssproperty --dds-icon-button-inverted-brand-bg - Background color for inverted brand variant (default: var(--dds-button-primary-background-enabled))\n * @cssproperty --dds-icon-button-inverted-brand-color - Text color for inverted brand variant (default: var(--dds-button-primary-icon-enabled))\n * @cssproperty --dds-icon-button-inverted-brand-hover-bg - Hover background color for inverted brand variant (default: var(--dds-button-primary-background-enabled))\n * @cssproperty --dds-icon-button-inverted-brand-active-bg - Active background color for inverted brand variant (default: var(--dds-button-primary-background-enabled))\n * @cssproperty --dds-icon-button-disabled-color - Color for disabled state (default: var(--dds-icon-neutral-disabled))\n * @cssproperty --dds-icon-button-disabled-bg - Background color for disabled state (default: transparent)\n */\nexport default class DapDSIconButton extends IconButtonBaseWithSized {\n static tagName = 'dap-ds-icon-button'\n\n static dependencies = {\n 'dap-ds-icon': DapDSIcon,\n }\n\n /** The type of the button.\n * @type {'neutral' | 'brand' | 'inverted' | 'inverted-brand'}\n */\n @property({ reflect: true }) variant?: ButtonVariant = 'neutral'\n\n /** Adds a transparent background to the button */\n @property({ type: Boolean, reflect: true }) clean? = false\n\n /**\n * The size of the icon in pixels. By default the icon gets the size of the button. This property overwrites the size of the icon.\n */\n @property({ type: Number }) iconSize: number\n\n constructor() {\n super()\n this.size = 'md' as ButtonSize\n }\n\n /** The disabled state of the button. */\n @property({ type: Boolean, reflect: true }) disabled = false\n\n /**\n * The type of the button.\n * @type {'button' | 'submit' | 'reset'}\n */\n @property() htmlType: HtmlButtonType = 'button'\n\n /** The icon of the button. You can use the icon names from the icon component */\n @property() icon: string\n\n /** The name of the button */\n @property() name: string\n\n static readonly styles = unsafeCSS(styles)\n\n /** Persisted aria-label for the inner button; host attribute is removed so we keep the value here */\n private _ariaLabelForButton: string | null = null\n\n /** Aria-label for the inner button; survives host attribute removal so Lit does not clear it */\n private get effectiveAriaLabel(): string | null {\n return this.ariaLabel ?? this._ariaLabelForButton\n }\n\n /**\n * Recursively finds all icon elements in slots and nested slots\n */\n private findIconElementsInSlot(slot: HTMLSlotElement): Element[] {\n const iconElements: Element[] = []\n\n // Get both assigned elements and nodes (to catch all content)\n const assignedElements = slot.assignedElements({ flatten: true })\n const assignedNodes = slot.assignedNodes({ flatten: true })\n\n // First, check assigned elements\n for (const element of assignedElements) {\n // If it's an icon element, add it\n if (element.tagName === 'DAP-DS-ICON') {\n iconElements.push(element)\n }\n // If it's a nested slot, recursively find icons in it\n else if (element instanceof HTMLSlotElement) {\n iconElements.push(...this.findIconElementsInSlot(element))\n }\n // If it's a custom element, search for icons in its light DOM children\n // (slot default content appears in light DOM)\n else if (element.children) {\n const lightDomIcons = Array.from(\n element.querySelectorAll('dap-ds-icon'),\n )\n iconElements.push(...lightDomIcons)\n }\n }\n\n // Also check assigned nodes for icon elements (in case they're not in assignedElements)\n for (const node of assignedNodes) {\n if (node instanceof Element && node.tagName === 'DAP-DS-ICON') {\n if (!iconElements.includes(node)) {\n iconElements.push(node)\n }\n }\n // Check children of element nodes\n else if (node instanceof Element) {\n const childIcons = Array.from(node.querySelectorAll('dap-ds-icon'))\n for (const icon of childIcons) {\n if (!iconElements.includes(icon)) {\n iconElements.push(icon)\n }\n }\n }\n }\n\n return iconElements\n }\n\n /**\n * Applies size props to all icon elements in the slot\n */\n private applySizeToSlotIcons(): void {\n if (!this.shadowRoot) return\n\n const iconSlot = this.shadowRoot.querySelector('slot') as HTMLSlotElement\n if (!iconSlot) return\n\n const iconElements = this.findIconElementsInSlot(iconSlot)\n\n for (const iconElement of iconElements) {\n if (this.iconSize !== undefined) {\n iconElement.setAttribute('staticSize', this.iconSize.toString())\n iconElement.setAttribute('size', this.iconSize.toString())\n } else {\n iconElement.setAttribute('size', this.effectiveSize)\n iconElement.removeAttribute('staticSize')\n }\n }\n }\n\n /**\n * Handles slot change events to update icon sizes\n */\n private handleSlotChange = (): void => {\n // Set up listeners on any newly assigned nested slots\n if (this.shadowRoot) {\n const iconSlot = this.shadowRoot.querySelector('slot') as HTMLSlotElement\n if (iconSlot) {\n const assignedElements = iconSlot.assignedElements({ flatten: true })\n for (const element of assignedElements) {\n if (element instanceof HTMLSlotElement) {\n // Check if we already have a listener on this slot\n if (!(element as any).__ddsSlotListenerAdded) {\n element.addEventListener('slotchange', this.handleSlotChange)\n ;(element as any).__ddsSlotListenerAdded = true\n }\n }\n }\n }\n }\n\n // Apply size to icons\n this.applySizeToSlotIcons()\n }\n\n /**\n * Sets up slotchange listeners for the main slot and any nested slots\n */\n private setupSlotListeners(slot: HTMLSlotElement): void {\n slot.addEventListener('slotchange', this.handleSlotChange)\n\n // Also listen to nested slots that are already assigned\n const assignedElements = slot.assignedElements({ flatten: true })\n for (const element of assignedElements) {\n if (element instanceof HTMLSlotElement) {\n element.addEventListener('slotchange', this.handleSlotChange)\n ;(element as any).__ddsSlotListenerAdded = true\n }\n }\n }\n\n protected firstUpdated(\n _changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>,\n ): void {\n super.firstUpdated(_changedProperties)\n\n if (this.shadowRoot) {\n const iconSlot = this.shadowRoot.querySelector('slot') as HTMLSlotElement\n if (iconSlot) {\n this.setupSlotListeners(iconSlot)\n }\n }\n\n // Use requestAnimationFrame to ensure slots are fully assigned\n requestAnimationFrame(() => {\n this.applySizeToSlotIcons()\n })\n }\n\n protected updated(\n changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>,\n ): void {\n super.updated(changedProperties)\n\n // Persist value before removing host attribute so the inner button keeps it.\n // Read the attribute string directly: the native `ariaLabel` getter is empty\n // once the attribute is stripped, and Lit's AttributePart caches the value so\n // it is never re-applied to the host on later re-renders (e.g. when the button\n // toggles disabled). Fall back to the native property for consumers that set it\n // via `.ariaLabel`. Only overwrite when a value is actually present so the\n // persisted label survives re-renders that no longer carry the attribute.\n const incomingAriaLabel = this.getAttribute('aria-label') ?? this.ariaLabel\n if (incomingAriaLabel != null && incomingAriaLabel !== '') {\n this._ariaLabelForButton = incomingAriaLabel\n }\n this.removeAttribute('aria-label')\n\n // Update slot icons when size, sizeMap, or iconSize changes (sizeMap drives effectiveSize on viewport change)\n if (\n changedProperties.has('size') ||\n changedProperties.has('sizeMap') ||\n changedProperties.has('iconSize') ||\n this.sizeMap\n ) {\n requestAnimationFrame(() => {\n this.applySizeToSlotIcons()\n })\n }\n }\n\n focus() {\n this.shadowRoot?.querySelector('button')?.focus()\n }\n\n render() {\n return html`\n <button\n part=\"base\"\n .disabled=${this.disabled}\n type=${this.htmlType}\n aria-label=${ifDefined(this.effectiveAriaLabel) || ''}\n class=${clsx(\n 'icon-button',\n {\n [`icon-button--${this.effectiveSize}`]:\n this.effectiveSize && this.iconSize === undefined,\n },\n { [`icon-button--${this.size}`]: this.size },\n { 'icon-button--disabled': this.disabled },\n { 'icon-button--clean': this.clean },\n `icon-button--${this.variant}`,\n )}>\n <div part=\"high-contrast\" class=\"button__highcontrast\"></div>\n ${this.icon\n ? html` <dap-ds-icon\n part=\"content\"\n exportparts=\"icon, base: icon-base\"\n name=\"${this.icon}\"\n aria-hidden=\"true\"\n staticSize=${ifDefined(this.iconSize)}\n size=${(this.effectiveSize === 'xxs'\n ? 'xs'\n : this.effectiveSize) as ButtonSize}>\n </dap-ds-icon>`\n : html` <slot></slot> `}\n </button>\n `\n }\n}\n"],"names":["IconButtonBaseWithSized","SizedMixin","DdsElement","_DapDSIconButton","iconSlot","assignedElements","element","_a","slot","iconElements","assignedNodes","lightDomIcons","node","childIcons","icon","iconElement","_changedProperties","changedProperties","incomingAriaLabel","_b","html","ifDefined","clsx","DapDSIcon","unsafeCSS","styles","DapDSIconButton","__decorateClass","property"],"mappings":";;;;;;;;;;;;;;;;;AAYA,MAAMA,IAA0BC,EAAWC,CAAU,GAyDhCC,IAArB,MAAqBA,UAAwBH,EAAwB;AAAA,EAoBnE,cAAc;AACN,UAAA,GAX+C,KAAA,UAAA,WAGF,KAAA,QAAA,IAaE,KAAA,WAAA,IAMhB,KAAA,WAAA,UAWvC,KAAQ,sBAAqC,MAmF7C,KAAQ,mBAAmB,MAAY;AAErC,UAAI,KAAK,YAAY;AACnB,cAAMI,IAAW,KAAK,WAAW,cAAc,MAAM;AACrD,YAAIA,GAAU;AACZ,gBAAMC,IAAmBD,EAAS,iBAAiB,EAAE,SAAS,IAAM;AACpE,qBAAWE,KAAWD;AACpB,YAAIC,aAAmB,oBAEfA,EAAgB,2BACZA,EAAA,iBAAiB,cAAc,KAAK,gBAAgB,GAC1DA,EAAgB,yBAAyB;AAAA,QAGjD;AAAA,MACF;AAIF,WAAK,qBAAqB;AAAA,IAC5B,GA5HE,KA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AGAC,EAAA;AAAA,EAAXC,EAAS;AAAA,GAtCSF,EAsCP,WAAA,MAAA;"}
|
|
@@ -58,10 +58,10 @@ const i = (a = class extends C {
|
|
|
58
58
|
super.attributeChangedCallback(t, e, n), t === "value" && this.input && (this.input.value = n);
|
|
59
59
|
}
|
|
60
60
|
onInput() {
|
|
61
|
-
|
|
61
|
+
this.count = this.input.value.length, this.value = this.input.value, super.onInput(), this.emit("dds-count-change", { value: this.count }), this.setValidity();
|
|
62
62
|
}
|
|
63
63
|
onChange() {
|
|
64
|
-
|
|
64
|
+
this.count = this.input.value.length, this.value = this.input.value, super.onChange(), this.emit("dds-count-change", { value: this.count }), this.setValidity();
|
|
65
65
|
}
|
|
66
66
|
onSelect(t) {
|
|
67
67
|
const e = t.target, n = e.value.substring(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textarea.component.js","sources":["../../../src/components/textarea/textarea.component.ts"],"sourcesContent":["import clsx from 'clsx'\nimport { nothing, unsafeCSS } from 'lit'\nimport { property, query, state } from 'lit/decorators.js'\nimport { ifDefined } from 'lit/directives/if-defined.js'\nimport { html } from 'lit/static-html.js'\n\nimport { GenericFormElement } from '@/internal/mixin/genericFormElement'\n\nimport { CommonFormElementSize, CommonSize } from '../../common/types'\nimport DapDSFeedback from '../feedback/feedback.component'\nimport DapDSTypography from '../typography/typography.component'\nimport styles from './textarea.scss?inline'\n\n/**\n * `dap-ds-textarea`\n * @summary A textarea is a multi-line text input field.\n * @element dap-ds-textarea\n * @title - Textarea\n *\n * @property {'xs' | 'sm' | 'lg'} size - The size of the textarea. Default is `md`.\n * @property {boolean} disabled - The disabled state of the textarea.\n * @property {number} minlength - The minimum length of the textarea.\n * @property {string} value - The value of the textarea.\n * @property {string} tooltip - The tooltip of the textarea.\n * @property {'top' | 'right' | 'bottom' | 'left'} tooltipPlacement - The tooltip placement of the textarea.\n * @property {InputStatus} status - The status of the textarea. Can be `success` or `error`.\n * @property {boolean} readonly - The readonly state of the textarea.\n * @property {boolean} required - The required state of the textarea.\n * @property {string} label - The label of the textarea.\n * @property {boolean} hideLabel - Visually hides the label while keeping it available to assistive technology. (default: false)\n * @property {string} description - The description of the textarea.\n * @property {string} feedback - The feedback of the textarea.\n * @property {'negative' | 'positive' | 'warning'} feedbackType - The feedback type of the textarea. Can be `negative`, `positive`, or `warning`.\n * @property {boolean} optional - The optional state of the textarea.\n * @property {string} optionalLabel - The optional label of the textarea.\n * @property {string} requiredLabel - The required indicator of the textarea. (default: '*')\n * @property {boolean} subtle - The weight of the label. Default is `false`\n * @property {boolean} autofocus - The autofocus state of the textarea.\n *\n * @event {{ value: number }} dds-count-change - Fires when the count of the textarea changes.\n * @event {{ value: string }} dds-change - Fired when the textarea value changes.\n * @event {{ value: string }} dds-input - Fired when the textarea value changes.\n * @event {{ value: string, originalEvent: Event }} dds-keydown - Fired when a key is pressed down.\n * @event {{ void }} dds-blur - Fired when the textarea loses focus.\n * @event {{ void }} dds-focus - Emitted when the textarea gains focus.\n * @event {{ value: string }} dds-select - Emitted when select text in textarea.\n *\n * @slot feedback-icon - The custom icon of the feedback.\n *\n * @csspart base - The main textarea container.\n * @csspart input - The native input of the textarea.\n * @csspart counter - The counter of the textarea.\n * @csspart counter-base - The base of the counter.\n * @csspart feedback - The feedback of the textarea.\n * @csspart feedback-base - The base of the feedback.\n * @csspart feedback-text - The text of the feedback.\n * @csspart feedback-icon - The icon of the feedback.\n *\n * @cssproperty --dds-textarea-min-rows - Minimum number of rows in the textarea. (default: 2)\n * @cssproperty --dds-textarea-spacing - Gap between elements in the textarea container. (default: var(--dds-spacing-200))\n * @cssproperty --dds-textarea-gap - Gap between elements in the textarea container. (default: var(--dds-spacing-200))\n * @cssproperty --dds-textarea-margin-top - Top margin of the textarea. (default: var(--dds-spacing-200))\n * @cssproperty --dds-textarea-padding - Padding of the textarea control. (default: var(--dds-spacing-200) var(--dds-spacing-300))\n * @cssproperty --dds-textarea-border-width - Border width of the textarea. (default: var(--dds-border-width-base))\n * @cssproperty --dds-textarea-border-color - Border color of the textarea. (default: var(--dds-border-neutral-base))\n * @cssproperty --dds-textarea-background - Background color of the textarea. (default: var(--dds-fields-background-default))\n * @cssproperty --dds-textarea-color - Text color of the textarea. (default: var(--dds-text-neutral-base))\n * @cssproperty --dds-textarea-border-radius - Border radius of the textarea. (default: var(--dds-radius-base))\n * @cssproperty --dds-textarea-disabled-bg - Background color when disabled. (default: var(--dds-fields-background-disabled))\n * @cssproperty --dds-textarea-disabled-color - Text color when disabled. (default: var(--dds-text-neutral-disabled))\n * @cssproperty --dds-textarea-readonly-bg - Background color when readonly. (default: var(--dds-fields-background-read-only))\n * @cssproperty --dds-textarea-readonly-color - Text color when readonly. (default: var(--dds-text-neutral-subtle))\n * @cssproperty --dds-textarea-error-border - Border color when in error state. (default: var(--dds-border-negative-base))\n * @cssproperty --dds-textarea-success-border - Border color when in success state. (default: var(--dds-border-positive-base))\n */\nexport default class DapDSTextarea extends GenericFormElement {\n static tagName = 'dap-ds-textarea'\n\n static dependencies = {\n 'dap-ds-typography': DapDSTypography,\n 'dap-ds-feedback': DapDSFeedback,\n }\n\n private static nextId = 0\n\n private readonly inputId: string\n private readonly labelId: string\n private readonly descriptionId: string\n private readonly counterId: string\n\n /**@ignore */\n @query('.textarea__control') input!: HTMLTextAreaElement\n /** Hide character counter. */\n @property({ type: Boolean, reflect: true }) hideCounter = false\n /** The minimum length of the textarea. */\n @property({ type: Number }) minlength?: number\n /** The maximum length of the textarea. */\n @property({ type: Number }) maxlength?: number\n /** The number of rows in the textarea. */\n @property({ type: Number }) rows?: number = 6\n /** The number of columns in the textarea. */\n @property({ type: Number }) cols?: number\n /** The placeholder of the textarea. */\n @property() placeholder = ''\n /** Indicates how the control should wrap the value for form submission. */\n @property() wrap: 'hard' | 'soft'\n\n /**@ignore */\n @state() count = 0\n\n static readonly styles = unsafeCSS(styles)\n\n constructor() {\n super()\n DapDSTextarea.nextId++\n const uniqueSuffix =\n typeof crypto !== 'undefined' && crypto.randomUUID\n ? crypto.randomUUID().slice(0, 8)\n : Date.now().toString(36)\n this.inputId = `input-${DapDSTextarea.nextId}-${uniqueSuffix}`\n this.labelId = `label-${DapDSTextarea.nextId}-${uniqueSuffix}`\n this.descriptionId = `description-${DapDSTextarea.nextId}-${uniqueSuffix}`\n this.counterId = `counter-${DapDSTextarea.nextId}-${uniqueSuffix}`\n // Initialize the feedbackId from FeedbackMixin\n this.feedbackId = `feedback-${DapDSTextarea.nextId}-${uniqueSuffix}`\n }\n\n get focusElement() {\n return this.input\n }\n\n private _handleSlotChange(event: Event) {\n const target = event?.target as HTMLInputElement\n target.setAttribute('slot', 'icon')\n }\n\n async connectedCallback() {\n super.connectedCallback()\n\n await this.updateComplete\n this.input.value = this.value ?? ''\n this.count = this.input.value.length\n }\n\n attributeChangedCallback(name: string, oldValue: any, newValue: any) {\n super.attributeChangedCallback(name, oldValue, newValue)\n\n if (name === 'value' && this.input) {\n this.input.value = newValue\n }\n }\n\n onInput() {\n super.onInput()\n\n this.count = this.input.value.length\n this.value = this.input.value\n this.emit('dds-count-change', { value: this.count })\n\n this.setValidity()\n }\n\n onChange() {\n super.onChange()\n\n this.count = this.input.value.length\n this.value = this.input.value\n this.emit('dds-count-change', { value: this.count })\n\n this.setValidity()\n }\n\n onSelect(e: Event) {\n const target = e.target as HTMLTextAreaElement\n const selection = target.value.substring(\n target.selectionStart,\n target.selectionEnd,\n )\n this.emit('dds-select', { value: selection })\n }\n\n formResetCallback() {\n this.internals.setValidity({})\n this.internals.setFormValue(this.defaultValue || '')\n this.value = this.defaultValue || ''\n this.input.value = this.defaultValue || ''\n }\n\n handleInvalid(event: Event) {\n event.preventDefault()\n }\n\n private _renderFooter() {\n const counter = !this.hideCounter\n ? html`\n <dap-ds-typography\n part=\"counter\"\n exportparts=\"base: counter-base\"\n class=${clsx('textarea__counter', {\n 'textarea__counter--error': this.status === 'error',\n })}\n variant=\"caption\"\n size=\"${this.size as CommonFormElementSize}\"\n id=${this.counterId}\n aria-hidden=\"true\">\n ${this.count}\n </dap-ds-typography>\n </div>\n `\n : nothing\n\n return html`\n <div class=\"textarea__footer\" part=\"footer\">\n ${this.feedback && this._renderFeedback()}\n <span part=\"counter-container\">${counter}</span>\n </div>\n `\n }\n\n render() {\n return this.renderLabel(\n this.labelId,\n html`\n <div\n part=\"base\"\n class=${clsx(\n 'textarea',\n `textarea--${this.effectiveSize}`,\n { 'textarea--success': this.status === 'success' },\n { 'textarea--error': this.status === 'error' },\n { 'textarea--disabled': this.disabled },\n { 'textarea--readonly': this.readonly },\n { 'textarea--optional': this.optional },\n )}>\n <textarea\n id=${this.inputId}\n part=\"input\"\n class=\"textarea__control\"\n aria-disabled=${this.disabled}\n aria-describedby=\"${ifDefined(\n this.description ? this.descriptionId : nothing,\n )} ${this.feedback ? this.feedbackId : nothing}\"\n ?disabled=${this.disabled}\n ?readonly=${this.readonly}\n ?required=${this.required}\n minlength=${ifDefined(this.minlength)}\n maxlength=${ifDefined(this.maxlength)}\n wrap=${ifDefined(this.wrap)}\n cols=${ifDefined(this.cols)}\n rows=${ifDefined(this.rows)}\n placeholder=${ifDefined(this.placeholder)}\n ?autofocus=${this.autofocus}\n ?value=${this.value}\n aria-labelledby=${ifDefined(this.label ? this.labelId : nothing)}\n @input=${this.onInput}\n @keydown=${this.onKeydown}\n @change=${this.onChange}\n @blur=${this.onBlur}\n @focus=${this.onFocus}\n @select=${this.onSelect}\n @invalid=${this.handleInvalid}></textarea>\n\n ${this._renderFooter()}\n </div>\n `,\n )\n }\n\n private _renderFeedback() {\n return html`\n <dap-ds-feedback\n part=\"feedback\"\n feedbackType=${ifDefined(this.feedbackType)}\n feedbackSize=${ifDefined(this.effectiveSize) as CommonSize}\n class=${clsx('textarea__feedback', {\n 'textarea__feedback--sm': this.effectiveSize === 'sm',\n })}\n id=${ifDefined(this.feedbackId)}\n exportparts=\"base:feedback-base, text:feedback-text, icon:feedback-icon\"\n .subtle=${this.subtle}>\n <slot\n name=\"feedback-icon\"\n @slotchange=\"${this._handleSlotChange}\"></slot>\n ${this.feedback}\n </dap-ds-feedback>\n `\n }\n}\n"],"names":["_DapDSTextarea","_a","GenericFormElement","uniqueSuffix","event","__async","__superGet","name","oldValue","newValue","e","target","selection","counter","nothing","html","clsx","ifDefined","DapDSTypography","DapDSFeedback","unsafeCSS","styles","__decorateClass","query","property","state","DapDSTextarea"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2EA,MAAqBA,KAArBC,IAAA,cAA2CC,EAAmB;AAAA,EAqC5D,cAAc;AACN,UAAA,GApBkD,KAAA,cAAA,IAMd,KAAA,OAAA,GAIlB,KAAA,cAAA,IAKT,KAAA,QAAA,GAMDD,EAAA;AACd,UAAME,IACJ,OAAO,UAAW,eAAe,OAAO,aACpC,OAAO,WAAA,EAAa,MAAM,GAAG,CAAC,IAC9B,KAAK,IAAI,EAAE,SAAS,EAAE;AAC5B,SAAK,UAAU,SAASF,EAAc,MAAM,IAAIE,CAAY,IAC5D,KAAK,UAAU,SAASF,EAAc,MAAM,IAAIE,CAAY,IAC5D,KAAK,gBAAgB,eAAeF,EAAc,MAAM,IAAIE,CAAY,IACxE,KAAK,YAAY,WAAWF,EAAc,MAAM,IAAIE,CAAY,IAEhE,KAAK,aAAa,YAAYF,EAAc,MAAM,IAAIE,CAAY;AAAA,EAAA;AAAA,EAGpE,IAAI,eAAe;AACjB,WAAO,KAAK;AAAA,EAAA;AAAA,EAGN,kBAAkBC,GAAc;AAE/B,KADQA,KAAA,gBAAAA,EAAO,QACf,aAAa,QAAQ,MAAM;AAAA,EAAA;AAAA,EAG9B,oBAAoB;AAAA,WAAAC,EAAA;;AACxB,MAAAC,EAAAL,EAAA,iBAAM,0BAAN,IAAwB,GAExB,MAAM,KAAK,gBACN,KAAA,MAAM,SAAQA,IAAA,KAAK,UAAL,OAAAA,IAAc,IAC5B,KAAA,QAAQ,KAAK,MAAM,MAAM;AAAA,IAAA;AAAA;AAAA,EAGhC,yBAAyBM,GAAcC,G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B,EAAA;AAAA,EAAXE,EAAS;AAAA,GA9BSxB,EA8BP,WAAA,MAAA;AAGHsB,EAAA;AAAA,EAARG,EAAM;AAAA,GAjCYzB,EAiCV,WAAA,OAAA;AAjCX,IAAqB0B,IAArB1B;"}
|
|
1
|
+
{"version":3,"file":"textarea.component.js","sources":["../../../src/components/textarea/textarea.component.ts"],"sourcesContent":["import clsx from 'clsx'\nimport { nothing, unsafeCSS } from 'lit'\nimport { property, query, state } from 'lit/decorators.js'\nimport { ifDefined } from 'lit/directives/if-defined.js'\nimport { html } from 'lit/static-html.js'\n\nimport { GenericFormElement } from '@/internal/mixin/genericFormElement'\n\nimport { CommonFormElementSize, CommonSize } from '../../common/types'\nimport DapDSFeedback from '../feedback/feedback.component'\nimport DapDSTypography from '../typography/typography.component'\nimport styles from './textarea.scss?inline'\n\n/**\n * `dap-ds-textarea`\n * @summary A textarea is a multi-line text input field.\n * @element dap-ds-textarea\n * @title - Textarea\n *\n * @property {'xs' | 'sm' | 'lg'} size - The size of the textarea. Default is `md`.\n * @property {boolean} disabled - The disabled state of the textarea.\n * @property {number} minlength - The minimum length of the textarea.\n * @property {string} value - The value of the textarea.\n * @property {string} tooltip - The tooltip of the textarea.\n * @property {'top' | 'right' | 'bottom' | 'left'} tooltipPlacement - The tooltip placement of the textarea.\n * @property {InputStatus} status - The status of the textarea. Can be `success` or `error`.\n * @property {boolean} readonly - The readonly state of the textarea.\n * @property {boolean} required - The required state of the textarea.\n * @property {string} label - The label of the textarea.\n * @property {boolean} hideLabel - Visually hides the label while keeping it available to assistive technology. (default: false)\n * @property {string} description - The description of the textarea.\n * @property {string} feedback - The feedback of the textarea.\n * @property {'negative' | 'positive' | 'warning'} feedbackType - The feedback type of the textarea. Can be `negative`, `positive`, or `warning`.\n * @property {boolean} optional - The optional state of the textarea.\n * @property {string} optionalLabel - The optional label of the textarea.\n * @property {string} requiredLabel - The required indicator of the textarea. (default: '*')\n * @property {boolean} subtle - The weight of the label. Default is `false`\n * @property {boolean} autofocus - The autofocus state of the textarea.\n *\n * @event {{ value: number }} dds-count-change - Fires when the count of the textarea changes.\n * @event {{ value: string }} dds-change - Fired when the textarea value changes.\n * @event {{ value: string }} dds-input - Fired when the textarea value changes.\n * @event {{ value: string, originalEvent: Event }} dds-keydown - Fired when a key is pressed down.\n * @event {{ void }} dds-blur - Fired when the textarea loses focus.\n * @event {{ void }} dds-focus - Emitted when the textarea gains focus.\n * @event {{ value: string }} dds-select - Emitted when select text in textarea.\n *\n * @slot feedback-icon - The custom icon of the feedback.\n *\n * @csspart base - The main textarea container.\n * @csspart input - The native input of the textarea.\n * @csspart counter - The counter of the textarea.\n * @csspart counter-base - The base of the counter.\n * @csspart feedback - The feedback of the textarea.\n * @csspart feedback-base - The base of the feedback.\n * @csspart feedback-text - The text of the feedback.\n * @csspart feedback-icon - The icon of the feedback.\n *\n * @cssproperty --dds-textarea-min-rows - Minimum number of rows in the textarea. (default: 2)\n * @cssproperty --dds-textarea-spacing - Gap between elements in the textarea container. (default: var(--dds-spacing-200))\n * @cssproperty --dds-textarea-gap - Gap between elements in the textarea container. (default: var(--dds-spacing-200))\n * @cssproperty --dds-textarea-margin-top - Top margin of the textarea. (default: var(--dds-spacing-200))\n * @cssproperty --dds-textarea-padding - Padding of the textarea control. (default: var(--dds-spacing-200) var(--dds-spacing-300))\n * @cssproperty --dds-textarea-border-width - Border width of the textarea. (default: var(--dds-border-width-base))\n * @cssproperty --dds-textarea-border-color - Border color of the textarea. (default: var(--dds-border-neutral-base))\n * @cssproperty --dds-textarea-background - Background color of the textarea. (default: var(--dds-fields-background-default))\n * @cssproperty --dds-textarea-color - Text color of the textarea. (default: var(--dds-text-neutral-base))\n * @cssproperty --dds-textarea-border-radius - Border radius of the textarea. (default: var(--dds-radius-base))\n * @cssproperty --dds-textarea-disabled-bg - Background color when disabled. (default: var(--dds-fields-background-disabled))\n * @cssproperty --dds-textarea-disabled-color - Text color when disabled. (default: var(--dds-text-neutral-disabled))\n * @cssproperty --dds-textarea-readonly-bg - Background color when readonly. (default: var(--dds-fields-background-read-only))\n * @cssproperty --dds-textarea-readonly-color - Text color when readonly. (default: var(--dds-text-neutral-subtle))\n * @cssproperty --dds-textarea-error-border - Border color when in error state. (default: var(--dds-border-negative-base))\n * @cssproperty --dds-textarea-success-border - Border color when in success state. (default: var(--dds-border-positive-base))\n */\nexport default class DapDSTextarea extends GenericFormElement {\n static tagName = 'dap-ds-textarea'\n\n static dependencies = {\n 'dap-ds-typography': DapDSTypography,\n 'dap-ds-feedback': DapDSFeedback,\n }\n\n private static nextId = 0\n\n private readonly inputId: string\n private readonly labelId: string\n private readonly descriptionId: string\n private readonly counterId: string\n\n /**@ignore */\n @query('.textarea__control') input!: HTMLTextAreaElement\n /** Hide character counter. */\n @property({ type: Boolean, reflect: true }) hideCounter = false\n /** The minimum length of the textarea. */\n @property({ type: Number }) minlength?: number\n /** The maximum length of the textarea. */\n @property({ type: Number }) maxlength?: number\n /** The number of rows in the textarea. */\n @property({ type: Number }) rows?: number = 6\n /** The number of columns in the textarea. */\n @property({ type: Number }) cols?: number\n /** The placeholder of the textarea. */\n @property() placeholder = ''\n /** Indicates how the control should wrap the value for form submission. */\n @property() wrap: 'hard' | 'soft'\n\n /**@ignore */\n @state() count = 0\n\n static readonly styles = unsafeCSS(styles)\n\n constructor() {\n super()\n DapDSTextarea.nextId++\n const uniqueSuffix =\n typeof crypto !== 'undefined' && crypto.randomUUID\n ? crypto.randomUUID().slice(0, 8)\n : Date.now().toString(36)\n this.inputId = `input-${DapDSTextarea.nextId}-${uniqueSuffix}`\n this.labelId = `label-${DapDSTextarea.nextId}-${uniqueSuffix}`\n this.descriptionId = `description-${DapDSTextarea.nextId}-${uniqueSuffix}`\n this.counterId = `counter-${DapDSTextarea.nextId}-${uniqueSuffix}`\n // Initialize the feedbackId from FeedbackMixin\n this.feedbackId = `feedback-${DapDSTextarea.nextId}-${uniqueSuffix}`\n }\n\n get focusElement() {\n return this.input\n }\n\n private _handleSlotChange(event: Event) {\n const target = event?.target as HTMLInputElement\n target.setAttribute('slot', 'icon')\n }\n\n async connectedCallback() {\n super.connectedCallback()\n\n await this.updateComplete\n this.input.value = this.value ?? ''\n this.count = this.input.value.length\n }\n\n attributeChangedCallback(name: string, oldValue: any, newValue: any) {\n super.attributeChangedCallback(name, oldValue, newValue)\n\n if (name === 'value' && this.input) {\n this.input.value = newValue\n }\n }\n\n onInput() {\n // Sync the host `value` property BEFORE emitting dds-input. super.onInput()\n // dispatches dds-input synchronously, so consumers that read the host `value`\n // in that listener (e.g. RHF bindings) would otherwise see the previous value\n // and lag one keystroke behind. Matches dap-ds-input's ordering.\n this.count = this.input.value.length\n this.value = this.input.value\n\n super.onInput()\n\n this.emit('dds-count-change', { value: this.count })\n\n this.setValidity()\n }\n\n onChange() {\n // Same ordering as onInput: update the host `value` before super emits dds-change.\n this.count = this.input.value.length\n this.value = this.input.value\n\n super.onChange()\n\n this.emit('dds-count-change', { value: this.count })\n\n this.setValidity()\n }\n\n onSelect(e: Event) {\n const target = e.target as HTMLTextAreaElement\n const selection = target.value.substring(\n target.selectionStart,\n target.selectionEnd,\n )\n this.emit('dds-select', { value: selection })\n }\n\n formResetCallback() {\n this.internals.setValidity({})\n this.internals.setFormValue(this.defaultValue || '')\n this.value = this.defaultValue || ''\n this.input.value = this.defaultValue || ''\n }\n\n handleInvalid(event: Event) {\n event.preventDefault()\n }\n\n private _renderFooter() {\n const counter = !this.hideCounter\n ? html`\n <dap-ds-typography\n part=\"counter\"\n exportparts=\"base: counter-base\"\n class=${clsx('textarea__counter', {\n 'textarea__counter--error': this.status === 'error',\n })}\n variant=\"caption\"\n size=\"${this.size as CommonFormElementSize}\"\n id=${this.counterId}\n aria-hidden=\"true\">\n ${this.count}\n </dap-ds-typography>\n </div>\n `\n : nothing\n\n return html`\n <div class=\"textarea__footer\" part=\"footer\">\n ${this.feedback && this._renderFeedback()}\n <span part=\"counter-container\">${counter}</span>\n </div>\n `\n }\n\n render() {\n return this.renderLabel(\n this.labelId,\n html`\n <div\n part=\"base\"\n class=${clsx(\n 'textarea',\n `textarea--${this.effectiveSize}`,\n { 'textarea--success': this.status === 'success' },\n { 'textarea--error': this.status === 'error' },\n { 'textarea--disabled': this.disabled },\n { 'textarea--readonly': this.readonly },\n { 'textarea--optional': this.optional },\n )}>\n <textarea\n id=${this.inputId}\n part=\"input\"\n class=\"textarea__control\"\n aria-disabled=${this.disabled}\n aria-describedby=\"${ifDefined(\n this.description ? this.descriptionId : nothing,\n )} ${this.feedback ? this.feedbackId : nothing}\"\n ?disabled=${this.disabled}\n ?readonly=${this.readonly}\n ?required=${this.required}\n minlength=${ifDefined(this.minlength)}\n maxlength=${ifDefined(this.maxlength)}\n wrap=${ifDefined(this.wrap)}\n cols=${ifDefined(this.cols)}\n rows=${ifDefined(this.rows)}\n placeholder=${ifDefined(this.placeholder)}\n ?autofocus=${this.autofocus}\n ?value=${this.value}\n aria-labelledby=${ifDefined(this.label ? this.labelId : nothing)}\n @input=${this.onInput}\n @keydown=${this.onKeydown}\n @change=${this.onChange}\n @blur=${this.onBlur}\n @focus=${this.onFocus}\n @select=${this.onSelect}\n @invalid=${this.handleInvalid}></textarea>\n\n ${this._renderFooter()}\n </div>\n `,\n )\n }\n\n private _renderFeedback() {\n return html`\n <dap-ds-feedback\n part=\"feedback\"\n feedbackType=${ifDefined(this.feedbackType)}\n feedbackSize=${ifDefined(this.effectiveSize) as CommonSize}\n class=${clsx('textarea__feedback', {\n 'textarea__feedback--sm': this.effectiveSize === 'sm',\n })}\n id=${ifDefined(this.feedbackId)}\n exportparts=\"base:feedback-base, text:feedback-text, icon:feedback-icon\"\n .subtle=${this.subtle}>\n <slot\n name=\"feedback-icon\"\n @slotchange=\"${this._handleSlotChange}\"></slot>\n ${this.feedback}\n </dap-ds-feedback>\n `\n }\n}\n"],"names":["_DapDSTextarea","_a","GenericFormElement","uniqueSuffix","event","__async","__superGet","name","oldValue","newValue","e","target","selection","counter","nothing","html","clsx","ifDefined","DapDSTypography","DapDS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