@universal-material/web 3.3.1 → 3.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@universal-material/web",
3
- "version": "3.3.1",
3
+ "version": "3.3.3",
4
4
  "description": "Material web components",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -14,10 +14,12 @@ export declare enum SnackbarDuration {
14
14
  }
15
15
  export declare class UmSnackbar extends LitElement {
16
16
  static styles: import("lit").CSSResult[];
17
+ static minDisplayTime: number;
17
18
  message: string;
18
19
  action: string;
19
20
  showClose: boolean;
20
- dismissed: boolean;
21
+ _dismissed: boolean;
22
+ _canDismiss: boolean;
21
23
  duration: SnackbarDuration | number;
22
24
  private readonly container;
23
25
  render(): HTMLTemplateResult;
@@ -25,12 +27,13 @@ export declare class UmSnackbar extends LitElement {
25
27
  private renderCloseButton;
26
28
  actionClick(e: Event): void;
27
29
  dismiss(): void;
30
+ private static _displayingSnackbar;
28
31
  private static _queue;
29
32
  private static _consuming;
30
33
  static show(message: string): UmSnackbar;
31
34
  static show(config: SnackbarConfig): UmSnackbar;
32
35
  private static consumeQueue;
33
- private static showNext;
36
+ private static _showNext;
34
37
  private static createSnackbar;
35
38
  }
36
39
  declare global {
@@ -1 +1 @@
1
- {"version":3,"file":"snackbar.d.ts","sourceRoot":"","sources":["../../src/snackbar/snackbar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,kBAAkB,EAAE,UAAU,EAAW,MAAM,KAAK,CAAC;AAOpE,OAAO,qBAAqB,CAAC;AAC7B,OAAO,0BAA0B,CAAC;AAElC,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,oBAAY,gBAAgB;IAC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AED,oBAAY,gBAAgB;IAC1B,KAAK,OAAO;IACZ,IAAI,OAAO;IACX,QAAQ,KAAK;CACd;AAED,qBACa,UAAW,SAAQ,UAAU;IACxC,OAAgB,MAAM,4BAAwB;IAC9C,MAAM,CAAC,cAAc,SAAQ;IAEA,OAAO,SAAM;IACb,MAAM,SAAM;IAEzC,SAAS,UAAS;IACT,UAAU,UAAS;IACnB,WAAW,UAAS;IAE7B,QAAQ,EAAG,gBAAgB,GAAG,MAAM,CAAC;IACV,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAe;IAE3D,MAAM,IAAI,kBAAkB;IAcrC,OAAO,CAAC,YAAY;IAapB,OAAO,CAAC,iBAAiB;IAqBzB,WAAW,CAAC,CAAC,EAAE,KAAK,GAAG,IAAI;IAc3B,OAAO,IAAI,IAAI;IAqBf,OAAO,CAAC,MAAM,CAAC,mBAAmB,CAA2B;IAC7D,OAAO,CAAC,MAAM,CAAC,MAAM,CAAoB;IACzC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAU;IAEnC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU;IACxC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,cAAc,GAAG,UAAU;IAsB/C,OAAO,CAAC,MAAM,CAAC,YAAY;IAO3B,OAAO,CAAC,MAAM,CAAC,SAAS;IAyBxB,OAAO,CAAC,MAAM,CAAC,cAAc;CAS9B;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,YAAY,EAAE,UAAU,CAAC;KAC1B;CACF"}
@@ -1,7 +1,7 @@
1
1
  var UmSnackbar_1;
2
2
  import { __decorate } from "tslib";
3
3
  import { html, LitElement, nothing } from 'lit';
4
- import { customElement, property, query } from 'lit/decorators.js';
4
+ import { customElement, property, query, state } from 'lit/decorators.js';
5
5
  import { classMap } from 'lit/directives/class-map.js';
6
6
  import { styles as baseStyles } from '../shared/base.styles.js';
7
7
  import { styles } from './snackbar.styles.js';
@@ -19,12 +19,14 @@ let UmSnackbar = class UmSnackbar extends LitElement {
19
19
  this.message = '';
20
20
  this.action = '';
21
21
  this.showClose = false;
22
- this.dismissed = false;
22
+ this._dismissed = false;
23
+ this._canDismiss = false;
23
24
  }
24
25
  static { UmSnackbar_1 = this; }
25
26
  static { this.styles = [baseStyles, styles]; }
27
+ static { this.minDisplayTime = 1500; }
26
28
  render() {
27
- const classes = { dismiss: this.dismissed };
29
+ const classes = { dismiss: this._dismissed && this._canDismiss };
28
30
  return html `
29
31
  <div class="container ${classMap(classes)}" part="container">
30
32
  <u-elevation></u-elevation>
@@ -77,17 +79,21 @@ let UmSnackbar = class UmSnackbar extends LitElement {
77
79
  this.dismiss();
78
80
  }
79
81
  dismiss() {
80
- if (this.dismissed) {
82
+ if (this._dismissed) {
81
83
  return;
82
84
  }
83
- this.dismissed = true;
85
+ this._dismissed = true;
84
86
  const onAnimationEnd = () => {
85
87
  this.container.removeEventListener('animationend', onAnimationEnd);
86
88
  this.remove();
87
- UmSnackbar_1.showNext();
89
+ if (UmSnackbar_1._displayingSnackbar === this) {
90
+ UmSnackbar_1._displayingSnackbar = null;
91
+ }
92
+ UmSnackbar_1._showNext();
88
93
  };
89
94
  this.container.addEventListener('animationend', onAnimationEnd);
90
95
  }
96
+ static { this._displayingSnackbar = null; }
91
97
  static { this._queue = []; }
92
98
  static show(configOrMessage) {
93
99
  if (typeof configOrMessage === 'string') {
@@ -98,6 +104,7 @@ let UmSnackbar = class UmSnackbar extends LitElement {
98
104
  configOrMessage.duration ??= SnackbarDuration.short;
99
105
  const snackbar = this.createSnackbar(configOrMessage);
100
106
  UmSnackbar_1._queue.push(snackbar);
107
+ UmSnackbar_1._displayingSnackbar?.dismiss();
101
108
  if (!UmSnackbar_1._consuming) {
102
109
  UmSnackbar_1.consumeQueue();
103
110
  }
@@ -106,17 +113,24 @@ let UmSnackbar = class UmSnackbar extends LitElement {
106
113
  static consumeQueue() {
107
114
  if (UmSnackbar_1._queue.length) {
108
115
  UmSnackbar_1._consuming = true;
109
- UmSnackbar_1.showNext();
116
+ UmSnackbar_1._showNext();
110
117
  }
111
118
  }
112
- static showNext() {
119
+ static _showNext() {
113
120
  if (!UmSnackbar_1._queue.length) {
114
121
  UmSnackbar_1._consuming = false;
115
122
  return;
116
123
  }
117
124
  const snackbar = UmSnackbar_1._queue[0];
125
+ UmSnackbar_1._displayingSnackbar = snackbar;
118
126
  UmSnackbar_1._queue = UmSnackbar_1._queue.slice(1);
119
127
  document.body.appendChild(snackbar);
128
+ if (UmSnackbar_1.minDisplayTime > 0) {
129
+ setTimeout(() => snackbar._canDismiss = true, UmSnackbar_1.minDisplayTime);
130
+ }
131
+ else {
132
+ snackbar._canDismiss = true;
133
+ }
120
134
  if (snackbar.duration === -1) {
121
135
  return;
122
136
  }
@@ -141,8 +155,11 @@ __decorate([
141
155
  property({ type: Boolean, attribute: 'show-close', reflect: true })
142
156
  ], UmSnackbar.prototype, "showClose", void 0);
143
157
  __decorate([
144
- property({ type: Boolean, reflect: true })
145
- ], UmSnackbar.prototype, "dismissed", void 0);
158
+ state()
159
+ ], UmSnackbar.prototype, "_dismissed", void 0);
160
+ __decorate([
161
+ state()
162
+ ], UmSnackbar.prototype, "_canDismiss", void 0);
146
163
  __decorate([
147
164
  query('.container', true)
148
165
  ], UmSnackbar.prototype, "container", void 0);
@@ -1 +1 @@
1
- {"version":3,"file":"snackbar.js","sourceRoot":"","sources":["../../src/snackbar/snackbar.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,IAAI,EAAsB,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEvD,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;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AAO,EAAE,SAAS,EAAE,YAAY,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;6CAClD;AAC0B;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;6CAAmB;AAGlB;IAA3C,KAAK,CAAC,YAAY,EAAE,IAAI,CAAC;6CAA0C;AAVzD,UAAU;IADtB,aAAa,CAAC,YAAY,CAAC;GACf,UAAU,CAsJtB","sourcesContent":["import { html, HTMLTemplateResult, LitElement, nothing } from 'lit';\nimport { customElement, property, query } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\n\nimport { styles as baseStyles } from '../shared/base.styles.js';\nimport { styles } from './snackbar.styles.js';\n\nimport '../button/button.js';\nimport '../button/icon-button.js';\n\nexport interface SnackbarConfig {\n message: string;\n duration?: SnackbarDuration;\n action?: string;\n showClose?: boolean;\n}\n\nexport enum SnackbarDuration {\n short = 2500,\n long = 5000,\n infinite = -1,\n}\n\n@customElement('u-snackbar')\nexport class UmSnackbar extends LitElement {\n static override styles = [baseStyles, styles];\n\n @property({ reflect: true }) message = '';\n @property({ reflect: true }) action = '';\n @property({ type: Boolean, attribute: 'show-close', reflect: true })\n showClose = false;\n @property({ type: Boolean, reflect: true }) dismissed = false;\n\n duration!: SnackbarDuration | number;\n @query('.container', true) private readonly container!: HTMLElement;\n\n override render(): HTMLTemplateResult {\n const classes = { dismiss: this.dismissed };\n\n return html`\n <div class=\"container ${classMap(classes)}\" part=\"container\">\n <u-elevation></u-elevation>\n <div class=\"message-container\" part=\"message-container\">\n <div class=\"message\" part=\"message\">${this.message}</div>\n </div>\n ${this.renderButton()} ${this.renderCloseButton()}\n </div>\n `;\n }\n\n private renderButton() {\n return this.action\n ? html`\n <u-button\n variant=\"text\"\n @click=${this.actionClick.bind(this)}\n part=\"action\"\n >${this.action}\n </u-button>\n `\n : nothing;\n }\n\n private renderCloseButton() {\n return this.showClose\n ? html`\n <u-icon-button\n @click=${this.dismiss.bind(this)}\n part=\"close\"\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n height=\"1em\"\n viewBox=\"0 -960 960 960\"\n width=\"1em\"\n fill=\"currentColor\">\n <path\n d=\"m256-200-56-56 224-224-224-224 56-56 224 224 224-224 56 56-224 224 224 224-56 56-224-224-224 224Z\" />\n </svg>\n </u-icon-button>\n `\n : nothing;\n }\n\n actionClick(e: Event): void {\n e.stopPropagation();\n\n const actionClickEvent = new CustomEvent('actionClick', { cancelable: true });\n\n this.dispatchEvent(actionClickEvent);\n\n if (actionClickEvent.defaultPrevented) {\n return;\n }\n\n this.dismiss();\n }\n\n dismiss(): void {\n if (this.dismissed) {\n return;\n }\n\n this.dismissed = true;\n\n const onAnimationEnd = () => {\n this.container.removeEventListener('animationend', onAnimationEnd);\n this.remove();\n\n UmSnackbar.showNext();\n };\n\n this.container.addEventListener('animationend', onAnimationEnd);\n }\n\n private static _queue: UmSnackbar[] = [];\n private static _consuming: boolean;\n\n static show(message: string): UmSnackbar;\n static show(config: SnackbarConfig): UmSnackbar;\n static show(configOrMessage: SnackbarConfig | string): UmSnackbar {\n if (typeof configOrMessage === 'string') {\n configOrMessage = {\n message: configOrMessage,\n };\n }\n\n configOrMessage.duration ??= SnackbarDuration.short;\n\n const snackbar = this.createSnackbar(configOrMessage);\n UmSnackbar._queue.push(snackbar);\n\n if (!UmSnackbar._consuming) {\n UmSnackbar.consumeQueue();\n }\n\n return snackbar;\n }\n\n private static consumeQueue() {\n if (UmSnackbar._queue.length) {\n UmSnackbar._consuming = true;\n UmSnackbar.showNext();\n }\n }\n\n private static showNext() {\n if (!UmSnackbar._queue.length) {\n UmSnackbar._consuming = false;\n return;\n }\n\n const snackbar = UmSnackbar._queue[0];\n\n UmSnackbar._queue = UmSnackbar._queue.slice(1);\n\n document.body.appendChild(snackbar);\n\n if (snackbar.duration === -1) {\n return;\n }\n\n setTimeout(() => snackbar.dismiss(), snackbar.duration);\n }\n\n private static createSnackbar(config: SnackbarConfig): UmSnackbar {\n const snackbar = document.createElement('u-snackbar');\n snackbar.message = config.message;\n snackbar.action = config.action || '';\n snackbar.showClose = config.showClose!;\n snackbar.duration = config.duration!;\n\n return snackbar as unknown as UmSnackbar;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'u-snackbar': UmSnackbar;\n }\n}\n"]}
1
+ {"version":3,"file":"snackbar.js","sourceRoot":"","sources":["../../src/snackbar/snackbar.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,IAAI,EAAsB,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEvD,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,OAAO,qBAAqB,CAAC;AAC7B,OAAO,0BAA0B,CAAC;AASlC,MAAM,CAAN,IAAY,gBAIX;AAJD,WAAY,gBAAgB;IAC1B,4DAAY,CAAA;IACZ,0DAAW,CAAA;IACX,gEAAa,CAAA;AACf,CAAC,EAJW,gBAAgB,KAAhB,gBAAgB,QAI3B;AAGM,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,UAAU;IAAnC;;QAIwB,YAAO,GAAG,EAAE,CAAC;QACb,WAAM,GAAG,EAAE,CAAC;QAEzC,cAAS,GAAG,KAAK,CAAC;QACT,eAAU,GAAG,KAAK,CAAC;QACnB,gBAAW,GAAG,KAAK,CAAC;IA4J/B,CAAC;;aApKiB,WAAM,GAAG,CAAC,UAAU,EAAE,MAAM,CAAC,AAAvB,CAAwB;aACvC,mBAAc,GAAG,IAAI,AAAP,CAAQ;IAYpB,MAAM;QACb,MAAM,OAAO,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC,UA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AE,OAAO,EAAE,IAAI,EAAE,CAAC;6CAClD;AACT;IAAR,KAAK,EAAE;8CAAoB;AACnB;IAAR,KAAK,EAAE;+CAAqB;AAGe;IAA3C,KAAK,CAAC,YAAY,EAAE,IAAI,CAAC;6CAA0C;AAZzD,UAAU;IADtB,aAAa,CAAC,YAAY,CAAC;GACf,UAAU,CAqKtB","sourcesContent":["import { html, HTMLTemplateResult, LitElement, nothing } from 'lit';\nimport { customElement, property, query, state } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\n\nimport { styles as baseStyles } from '../shared/base.styles.js';\nimport { styles } from './snackbar.styles.js';\n\nimport '../button/button.js';\nimport '../button/icon-button.js';\n\nexport interface SnackbarConfig {\n message: string;\n duration?: SnackbarDuration;\n action?: string;\n showClose?: boolean;\n}\n\nexport enum SnackbarDuration {\n short = 2500,\n long = 5000,\n infinite = -1,\n}\n\n@customElement('u-snackbar')\nexport class UmSnackbar extends LitElement {\n static override styles = [baseStyles, styles];\n static minDisplayTime = 1500;\n\n @property({ reflect: true }) message = '';\n @property({ reflect: true }) action = '';\n @property({ type: Boolean, attribute: 'show-close', reflect: true })\n showClose = false;\n @state() _dismissed = false;\n @state() _canDismiss = false;\n\n duration!: SnackbarDuration | number;\n @query('.container', true) private readonly container!: HTMLElement;\n\n override render(): HTMLTemplateResult {\n const classes = { dismiss: this._dismissed && this._canDismiss };\n\n return html`\n <div class=\"container ${classMap(classes)}\" part=\"container\">\n <u-elevation></u-elevation>\n <div class=\"message-container\" part=\"message-container\">\n <div class=\"message\" part=\"message\">${this.message}</div>\n </div>\n ${this.renderButton()} ${this.renderCloseButton()}\n </div>\n `;\n }\n\n private renderButton() {\n return this.action\n ? html`\n <u-button\n variant=\"text\"\n @click=${this.actionClick.bind(this)}\n part=\"action\"\n >${this.action}\n </u-button>\n `\n : nothing;\n }\n\n private renderCloseButton() {\n return this.showClose\n ? html`\n <u-icon-button\n @click=${this.dismiss.bind(this)}\n part=\"close\"\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n height=\"1em\"\n viewBox=\"0 -960 960 960\"\n width=\"1em\"\n fill=\"currentColor\">\n <path\n d=\"m256-200-56-56 224-224-224-224 56-56 224 224 224-224 56 56-224 224 224 224-56 56-224-224-224 224Z\" />\n </svg>\n </u-icon-button>\n `\n : nothing;\n }\n\n actionClick(e: Event): void {\n e.stopPropagation();\n\n const actionClickEvent = new CustomEvent('actionClick', { cancelable: true });\n\n this.dispatchEvent(actionClickEvent);\n\n if (actionClickEvent.defaultPrevented) {\n return;\n }\n\n this.dismiss();\n }\n\n dismiss(): void {\n if (this._dismissed) {\n return;\n }\n\n this._dismissed = true;\n\n const onAnimationEnd = () => {\n this.container.removeEventListener('animationend', onAnimationEnd);\n this.remove();\n\n if (UmSnackbar._displayingSnackbar === this) {\n UmSnackbar._displayingSnackbar = null;\n }\n\n UmSnackbar._showNext();\n };\n\n this.container.addEventListener('animationend', onAnimationEnd);\n }\n\n private static _displayingSnackbar: UmSnackbar | null = null;\n private static _queue: UmSnackbar[] = [];\n private static _consuming: boolean;\n\n static show(message: string): UmSnackbar;\n static show(config: SnackbarConfig): UmSnackbar;\n static show(configOrMessage: SnackbarConfig | string): UmSnackbar {\n if (typeof configOrMessage === 'string') {\n configOrMessage = {\n message: configOrMessage,\n };\n }\n\n configOrMessage.duration ??= SnackbarDuration.short;\n\n const snackbar = this.createSnackbar(configOrMessage);\n UmSnackbar._queue.push(snackbar);\n\n UmSnackbar._displayingSnackbar?.dismiss();\n\n if (!UmSnackbar._consuming) {\n UmSnackbar.consumeQueue();\n }\n\n return snackbar;\n }\n\n private static consumeQueue() {\n if (UmSnackbar._queue.length) {\n UmSnackbar._consuming = true;\n UmSnackbar._showNext();\n }\n }\n\n private static _showNext() {\n if (!UmSnackbar._queue.length) {\n UmSnackbar._consuming = false;\n return;\n }\n\n const snackbar = UmSnackbar._queue[0];\n UmSnackbar._displayingSnackbar = snackbar;\n UmSnackbar._queue = UmSnackbar._queue.slice(1);\n\n document.body.appendChild(snackbar);\n\n if (UmSnackbar.minDisplayTime > 0) {\n setTimeout(() => snackbar._canDismiss = true, UmSnackbar.minDisplayTime);\n } else {\n snackbar._canDismiss = true;\n }\n\n if (snackbar.duration === -1) {\n return;\n }\n\n setTimeout(() => snackbar.dismiss(), snackbar.duration);\n }\n\n private static createSnackbar(config: SnackbarConfig): UmSnackbar {\n const snackbar = document.createElement('u-snackbar');\n snackbar.message = config.message;\n snackbar.action = config.action || '';\n snackbar.showClose = config.showClose!;\n snackbar.duration = config.duration!;\n\n return snackbar as unknown as UmSnackbar;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'u-snackbar': UmSnackbar;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"highlight.d.ts","sourceRoot":"","sources":["../../src/typeahead/highlight.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,kBAAkB,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAS3D,qBACa,WAAY,SAAQ,UAAU;;IACzC,OAAgB,MAAM,0BAAU;IAIvB,OAAO,CAAC,KAAK,CAAuB;IAE7C;;OAEG;IACH,IACI,MAAM,IAAI,MAAM,GAAG,SAAS,CAE/B;IAED,IAAI,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAInC;IAED;;OAEG;IACH,IACI,IAAI,IAAI,MAAM,GAAG,SAAS,CAE7B;IAED,IAAI,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAIjC;cAEkB,MAAM,IAAI,kBAAkB,GAAG,kBAAkB,EAAE;IAQtE,OAAO,CAAC,QAAQ;CAqBjB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,aAAa,EAAE,WAAW,CAAC;KAC5B;CACF"}
1
+ {"version":3,"file":"highlight.d.ts","sourceRoot":"","sources":["../../src/typeahead/highlight.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,kBAAkB,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAS3D,qBACa,WAAY,SAAQ,UAAU;;IACzC,OAAgB,MAAM,0BAAU;IAIvB,OAAO,CAAC,KAAK,CAAuB;IAE7C;;OAEG;IACH,IACI,MAAM,IAAI,MAAM,GAAG,SAAS,CAE/B;IAED,IAAI,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAInC;IAED;;OAEG;IACH,IACI,IAAI,IAAI,MAAM,GAAG,SAAS,CAE7B;IAED,IAAI,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAIjC;cAEkB,MAAM,IAAI,kBAAkB,GAAG,kBAAkB,EAAE;IAQtE,OAAO,CAAC,QAAQ;CAmBjB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,aAAa,EAAE,WAAW,CAAC;KAC5B;CACF"}
@@ -44,11 +44,9 @@ let UmHighlight = class UmHighlight extends LitElement {
44
44
  this.parts = [resultStr];
45
45
  return;
46
46
  }
47
- console.log(regExpEscape(termLC));
48
47
  this.parts = resultNormalized
49
48
  .split(new RegExp(`(${regExpEscape(termLC)})`))
50
49
  .map(part => {
51
- console.log(part);
52
50
  const originalPart = resultStr.substring(currentIdx, currentIdx + part.length);
53
51
  currentIdx += part.length;
54
52
  return originalPart;
@@ -1 +1 @@
1
- {"version":3,"file":"highlight.js","sourceRoot":"","sources":["../../src/typeahead/highlight.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAsB,UAAU,EAAE,MAAM,KAAK,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAEnE,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE/C,MAAM,YAAY,GAAG,CAAC,IAAY,EAAE,EAAE,CACpC,IAAI,CAAC,OAAO,CAAC,0BAA0B,EAAE,MAAM,CAAC,CAAC;A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AC;YACzB,OAAO;QACT,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC;QAClC,IAAI,CAAC,KAAK,GAAG,gBAAgB;aAC1B,KAAK,CAAC,IAAI,MAAM,CAAC,IAAI,YAAY,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;aAC9C,GAAG,CAAC,IAAI,CAAC,EAAE;YACV,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAClB,MAAM,YAAY,GAAG,SAAS,CAAC,SAAS,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;YAC/E,UAAU,IAAI,IAAI,CAAC,MAAM,CAAC;YAC1B,OAAO,YAAY,CAAC;QACtB,CAAC,CAAC,CAAC;IACP,CAAC;;AA1DgB;IAAhB,KAAK,EAAE;0CAAqC;AAM7C;IADC,QAAQ,EAAE;yCAGV;AAYD;IADC,QAAQ,EAAE;uCAGV;AA3BU,WAAW;IADvB,aAAa,CAAC,aAAa,CAAC;GAChB,WAAW,CAgEvB","sourcesContent":["import { html, HTMLTemplateResult, LitElement } from 'lit';\nimport { customElement, property, state } from 'lit/decorators.js';\n\nimport { normalizeText } from '../shared/normalize-text.js';\nimport { styles } from './highlight.styles.js';\n\nconst regExpEscape = (text: string) =>\n text.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, '\\\\$&');\n\n@customElement('u-highlight')\nexport class UmHighlight extends LitElement {\n static override styles = styles;\n\n #result: string | undefined;\n #term: string | undefined;\n @state() private parts: string[] | undefined;\n\n /**\n * The result text to display. If the term is found inside this text, it's highlighted\n */\n @property()\n get result(): string | undefined {\n return this.#result;\n }\n\n set result(value: string | undefined) {\n this.#result = value;\n\n this.setParts();\n }\n\n /**\n * The searched term\n */\n @property()\n get term(): string | undefined {\n return this.#term;\n }\n\n set term(value: string | undefined) {\n this.#term = value;\n\n this.setParts();\n }\n\n protected override render(): HTMLTemplateResult | HTMLTemplateResult[] {\n return this.parts\n ? this.parts.map((part, index) => index % 2\n ? html`<strong>${part}</strong>`\n : html`<span>${part}</span>`)\n : html`<span></span>`;\n }\n\n private setParts() {\n const resultStr = this.result || '';\n const resultNormalized = normalizeText(resultStr).toLowerCase();\n const termLC = normalizeText(this.term || '').toLowerCase();\n let currentIdx = 0;\n\n if (termLC.length <= 0) {\n this.parts = [resultStr];\n return;\n }\n\n console.log(regExpEscape(termLC));\n this.parts = resultNormalized\n .split(new RegExp(`(${regExpEscape(termLC)})`))\n .map(part => {\n console.log(part);\n const originalPart = resultStr.substring(currentIdx, currentIdx + part.length);\n currentIdx += part.length;\n return originalPart;\n });\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'u-highlight': UmHighlight;\n }\n}\n"]}
1
+ {"version":3,"file":"highlight.js","sourceRoot":"","sources":["../../src/typeahead/highlight.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAsB,UAAU,EAAE,MAAM,KAAK,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAEnE,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE/C,MAAM,YAAY,GAAG,CAAC,IAAY,EAAE,EAAE,CACpC,IAAI,CAAC,OAAO,CAAC,0BAA0B,EAAE,MAAM,CAAC,CAAC;AAG5C,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,UAAU;aACzB,WAAM,GAAG,MAAM,AAAT,CAAU;IAEhC,OAAO,CAAqB;IAC5B,KAAK,CAAqB;IAG1B;;OAEG;IAEH,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,IAAI,MAAM,CAAC,KAAyB;QAClC,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QAErB,IAAI,CAAC,QAAQ,EAAE,CAAC;IAClB,C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,CAAC;YAC1B,OAAO,YAAY,CAAC;QACtB,CAAC,CAAC,CAAC;IACP,CAAC;;AAxDgB;IAAhB,KAAK,EAAE;0CAAqC;AAM7C;IADC,QAAQ,EAAE;yCAGV;AAYD;IADC,QAAQ,EAAE;uCAGV;AA3BU,WAAW;IADvB,aAAa,CAAC,aAAa,CAAC;GAChB,WAAW,CA8DvB","sourcesContent":["import { html, HTMLTemplateResult, LitElement } from 'lit';\nimport { customElement, property, state } from 'lit/decorators.js';\n\nimport { normalizeText } from '../shared/normalize-text.js';\nimport { styles } from './highlight.styles.js';\n\nconst regExpEscape = (text: string) =>\n text.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, '\\\\$&');\n\n@customElement('u-highlight')\nexport class UmHighlight extends LitElement {\n static override styles = styles;\n\n #result: string | undefined;\n #term: string | undefined;\n @state() private parts: string[] | undefined;\n\n /**\n * The result text to display. If the term is found inside this text, it's highlighted\n */\n @property()\n get result(): string | undefined {\n return this.#result;\n }\n\n set result(value: string | undefined) {\n this.#result = value;\n\n this.setParts();\n }\n\n /**\n * The searched term\n */\n @property()\n get term(): string | undefined {\n return this.#term;\n }\n\n set term(value: string | undefined) {\n this.#term = value;\n\n this.setParts();\n }\n\n protected override render(): HTMLTemplateResult | HTMLTemplateResult[] {\n return this.parts\n ? this.parts.map((part, index) => index % 2\n ? html`<strong>${part}</strong>`\n : html`<span>${part}</span>`)\n : html`<span></span>`;\n }\n\n private setParts() {\n const resultStr = this.result || '';\n const resultNormalized = normalizeText(resultStr).toLowerCase();\n const termLC = normalizeText(this.term || '').toLowerCase();\n let currentIdx = 0;\n\n if (termLC.length <= 0) {\n this.parts = [resultStr];\n return;\n }\n\n this.parts = resultNormalized\n .split(new RegExp(`(${regExpEscape(termLC)})`))\n .map(part => {\n const originalPart = resultStr.substring(currentIdx, currentIdx + part.length);\n currentIdx += part.length;\n return originalPart;\n });\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'u-highlight': UmHighlight;\n }\n}\n"]}
@@ -957,6 +957,23 @@
957
957
  ],
958
958
  "references": []
959
959
  },
960
+ {
961
+ "name": "u-list-item",
962
+ "description": "\n---\n",
963
+ "attributes": [
964
+ {
965
+ "name": "selectable",
966
+ "values": []
967
+ }
968
+ ],
969
+ "references": []
970
+ },
971
+ {
972
+ "name": "u-list",
973
+ "description": "\n---\n",
974
+ "attributes": [],
975
+ "references": []
976
+ },
960
977
  {
961
978
  "name": "u-menu-item",
962
979
  "description": "\n---\n",
@@ -1077,23 +1094,6 @@
1077
1094
  ],
1078
1095
  "references": []
1079
1096
  },
1080
- {
1081
- "name": "u-list-item",
1082
- "description": "\n---\n",
1083
- "attributes": [
1084
- {
1085
- "name": "selectable",
1086
- "values": []
1087
- }
1088
- ],
1089
- "references": []
1090
- },
1091
- {
1092
- "name": "u-list",
1093
- "description": "\n---\n",
1094
- "attributes": [],
1095
- "references": []
1096
- },
1097
1097
  {
1098
1098
  "name": "u-drawer-headline",
1099
1099
  "description": "\n---\n",
@@ -1215,18 +1215,6 @@
1215
1215
  ],
1216
1216
  "references": []
1217
1217
  },
1218
- {
1219
- "name": "u-ripple",
1220
- "description": "\n---\n",
1221
- "attributes": [
1222
- {
1223
- "name": "disabled",
1224
- "description": "Disables the ripple.",
1225
- "values": []
1226
- }
1227
- ],
1228
- "references": []
1229
- },
1230
1218
  {
1231
1219
  "name": "u-radio-list-item",
1232
1220
  "description": "\n---\n",
@@ -1288,128 +1276,12 @@
1288
1276
  "references": []
1289
1277
  },
1290
1278
  {
1291
- "name": "u-option",
1292
- "description": "\n---\n",
1293
- "attributes": [
1294
- {
1295
- "name": "value",
1296
- "values": []
1297
- },
1298
- {
1299
- "name": "selected",
1300
- "values": []
1301
- },
1302
- {
1303
- "name": "active",
1304
- "description": "Force show focus ring",
1305
- "values": []
1306
- },
1307
- {
1308
- "name": "has-leading-icon",
1309
- "description": "Whether the menu item has leading icon or not\n\n_Note:_ Readonly",
1310
- "values": []
1311
- },
1312
- {
1313
- "name": "has-trailing-icon",
1314
- "description": "Whether the menu item has trailing icon or not\n\n_Note:_ Readonly",
1315
- "values": []
1316
- },
1317
- {
1318
- "name": "has-badge",
1319
- "description": "Whether the drawer item has badge or not\n\n_Note:_ Readonly",
1320
- "values": []
1321
- },
1322
- {
1323
- "name": "disabled",
1324
- "description": "Whether the button is disabled or not.",
1325
- "values": []
1326
- },
1327
- {
1328
- "name": "href",
1329
- "description": "The URL that the link button points to.",
1330
- "values": []
1331
- },
1332
- {
1333
- "name": "target",
1334
- "description": "Where to display the linked `href` URL for a link button. Common options\ninclude `_blank` to open in a new tab.",
1335
- "values": []
1336
- },
1337
- {
1338
- "name": "name",
1339
- "values": []
1340
- }
1341
- ],
1342
- "references": []
1343
- },
1344
- {
1345
- "name": "u-select",
1279
+ "name": "u-ripple",
1346
1280
  "description": "\n---\n",
1347
1281
  "attributes": [
1348
- {
1349
- "name": "placeholder",
1350
- "values": []
1351
- },
1352
- {
1353
- "name": "variant",
1354
- "values": [
1355
- {
1356
- "name": "filled"
1357
- },
1358
- {
1359
- "name": "outlined"
1360
- }
1361
- ]
1362
- },
1363
- {
1364
- "name": "label",
1365
- "description": "The floating label for the field",
1366
- "values": []
1367
- },
1368
- {
1369
- "name": "counter",
1370
- "values": []
1371
- },
1372
- {
1373
- "name": "hide-counter",
1374
- "values": []
1375
- },
1376
- {
1377
- "name": "supporting-text",
1378
- "description": "Supporting text conveys additional information about the field, such as how it will be used",
1379
- "values": []
1380
- },
1381
- {
1382
- "name": "error-text",
1383
- "description": "For text fields that validate their content (such as passwords), replace supporting text with error text when applicable.\nIf `errorText` is not an empty string, changing the property `invalid` to `true` will show the `errorText` instead of `supportingText`",
1384
- "values": []
1385
- },
1386
- {
1387
- "name": "empty",
1388
- "description": "Whether the field is empty or not. This changes the behavior of the floating label when the field is not focused.",
1389
- "values": []
1390
- },
1391
1282
  {
1392
1283
  "name": "disabled",
1393
- "values": []
1394
- },
1395
- {
1396
- "name": "invalid",
1397
- "description": "Get or sets where or not the field is in a visually invalid state.",
1398
- "values": []
1399
- },
1400
- {
1401
- "name": "has-leading-icon",
1402
- "description": "Whether the field has a leading icon or not\n\n_Note:_ Readonly",
1403
- "values": []
1404
- },
1405
- {
1406
- "name": "has-trailing-icon",
1407
- "description": "Whether the field has a trailing icon or not\n\n_Note:_ Readonly",
1408
- "values": []
1409
- },
1410
- {
1411
- "name": "has-error-text",
1412
- "description": "Whether the field has an error text or not\n\n_Note:_ Readonly",
1284
+ "description": "Disables the ripple.",
1413
1285
  "values": []
1414
1286
  }
1415
1287
  ],
@@ -1430,10 +1302,6 @@
1430
1302
  {
1431
1303
  "name": "show-close",
1432
1304
  "values": []
1433
- },
1434
- {
1435
- "name": "dismissed",
1436
- "values": []
1437
1305
  }
1438
1306
  ],
1439
1307
  "references": []
@@ -1826,6 +1694,145 @@
1826
1694
  }
1827
1695
  ],
1828
1696
  "references": []
1697
+ },
1698
+ {
1699
+ "name": "u-option",
1700
+ "description": "\n---\n",
1701
+ "attributes": [
1702
+ {
1703
+ "name": "value",
1704
+ "values": []
1705
+ },
1706
+ {
1707
+ "name": "selected",
1708
+ "values": []
1709
+ },
1710
+ {
1711
+ "name": "active",
1712
+ "description": "Force show focus ring",
1713
+ "values": []
1714
+ },
1715
+ {
1716
+ "name": "has-leading-icon",
1717
+ "description": "Whether the menu item has leading icon or not\n\n_Note:_ Readonly",
1718
+ "values": []
1719
+ },
1720
+ {
1721
+ "name": "has-trailing-icon",
1722
+ "description": "Whether the menu item has trailing icon or not\n\n_Note:_ Readonly",
1723
+ "values": []
1724
+ },
1725
+ {
1726
+ "name": "has-badge",
1727
+ "description": "Whether the drawer item has badge or not\n\n_Note:_ Readonly",
1728
+ "values": []
1729
+ },
1730
+ {
1731
+ "name": "disabled",
1732
+ "description": "Whether the button is disabled or not.",
1733
+ "values": []
1734
+ },
1735
+ {
1736
+ "name": "href",
1737
+ "description": "The URL that the link button points to.",
1738
+ "values": []
1739
+ },
1740
+ {
1741
+ "name": "target",
1742
+ "description": "Where to display the linked `href` URL for a link button. Common options\ninclude `_blank` to open in a new tab.",
1743
+ "values": []
1744
+ },
1745
+ {
1746
+ "name": "name",
1747
+ "values": []
1748
+ }
1749
+ ],
1750
+ "references": []
1751
+ },
1752
+ {
1753
+ "name": "u-select",
1754
+ "description": "\n---\n",
1755
+ "attributes": [
1756
+ {
1757
+ "name": "menu-positioning",
1758
+ "values": [
1759
+ {
1760
+ "name": "relative"
1761
+ },
1762
+ {
1763
+ "name": "fixed"
1764
+ }
1765
+ ]
1766
+ },
1767
+ {
1768
+ "name": "placeholder",
1769
+ "values": []
1770
+ },
1771
+ {
1772
+ "name": "variant",
1773
+ "values": [
1774
+ {
1775
+ "name": "filled"
1776
+ },
1777
+ {
1778
+ "name": "outlined"
1779
+ }
1780
+ ]
1781
+ },
1782
+ {
1783
+ "name": "label",
1784
+ "description": "The floating label for the field",
1785
+ "values": []
1786
+ },
1787
+ {
1788
+ "name": "counter",
1789
+ "values": []
1790
+ },
1791
+ {
1792
+ "name": "hide-counter",
1793
+ "values": []
1794
+ },
1795
+ {
1796
+ "name": "supporting-text",
1797
+ "description": "Supporting text conveys additional information about the field, such as how it will be used",
1798
+ "values": []
1799
+ },
1800
+ {
1801
+ "name": "error-text",
1802
+ "description": "For text fields that validate their content (such as passwords), replace supporting text with error text when applicable.\nIf `errorText` is not an empty string, changing the property `invalid` to `true` will show the `errorText` instead of `supportingText`",
1803
+ "values": []
1804
+ },
1805
+ {
1806
+ "name": "empty",
1807
+ "description": "Whether the field is empty or not. This changes the behavior of the floating label when the field is not focused.",
1808
+ "values": []
1809
+ },
1810
+ {
1811
+ "name": "disabled",
1812
+ "values": []
1813
+ },
1814
+ {
1815
+ "name": "invalid",
1816
+ "description": "Get or sets where or not the field is in a visually invalid state.",
1817
+ "values": []
1818
+ },
1819
+ {
1820
+ "name": "has-leading-icon",
1821
+ "description": "Whether the field has a leading icon or not\n\n_Note:_ Readonly",
1822
+ "values": []
1823
+ },
1824
+ {
1825
+ "name": "has-trailing-icon",
1826
+ "description": "Whether the field has a trailing icon or not\n\n_Note:_ Readonly",
1827
+ "values": []
1828
+ },
1829
+ {
1830
+ "name": "has-error-text",
1831
+ "description": "Whether the field has an error text or not\n\n_Note:_ Readonly",
1832
+ "values": []
1833
+ }
1834
+ ],
1835
+ "references": []
1829
1836
  }
1830
1837
  ]
1831
1838
  }