@microsoft/webui-framework 0.0.8 → 0.0.9

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,3 +1,5 @@
1
+ /** Convert camelCase to kebab-case for attribute reflection. */
2
+ export declare function toKebabCase(str: string): string;
1
3
  export declare function getObservableNames(ctor: Function): Set<string>;
2
4
  /**
3
5
  * Marks a property as observable. When the value changes the decorator will:
@@ -9,9 +9,74 @@
9
9
  // ---------------------------------------------------------------------------
10
10
  // Internal helpers
11
11
  // ---------------------------------------------------------------------------
12
+ /**
13
+ * Map of camelCase property names to their HTML attribute names.
14
+ *
15
+ * Covers two categories of irregular mappings:
16
+ *
17
+ * 1. Multi-word ARIA attributes — concatenated lowercase after `aria-`
18
+ * (e.g., `ariaDescribedBy` → `aria-describedby`), per the ARIAMixin spec.
19
+ * 2. HTML global/element attributes — concatenated lowercase attribute names
20
+ * with camelCase property counterparts (e.g., `readOnly` → `readonly`).
21
+ */
22
+ const propertyToAttribute = Object.assign(Object.create(null), {
23
+ // --- ARIA (ARIAMixin) ---
24
+ ariaActiveDescendant: 'aria-activedescendant',
25
+ ariaAutoComplete: 'aria-autocomplete',
26
+ ariaBrailleLabel: 'aria-braillelabel',
27
+ ariaBrailleRoleDescription: 'aria-brailleroledescription',
28
+ ariaColCount: 'aria-colcount',
29
+ ariaColIndex: 'aria-colindex',
30
+ ariaColIndexText: 'aria-colindextext',
31
+ ariaColSpan: 'aria-colspan',
32
+ ariaDescribedBy: 'aria-describedby',
33
+ ariaDropEffect: 'aria-dropeffect',
34
+ ariaErrorMessage: 'aria-errormessage',
35
+ ariaFlowTo: 'aria-flowto',
36
+ ariaHasPopup: 'aria-haspopup',
37
+ ariaKeyShortcuts: 'aria-keyshortcuts',
38
+ ariaLabelledBy: 'aria-labelledby',
39
+ ariaMultiLine: 'aria-multiline',
40
+ ariaMultiSelectable: 'aria-multiselectable',
41
+ ariaPosInSet: 'aria-posinset',
42
+ ariaReadOnly: 'aria-readonly',
43
+ ariaRoleDescription: 'aria-roledescription',
44
+ ariaRowCount: 'aria-rowcount',
45
+ ariaRowIndex: 'aria-rowindex',
46
+ ariaRowIndexText: 'aria-rowindextext',
47
+ ariaRowSpan: 'aria-rowspan',
48
+ ariaSetSize: 'aria-setsize',
49
+ ariaValueMax: 'aria-valuemax',
50
+ ariaValueMin: 'aria-valuemin',
51
+ ariaValueNow: 'aria-valuenow',
52
+ ariaValueText: 'aria-valuetext',
53
+ // --- HTML global/element attributes ---
54
+ accessKey: 'accesskey',
55
+ autoCapitalize: 'autocapitalize',
56
+ contentEditable: 'contenteditable',
57
+ crossOrigin: 'crossorigin',
58
+ dirName: 'dirname',
59
+ fetchPriority: 'fetchpriority',
60
+ formAction: 'formaction',
61
+ formEnctype: 'formenctype',
62
+ formMethod: 'formmethod',
63
+ formNoValidate: 'formnovalidate',
64
+ formTarget: 'formtarget',
65
+ inputMode: 'inputmode',
66
+ isMap: 'ismap',
67
+ maxLength: 'maxlength',
68
+ minLength: 'minlength',
69
+ noModule: 'nomodule',
70
+ noValidate: 'novalidate',
71
+ readOnly: 'readonly',
72
+ referrerPolicy: 'referrerpolicy',
73
+ tabIndex: 'tabindex',
74
+ useMap: 'usemap',
75
+ });
12
76
  /** Convert camelCase to kebab-case for attribute reflection. */
13
- function toKebabCase(str) {
14
- return str.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
77
+ export function toKebabCase(str) {
78
+ const mapped = propertyToAttribute[str];
79
+ return mapped ?? str.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
15
80
  }
16
81
  /**
17
82
  * Shared logic for installing a reactive getter/setter on a class prototype.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/webui-framework",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "type": "module",
5
5
  "description": "WebUI Framework Next — Preact-inspired lightweight Web Component runtime with SSR hydration. 15KB minified, compiled-template path mapping, no hydration markers.",
6
6
  "license": "MIT",
@@ -19,7 +19,7 @@
19
19
  "@playwright/test": "^1.58.2",
20
20
  "@types/node": "^25.3.5",
21
21
  "typescript": "^5.9.3",
22
- "@microsoft/webui-test-support": "0.0.8"
22
+ "@microsoft/webui-test-support": "0.0.9"
23
23
  },
24
24
  "scripts": {
25
25
  "build": "tsc",