@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.
package/index.d.ts CHANGED
@@ -8,8 +8,8 @@ import './components/mu-select-label-content.js';
8
8
  import './components/mu-range.js';
9
9
  import './components/mu-range-thumb.js';
10
10
  import './components/mu-icon.js';
11
- import './components/mu-element.js';
12
11
  import 'lit';
12
+ import './components/mu-element.js';
13
13
  import '@mustib/utils/browser';
14
14
  import './components/mu-range-fill.js';
15
15
  import './components/mu-range-thumb-value.js';
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import './mu-element-CZDI_RCY.js';
1
+ import './mu-element-BTuCCJpo.js';
2
2
  import './components/mu-transparent.js';
3
3
  import './components/mu-trigger.js';
4
4
  import './components/mu-select.js';
@@ -13,5 +13,4 @@ import './components/mu-range-thumb-value.js';
13
13
  import './components/mu-icon.js';
14
14
  import 'lit';
15
15
  import 'lit/decorators.js';
16
- import './decorators.js';
17
16
  import 'lit/directives/repeat.js';
@@ -1,6 +1,5 @@
1
1
  import { css, LitElement } from 'lit';
2
2
  import { property } from 'lit/decorators.js';
3
- import { staticProperty } from './decorators.js';
4
3
 
5
4
  /******************************************************************************
6
5
  Copyright (c) Microsoft Corporation.
@@ -900,6 +899,7 @@ class MUElement extends LitElement {
900
899
  static register(tagName) {
901
900
  if (customElements.get(tagName))
902
901
  return;
902
+ // biome-ignore lint/complexity/noThisInStatic: <>
903
903
  customElements.define(tagName, this);
904
904
  }
905
905
  get interactable() {
@@ -919,12 +919,12 @@ class MUElement extends LitElement {
919
919
  value: `mu-element-${++count}`,
920
920
  configurable: false,
921
921
  writable: false,
922
- enumerable: true
922
+ enumerable: true,
923
923
  });
924
924
  }
925
925
  generateIsReadyPromise({ timeout = 1000, onTimeout = () => {
926
926
  console.warn('timeout reached for isReady promise', this);
927
- } } = {}) {
927
+ }, } = {}) {
928
928
  const obj = {
929
929
  status: 'pending',
930
930
  resolved: false,
@@ -974,9 +974,9 @@ class MUElement extends LitElement {
974
974
  * - `shouldBreak` - An optional function that takes an item and returns a boolean indicating whether to break the loop.
975
975
  */
