@mustib/web-components 0.0.0-alpha.0 → 0.0.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- import { LitElement } from 'lit';
2
1
  import { closestPierce, EventAction } from '@mustib/utils/browser';
2
+ import { LitElement } from 'lit';
3
3
 
4
4
  type Elements = [
5
5
  'mu-select-item',
@@ -61,7 +61,7 @@ declare abstract class MUElement extends LitElement {
61
61
  get interactable(): boolean;
62
62
  muId: string;
63
63
  constructor();
64
- generateIsReadyPromise({ timeout, onTimeout }?: {
64
+ generateIsReadyPromise({ timeout, onTimeout, }?: {
65
65
  timeout?: number;
66
66
  onTimeout?: () => void;
67
67
  }): Readonly<{
@@ -1,4 +1,3 @@
1
- export { M as MUElement } from '../mu-element-CZDI_RCY.js';
1
+ export { M as MUElement } from '../mu-element-BTuCCJpo.js';
2
2
  import 'lit';
3
3
  import 'lit/decorators.js';
4
- import '../decorators.js';
@@ -2,6 +2,11 @@ import { CSSResultGroup, PropertyValues } from 'lit';
2
2
  import { MUElement } from './mu-element.js';
3
3
  import '@mustib/utils/browser';
4
4
 
5
+ type MuIconComponent = {
6
+ attributes: {
7
+ name: MuIcon['name'];
8
+ };
9
+ };
5
10
  declare class MuIcon extends MUElement {
6
11
  static styles?: CSSResultGroup | undefined;
7
12
  eventActionData: undefined;
@@ -23,3 +28,4 @@ declare global {
23
28
  }
24
29
 
25
30
  export { MuIcon };
31
+ export type { MuIconComponent };
@@ -1,7 +1,6 @@
1
- import { M as MUElement, _ as __decorate } from '../mu-element-CZDI_RCY.js';
1
+ import { M as MUElement, _ as __decorate } from '../mu-element-BTuCCJpo.js';
2
2
  import { css, html } from 'lit';
3
- import { staticProperty } from '../decorators.js';
4
- import 'lit/decorators.js';
3
+ import { property } from 'lit/decorators.js';
5
4
 
6
5
  class MuIcon extends MUElement {
7
6
  constructor() {
@@ -17,15 +16,21 @@ class MuIcon extends MUElement {
17
16
  }
18
17
  render() {
19
18
  const name = this.name;
20
- const icon = name && Reflect.has(MuIcon.icons, name) ? MuIcon.icons[name] : MuIcon.icons['noImage'];
21
- return name ? html `
19
+ const icon = name && Reflect.has(MuIcon.icons, name)
20
+ ? MuIcon.icons[name]
21
+ : MuIcon.icons.noImage;
22
+ return name
23
+ ? html `
22
24
  <div id='container' part='container'>
23
25
  ${icon}
24
26
  </div>
25
- ` : undefined;
27
+ `
28
+ : undefined;
26
29
  }
27
30
  }
28
- MuIcon.styles = [MUElement.cssBase, css `
31
+ MuIcon.styles = [
32
+ MUElement.cssBase,
33
+ css `
29
34
  :host {
30
35
  display: inline-block;
31
36
  }
@@ -40,7 +45,7 @@ MuIcon.styles = [MUElement.cssBase, css `
40
45
  height: var(--icon-size);
41
46
  transition: all 0.1s ease-in-out;
42
47
  }
43
- `
48
+ `,
44
49
  ];
45
50
  MuIcon.icons = {
46
51
  downArrow: html `
@@ -55,10 +60,10 @@ MuIcon.icons = {
55
60
  `,
56
61
  noImage: html `
57
62
  <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 115.19 123.38" style="enable-background:new 0 0 115.19 123.38" xml:space="preserve"><style type="text/css">.st0{fill-rule:evenodd;clip-rule:evenodd;stroke:#000000;stroke-width:0.5;stroke-miterlimit:2.6131;}</style><g><path class="st0" d="M93.13,79.5c12.05,0,21.82,9.77,21.82,21.82c0,12.05-9.77,21.82-21.82,21.82c-12.05,0-21.82-9.77-21.82-21.82 C71.31,89.27,81.08,79.5,93.13,79.5L93.13,79.5z M8.08,0.25h95.28c2.17,0,4.11,0.89,5.53,2.3c1.42,1.42,2.3,3.39,2.3,5.53v70.01 c-2.46-1.91-5.24-3.44-8.25-4.48V9.98c0-0.43-0.16-0.79-0.46-1.05c-0.26-0.26-0.66-0.46-1.05-0.46H9.94 c-0.43,0-0.79,0.16-1.05,0.46C8.63,9.19,8.43,9.58,8.43,9.98v70.02h0.03l31.97-30.61c1.28-1.18,3.29-1.05,4.44,0.23 c0.03,0.03,0.03,0.07,0.07,0.07l26.88,31.8c-4.73,5.18-7.62,12.08-7.62,19.65c0,3.29,0.55,6.45,1.55,9.4H8.08 c-2.17,0-4.11-0.89-5.53-2.3s-2.3-3.39-2.3-5.53V8.08c0-2.17,0.89-4.11,2.3-5.53S5.94,0.25,8.08,0.25L8.08,0.25z M73.98,79.35 l3.71-22.79c0.3-1.71,1.91-2.9,3.62-2.6c0.66,0.1,1.25,0.43,1.71,0.86l17.1,17.97c-2.18-0.52-4.44-0.79-6.78-0.79 C85.91,71.99,79.13,74.77,73.98,79.35L73.98,79.35z M81.98,18.19c3.13,0,5.99,1.28,8.03,3.32c2.07,2.07,3.32,4.9,3.32,8.03 c0,3.13-1.28,5.99-3.32,8.03c-2.07,2.07-4.9,3.32-8.03,3.32c-3.13,0-5.99-1.28-8.03-3.32c-2.07-2.07-3.32-4.9-3.32-8.03 c0-3.13,1.28-5.99,3.32-8.03C76.02,19.44,78.86,18.19,81.98,18.19L81.98,18.19z M85.82,88.05l19.96,21.6 c1.58-2.39,2.5-5.25,2.5-8.33c0-8.36-6.78-15.14-15.14-15.14C90.48,86.17,87.99,86.85,85.82,88.05L85.82,88.05z M100.44,114.58 l-19.96-21.6c-1.58,2.39-2.5,5.25-2.5,8.33c0,8.36,6.78,15.14,15.14,15.14C95.78,116.46,98.27,115.78,100.44,114.58L100.44,114.58z"/></g></svg>
58
- `
63
+ `,
59
64
  };
60
65
  __decorate([
61
- staticProperty()
66
+ property()
62
67
  ], MuIcon.prototype, "name", void 0);
63
68
  MuIcon.register('mu-icon');
64
69
 
@@ -2,6 +2,12 @@ import { CSSResultGroup } from 'lit';
2
2
  import { MUElement } from './mu-element.js';
3
3
  import '@mustib/utils/browser';
4
4
 
5
+ type MuRangeFillComponent = {
6
+ attributes: {
7
+ for: MuRangeFill['for'];
8
+ type: MuRangeFill['type'];
9
+ };
10
+ };
5
11
  declare class MuRangeFill extends MUElement {
6
12
  static styles: CSSResultGroup;
7
13
  eventActionData: undefined;
@@ -46,3 +52,4 @@ declare class MuRangeFill extends MUElement {
46
52
  }
47
53
 
48
54
  export { MuRangeFill };
55
+ export type { MuRangeFillComponent };
@@ -1,7 +1,6 @@
1
- import { M as MUElement, _ as __decorate } from '../mu-element-CZDI_RCY.js';
1
+ import { M as MUElement, _ as __decorate } from '../mu-element-BTuCCJpo.js';
2
2
  import { css, html } from 'lit';
3
3
  import { property, query } from 'lit/decorators.js';
4
- import '../decorators.js';
5
4
 
6
5
  class MuRangeFill extends MUElement {
7
6
  constructor() {
@@ -48,7 +47,9 @@ class MuRangeFill extends MUElement {
48
47
  `;
49
48
  }
50
49
  }
51
- MuRangeFill.styles = [MUElement.cssBase, css `
50
+ MuRangeFill.styles = [
51
+ MUElement.cssBase,
52
+ css `
52
53
  #container {
53
54
  --range-fill-background-color: var(--mu-range-fill-background-color, var(--mu-color-500));
54
55
  --start: 25%;
@@ -79,7 +80,8 @@ MuRangeFill.styles = [MUElement.cssBase, css `
79
80
  top: var(--start);
80
81
  bottom: calc(100% - var(--end));
81
82
  }
82
- `];
83
+ `,
84
+ ];
83
85
  __decorate([
84
86
  property()
85
87
  ], MuRangeFill.prototype, "for", void 0);
@@ -2,6 +2,12 @@ import { CSSResultGroup } from 'lit';
2
2
  import { MUElement } from './mu-element.js';
3
3
  import '@mustib/utils/browser';
4
4
 
5
+ type MuRangeThumbValueComponent = {
6
+ attributes: {
7
+ reversed: MuRangeThumbValue['reversed'];
8
+ type: MuRangeThumbValue['type'];
9
+ };
10
+ };
5
11
  declare class MuRangeThumbValue extends MUElement {
6
12
  static styles: CSSResultGroup;
7
13
  eventActionData: undefined;
@@ -46,3 +52,4 @@ declare class MuRangeThumbValue extends MUElement {
46
52
  }
47
53
 
48
54
  export { MuRangeThumbValue };
55
+ export type { MuRangeThumbValueComponent };
@@ -1,7 +1,6 @@
1
- import { M as MUElement, _ as __decorate } from '../mu-element-CZDI_RCY.js';
1
+ import { M as MUElement, _ as __decorate } from '../mu-element-BTuCCJpo.js';
2
2
  import { css, html } from 'lit';
3
3
  import { property, query } from 'lit/decorators.js';
4
- import '../decorators.js';
5
4
 
6
5
  class MuRangeThumbValue extends MUElement {
7
6
  constructor() {
@@ -41,16 +40,16 @@ class MuRangeThumbValue extends MUElement {
41
40
  async setValue(data) {
42
41
  await this.updateComplete;
43
42
  switch (this.type) {
44
- case "percentage":
43
+ case 'percentage':
45
44
  // keep two decimal places
46
- this.contentEl.textContent = `${(Math.trunc(data.percentage * 100) / 100)}%`;
45
+ this.contentEl.textContent = `${Math.trunc(data.percentage * 100) / 100}%`;
47
46
  break;
48
- case "percentage:round":
47
+ case 'percentage:round':
49
48
  this.contentEl.textContent = `${Math.round(data.percentage)}%`;
50
49
  break;
51
- case "unit":
50
+ case 'unit':
52
51
  // keep one decimal place
53
- this.contentEl.textContent = `${(Math.trunc(data.value * 10) / 10)}`;
52
+ this.contentEl.textContent = `${Math.trunc(data.value * 10) / 10}`;
54
53
  break;
55
54
  default:
56
55
  this.type;
@@ -72,7 +71,9 @@ class MuRangeThumbValue extends MUElement {
72
71
  `;
73
72
  }
74
73
  }
75
- MuRangeThumbValue.styles = [MUElement.cssBase, css `
74
+ MuRangeThumbValue.styles = [
75
+ MUElement.cssBase,
76
+ css `
76
77
  :host([reversed]) #container[axis='x'] {
77
78
  top: 100%;
78
79
  bottom: unset;
@@ -122,7 +123,8 @@ MuRangeThumbValue.styles = [MUElement.cssBase, css `
122
123
  color: var(--mu-color-100);
123
124
  }
124
125
  }
125
- `];
126
+ `,
127
+ ];
126
128
  __decorate([
127
129
  property({ type: Boolean })
128
130
  ], MuRangeThumbValue.prototype, "reversed", void 0);
@@ -3,6 +3,19 @@ import { MUElement } from './mu-element.js';
3
3
  import { MuRangeThumbValue } from './mu-range-thumb-value.js';
4
4
  import '@mustib/utils/browser';
5
5
 
6
+ type MuRangeThumbComponent = {
7
+ attributes: {
8
+ 'min-value': MuRangeThumb['minValue'];
9
+ 'max-value': MuRangeThumb['maxValue'];
10
+ value: MuRangeThumb['value'];
11
+ step: MuRangeThumb['step'];
12
+ name: MuRangeThumb['name'];
13
+ focused: MuRangeThumb['focused'];
14
+ 'intersect-behavior': MuRangeThumb['intersectBehavior'];
15
+ transparent: MuRangeThumb['transparent'];
16
+ 'force-step': MuRangeThumb['forceStep'];
17
+ };
18
+ };
6
19
  declare class MuRangeThumb extends MUElement {
7
20
  static styles?: CSSResultGroup | undefined;
8
21
  eventActionData: undefined;
@@ -118,3 +131,4 @@ declare global {
118
131
  }
119
132
 
120
133
  export { MuRangeThumb };
134
+ export type { MuRangeThumbComponent };
@@ -1,16 +1,16 @@
1
- import { M as MUElement, _ as __decorate, g as getElementBoundaries } from '../mu-element-CZDI_RCY.js';
1
+ import { M as MUElement, _ as __decorate, g as getElementBoundaries } from '../mu-element-BTuCCJpo.js';
2
2
  import { css, html } from 'lit';
3
3
  import { state, property, query } from 'lit/decorators.js';
4
- import { MuRangeThumbValue } from './mu-range-thumb-value.js';
5
4
  import { MuTransparent } from './mu-transparent.js';
6
- import '../decorators.js';
5
+ import { MuRangeThumbValue } from './mu-range-thumb-value.js';
7
6
 
8
7
  class MuRangeThumb extends MUElement {
9
8
  get range() {
10
9
  return this._range;
11
10
  }
12
11
  set range(value) {
13
- if (this._isRangeReady.resolved && (value[0] > this.minValue || value[1] < this.maxValue)) {
12
+ if (this._isRangeReady.resolved &&
13
+ (value[0] > this.minValue || value[1] < this.maxValue)) {
14
14
  console.warn(`range must not be less than max value (${this.maxValue}) or greater than min value (${this.minValue}), but got (${value})`, this);
15
15
  return;
16
16
  }
@@ -71,7 +71,10 @@ class MuRangeThumb extends MUElement {
71
71
  this._valueElements.add(el);
72
72
  }
73
73
  };
74
- this.renderRoot.querySelector('slot')?.assignedElements({ flatten: true }).forEach(el => {
74
+ this.renderRoot
75
+ .querySelector('slot')
76
+ ?.assignedElements({ flatten: true })
77
+ .forEach((el) => {
75
78
  if (el instanceof MuTransparent) {
76
79
  el.contents.forEach(addElement);
77
80
  }
@@ -121,10 +124,10 @@ class MuRangeThumb extends MUElement {
121
124
  _updateValueElements() {
122
125
  if (this._valueElements.size === 0)
123
126
  return;
124
- this._valueElements.forEach(el => {
127
+ this._valueElements.forEach((el) => {
125
128
  el.setValue({
126
129
  value: this.value,
127
- percentage: this.getPercentageFromValue(this.value)
130
+ percentage: this.getPercentageFromValue(this.value),
128
131
  });
129
132
  });
130
133
  }
@@ -158,26 +161,29 @@ class MuRangeThumb extends MUElement {
158
161
  * @returns A boolean indicating if the value was changed
159
162
  */
160
163
  setValueFromPercentage(percentage) {
161
- const value = ((percentage / 100) * (this.range[1] - this.range[0])) + this.range[0];
164
+ const value = (percentage / 100) * (this.range[1] - this.range[0]) + this.range[0];
162
165
  return this.setValue(value);
163
166
  }
164
167
  /**
165
168
  * Converts a given value to a percentage based on the current range and returns it.
166
169
  */
167
170
  getPercentageFromValue(value) {
168
- return ((value) / (this.range[1] - this.range[0])) * 100;
171
+ return (value / (this.range[1] - this.range[0])) * 100;
169
172
  }
170
173
  /**
171
174
  * Updates the axis of related mu-range-thumb-value elements
172
175
  */
173
176
  updateValueElementsAxis() {
174
- this._valueElements.forEach(el => el.setAxis(this.axis === 'x' || this.axis === '-x' ? 'x' : 'y'));
177
+ this._valueElements.forEach((el) => {
178
+ el.setAxis(this.axis === 'x' || this.axis === '-x' ? 'x' : 'y');
179
+ });
175
180
  }
176
181
  async updated(_changedProperties) {
177
182
  await this.updateComplete;
178
183
  if (_changedProperties.has('axis')) {
179
184
  this.updateValueElementsAxis();
180
- this.ariaOrientation = this.axis === '-y' || this.axis === 'y' ? 'vertical' : 'horizontal';
185
+ this.ariaOrientation =
186
+ this.axis === '-y' || this.axis === 'y' ? 'vertical' : 'horizontal';
181
187
  }
182
188
  if (_changedProperties.has('value')) {
183
189
  if (!this.isValidValue(this.value)) {
@@ -187,13 +193,15 @@ class MuRangeThumb extends MUElement {
187
193
  this.setAttribute('aria-valuenow', `${this.value}`);
188
194
  this._updateValueElements();
189
195
  }
190
- if (_changedProperties.has('minValue') || _changedProperties.has('maxValue')) {
196
+ if (_changedProperties.has('minValue') ||
197
+ _changedProperties.has('maxValue')) {
191
198
  this.setAttribute('aria-valuemin', `${this.minValue}`);
192
199
  this.setAttribute('aria-valuemax', `${this.maxValue}`);
193
200
  if (this.minValue > this.maxValue) {
194
201
  console.warn(`minValue attribute must not be greater than maxValue attribute, but got (${this.minValue}, ${this.maxValue})`, this);
195
202
  }
196
- else if (this.minValue < this.range[0] || this.maxValue > this.range[1]) {
203
+ else if (this.minValue < this.range[0] ||
204
+ this.maxValue > this.range[1]) {
197
205
  console.warn(`minValue (${this.minValue}) and maxValue (${this.maxValue}) attributes must be equal to or in the range of range property (${this.range})`, this);
198
206
  }
199
207
  }
@@ -206,7 +214,9 @@ class MuRangeThumb extends MUElement {
206
214
  `;
207
215
  }
208
216
  }
209
- MuRangeThumb.styles = [MUElement.cssBase, css `
217
+ MuRangeThumb.styles = [
218
+ MUElement.cssBase,
219
+ css `
210
220
  #container {
211
221
  --thumb-size: var(--mu-range-thumb-size, calc(var(--range-thickness) * 3));
212
222
  --range-thumb-background-color: var(--mu-range-thumb-background-color, var(--mu-color-500));
@@ -254,7 +264,8 @@ MuRangeThumb.styles = [MUElement.cssBase, css `
254
264
  left: 50%;
255
265
  transform: translateX(-50%);
256
266
  }
257
- `];
267
+ `,
268
+ ];
258
269
  __decorate([
259
270
  state()
260
271
  ], MuRangeThumb.prototype, "axis", void 0);
@@ -262,25 +273,25 @@ __decorate([
262
273
  property({
263
274
  reflect: true,
264
275
  type: Number,
265
- attribute: 'min-value'
276
+ attribute: 'min-value',
266
277
  })
267
278
  ], MuRangeThumb.prototype, "minValue", void 0);
268
279
  __decorate([
269
280
  property({
270
281
  reflect: true,
271
282
  type: Number,
272
- attribute: 'max-value'
283
+ attribute: 'max-value',
273
284
  })
274
285
  ], MuRangeThumb.prototype, "maxValue", void 0);
275
286
  __decorate([
276
287
  property({
277
288
  reflect: true,
278
289
  type: Number,
279
- attribute: 'value'
290
+ attribute: 'value',
280
291
  })
281
292
  ], MuRangeThumb.prototype, "value", void 0);
282
293
  __decorate([
283
- property({ reflect: true, type: Number, })
294
+ property({ reflect: true, type: Number })
284
295
  ], MuRangeThumb.prototype, "step", void 0);
285
296
  __decorate([
286
297
  property()
@@ -1,10 +1,21 @@
1
1
  import { CSSResultGroup, PropertyValues } from 'lit';
2
2
  import { MUElement } from './mu-element.js';
3
- import { MuRangeThumb } from './mu-range-thumb.js';
4
3
  import { MuRangeFill } from './mu-range-fill.js';
4
+ import { MuRangeThumb } from './mu-range-thumb.js';
5
5
  import '@mustib/utils/browser';
6
6
  import './mu-range-thumb-value.js';
7
7
 
8
+ type MuRangeComponent = {
9
+ attributes: {
10
+ axis: MuRange['axis'];
11
+ min: MuRange['min'];
12
+ max: MuRange['max'];
13
+ value: MuRange['value'];
14
+ 'default-value': MuRange['defaultValue'];
15
+ 'empty-area': MuRange['emptyArea'];
16
+ };
17
+ events: Events;
18
+ };
8
19
  type RangeThumb = {
9
20
  element: MuRangeThumb;
10
21
  linkedFillElements: RangeFill[] | undefined;
@@ -204,3 +215,4 @@ declare global {
204
215
  }
205
216
 
206
217
  export { MuRange };
218
+ export type { MuRangeComponent };