dap-design-system 0.62.1 → 0.62.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.
Files changed (45) hide show
  1. package/dist/components/combobox/comboboxBase.d.ts +6 -0
  2. package/dist/components/combobox/comboboxBase.js +79 -61
  3. package/dist/components/combobox/comboboxBase.js.map +1 -1
  4. package/dist/components/datatable/datatable.component.d.ts +2 -0
  5. package/dist/components/datatable/datatable.component.js +131 -112
  6. package/dist/components/datatable/datatable.component.js.map +1 -1
  7. package/dist/components/datatable/datatable.scss.js +1 -1
  8. package/dist/components/icon-button/icon-button.component.js +15 -12
  9. package/dist/components/icon-button/icon-button.component.js.map +1 -1
  10. package/dist/components/input/input-base-element.js +42 -38
  11. package/dist/components/input/input-base-element.js.map +1 -1
  12. package/dist/components/input/input.component.d.ts +1 -0
  13. package/dist/components/input/input.component.js.map +1 -1
  14. package/dist/components/option-list/option-list.component.js +16 -12
  15. package/dist/components/option-list/option-list.component.js.map +1 -1
  16. package/dist/components/select/select.component.js +71 -66
  17. package/dist/components/select/select.component.js.map +1 -1
  18. package/dist/components/snackbar/snackbar-message.component.js +16 -18
  19. package/dist/components/snackbar/snackbar-message.component.js.map +1 -1
  20. package/dist/components/snackbar/snackbar.component.js +48 -35
  21. package/dist/components/snackbar/snackbar.component.js.map +1 -1
  22. package/dist/components/table/table-header.component.d.ts +5 -1
  23. package/dist/components/table/table-header.component.js +24 -18
  24. package/dist/components/table/table-header.component.js.map +1 -1
  25. package/dist/components/table/table.component.d.ts +3 -0
  26. package/dist/components/table/table.component.js +33 -28
  27. package/dist/components/table/table.component.js.map +1 -1
  28. package/dist/components/textarea/textarea.component.d.ts +6 -1
  29. package/dist/components/textarea/textarea.component.js +43 -36
  30. package/dist/components/textarea/textarea.component.js.map +1 -1
  31. package/dist/components/tooltip/tooltip.component.d.ts +2 -0
  32. package/dist/components/tooltip/tooltip.component.js +51 -53
  33. package/dist/components/tooltip/tooltip.component.js.map +1 -1
  34. package/dist/internal/mixin/labelableMixin.d.ts +3 -0
  35. package/dist/internal/mixin/labelableMixin.js +15 -12
  36. package/dist/internal/mixin/labelableMixin.js.map +1 -1
  37. package/dist/manifest/types/vue/index.d.ts +632 -628
  38. package/dist/manifest/vscode.html-custom-data.json +348 -339
  39. package/dist/manifest/web-types.json +1206 -1186
  40. package/dist/react/dap-ds-input/index.d.ts +1 -0
  41. package/dist/react/dap-ds-input/index.js.map +1 -1
  42. package/dist/react/index.d.ts +23 -23
  43. package/dist/react-types.ts +24 -24
  44. package/dist/react.js +160 -160
  45. package/package.json +1 -1
@@ -1,46 +1,46 @@
1
1
  var v = Object.getPrototypeOf;
2
2
  var x = Reflect.get;