976
976
  getNavigationItem(data) {
977
- const { direction, switchBack = false, items, fromIndex = direction === 'next' ? -1 : items.length, isNavigable, shouldBreak } = data;
977
+ const { direction, switchBack = false, items, fromIndex = direction === 'next' ? -1 : items.length, isNavigable, shouldBreak, } = data;
978
978
  let navigationItem;
979
- const getItem = ({ endIndex, startIndex }) => {
979
+ const getItem = ({ endIndex, startIndex, }) => {
980
980
  const numOfRetries = endIndex + 1 - startIndex;
981
981
  for (let i = 0; i < numOfRetries && !navigationItem; i++) {
982
982
  const itemIndex = direction === 'next' ? startIndex + i : endIndex - i;
@@ -993,26 +993,26 @@ class MUElement extends LitElement {
993
993
  if (direction === 'next') {
994
994
  getItem({
995
995
  startIndex: fromIndex + 1,
996
- endIndex: items.length - 1
996
+ endIndex: items.length - 1,
997
997
  });
998
998
  }
999
999
  else {
1000
1000
  getItem({
1001
1001
  startIndex: 0,
1002
- endIndex: fromIndex - 1
1002
+ endIndex: fromIndex - 1,
1003
1003
  });
1004
1004
  }
1005
1005
  if (!navigationItem && switchBack) {
1006
1006
  if (direction === 'next') {
1007
1007
  getItem({
1008
1008
  startIndex: 0,
1009
- endIndex: fromIndex - 1
1009
+ endIndex: fromIndex - 1,
1010
1010
  });
1011
1011
  }
1012
1012
  else {
1013
1013
  getItem({
1014
1014
  startIndex: fromIndex + 1,
1015
- endIndex: items.length - 1
1015
+ endIndex: items.length - 1,
1016
1016
  });
1017
1017
  }
1018
1018
  }
@@ -1043,7 +1043,7 @@ MUElement.css = {
1043
1043
  focus: css `
1044
1044
  --focus-color: oklch(from currentColor l c h / 0.5);
1045
1045
  box-shadow: 0 0 0 var(--focus-width, 2px) var(--mu-focus-color, var(--focus-color)) inset;
1046
- `
1046
+ `,
1047
1047
  };
1048
1048
  MUElement.cssColors = css `
1049
1049
  --mu-color-100: hsl(var(--mu-hue), 20%, 95%);
@@ -1104,13 +1104,21 @@ __decorate([
1104
1104
  property({ type: Boolean, reflect: true })
1105
1105
  ], MUElement.prototype, "readonly", void 0);
1106
1106
  __decorate([
1107
- staticProperty({
1108
- converter: Boolean
1107
+ property({
1108
+ type: Boolean,
1109
+ attribute: 'no-event-action-attributes',
1109
1110
  })
1110
1111
  ], MUElement.prototype, "noEventActionAttributes", void 0);
1111
1112
  __decorate([
1112
- staticProperty({
1113
- converter: parseJson
1113
+ property({
1114
+ converter: {
1115
+ toAttribute(value, _type) {
1116
+ return JSON.stringify(value);
1117
+ },
1118
+ fromAttribute(value, _type) {
1119
+ return value === null ? [] : parseJson(value);
1120
+ },
1121
+ },
1114
1122
  })
1115
1123
  ], MUElement.prototype, "eventActionEvents", void 0);
1116
1124
 
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "type": "module",
4
4
  "description": "A customizable web-components library with lit",
5
5
  "private": false,
6
- "version": "0.0.0-alpha.0",
6
+ "version": "0.0.0-alpha.2",
7
7
  "dependencies": {
8
8
  "@mustib/utils": "2.7.0"
9
9
  },
@@ -11,6 +11,7 @@
11
11
  "lit": "^3.3.1"
12
12
  },
13
13
  "devDependencies": {
14
+ "@biomejs/biome": "2.3.5",
14
15
  "@rollup/plugin-multi-entry": "^7.1.0",
15
16
  "@rollup/plugin-node-resolve": "^16.0.3",
16
17
  "@rollup/plugin-typescript": "^12.3.0",
package/decorators.d.ts DELETED
@@ -1,34 +0,0 @@
1
- type Options = {
2
- /**
3
- * The HTML attribute to get the value from.
4
- * If not provided, it defaults to the kebab case version of the property name.
5
- * @example If the property name is "propName", the attribute will default to "prop-name".
6
- */
7
- attribute?: string;
8
- /**
9
- * A function that converts the attribute value to the property value.
10
- */
11
- converter?: (value: string | null) => any;
12
- /**
13
- * Whether to reflect the default value of the property to the attribute.
14
- *
15
- * The default value is the value that is assigned to the property on the class definition like so:
16
- * `propName = value` or basically any value that calls the setter before the first call to the getter.
17
- *
18
- * This is useful when you want the attribute to have the same value as the property by default.
19
- *
20
- * For example, if you have a property `visible` with a default value of `true`, and you want the attribute `visible` to have the value `"true"` by default, you can set `reflectDefault` to `true`.
21
- *
22
- * @default false
23
- */
24
- reflectDefault?: boolean;
25
- /**
26
- * A function that converts the default property value to the attribute value.
27
- *
28
- * this is only used if `reflectDefault` is true
29
- */
30
- reflectConverter?: (value: any) => string;
31
- };
32
- declare function staticProperty(options?: Options): <T extends HTMLElement>(target: T, key: string) => void;
33
-
34
- export { staticProperty };
package/decorators.js DELETED
@@ -1,50 +0,0 @@
1
- const defaultConverter = (value) => (value ?? undefined);
2
- const toKebabCase = (str) => str.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
3
- const defaultReflectConverter = (value) => value.toString();
4
- function staticProperty(options) {
5
- return function staticPropertyDecorator(target, key) {
6
- if (!Reflect.has(target, '__staticProperties')) {
7
- Reflect.set(target, '__staticProperties', new WeakMap());
8
- }
9
- const { attribute = toKebabCase(key), converter = defaultConverter, reflectDefault = false, reflectConverter = defaultReflectConverter } = options ?? {};
10
- Reflect.defineProperty(target, key, {
11
- configurable: false,
12
- enumerable: true,
13
- set(v) {
14
- const mapData = getOrCreateMapData(this, key);
15
- if (mapData.hasBeenCalled) {
16
- throw new Error(`cannot set ${v} for a static property ${key} after first call to get`);
17
- }
18
- if (reflectDefault) {
19
- this.setAttribute(attribute, reflectConverter(v));
20
- }
21
- mapData.defaultValue = v;
22
- },
23
- get() {
24
- const mapData = getOrCreateMapData(this, key);
25
- if (mapData.hasBeenCalled)
26
- return mapData.value;
27
- mapData.hasBeenCalled = true;
28
- const attrValue = this.getAttribute(attribute);
29
- if (attrValue === null && mapData.defaultValue !== undefined) {
30
- mapData.value = mapData.defaultValue;
31
- }
32
- else
33
- mapData.value = converter(attrValue);
34
- return mapData.value;
35
- },
36
- });
37
- };
38
- }
39
- function getOrCreateMapData(instance, key) {
40
- let properties = Reflect.get(Reflect.getPrototypeOf(instance), '__staticProperties');
41
- let _mapData = properties.get(instance) || properties.set(instance, {}).get(instance);
42
- const staticData = _mapData[key] ||= {
43
- value: undefined,
44
- hasBeenCalled: false,
45
- defaultValue: undefined
46
- };
47
- return staticData;
48
- }
49
-
50
- export { staticProperty };