@eagami/ui 5.28.0 → 5.30.0
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/README.md +11 -0
- package/fesm2022/eagami-ui-testing.mjs +42 -0
- package/fesm2022/eagami-ui-testing.mjs.map +1 -0
- package/fesm2022/eagami-ui.mjs +318 -63
- package/fesm2022/eagami-ui.mjs.map +1 -1
- package/package.json +6 -1
- package/testing/package.json +4 -0
- package/types/eagami-ui-testing.d.ts +10 -0
- package/types/eagami-ui.d.ts +107 -13
package/README.md
CHANGED
|
@@ -126,6 +126,17 @@ Every component adheres to WCAG 2.2 Level AA and follows the matching [WAI-ARIA
|
|
|
126
126
|
|
|
127
127
|
The library is SSR-safe and renders on the server (Angular Universal / `@angular/ssr`) without reaching for `window` or `document`. Browser-only work (focus management, the native `<dialog>`, overlay positioning, resize/intersection observers) is deferred to the client via `afterNextRender` and `isPlatformBrowser` guards, so prerendering, streaming SSR, and hydration work with no extra configuration.
|
|
128
128
|
|
|
129
|
+
## Testing
|
|
130
|
+
|
|
131
|
+
jsdom implements `<dialog>` without `showModal()` or `close()`, so a unit test that creates a component holding an open `<ea-dialog>` or `<ea-drawer>` throws before the spec body runs. The `@eagami/ui/testing` entry point ships a shim that fills in the missing methods; it patches only what the runtime lacks, so it is a no-op in real browsers. Call it once from your test setup file:
|
|
132
|
+
|
|
133
|
+
```ts
|
|
134
|
+
// test-setup.ts
|
|
135
|
+
import { installNativeDialogShim } from '@eagami/ui/testing';
|
|
136
|
+
|
|
137
|
+
installNativeDialogShim();
|
|
138
|
+
```
|
|
139
|
+
|
|
129
140
|
## Framework integration
|
|
130
141
|
|
|
131
142
|
`@eagami/ui` is Angular-only, but its design tokens are framework-agnostic. Self-contained copy-and-paste guides and a machine-readable token export are published with the docs and kept in sync with the token source on every release:
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fills in the native `<dialog>` methods jsdom leaves unimplemented, so a spec
|
|
3
|
+
* can create a component that opens an `ea-dialog` or `ea-drawer` without the
|
|
4
|
+
* test runner throwing on `showModal()` or `close()`. Call once from the test
|
|
5
|
+
* setup file. Only missing methods are patched, so a runtime that implements
|
|
6
|
+
* the element keeps its own behavior.
|
|
7
|
+
*/
|
|
8
|
+
function installNativeDialogShim() {
|
|
9
|
+
if (typeof HTMLDialogElement === 'undefined') {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const proto = HTMLDialogElement.prototype;
|
|
13
|
+
if (typeof proto.show !== 'function') {
|
|
14
|
+
proto.show = function () {
|
|
15
|
+
this.open = true;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
if (typeof proto.showModal !== 'function') {
|
|
19
|
+
proto.showModal = function () {
|
|
20
|
+
this.open = true;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
if (typeof proto.close !== 'function') {
|
|
24
|
+
proto.close = function (returnValue) {
|
|
25
|
+
if (!this.open) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (returnValue !== undefined) {
|
|
29
|
+
this.returnValue = returnValue;
|
|
30
|
+
}
|
|
31
|
+
this.open = false;
|
|
32
|
+
this.dispatchEvent(new Event('close'));
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Generated bundle index. Do not edit.
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
export { installNativeDialogShim };
|
|
42
|
+
//# sourceMappingURL=eagami-ui-testing.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eagami-ui-testing.mjs","sources":["../../../testing/src/native-dialog.ts","../../../testing/src/eagami-ui-testing.ts"],"sourcesContent":["/**\n * Fills in the native `<dialog>` methods jsdom leaves unimplemented, so a spec\n * can create a component that opens an `ea-dialog` or `ea-drawer` without the\n * test runner throwing on `showModal()` or `close()`. Call once from the test\n * setup file. Only missing methods are patched, so a runtime that implements\n * the element keeps its own behavior.\n */\nexport function installNativeDialogShim(): void {\n if (typeof HTMLDialogElement === 'undefined') {\n return;\n }\n const proto = HTMLDialogElement.prototype;\n if (typeof proto.show !== 'function') {\n proto.show = function (this: HTMLDialogElement): void {\n this.open = true;\n };\n }\n if (typeof proto.showModal !== 'function') {\n proto.showModal = function (this: HTMLDialogElement): void {\n this.open = true;\n };\n }\n if (typeof proto.close !== 'function') {\n proto.close = function (this: HTMLDialogElement, returnValue?: string): void {\n if (!this.open) {\n return;\n }\n if (returnValue !== undefined) {\n this.returnValue = returnValue;\n }\n this.open = false;\n this.dispatchEvent(new Event('close'));\n };\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":"AAAA;;;;;;AAMG;SACa,uBAAuB,GAAA;AACrC,IAAA,IAAI,OAAO,iBAAiB,KAAK,WAAW,EAAE;QAC5C;IACF;AACA,IAAA,MAAM,KAAK,GAAG,iBAAiB,CAAC,SAAS;AACzC,IAAA,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,UAAU,EAAE;QACpC,KAAK,CAAC,IAAI,GAAG,YAAA;AACX,YAAA,IAAI,CAAC,IAAI,GAAG,IAAI;AAClB,QAAA,CAAC;IACH;AACA,IAAA,IAAI,OAAO,KAAK,CAAC,SAAS,KAAK,UAAU,EAAE;QACzC,KAAK,CAAC,SAAS,GAAG,YAAA;AAChB,YAAA,IAAI,CAAC,IAAI,GAAG,IAAI;AAClB,QAAA,CAAC;IACH;AACA,IAAA,IAAI,OAAO,KAAK,CAAC,KAAK,KAAK,UAAU,EAAE;AACrC,QAAA,KAAK,CAAC,KAAK,GAAG,UAAmC,WAAoB,EAAA;AACnE,YAAA,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;gBACd;YACF;AACA,YAAA,IAAI,WAAW,KAAK,SAAS,EAAE;AAC7B,gBAAA,IAAI,CAAC,WAAW,GAAG,WAAW;YAChC;AACA,YAAA,IAAI,CAAC,IAAI,GAAG,KAAK;YACjB,IAAI,CAAC,aAAa,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;AACxC,QAAA,CAAC;IACH;AACF;;AClCA;;AAEG;;;;"}
|