3
- var y = (h, t, e) => x(v(h), e, t);
4
- var g = (h, t, e) => new Promise((n, r) => {
3
+ var $ = (h, t, e) => x(v(h), e, t);
4
+ var y = (h, t, e) => new Promise((n, r) => {
5
5
  var c = (d) => {
6
6
  try {
7
- b(e.next(d));
8
- } catch (m) {
9
- r(m);
7
+ f(e.next(d));
8
+ } catch (b) {
9
+ r(b);
10
10
  }
11
- }, p = (d) => {
11
+ }, u = (d) => {
12
12
  try {
13
- b(e.throw(d));
14
- } catch (m) {
15
- r(m);
13
+ f(e.throw(d));
14
+ } catch (b) {
15
+ r(b);
16
16
  }
17
- }, b = (d) => d.done ? n(d.value) : Promise.resolve(d.value).then(c, p);
18
- b((e = e.apply(h, t)).next());
17
+ }, f = (d) => d.done ? n(d.value) : Promise.resolve(d.value).then(c, u);
18
+ f((e = e.apply(h, t)).next());
19
19
  });
20
- import { clsx as $ } from "../../node_modules/clsx/dist/clsx.js";
20
+ import { clsx as m } from "../../node_modules/clsx/dist/clsx.js";
21
21
  import "../../node_modules/@lit/reactive-element/reactive-element.js";
22
- import { nothing as u } from "../../node_modules/lit-html/lit-html.js";
22
+ import { nothing as g } from "../../node_modules/lit-html/lit-html.js";
23
23
  import "../../node_modules/lit-element/lit-element.js";
24
24
  import { property as l } from "../../node_modules/@lit/reactive-element/decorators/property.js";
25
25
  import { state as k } from "../../node_modules/@lit/reactive-element/decorators/state.js";
26
26
  import { query as I } from "../../node_modules/@lit/reactive-element/decorators/query.js";
27
27
  import { ifDefined as s } from "../../node_modules/lit-html/directives/if-defined.js";
28
- import { html as f } from "../../node_modules/lit-html/static.js";
28
+ import { html as p } from "../../node_modules/lit-html/static.js";
29
29
  import { GenericFormElement as C } from "../../internal/mixin/genericFormElement.js";
30
30
  import S from "../feedback/feedback.component.js";
31
- import w from "../typography/typography.component.js";
32
- import _ from "./textarea.scss.js";
31
+ import _ from "../typography/typography.component.js";
32
+ import w from "./textarea.scss.js";
33
33
  import { unsafeCSS as F } from "../../node_modules/@lit/reactive-element/css-tag.js";
34
- var z = Object.defineProperty, o = (h, t, e, n) => {
35
- for (var r = void 0, c = h.length - 1, p; c >= 0; c--)
36
- (p = h[c]) && (r = p(t, e, r) || r);
37
- return r && z(t, e, r), r;
34
+ var D = Object.defineProperty, o = (h, t, e, n) => {
35
+ for (var r = void 0, c = h.length - 1, u; c >= 0; c--)
36
+ (u = h[c]) && (r = u(t, e, r) || r);
37
+ return r && D(t, e, r), r;
38
38
  }, a;
39
39
  const i = (a = class extends C {
40
40
  constructor() {
41
41
  super(), this.hideCounter = !1, this.rows = 6, this.placeholder = "", this.count = 0, a.nextId++;
42
42
  const t = typeof crypto != "undefined" && crypto.randomUUID ? crypto.randomUUID().slice(0, 8) : Date.now().toString(36);
43
- this.inputId = `input-${a.nextId}-${t}`, this.labelId = `label-${a.nextId}-${t}`, this.descriptionId = `description-${a.nextId}-${t}`, this.counterId = `counter-${a.nextId}-${t}`, this.feedbackId = `feedback-${a.nextId}-${t}`;
43
+ this.inputId = `input-${a.nextId}-${t}`, this.labelId = `label-${a.nextId}-${t}`, this.counterId = `counter-${a.nextId}-${t}`, this.feedbackId = `feedback-${a.nextId}-${t}`;
44
44
  }
45
45
  get focusElement() {
46
46
  return this.input;
@@ -49,9 +49,9 @@ const i = (a = class extends C {
49
49
  (t == null ? void 0 : t.target).setAttribute("slot", "icon");
50
50
  }
51
51
  connectedCallback() {
52
- return g(this, null, function* () {
52
+ return y(this, null, function* () {
53
53
  var t;
54
- y(a.prototype, this, "connectedCallback").call(this), yield this.updateComplete, this.input.value = (t = this.value) != null ? t : "", this.count = this.input.value.length;
54
+ $(a.prototype, this, "connectedCallback").call(this), yield this.updateComplete, this.input.value = (t = this.value) != null ? t : "", this.count = this.input.value.length;
55
55
  });
56
56
  }
57
57
  attributeChangedCallback(t, e, n) {
@@ -76,12 +76,21 @@ const i = (a = class extends C {
76
76
  handleInvalid(t) {
77
77
  t.preventDefault();
78
78
  }
79
+ /**
80
+ * Combines description and feedback ids. Built as one value because a Lit
81
+ * attribute with several parts is removed entirely if any part is `nothing`.
82
+ * The description element is rendered by LabelableMixin with id="description".
83
+ */
84
+ getAriaDescribedBy() {
85
+ const t = [];
86
+ return this.description && t.push("description"), this.feedback && this.feedbackId && t.push(this.feedbackId), t.length > 0 ? t.join(" ") : void 0;
87
+ }
79
88
  _renderFooter() {
80
- const t = this.hideCounter ? u : f`
89
+ const t = this.hideCounter ? g : p`
81
90
  <dap-ds-typography
82
91
  part="counter"
83
92
  exportparts="base: counter-base"
84
- class=${$("textarea__counter", {
93
+ class=${m("textarea__counter", {
85
94
  "textarea__counter--error": this.status === "error"
86
95
  })}
87
96
  variant="caption"
@@ -92,7 +101,7 @@ const i = (a = class extends C {
92
101
  </dap-ds-typography>
93
102
  </div>
94
103
  `;
95
- return f`
104
+ return p`
96
105
  <div class="textarea__footer" part="footer">
97
106
  ${this.feedback && this._renderFeedback()}
98
107
  <span part="counter-container">${t}</span>
@@ -102,10 +111,10 @@ const i = (a = class extends C {
102
111
  render() {
103
112
  return this.renderLabel(
104
113
  this.labelId,
105
- f`
114
+ p`
106
115
  <div
107
116
  part="base"
108
- class=${$(
117
+ class=${m(
109
118
  "textarea",
110
119
  `textarea--${this.effectiveSize}`,
111
120
  { "textarea--success": this.status === "success" },
@@ -119,9 +128,7 @@ const i = (a = class extends C {
119
128
  part="input"
120
129
  class="textarea__control"
121
130
  aria-disabled=${this.disabled}
122
- aria-describedby="${s(
123
- this.description ? this.descriptionId : u
124
- )} ${this.feedback ? this.feedbackId : u}"
131
+ aria-describedby=${s(this.getAriaDescribedBy())}
125
132
  ?disabled=${this.disabled}
126
133
  ?readonly=${this.readonly}
127
134
  ?required=${this.required}
@@ -133,7 +140,7 @@ const i = (a = class extends C {
133
140
  placeholder=${s(this.placeholder)}
134
141
  ?autofocus=${this.autofocus}
135
142
  ?value=${this.value}
136
- aria-labelledby=${s(this.label ? this.labelId : u)}
143
+ aria-labelledby=${s(this.label ? this.labelId : g)}
137
144
  @input=${this.onInput}
138
145
  @keydown=${this.onKeydown}
139
146
  @change=${this.onChange}
@@ -148,12 +155,12 @@ const i = (a = class extends C {
148
155
  );
149
156
  }
150
157
  _renderFeedback() {
151
- return f`
158
+ return p`
152
159
  <dap-ds-feedback
153
160
  part="feedback"
154
161
  feedbackType=${s(this.feedbackType)}
155
162
  feedbackSize=${s(this.effectiveSize)}
156
- class=${$("textarea__feedback", {
163
+ class=${m("textarea__feedback", {
157
164
  "textarea__feedback--sm": this.effectiveSize === "sm"
158
165
  })}
159
166
  id=${s(this.feedbackId)}
@@ -167,9 +174,9 @@ const i = (a = class extends C {
167
174
  `;
168
175
  }
169
176
  }, a.tagName = "dap-ds-textarea", a.dependencies = {
170
- "dap-ds-typography": w,
177
+ "dap-ds-typography": _,
171
178
  "dap-ds-feedback": S
172
- }, a.nextId = 0, a.styles = F(_), a);
179
+ }, a.nextId = 0, a.styles = F(w), a);
173
180
  o([
174
181
  I(".textarea__control")
175
182
  ], i.prototype, "input");
@@ -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 // 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","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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BC;AACrB,GAEAlB,EAAe,SAAS,GA2BRA,EAAA,SAASmB,EAAUC,CAAM,GAnC3CpB;AAgB+BqB,EAAA;AAAA,EAA5BC,EAAM,oBAAoB;AAAA,GAhBRvB,EAgBU,WAAA,OAAA;AAEesB,EAAA;AAAA,EAA3CE,EAAS,EAAE,MAAM,SAAS,SAAS,GAAM,CAAA;AAAA,GAlBvBxB,EAkByB,WAAA,aAAA;AAEhBsB,EAAA;AAAA,EAA3BE,EAAS,EAAE,MAAM,OAAQ,CAAA;AAAA,GApBPxB,EAoBS,WAAA,WAAA;AAEAsB,EAAA;AAAA,EAA3BE,EAAS,EAAE,MAAM,OAAQ,CAAA;AAAA,GAtBPxB,EAsBS,WAAA,WAAA;AAEAsB,EAAA;AAAA,EAA3BE,EAAS,EAAE,MAAM,OAAQ,CAAA;AAAA,GAxBPxB,EAwBS,WAAA,MAAA;AAEAsB,EAAA;AAAA,EAA3BE,EAAS,EAAE,MAAM,OAAQ,CAAA;AAAA,GA1BPxB,EA0BS,WAAA,MAAA;AAEhBsB,EAAA;AAAA,EAAXE,EAAS;AAAA,GA5BSxB,EA4BP,WAAA,aAAA;AAEAsB,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 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.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 /**\n * Combines description and feedback ids. Built as one value because a Lit\n * attribute with several parts is removed entirely if any part is `nothing`.\n * The description element is rendered by LabelableMixin with id=\"description\".\n */\n private getAriaDescribedBy(): string | undefined {\n const ids: string[] = []\n\n if (this.description) {\n ids.push('description')\n }\n\n if (this.feedback && this.feedbackId) {\n ids.push(this.feedbackId)\n }\n\n return ids.length > 0 ? ids.join(' ') : undefined\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(this.getAriaDescribedBy())}\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","ids","counter","nothing","html","clsx","ifDefined","DapDSTypography","DapDSFeedback","unsafeCSS","styles","__decorateClass","query","property","state","DapDSTextarea"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2EA,MAAqBA,KAArBC,IAAA,cAA2CC,EAAmB;AAAA,EAoC5D,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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AA;AAIvB,GAzOEjB,EAAO,UAAU,mBAEjBA,EAAO,eAAe;AAAA,EACpB,qBAAqBkB;AAAA,EACrB,mBAAmBC;AACrB,GAEAnB,EAAe,SAAS,GA0BRA,EAAA,SAASoB,EAAUC,CAAM,GAlC3CrB;AAe+BsB,EAAA;AAAA,EAA5BC,EAAM,oBAAoB;AAAA,GAfRxB,EAeU,WAAA,OAAA;AAEeuB,EAAA;AAAA,EAA3CE,EAAS,EAAE,MAAM,SAAS,SAAS,GAAM,CAAA;AAAA,GAjBvBzB,EAiByB,WAAA,aAAA;AAEhBuB,EAAA;AAAA,EAA3BE,EAAS,EAAE,MAAM,OAAQ,CAAA;AAAA,GAnBPzB,EAmBS,WAAA,WAAA;AAEAuB,EAAA;AAAA,EAA3BE,EAAS,EAAE,MAAM,OAAQ,CAAA;AAAA,GArBPzB,EAqBS,WAAA,WAAA;AAEAuB,EAAA;AAAA,EAA3BE,EAAS,EAAE,MAAM,OAAQ,CAAA;AAAA,GAvBPzB,EAuBS,WAAA,MAAA;AAEAuB,EAAA;AAAA,EAA3BE,EAAS,EAAE,MAAM,OAAQ,CAAA;AAAA,GAzBPzB,EAyBS,WAAA,MAAA;AAEhBuB,EAAA;AAAA,EAAXE,EAAS;AAAA,GA3BSzB,EA2BP,WAAA,aAAA;AAEAuB,EAAA;AAAA,EAAXE,EAAS;AAAA,GA7BSzB,EA6BP,WAAA,MAAA;AAGHuB,EAAA;AAAA,EAARG,EAAM;AAAA,GAhCY1B,EAgCV,WAAA,OAAA;AAhCX,IAAqB2B,IAArB3B;"}
@@ -60,8 +60,10 @@ export default class DapDSTooltip extends DdsElement {
60
60
  connectedCallback(): void;
61
61
  disconnectedCallback(): void;
62
62
  protected firstUpdated(_changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>): void;
63
+ private setTriggerExpanded;
63
64
  showTooltip(): Promise<void>;
64
65
  hideTooltip(): Promise<void>;
66
+ private readonly handleDocumentKeyDown;
65
67
  private readonly handleBlur;
66
68
  private readonly handleClick;
67
69
  private readonly handleFocus;
@@ -1,38 +1,40 @@
1
- var g = (d, t, s) => new Promise((l, o) => {
2
- var p = (h) => {
1
+ var g = (a, e, t) => new Promise((h, s) => {
2
+ var p = (n) => {
3
3
  try {
4
- u(s.next(h));
4
+ u(t.next(n));
5
5
  } catch (c) {
6
- o(c);
6
+ s(c);
7
7
  }
8
- }, n = (h) => {
8
+ }, l = (n) => {
9
9
  try {
10
- u(s.throw(h));
10
+ u(t.throw(n));
11
11
  } catch (c) {
12
- o(c);
12
+ s(c);
13
13
  }
14
- }, u = (h) => h.done ? l(h.value) : Promise.resolve(h.value).then(p, n);
15
- u((s = s.apply(d, t)).next());
14
+ }, u = (n) => n.done ? h(n.value) : Promise.resolve(n.value).then(p, l);
15
+ u((t = t.apply(a, e)).next());
16
16
  });
17
- import { clsx as m } from "../../node_modules/clsx/dist/clsx.js";
17
+ import { clsx as f } from "../../node_modules/clsx/dist/clsx.js";
18
18
  import "../../node_modules/@lit/reactive-element/reactive-element.js";
19
19
  import "../../node_modules/lit-html/lit-html.js";
20
20
  import "../../node_modules/lit-element/lit-element.js";
21
21
  import { property as r } from "../../node_modules/@lit/reactive-element/decorators/property.js";
22
22
  import { state as v } from "../../node_modules/@lit/reactive-element/decorators/state.js";
23
- import { html as f } from "../../node_modules/lit-html/static.js";
23
+ import { html as m } from "../../node_modules/lit-html/static.js";
24
24
  import { DdsElement as y } from "../../internal/dds-hu-element.js";
25
- import b from "../popup/popup.component.js";
25
+ import w from "../popup/popup.component.js";
26
26
  import T from "./tooltip.scss.js";
27
- import { unsafeCSS as w } from "../../node_modules/@lit/reactive-element/css-tag.js";
28
- var O = Object.defineProperty, C = Object.getOwnPropertyDescriptor, i = (d, t, s, l) => {
29
- for (var o = l > 1 ? void 0 : l ? C(t, s) : t, p = d.length - 1, n; p >= 0; p--)
30
- (n = d[p]) && (o = (l ? n(t, s, o) : n(o)) || o);
31
- return l && o && O(t, s, o), o;
27
+ import { unsafeCSS as b } from "../../node_modules/@lit/reactive-element/css-tag.js";
28
+ var E = Object.defineProperty, O = Object.getOwnPropertyDescriptor, i = (a, e, t, h) => {
29
+ for (var s = h > 1 ? void 0 : h ? O(e, t) : e, p = a.length - 1, l; p >= 0; p--)
30
+ (l = a[p]) && (s = (h ? l(e, t, s) : l(s)) || s);
31
+ return h && s && E(e, t, s), s;
32
32
  };
33
- const $ = 8, a = class a extends y {
33
+ const L = 8, d = class d extends y {
34
34
  constructor() {
35
- super(...arguments), this.placement = "bottom", this.opened = !1, this.mode = "tooltip", this.noArrow = !1, this.floatingStrategy = "absolute", this.disableViewportAutoClose = !1, this._trigger = "hover focus", this.mouseOverTooltip = !1, this.handleBlur = () => {
35
+ super(...arguments), this.placement = "bottom", this.opened = !1, this.mode = "tooltip", this.noArrow = !1, this.floatingStrategy = "absolute", this.disableViewportAutoClose = !1, this._trigger = "hover focus", this.mouseOverTooltip = !1, this.handleDocumentKeyDown = (e) => {
36
+ e.key === "Escape" && this.opened && (e.preventDefault(), e.stopPropagation(), this.hideTooltip());
37
+ }, this.handleBlur = () => {
36
38
  this.hasTrigger("focus") && this.hideTooltip();
37
39
  }, this.handleClick = () => {
38
40
  this.hasTrigger("click") && (this.opened && !this.hasTrigger("focus") ? this.hideTooltip() : this.showTooltip());
@@ -42,10 +44,10 @@ const $ = 8, a = class a extends y {
42
44
  this.hasTrigger("hover") && this.showTooltip();
43
45
  }, this.handleMouseOut = () => {
44
46
  this.mouseOverTooltip || this.hasTrigger("hover") && this.hideTooltip();
45
- }, this.hasTrigger = (t) => this.trigger.split(" ").includes(t);
47
+ }, this.hasTrigger = (e) => this.trigger.split(" ").includes(e);
46
48
  }
47
- set trigger(t) {
48
- this._trigger = t;
49
+ set trigger(e) {
50
+ this._trigger = e;
49
51
  }
50
52
  get trigger() {
51
53
  return this.mode ? this.mode === "toggle" ? "click" : this._trigger : "hover focus";
@@ -54,31 +56,27 @@ const $ = 8, a = class a extends y {
54
56
  super.connectedCallback(), this.addEventListener("blur", this.handleBlur, !0), this.addEventListener("focus", this.handleFocus, !0), this.addEventListener("click", this.handleClick), this.addEventListener("mouseover", this.handleMouseOver), this.addEventListener("mouseout", this.handleMouseOut);
55
57
  }
56
58
  disconnectedCallback() {
57
- this.removeEventListener("blur", this.handleBlur, !0), this.removeEventListener("focus", this.handleFocus, !0), this.removeEventListener("click", this.handleClick), this.removeEventListener("mouseover", this.handleMouseOver), this.removeEventListener("mouseout", this.handleMouseOut), super.disconnectedCallback();
59
+ this.removeEventListener("blur", this.handleBlur, !0), this.removeEventListener("focus", this.handleFocus, !0), this.removeEventListener("click", this.handleClick), this.removeEventListener("mouseover", this.handleMouseOver), this.removeEventListener("mouseout", this.handleMouseOut), document.removeEventListener("keydown", this.handleDocumentKeyDown, !0), super.disconnectedCallback();
58
60
  }
59
- firstUpdated(t) {
60
- super.firstUpdated(t), this.setAttribute("role", "status");
61
+ firstUpdated(e) {
62
+ super.firstUpdated(e), this.setAttribute("role", "status"), this.setTriggerExpanded(!!this.opened), this.opened && document.addEventListener("keydown", this.handleDocumentKeyDown, !0);
63
+ }
64
+ setTriggerExpanded(e) {
65
+ const t = this.querySelector('[slot="trigger"]');
66
+ t && t.setAttribute("aria-expanded", String(e));
61
67
  }
62
68
  showTooltip() {
63
69
  return g(this, null, function* () {
64
- if (this.opened)
65
- return;
66
- this.opened = !0;
67
- const t = this.querySelector('[slot="trigger"]');
68
- t && t.setAttribute("aria-expanded", "true");
70
+ this.opened || (this.opened = !0, this.setTriggerExpanded(!0), document.addEventListener("keydown", this.handleDocumentKeyDown, !0));
69
71
  });
70
72
  }
71
73
  hideTooltip() {
72
74
  return g(this, null, function* () {
73
- if (!this.opened)
74
- return;
75
- this.opened = !1;
76
- const t = this.querySelector('[slot="trigger"]');
77
- t && t.setAttribute("aria-expanded", "false");
75
+ this.opened && (this.opened = !1, this.setTriggerExpanded(!1), document.removeEventListener("keydown", this.handleDocumentKeyDown, !0));
78
76
  });
79
77
  }
80
78
  render() {
81
- return f`
79
+ return m`
82
80
  <dap-ds-popup
83
81
  part="base"
84
82
  role="tooltip"
@@ -87,14 +85,14 @@ const $ = 8, a = class a extends y {
87
85
  popup:base__popup,
88
86
  arrow:base__arrow
89
87
  "
90
- class=${m("tooltip", {
88
+ class=${f("tooltip", {
91
89
  "tooltip--open": this.opened,
92
90
  "tooltip--tooltip": this.mode === "tooltip",
93
91
  "tooltip--toggle": this.mode === "toggle"
94
92
  })}
95
93
  ?opened=${this.opened}
96
94
  placement=${this.placement}
97
- offset=${$}
95
+ offset=${L}
98
96
  floatingStrategy=${this.floatingStrategy}
99
97
  ?disableViewportAutoClose=${this.disableViewportAutoClose}
100
98
  ?hasArrow=${!this.noArrow}
@@ -106,43 +104,43 @@ const $ = 8, a = class a extends y {
106
104
  name="trigger"
107
105
  slot="trigger"
108
106
  aria-describedby="tooltip"></slot>
109
- ${this.content ? f`${this.content}` : f`<slot></slot>`}
107
+ ${this.content ? m`${this.content}` : m`<slot></slot>`}
110
108
  </dap-ds-popup>
111
109
  `;
112
110
  }
113
111
  };
114
- a.tagName = "dap-ds-tooltip", a.dependencies = {
115
- "dap-ds-popup": b
116
- }, a.styles = w(T);
117
- let e = a;
112
+ d.tagName = "dap-ds-tooltip", d.dependencies = {
113
+ "dap-ds-popup": w
114
+ }, d.styles = b(T);
115
+ let o = d;
118
116
  i([
119
117
  r()
120
- ], e.prototype, "content", 2);
118
+ ], o.prototype, "content", 2);
121
119
  i([
122
120
  r({ reflect: !0 })
123
- ], e.prototype, "placement", 2);
121
+ ], o.prototype, "placement", 2);
124
122
  i([
125
123
  r({ type: Boolean, reflect: !0 })
126
- ], e.prototype, "opened", 2);
124
+ ], o.prototype, "opened", 2);
127
125
  i([
128
126
  r()
129
- ], e.prototype, "mode", 2);
127
+ ], o.prototype, "mode", 2);
130
128
  i([
131
129
  r({ type: Boolean, reflect: !0 })
132
- ], e.prototype, "noArrow", 2);
130
+ ], o.prototype, "noArrow", 2);
133
131
  i([
134
132
  r({ reflect: !0 })
135
- ], e.prototype, "floatingStrategy", 2);
133
+ ], o.prototype, "floatingStrategy", 2);
136
134
  i([
137
135
  r({ type: Boolean })
138
- ], e.prototype, "disableViewportAutoClose", 2);
136
+ ], o.prototype, "disableViewportAutoClose", 2);
139
137
  i([
140
138
  r()
141
- ], e.prototype, "trigger", 1);
139
+ ], o.prototype, "trigger", 1);
142
140
  i([
143
141
  v()
144
- ], e.prototype, "mouseOverTooltip", 2);
142
+ ], o.prototype, "mouseOverTooltip", 2);
145
143
  export {
146
- e as default
144
+ o as default
147
145
  };
148
146
  //# sourceMappingURL=tooltip.component.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tooltip.component.js","sources":["../../../src/components/tooltip/tooltip.component.ts"],"sourcesContent":["import { clsx } from 'clsx'\nimport { PropertyValueMap, unsafeCSS } from 'lit'\nimport { property, state } from 'lit/decorators.js'\nimport { html } from 'lit/static-html.js'\n\nimport { PopupPlacement } from '../../common/types'\nimport { DdsElement } from '../../internal/dds-hu-element'\nimport DapDSPopup from '../popup/popup.component'\nimport styles from './tooltip.scss?inline'\nexport type TooltipMode = 'tooltip' | 'toggle'\n\n/**\n * The distance in pixels between the tooltip and the trigger element.\n */\nconst TOOLTIP_OFFSET = 8\n\n/**\n * `dap-ds-tooltip`\n * @summary A tooltip is a container for tooltip content.\n * @element dap-ds-tooltip\n * @title - Tooltip\n *\n * @slot - The content of the tooltip.\n * @slot trigger - The trigger element of the tooltip.\n *\n * @csspart base - The main tooltip container.\n * @csspart trigger - The trigger element of the tooltip.\n * @csspart popup - The popup of the tooltip.\n * @csspart arrow - The arrow of the tooltip.\n *\n * @cssproperty --dds-tooltip-max-width - The maximum width of the tooltip before its content will wrap (default: 14rem)\n * @cssproperty --dds-tooltip-padding - The padding inside the tooltip (default: var(--dds-spacing-400))\n * @cssproperty --dds-tooltip-border-color - The border color of the tooltip (default: var(--dds-border-neutral-subtle))\n * @cssproperty --dds-tooltip-bg-color - The background color of the tooltip (default: var(--dds-background-neutral-base))\n * @cssproperty --dds-tooltip-text-color - The text color of the tooltip (default: var(--dds-text-neutral-base))\n * @cssproperty --dds-tooltip-font-size - The font size of the tooltip text (default: var(--dds-font-sm))\n * @cssproperty --dds-tooltip-box-shadow - The box shadow of the tooltip (default: 0 8px 12px -2px rgb(0 0 0 / 8%), 0 2px 6px -2px rgb(0 0 0 / 6%))\n */\nexport default class DapDSTooltip extends DdsElement {\n static tagName = 'dap-ds-tooltip'\n\n static dependencies = {\n 'dap-ds-popup': DapDSPopup,\n }\n\n static readonly styles = unsafeCSS(styles)\n\n /** The content of the tooltip, supporting text only. */\n @property() content: string\n\n /** The position of the tooltip around the trigger element.\n * @type { 'top' | 'right' | 'bottom' | 'left' }\n */\n @property({ reflect: true }) placement: PopupPlacement = 'bottom'\n\n /** Sets the tooltip to opened by default (will still be closed on closing events). */\n @property({ type: Boolean, reflect: true }) opened? = false\n\n /** Sets the tooltip to toggle mode.\n * @type { 'tooltip' | 'toggle' }\n */\n @property() mode?: TooltipMode = 'tooltip'\n\n /** Hides the arrow of the tooltip. */\n @property({ type: Boolean, reflect: true }) noArrow? = false\n\n /** The floating strategy of the tooltip. Default is `absolute`. Can be `absolute` or `fixed`.\n * @type { 'absolute' | 'fixed' }\n */\n @property({ reflect: true })\n floatingStrategy: 'absolute' | 'fixed' = 'absolute'\n\n /** Whether to keep popup open when trigger leaves viewport. */\n @property({ type: Boolean }) disableViewportAutoClose: boolean = false\n\n private _trigger: string = 'hover focus'\n\n /** Sets custom trigger event (hover, focus, click). Default is `hover focus`. */\n @property()\n set trigger(value: string) {\n this._trigger = value\n }\n get trigger() {\n if (!this.mode) {\n return 'hover focus'\n }\n\n if (this.mode === 'toggle') {\n return 'click'\n }\n\n return this._trigger\n }\n\n /** @ignore */\n @state() mouseOverTooltip: boolean = false\n\n connectedCallback() {\n super.connectedCallback()\n this.addEventListener('blur', this.handleBlur, true)\n this.addEventListener('focus', this.handleFocus, true)\n this.addEventListener('click', this.handleClick)\n this.addEventListener('mouseover', this.handleMouseOver)\n this.addEventListener('mouseout', this.handleMouseOut)\n }\n\n disconnectedCallback() {\n this.removeEventListener('blur', this.handleBlur, true)\n this.removeEventListener('focus', this.handleFocus, true)\n this.removeEventListener('click', this.handleClick)\n this.removeEventListener('mouseover', this.handleMouseOver)\n this.removeEventListener('mouseout', this.handleMouseOut)\n super.disconnectedCallback()\n }\n\n protected firstUpdated(\n _changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>,\n ): void {\n super.firstUpdated(_changedProperties)\n\n this.setAttribute('role', 'status')\n }\n\n async showTooltip() {\n if (this.opened) {\n return\n }\n\n this.opened = true\n\n const trigger = this.querySelector('[slot=\"trigger\"]')\n if (trigger) {\n trigger.setAttribute('aria-expanded', 'true')\n }\n }\n\n async hideTooltip() {\n if (!this.opened) {\n return\n }\n\n this.opened = false\n\n const trigger = this.querySelector('[slot=\"trigger\"]')\n if (trigger) {\n trigger.setAttribute('aria-expanded', 'false')\n }\n }\n\n private readonly handleBlur = () => {\n if (this.hasTrigger('focus')) {\n this.hideTooltip()\n }\n }\n\n private readonly handleClick = () => {\n if (this.hasTrigger('click')) {\n this.opened && !this.hasTrigger('focus')\n ? this.hideTooltip()\n : this.showTooltip()\n }\n }\n\n private readonly handleFocus = () => {\n if (this.hasTrigger('focus')) {\n this.showTooltip()\n }\n }\n\n private readonly handleMouseOver = () => {\n if (this.hasTrigger('hover')) {\n this.showTooltip()\n }\n }\n\n private readonly handleMouseOut = () => {\n if (!this.mouseOverTooltip) {\n if (this.hasTrigger('hover')) {\n this.hideTooltip()\n }\n }\n }\n\n private readonly hasTrigger = (triggerType: string) => {\n const triggers = this.trigger.split(' ')\n return triggers.includes(triggerType)\n }\n\n render() {\n return html`\n <dap-ds-popup\n part=\"base\"\n role=\"tooltip\"\n id=\"tooltip\"\n exportparts=\"\n popup:base__popup,\n arrow:base__arrow\n \"\n class=${clsx('tooltip', {\n 'tooltip--open': this.opened,\n 'tooltip--tooltip': this.mode === 'tooltip',\n 'tooltip--toggle': this.mode === 'toggle',\n })}\n ?opened=${this.opened}\n placement=${this.placement}\n offset=${TOOLTIP_OFFSET}\n floatingStrategy=${this.floatingStrategy}\n ?disableViewportAutoClose=${this.disableViewportAutoClose}\n ?hasArrow=${!this.noArrow}\n @dds-close=${this.hideTooltip}\n @dds-closed=${this.hideTooltip}\n @dds-opened=${this.showTooltip}>\n <slot\n part=\"trigger\"\n name=\"trigger\"\n slot=\"trigger\"\n aria-describedby=\"tooltip\"></slot>\n ${this.content ? html`${this.content}` : html`<slot></slot>`}\n </dap-ds-popup>\n `\n }\n}\n"],"names":["TOOLTIP_OFFSET","_DapDSTooltip","DdsElement","triggerType","value","_changedProperties","__async","trigger","html","clsx","DapDSPopup","unsafeCSS","styles","DapDSTooltip","__decorateClass","property","state"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,MAAMA,IAAiB,GAwBFC,IAArB,MAAqBA,UAAqBC,EAAW;AAAA,EAArD,cAAA;AAAA,UAAA,GAAA,SAAA,GAe2D,KAAA,YAAA,UAGH,KAAA,SAAA,IAKrB,KAAA,OAAA,WAGsB,KAAA,UAAA,IAMd,KAAA,mBAAA,YAGwB,KAAA,2BAAA,IAEjE,KAAQ,WAAmB,eAoBU,KAAA,mBAAA,IAsDrC,KAAiB,aAAa,MAAM;AAC9B,MAAA,KAAK,WAAW,OAAO,KACzB,KAAK,YAAY;AAAA,IAErB,GAEA,KAAiB,cAAc,MAAM;AAC/B,MAAA,KAAK,WAAW,OAAO,MACpB,KAAA,UAAU,CAAC,KAAK,WAAW,OAAO,IACnC,KAAK,YAAA,IACL,KAAK,YAAY;AAAA,IAEzB,GAEA,KAAiB,cAAc,MAAM;AAC/B,MAAA,KAAK,WAAW,OAAO,KACzB,KAAK,YAAY;AAAA,IAErB,GAEA,KAAiB,kBAAkB,MAAM;AACnC,MAAA,KAAK,WAAW,OAAO,KACzB,KAAK,YAAY;AAAA,IAErB,GAEA,KAAiB,iBAAiB,MAAM;AAClC,MAA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CAAA;AAM5CC,EAAA;AAAA,EADCC,EAAS,EAAE,SAAS,GAAM,CAAA;AAAA,GA/BRF,EAgCnB,WAAA,oBAAA,CAAA;AAG6BC,EAAA;AAAA,EAA5BC,EAAS,EAAE,MAAM,QAAS,CAAA;AAAA,GAnCRF,EAmCU,WAAA,4BAAA,CAAA;AAMzBC,EAAA;AAAA,EADHC,EAAS;AAAA,GAxCSF,EAyCf,WAAA,WAAA,CAAA;AAgBKC,EAAA;AAAA,EAARE,EAAM;AAAA,GAzDYH,EAyDV,WAAA,oBAAA,CAAA;"}
1
+ {"version":3,"file":"tooltip.component.js","sources":["../../../src/components/tooltip/tooltip.component.ts"],"sourcesContent":["import { clsx } from 'clsx'\nimport { PropertyValueMap, unsafeCSS } from 'lit'\nimport { property, state } from 'lit/decorators.js'\nimport { html } from 'lit/static-html.js'\n\nimport { PopupPlacement } from '../../common/types'\nimport { DdsElement } from '../../internal/dds-hu-element'\nimport DapDSPopup from '../popup/popup.component'\nimport styles from './tooltip.scss?inline'\nexport type TooltipMode = 'tooltip' | 'toggle'\n\n/**\n * The distance in pixels between the tooltip and the trigger element.\n */\nconst TOOLTIP_OFFSET = 8\n\n/**\n * `dap-ds-tooltip`\n * @summary A tooltip is a container for tooltip content.\n * @element dap-ds-tooltip\n * @title - Tooltip\n *\n * @slot - The content of the tooltip.\n * @slot trigger - The trigger element of the tooltip.\n *\n * @csspart base - The main tooltip container.\n * @csspart trigger - The trigger element of the tooltip.\n * @csspart popup - The popup of the tooltip.\n * @csspart arrow - The arrow of the tooltip.\n *\n * @cssproperty --dds-tooltip-max-width - The maximum width of the tooltip before its content will wrap (default: 14rem)\n * @cssproperty --dds-tooltip-padding - The padding inside the tooltip (default: var(--dds-spacing-400))\n * @cssproperty --dds-tooltip-border-color - The border color of the tooltip (default: var(--dds-border-neutral-subtle))\n * @cssproperty --dds-tooltip-bg-color - The background color of the tooltip (default: var(--dds-background-neutral-base))\n * @cssproperty --dds-tooltip-text-color - The text color of the tooltip (default: var(--dds-text-neutral-base))\n * @cssproperty --dds-tooltip-font-size - The font size of the tooltip text (default: var(--dds-font-sm))\n * @cssproperty --dds-tooltip-box-shadow - The box shadow of the tooltip (default: 0 8px 12px -2px rgb(0 0 0 / 8%), 0 2px 6px -2px rgb(0 0 0 / 6%))\n */\nexport default class DapDSTooltip extends DdsElement {\n static tagName = 'dap-ds-tooltip'\n\n static dependencies = {\n 'dap-ds-popup': DapDSPopup,\n }\n\n static readonly styles = unsafeCSS(styles)\n\n /** The content of the tooltip, supporting text only. */\n @property() content: string\n\n /** The position of the tooltip around the trigger element.\n * @type { 'top' | 'right' | 'bottom' | 'left' }\n */\n @property({ reflect: true }) placement: PopupPlacement = 'bottom'\n\n /** Sets the tooltip to opened by default (will still be closed on closing events). */\n @property({ type: Boolean, reflect: true }) opened? = false\n\n /** Sets the tooltip to toggle mode.\n * @type { 'tooltip' | 'toggle' }\n */\n @property() mode?: TooltipMode = 'tooltip'\n\n /** Hides the arrow of the tooltip. */\n @property({ type: Boolean, reflect: true }) noArrow? = false\n\n /** The floating strategy of the tooltip. Default is `absolute`. Can be `absolute` or `fixed`.\n * @type { 'absolute' | 'fixed' }\n */\n @property({ reflect: true })\n floatingStrategy: 'absolute' | 'fixed' = 'absolute'\n\n /** Whether to keep popup open when trigger leaves viewport. */\n @property({ type: Boolean }) disableViewportAutoClose: boolean = false\n\n private _trigger: string = 'hover focus'\n\n /** Sets custom trigger event (hover, focus, click). Default is `hover focus`. */\n @property()\n set trigger(value: string) {\n this._trigger = value\n }\n get trigger() {\n if (!this.mode) {\n return 'hover focus'\n }\n\n if (this.mode === 'toggle') {\n return 'click'\n }\n\n return this._trigger\n }\n\n /** @ignore */\n @state() mouseOverTooltip: boolean = false\n\n connectedCallback() {\n super.connectedCallback()\n this.addEventListener('blur', this.handleBlur, true)\n this.addEventListener('focus', this.handleFocus, true)\n this.addEventListener('click', this.handleClick)\n this.addEventListener('mouseover', this.handleMouseOver)\n this.addEventListener('mouseout', this.handleMouseOut)\n }\n\n disconnectedCallback() {\n this.removeEventListener('blur', this.handleBlur, true)\n this.removeEventListener('focus', this.handleFocus, true)\n this.removeEventListener('click', this.handleClick)\n this.removeEventListener('mouseover', this.handleMouseOver)\n this.removeEventListener('mouseout', this.handleMouseOut)\n document.removeEventListener('keydown', this.handleDocumentKeyDown, true)\n super.disconnectedCallback()\n }\n\n protected firstUpdated(\n _changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>,\n ): void {\n super.firstUpdated(_changedProperties)\n\n this.setAttribute('role', 'status')\n\n // Expose the collapsed state from the start, not only after the first open\n this.setTriggerExpanded(!!this.opened)\n if (this.opened) {\n document.addEventListener('keydown', this.handleDocumentKeyDown, true)\n }\n }\n\n private setTriggerExpanded(expanded: boolean) {\n const trigger = this.querySelector('[slot=\"trigger\"]')\n if (trigger) {\n trigger.setAttribute('aria-expanded', String(expanded))\n }\n }\n\n async showTooltip() {\n if (this.opened) {\n return\n }\n\n this.opened = true\n this.setTriggerExpanded(true)\n document.addEventListener('keydown', this.handleDocumentKeyDown, true)\n }\n\n async hideTooltip() {\n if (!this.opened) {\n return\n }\n\n this.opened = false\n this.setTriggerExpanded(false)\n document.removeEventListener('keydown', this.handleDocumentKeyDown, true)\n }\n\n // Escape dismisses the tooltip without moving focus or pointer (WCAG 1.4.13).\n // Captured on document so it works for hover too, and stopped so an enclosing\n // modal does not close on the same keypress.\n private readonly handleDocumentKeyDown = (event: KeyboardEvent) => {\n if (event.key === 'Escape' && this.opened) {\n event.preventDefault()\n event.stopPropagation()\n this.hideTooltip()\n }\n }\n\n private readonly handleBlur = () => {\n if (this.hasTrigger('focus')) {\n this.hideTooltip()\n }\n }\n\n private readonly handleClick = () => {\n if (this.hasTrigger('click')) {\n this.opened && !this.hasTrigger('focus')\n ? this.hideTooltip()\n : this.showTooltip()\n }\n }\n\n private readonly handleFocus = () => {\n if (this.hasTrigger('focus')) {\n this.showTooltip()\n }\n }\n\n private readonly handleMouseOver = () => {\n if (this.hasTrigger('hover')) {\n this.showTooltip()\n }\n }\n\n private readonly handleMouseOut = () => {\n if (!this.mouseOverTooltip) {\n if (this.hasTrigger('hover')) {\n this.hideTooltip()\n }\n }\n }\n\n private readonly hasTrigger = (triggerType: string) => {\n const triggers = this.trigger.split(' ')\n return triggers.includes(triggerType)\n }\n\n render() {\n return html`\n <dap-ds-popup\n part=\"base\"\n role=\"tooltip\"\n id=\"tooltip\"\n exportparts=\"\n popup:base__popup,\n arrow:base__arrow\n \"\n class=${clsx('tooltip', {\n 'tooltip--open': this.opened,\n 'tooltip--tooltip': this.mode === 'tooltip',\n 'tooltip--toggle': this.mode === 'toggle',\n })}\n ?opened=${this.opened}\n placement=${this.placement}\n offset=${TOOLTIP_OFFSET}\n floatingStrategy=${this.floatingStrategy}\n ?disableViewportAutoClose=${this.disableViewportAutoClose}\n ?hasArrow=${!this.noArrow}\n @dds-close=${this.hideTooltip}\n @dds-closed=${this.hideTooltip}\n @dds-opened=${this.showTooltip}>\n <slot\n part=\"trigger\"\n name=\"trigger\"\n slot=\"trigger\"\n aria-describedby=\"tooltip\"></slot>\n ${this.content ? html`${this.content}` : html`<slot></slot>`}\n </dap-ds-popup>\n `\n }\n}\n"],"names":["TOOLTIP_OFFSET","_DapDSTooltip","DdsElement","event","triggerType","value","_changedProperties","expanded","trigger","__async","html","clsx","DapDSPopup","unsafeCSS","styles","DapDSTooltip","__decorateClass","property","state"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,MAAMA,IAAiB,GAwBFC,IAArB,MAAqBA,UAAqBC,EAAW;AAAA,EAArD,cAAA;AAAA,UAAA,GAAA,SAAA,GAe2D,KAAA,YAAA,UAGH,KAAA,SAAA,IAKrB,KAAA,OAAA,WAGsB,KAAA,UAAA,IAMd,KAAA,mBAAA,YAGwB,KAAA,2BAAA,IAEjE,KAAQ,WAAmB,eAoBU,KAAA,mBAAA,IAiEpB,KAAA,wBAAwB,CAACC,MAAyB;AACjE,MAAIA,EAAM,QAA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click` (click/Enter toggle) or `hover` (hover + keyboard focus). */
4
+ export type TooltipTrigger = 'click' | 'hover';
3
5
  type Constructor<T = Record<string, unknown>> = {
4
6
  new (...args: any[]): T;
5
7
  prototype: T;
@@ -10,6 +12,7 @@ export interface LabelableElementInterface {
10
12
  description?: string;
11
13
  tooltip?: string;
12
14
  tooltipPlacement: PopupPlacement;
15
+ tooltipTrigger: TooltipTrigger;
13
16
  size: Size;
14
17
  required: boolean;
15
18
  requiredLabel: string;
@@ -1,26 +1,26 @@
1
1
  import { clsx as d } from "../../node_modules/clsx/dist/clsx.js";
2
2
  import "../../node_modules/@lit/reactive-element/reactive-element.js";
3
- import { html as r } from "../../node_modules/lit-html/lit-html.js";
3
+ import { html as a } from "../../node_modules/lit-html/lit-html.js";
4
4
  import "../../node_modules/lit-element/lit-element.js";
5
5
  import { property as e } from "../../node_modules/@lit/reactive-element/decorators/property.js";
6
6
  import { ifDefined as b } from "../../node_modules/lit-html/directives/if-defined.js";
7
7
  import "../../localization/localization.js";
8
8
  import { t as h } from "../../node_modules/i18next/dist/esm/i18next.js";
9
- var c = Object.defineProperty, o = (l, t, p, a) => {
9
+ var c = Object.defineProperty, o = (l, t, p, r) => {
10
10
  for (var i = void 0, s = l.length - 1, n; s >= 0; s--)
11
11
  (n = l[s]) && (i = n(t, p, i) || i);
12
12
  return i && c(t, p, i), i;
13
13
  };
14
- const g = (l) => {
14
+ const q = (l) => {
15
15
  class t extends l {
16
16
  constructor() {
17
- super(...arguments), this.hideLabel = !1, this.tooltipPlacement = "bottom", this.size = "sm", this.optional = !1, this.optionalLabel = h("label.optional"), this.subtle = !1, this.required = !1, this.requiredLabel = "*", this.disabled = !1, this.tooltipAriaLabel = h("label.tooltip");
17
+ super(...arguments), this.hideLabel = !1, this.tooltipPlacement = "bottom", this.tooltipTrigger = "click", this.size = "sm", this.optional = !1, this.optionalLabel = h("label.optional"), this.subtle = !1, this.required = !1, this.requiredLabel = "*", this.disabled = !1, this.tooltipAriaLabel = h("label.tooltip");
18
18
  }
19
- renderLabel(a, i) {
20
- return r` <div class="label-container">
21
- ${this.label && r`<dap-ds-form-label
19
+ renderLabel(r, i) {
20
+ return a` <div class="label-container">
21
+ ${this.label && a`<dap-ds-form-label
22
22
  part="label"
23
- id=${a != null ? a : "label"}
23
+ id=${r != null ? r : "label"}
24
24
  exportparts="base: label-base, required: label-required, optional: label-optional"
25
25
  .size=${this.size}
26
26
  .required=${this.required}
@@ -35,10 +35,11 @@ const g = (l) => {
35
35
  for="input"
36
36
  label=${b(this.label)}></dap-ds-form-label>`}
37
37
  </dap-ds-form-label>
38
- ${this.tooltip && r` <dap-ds-tooltip
38
+ ${this.tooltip && a` <dap-ds-tooltip
39
39
  part="tooltip"
40
40
  content=${this.tooltip}
41
- mode="toggle"
41
+ mode=${this.tooltipTrigger === "hover" ? "tooltip" : "toggle"}
42
+ trigger=${this.tooltipTrigger === "hover" ? "hover focus" : "click"}
42
43
  placement=${this.tooltipPlacement}>
43
44
  <dap-ds-icon-button
44
45
  slot="trigger"
@@ -53,7 +54,7 @@ const g = (l) => {
53
54
  </dap-ds-icon-button>
54
55
  </dap-ds-tooltip>`}
55
56
  </div>
56
- ${this.description && r`
57
+ ${this.description && a`
57
58
  <dap-ds-typography
58
59
  part="description"
59
60
  variant="description"
@@ -78,6 +79,8 @@ const g = (l) => {
78
79
  e()
79
80
  ], t.prototype, "tooltipPlacement"), o([
80
81
  e()
82
+ ], t.prototype, "tooltipTrigger"), o([
83
+ e()
81
84
  ], t.prototype, "size"), o([
82
85
  e({ type: Boolean, reflect: !0 })
83
86
  ], t.prototype, "optional"), o([
@@ -95,6 +98,6 @@ const g = (l) => {
95
98
  ], t.prototype, "tooltipAriaLabel"), t;
96
99
  };
97
100
  export {
98
- g as LabelableMixin
101
+ q as LabelableMixin
99
102
  };
100
103
  //# sourceMappingURL=labelableMixin.js.map