@epa-wg/custom-element-dist 0.0.32 → 0.0.34
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/.claude/settings.local.json +18 -0
- package/.github/workflows/deploy.yml +59 -0
- package/.idea/copilot.data.migration.agent.xml +6 -0
- package/.idea/copilot.data.migration.ask.xml +6 -0
- package/.idea/copilot.data.migration.edit.xml +6 -0
- package/.idea/custom-element-dist.iml +2 -0
- package/.storybook/main.ts +20 -21
- package/.storybook/preview.ts +23 -25
- package/README.md +6 -4
- package/coverage/block-navigation.js +1 -1
- package/coverage/coverage-final.json +8 -18
- package/coverage/index.html +45 -30
- package/coverage/sorter.js +21 -7
- package/coverage/src/custom-element/coverage.svg +1 -1
- package/coverage/src/custom-element/custom-element.js/coverage.svg +1 -1
- package/coverage/src/custom-element/custom-element.js.html +687 -480
- package/coverage/src/custom-element/http-request.js/coverage.svg +1 -1
- package/coverage/src/custom-element/http-request.js.html +39 -18
- package/coverage/src/custom-element/index.html +35 -35
- package/coverage/src/custom-element/local-storage.js.html +1 -1
- package/coverage/src/custom-element/location-element.js.html +31 -31
- package/coverage/src/custom-element/module-url.js/coverage.svg +1 -1
- package/coverage/src/custom-element/module-url.js.html +20 -20
- package/coverage/src/index.html +1 -1
- package/coverage/src/{stories/local-storage.test.stories.ts → material/theme/colors.js}/coverage.svg +1 -1
- package/coverage/src/material/theme/colors.js.html +217 -0
- package/coverage/src/{stories/location-element.test.stories.ts → material/theme}/coverage.svg +1 -1
- package/coverage/src/material/theme/index.html +116 -0
- package/coverage/src/mocks/handlers.ts.html +1 -1
- package/coverage/src/mocks/index.html +1 -1
- package/coverage/src/stories/coverage.svg +1 -1
- package/coverage/src/stories/{external-template.test.stories.ts → frame.canvas.ts}/coverage.svg +1 -1
- package/coverage/src/stories/frame.canvas.ts.html +175 -0
- package/coverage/src/stories/http-request.stories.ts.html +1 -1
- package/coverage/src/stories/index.html +14 -179
- package/coverage/src/stories/testStoryBook.ts.html +12 -12
- package/coverage/src/sum.ts.html +1 -1
- package/dist/custom-element-BoYMoUtP.js +619 -0
- package/dist/custom-element-BqtjrCRF.cjs +97 -0
- package/dist/custom-element-bundle.cjs +1 -1
- package/dist/custom-element-bundle.js +3 -3
- package/dist/demo/a.html +10 -3
- package/dist/demo/a.svg +26 -26
- package/dist/demo/attributes.html +153 -0
- package/dist/demo/external-templates-sb-6.html +42 -0
- package/dist/demo/external-templates-sb-7.html +42 -0
- package/dist/demo/html-template.html +5 -4
- package/dist/demo/module-url-sb-2.html +46 -0
- package/dist/demo/module-url-sb-4.html +48 -0
- package/dist/demo/module-url-sb-5.html +53 -0
- package/dist/demo/s.xml +3859 -7
- package/dist/demo/s.xslt +13 -48
- package/dist/demo/s1.xml +3706 -0
- package/dist/demo/ss.html +13 -4
- package/dist/http-request-DSaowcG1.cjs +1 -0
- package/dist/{http-request-BOvP4KTl.js → http-request-DTCzZ1gc.js} +15 -9
- package/dist/mockServiceWorker.js +31 -8
- package/package.json +25 -26
- package/public/demo/a.html +10 -3
- package/public/demo/a.svg +26 -26
- package/public/demo/attributes.html +153 -0
- package/public/demo/external-templates-sb-6.html +42 -0
- package/public/demo/external-templates-sb-7.html +42 -0
- package/public/demo/html-template.html +5 -4
- package/public/demo/module-url-sb-2.html +46 -0
- package/public/demo/module-url-sb-4.html +48 -0
- package/public/demo/module-url-sb-5.html +53 -0
- package/public/demo/s.xml +3859 -7
- package/public/demo/s.xslt +13 -48
- package/public/demo/s1.xml +3706 -0
- package/public/demo/ss.html +13 -4
- package/public/mockServiceWorker.js +31 -8
- package/src/custom-element/custom-element.d.ts +4 -0
- package/src/custom-element/custom-element.js +119 -50
- package/src/custom-element/demo/a.html +10 -3
- package/src/custom-element/demo/a.svg +26 -26
- package/src/custom-element/demo/attributes.html +153 -0
- package/src/custom-element/demo/html-template.html +5 -4
- package/src/custom-element/demo/s.xml +3859 -7
- package/src/custom-element/demo/s.xslt +13 -48
- package/src/custom-element/demo/s1.xml +3706 -0
- package/src/custom-element/demo/ss.html +13 -4
- package/src/custom-element/http-request.js +7 -0
- package/src/custom-element/ide/web-types-dce.json +1 -1
- package/src/custom-element/ide/web-types-xsl.json +1 -1
- package/src/custom-element/index.html +1 -1
- package/src/material/angular.css +987 -987
- package/src/material/components/action.html +262 -0
- package/src/material/components/autocomplete.html +167 -239
- package/src/material/components/badge.html +239 -0
- package/src/material/components/dropdown.html +7 -13
- package/src/material/components/icon-link.html +160 -160
- package/src/material/components/icon.html +252 -0
- package/src/material/components/input.html +569 -362
- package/src/material/components/menu.html +235 -234
- package/src/material/components.html +157 -121
- package/src/material/demo.css +36 -36
- package/src/material/index.html +109 -110
- package/src/material/material.css +356 -356
- package/src/material/theme/Base-Principles.md +339 -0
- package/src/material/theme/README.md +298 -18
- package/src/material/theme/UI Domain Model in web applications.svg +1 -0
- package/src/material/theme/User Semantic Theme tokens.svg +1 -0
- package/src/material/theme/action-pending-poc.html +62 -0
- package/src/material/theme/actions-color.html +141 -0
- package/src/material/theme/colors-light.html +631 -0
- package/src/material/theme/colors-native.html +51 -0
- package/src/material/theme/colors-poc.html +66 -0
- package/src/material/theme/colors.html +297 -0
- package/src/material/theme/colors.js +44 -0
- package/src/material/theme/consumer-theme.css +745 -0
- package/src/material/theme/semantic.css +132 -113
- package/src/material/theme/style-bug.html +123 -0
- package/src/material/theme/theme-data.css +43 -0
- package/src/material/theme/theme-data.xhtml +2926 -0
- package/src/material/theme/todo.md +274 -0
- package/src/material/theme/tokens/action-colors.png +0 -0
- package/src/material/theme/tokens/cem-article-illustration-4x1-letterbox-2000x500.png +0 -0
- package/src/material/theme/tokens/cem-breakpoints.md +519 -0
- package/src/material/theme/tokens/cem-colors.md +715 -0
- package/src/material/theme/tokens/cem-consumerflow-typography-matrix.svg +198 -0
- package/src/material/theme/tokens/cem-coupling.md +372 -0
- package/src/material/theme/tokens/cem-data-vs-reading-numerals.svg +164 -0
- package/src/material/theme/tokens/cem-dimension.md +625 -0
- package/src/material/theme/tokens/cem-layering.md +562 -0
- package/src/material/theme/tokens/cem-m3-parity.md +343 -0
- package/src/material/theme/tokens/cem-responsive.md +238 -0
- package/src/material/theme/tokens/cem-shape.md +691 -0
- package/src/material/theme/tokens/cem-stroke-density-illustration-4to1-v3.svg +102 -0
- package/src/material/theme/tokens/cem-stroke.md +480 -0
- package/src/material/theme/tokens/cem-timing.md +198 -0
- package/src/material/theme/tokens/cem-typography-model-stack.svg +64 -0
- package/src/material/theme/tokens/cem-voice-fonts-typography.md +718 -0
- package/src/material/theme/tokens/cem-voice-ladder.svg +91 -0
- package/src/material/theme/tokens/chips.png +0 -0
- package/src/material/theme/tokens/columns-page.png +0 -0
- package/src/material/theme/tokens/initials.png +0 -0
- package/src/material/theme/tokens/nav-buttons.png +0 -0
- package/src/material/theme/tokens/script.png +0 -0
- package/src/material/theme/tokens/sufler.png +0 -0
- package/src/material/theme/tokens/typography-icons.png +0 -0
- package/src/mocks/versions.mock.ts +1 -1
- package/src/stories/__screenshots__/attributes.test.stories.ts +1 -0
- package/src/stories/__screenshots__/dom-merge.test.stories.ts/dom-merge-dom-merge-OrderPreservingOn2ndTransform-1.png +0 -0
- package/src/stories/__screenshots__/external-template.test.stories.ts +1 -0
- package/src/stories/__screenshots__/module-url.test.stories.ts +1 -0
- package/src/stories/__screenshots__/stories.test.ts/attributes-Attributes-definition-1.png +0 -0
- package/src/stories/__screenshots__/stories.test.ts/attributes-Attributes-runtime-change-1.png +0 -0
- package/src/stories/__screenshots__/stories.test.ts/attributes-Instance-Attributes-1.png +0 -0
- package/src/stories/__screenshots__/stories.test.ts/attributes-Instance-Attributes-2.png +0 -0
- package/src/stories/__screenshots__/stories.test.ts/attributes-cloneAs-el-newTag--1.png +0 -0
- package/src/stories/__screenshots__/stories.test.ts/attributes-mergeAttr--from--to---1.png +0 -0
- package/src/stories/__screenshots__/stories.test.ts/attributes-mergeAttr--from--to---2.png +0 -0
- package/src/stories/__screenshots__/stories.test.ts/attributes-mergeAttr--from--to---3.png +0 -0
- package/src/stories/__screenshots__/stories.test.ts/attributes-mix-to-from--1.png +0 -0
- package/src/stories/__screenshots__/stories.test.ts/http-request-Attributes-definition-1.png +0 -0
- package/src/stories/__screenshots__/stories.test.ts/http-request-Attributes-runtime-change-1.png +0 -0
- package/src/stories/__screenshots__/stories.test.ts/http-request-Instance-Attributes-1.png +0 -0
- package/src/stories/__screenshots__/stories.test.ts/http-request-Instance-Attributes-2.png +0 -0
- package/src/stories/__screenshots__/stories.test.ts/http-request-cloneAs-el-newTag--1.png +0 -0
- package/src/stories/__screenshots__/stories.test.ts/http-request-http-request-headers-and-response-status-and-headers-1.png +0 -0
- package/src/stories/__screenshots__/stories.test.ts/http-request-http-request-with-delayed--5-seconds-response-1.png +0 -0
- package/src/stories/__screenshots__/stories.test.ts/http-request-http-request-with-error-1.png +0 -0
- package/src/stories/__screenshots__/stories.test.ts/http-request-mergeAttr--from--to---1.png +0 -0
- package/src/stories/__screenshots__/stories.test.ts/http-request-mergeAttr--from--to---2.png +0 -0
- package/src/stories/__screenshots__/stories.test.ts/http-request-mergeAttr--from--to---3.png +0 -0
- package/src/stories/__screenshots__/stories.test.ts/http-request-mix-to-from--1.png +0 -0
- package/src/stories/__screenshots__/stories.test.ts/http-request-url-and-slice-1.png +0 -0
- package/src/stories/__screenshots__/stories.test.ts/http-request-url-change-1.png +0 -0
- package/src/stories/__screenshots__/xslt-conditionals.test.stories.ts/xslt-conditionals-xslt-conditionals-MultipleIfOrderingWorkaround-1.png +0 -0
- package/src/stories/attributes.test.stories.ts +83 -17
- package/src/stories/dom-merge.test.stories.ts +25 -1
- package/src/stories/external-template.test.stories.ts +16 -14
- package/src/stories/frame.canvas.ts +31 -0
- package/src/stories/module-url.test.stories.ts +29 -61
- package/src/stories/xslt-conditionals.test.stories.ts +492 -0
- package/src/stories/xslt-if.test.stories.ts +89 -0
- package/storybook-static/assets/Color-F6OSRLHC-CzTOSlqB.js +1 -0
- package/storybook-static/assets/Configure-7GqRsAoJ.js +165 -0
- package/storybook-static/assets/DocsRenderer-CFRXHY34-Duc5rSIm.js +2 -0
- package/storybook-static/assets/{attributes.test.stories-D1X6EBrd.js → attributes.test.stories-DYuxF8h1.js} +109 -38
- package/storybook-static/assets/{css.test.stories-Cp_g2hE1.js → css.test.stories-LOmvINyb.js} +1 -1
- package/storybook-static/assets/custom-element-Bwx7otrT.js +97 -0
- package/storybook-static/assets/{dom-merge.test.stories-hbpdCka0.js → dom-merge.test.stories-CEKhWjaS.js} +47 -6
- package/storybook-static/assets/entry-preview-BNCt9WBs.js +26 -0
- package/storybook-static/assets/entry-preview-docs-CbF8-81D.js +2 -0
- package/storybook-static/assets/{external-template.test.stories-BK89h6sk.js → external-template.test.stories-jHu0wsJ-.js} +38 -40
- package/storybook-static/assets/{form.test.stories-BfoLe_rw.js → form.test.stories-CUyUnmwP.js} +1 -1
- package/storybook-static/assets/frame.canvas-E5n9h6j1.js +1 -0
- package/storybook-static/assets/{handlers-yVPwH_Nz.js → handlers-F7GUfMqr.js} +17 -14
- package/storybook-static/assets/http-request-BWeEEBkP.js +1 -0
- package/storybook-static/assets/{http-request.stories-CBFJS2Ws.js → http-request.stories-wyX5-QOv.js} +1 -1
- package/storybook-static/assets/iframe-BS_DPWl0.js +199 -0
- package/storybook-static/assets/index-CGuyH0k-.js +240 -0
- package/storybook-static/assets/index-DB7LLObI.js +1 -0
- package/storybook-static/assets/index-DO1nmyvI.js +11 -0
- package/storybook-static/assets/index-V1EGs-wm.js +621 -0
- package/storybook-static/assets/{local-storage.test.stories-C0Yzy6Am.js → local-storage.test.stories-BxOhsf1k.js} +1 -1
- package/storybook-static/assets/{location-element.test.stories-DNFrEu5A.js → location-element.test.stories-DqhvvUoa.js} +1 -1
- package/storybook-static/assets/module-url.test.stories-C1gG9G7Y.js +142 -0
- package/storybook-static/assets/preview-1xJJ3sKE.js +1 -0
- package/storybook-static/assets/preview-Bn8igYMp.js +1 -0
- package/storybook-static/assets/preview-CTOeX_lO.js +1 -0
- package/storybook-static/assets/preview-Cwy1XFu2.js +2 -0
- package/storybook-static/assets/preview-D6sehqkw.js +50 -0
- package/storybook-static/assets/preview-DfTudP20.js +1 -0
- package/storybook-static/assets/{set-url.test.stories-BBfLxv2u.js → set-url.test.stories-BKQNdknJ.js} +1 -1
- package/storybook-static/assets/{slice-events.test.stories-HcXF8XQI.js → slice-events.test.stories-ChqULCeA.js} +1 -1
- package/storybook-static/assets/{slots.test.stories-i6mnIFM2.js → slots.test.stories-BlyLoCRe.js} +1 -1
- package/storybook-static/assets/{version-select.test.stories-BsUFH6Va.js → version-select.test.stories-CPGSh1tR.js} +1 -1
- package/storybook-static/assets/xslt-conditionals.test.stories-YC6QPqWZ.js +633 -0
- package/storybook-static/assets/xslt-if.test.stories-BRSWy2-x.js +71 -0
- package/storybook-static/demo/a.html +10 -3
- package/storybook-static/demo/a.svg +26 -26
- package/storybook-static/demo/attributes.html +153 -0
- package/storybook-static/demo/external-templates-sb-6.html +42 -0
- package/storybook-static/demo/external-templates-sb-7.html +42 -0
- package/storybook-static/demo/html-template.html +5 -4
- package/storybook-static/demo/module-url-sb-2.html +46 -0
- package/storybook-static/demo/module-url-sb-4.html +48 -0
- package/storybook-static/demo/module-url-sb-5.html +53 -0
- package/storybook-static/demo/s.xml +3859 -7
- package/storybook-static/demo/s.xslt +13 -48
- package/storybook-static/demo/s1.xml +3706 -0
- package/storybook-static/demo/ss.html +13 -4
- package/storybook-static/iframe.html +2 -2
- package/storybook-static/index.html +6 -10
- package/storybook-static/index.json +1 -1
- package/storybook-static/mockServiceWorker.js +31 -8
- package/storybook-static/project.json +1 -1
- package/storybook-static/sb-addons/essentials-actions-2/manager-bundle.js +3 -0
- package/storybook-static/sb-addons/essentials-backgrounds-4/manager-bundle.js +8 -8
- package/storybook-static/sb-addons/essentials-controls-1/manager-bundle.js +394 -0
- package/storybook-static/sb-addons/essentials-docs-3/manager-bundle.js +233 -0
- package/storybook-static/sb-addons/essentials-measure-7/manager-bundle.js +1 -1
- package/storybook-static/sb-addons/essentials-outline-8/manager-bundle.js +1 -1
- package/storybook-static/sb-addons/essentials-toolbars-6/manager-bundle.js +1 -1
- package/storybook-static/sb-addons/essentials-viewport-5/manager-bundle.js +1 -1
- package/storybook-static/sb-addons/interactions-9/manager-bundle.js +58 -58
- package/storybook-static/sb-manager/globals-module-info.js +9 -0
- package/storybook-static/sb-manager/globals-runtime.js +10719 -10473
- package/storybook-static/sb-manager/runtime.js +4944 -6321
- package/coverage/src/stories/attributes.test.stories.ts/coverage.svg +0 -10
- package/coverage/src/stories/attributes.test.stories.ts.html +0 -814
- package/coverage/src/stories/css.test.stories.ts/coverage.svg +0 -10
- package/coverage/src/stories/css.test.stories.ts.html +0 -460
- package/coverage/src/stories/dom-merge.test.stories.ts/coverage.svg +0 -10
- package/coverage/src/stories/dom-merge.test.stories.ts.html +0 -706
- package/coverage/src/stories/external-template.test.stories.ts.html +0 -865
- package/coverage/src/stories/form.test.stories.ts/coverage.svg +0 -10
- package/coverage/src/stories/form.test.stories.ts.html +0 -661
- package/coverage/src/stories/local-storage.test.stories.ts.html +0 -1315
- package/coverage/src/stories/location-element.test.stories.ts.html +0 -523
- package/coverage/src/stories/module-url.test.stories.ts/coverage.svg +0 -10
- package/coverage/src/stories/module-url.test.stories.ts.html +0 -640
- package/coverage/src/stories/set-url.test.stories.ts/coverage.svg +0 -10
- package/coverage/src/stories/set-url.test.stories.ts.html +0 -433
- package/coverage/src/stories/slice-events.test.stories.ts/coverage.svg +0 -10
- package/coverage/src/stories/slice-events.test.stories.ts.html +0 -952
- package/coverage/src/stories/slots.test.stories.ts/coverage.svg +0 -10
- package/coverage/src/stories/slots.test.stories.ts.html +0 -742
- package/coverage/src/stories/version-select.test.stories.ts/coverage.svg +0 -10
- package/coverage/src/stories/version-select.test.stories.ts.html +0 -397
- package/dist/custom-element-D2wf_rqP.js +0 -576
- package/dist/custom-element-Dtzhbjkc.cjs +0 -97
- package/dist/http-request-DPrY7mGh.cjs +0 -1
- package/storybook-static/assets/Color-F6OSRLHC-BU3iy8jH.js +0 -1
- package/storybook-static/assets/Configure-DN6ifayP.js +0 -165
- package/storybook-static/assets/DocsRenderer-CFRXHY34-BaVEufDj.js +0 -2
- package/storybook-static/assets/custom-element-uuAtIYWS.js +0 -97
- package/storybook-static/assets/entry-preview-DHVXbf3x.js +0 -26
- package/storybook-static/assets/entry-preview-docs-BbcIMweR.js +0 -2
- package/storybook-static/assets/http-request-DNq59pnj.js +0 -1
- package/storybook-static/assets/iframe-CJEL_4Nu.js +0 -2
- package/storybook-static/assets/index-BcZLpTeD.js +0 -8
- package/storybook-static/assets/index-CxRwF5Or.js +0 -234
- package/storybook-static/assets/index-D-8MO0q_.js +0 -1
- package/storybook-static/assets/index-D5fBh-7N.js +0 -1
- package/storybook-static/assets/index-DM-KBPdl.js +0 -1
- package/storybook-static/assets/index-RSFf30w1.js +0 -1
- package/storybook-static/assets/index-SnjB5uV8.js +0 -769
- package/storybook-static/assets/module-url.test.stories-CXibF5Ta.js +0 -208
- package/storybook-static/assets/preview-BhhEZcNS.js +0 -1
- package/storybook-static/assets/preview-Bnd0XhaF.js +0 -52
- package/storybook-static/assets/preview-CNKoaWES.js +0 -1
- package/storybook-static/assets/preview-DAeyCMnM.js +0 -1
- package/storybook-static/assets/preview-DHPc-V4N.js +0 -1
- package/storybook-static/assets/preview-DJMlNTk8.js +0 -2
- package/storybook-static/assets/preview-DYzi3Z2p.js +0 -1
- package/storybook-static/sb-addons/chromatic-com-storybook-10/manager-bundle.js +0 -333
- package/storybook-static/sb-addons/chromatic-com-storybook-10/manager-bundle.js.LEGAL.txt +0 -40
- package/storybook-static/sb-addons/essentials-actions-3/manager-bundle.js +0 -3
- package/storybook-static/sb-addons/essentials-controls-2/manager-bundle.js +0 -391
- package/storybook-static/sb-addons/links-1/manager-bundle.js +0 -3
- package/storybook-static/sb-preview/globals.js +0 -33
- package/storybook-static/sb-preview/runtime.js +0 -7174
- package/test-runner-jest.config.js +0 -15
- /package/storybook-static/sb-addons/{essentials-actions-3 → essentials-actions-2}/manager-bundle.js.LEGAL.txt +0 -0
- /package/storybook-static/sb-addons/{essentials-controls-2 → essentials-controls-1}/manager-bundle.js.LEGAL.txt +0 -0
- /package/storybook-static/sb-addons/{links-1 → essentials-docs-3}/manager-bundle.js.LEGAL.txt +0 -0
|
@@ -6,17 +6,16 @@
|
|
|
6
6
|
// test requires bin/vitest/vitest-browser-importmaps.mjs to inject importmap into tester.html
|
|
7
7
|
// the relative path prefix in vitest is `../../..`
|
|
8
8
|
|
|
9
|
-
import type {
|
|
10
|
-
import {expect,
|
|
9
|
+
import type {StoryObj} from '@storybook/web-components';
|
|
10
|
+
import {expect, within} from '@storybook/test';
|
|
11
11
|
|
|
12
12
|
import '../custom-element/custom-element.js';
|
|
13
13
|
import '../custom-element/module-url.js';
|
|
14
|
-
import {
|
|
14
|
+
import {frameCanvas} from "./frame.canvas";
|
|
15
15
|
|
|
16
16
|
type TProps = { title: string; body:string};
|
|
17
17
|
|
|
18
18
|
type Story = StoryObj<TProps>;
|
|
19
|
-
function sleep(ms: number) { return new Promise((resolve) => setTimeout(resolve, ms)); }
|
|
20
19
|
|
|
21
20
|
function render(args: TProps)
|
|
22
21
|
{
|
|
@@ -41,9 +40,11 @@ export default meta;
|
|
|
41
40
|
export const RelativeToPagePath:Story =
|
|
42
41
|
{ args : {title: '1. relative to page path', body:`
|
|
43
42
|
<custom-element>
|
|
44
|
-
<
|
|
45
|
-
<
|
|
46
|
-
|
|
43
|
+
<template>
|
|
44
|
+
<a href="/demo/embed-1.html">
|
|
45
|
+
<custom-element src="/demo/embed-1.html"></custom-element>
|
|
46
|
+
</a>
|
|
47
|
+
</template>
|
|
47
48
|
</custom-element>
|
|
48
49
|
`}
|
|
49
50
|
, play: async ({canvasElement}) =>
|
|
@@ -56,32 +57,19 @@ export const RelativeToPagePath:Story =
|
|
|
56
57
|
},
|
|
57
58
|
};
|
|
58
59
|
|
|
59
|
-
|
|
60
|
-
export const ModuleBySymbolicName:Story =
|
|
60
|
+
export const ModuleBySymbolicName:Story =
|
|
61
61
|
{ args : {title: '2. module by symbolic name', body:`
|
|
62
|
-
|
|
63
|
-
<template>
|
|
64
|
-
<module-url slice="lib-url" src="embed-lib"></module-url>
|
|
65
|
-
<if test="//lib-url/@error">
|
|
66
|
-
<p>error: <b>{//lib-url/@error}</b></p>
|
|
67
|
-
</if>
|
|
68
|
-
check the link:
|
|
69
|
-
<a href="{//lib-url}">
|
|
70
|
-
<custom-element src="embed-lib#embed-lib-component">
|
|
71
|
-
failed to load
|
|
72
|
-
</custom-element>
|
|
73
|
-
</a>
|
|
74
|
-
</template>
|
|
75
|
-
</custom-element>
|
|
62
|
+
<iframe src="/demo/module-url-sb-2.html" name="sb" data-testid="fr"></iframe>
|
|
76
63
|
`}
|
|
77
64
|
, play: async ({canvasElement}) =>
|
|
78
65
|
{
|
|
79
|
-
const p = import.meta.resolve('embed-lib');
|
|
80
66
|
const canvas = within(canvasElement);
|
|
81
67
|
await canvas.findByText(ModuleBySymbolicName.args!.title as string);
|
|
82
68
|
|
|
83
|
-
|
|
84
|
-
|
|
69
|
+
const frCanvas = await frameCanvas('fr',canvas);
|
|
70
|
+
|
|
71
|
+
await expect( await frCanvas.findByText('check the link:')).toBeInTheDocument();
|
|
72
|
+
await expect( await frCanvas.findByText('👋 from embed-lib-component')).toBeInTheDocument();
|
|
85
73
|
},
|
|
86
74
|
};
|
|
87
75
|
|
|
@@ -115,59 +103,39 @@ export const MissingImportmapEntry:Story =
|
|
|
115
103
|
|
|
116
104
|
export const ModuleByName:Story =
|
|
117
105
|
{ args : {title: '4. module path by symbolic name', body:`
|
|
118
|
-
<
|
|
119
|
-
<template>
|
|
120
|
-
<module-url slice="lib-url" src="lib-root/embed-lib.html#embed-relative-hash"></module-url>
|
|
121
|
-
<module-url slice="img-url" src="lib-root/Smiley.svg"></module-url>
|
|
122
|
-
<if test="//lib-url/@error">
|
|
123
|
-
<p>error: <b>{//lib-url/@error}</b></p>
|
|
124
|
-
</if>
|
|
125
|
-
check the link:
|
|
126
|
-
<a href="{//lib-url}"> lib-root/embed-lib.html#embed-relative-hash <img src="{//img-url}" alt=""/></a>
|
|
127
|
-
<custom-element src="lib-root/embed-lib.html#embed-relative-hash">
|
|
128
|
-
failed to load
|
|
129
|
-
</custom-element>
|
|
106
|
+
<iframe src="/demo/module-url-sb-4.html" name="sb" data-testid="fr"></iframe>
|
|
130
107
|
|
|
131
|
-
</template>
|
|
132
|
-
</custom-element>
|
|
133
108
|
`}
|
|
134
109
|
, play: async ({canvasElement}) =>
|
|
135
110
|
{
|
|
136
111
|
const canvas = within(canvasElement);
|
|
137
112
|
await canvas.findByText(ModuleByName.args!.title as string);
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
await expect(await
|
|
113
|
+
const frCanvas = await frameCanvas('fr',canvas);
|
|
114
|
+
|
|
115
|
+
await expect(await frCanvas.findByText('👌 from embed-relative-hash invoking')).toBeInTheDocument();
|
|
116
|
+
await expect(await frCanvas.findByText('lib-root/embed-lib.html#embed-relative-hash')).toBeInTheDocument();
|
|
117
|
+
await expect(await frCanvas.findByText('#embed-lib-component')).toBeInTheDocument();
|
|
141
118
|
},
|
|
142
119
|
};
|
|
143
120
|
|
|
144
121
|
|
|
145
122
|
export const HashWithinLib:Story =
|
|
146
123
|
{ args : {title: '5. module path by symbolic name to internal link within lib', body:`
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
<if test="//lib-url/@error">
|
|
151
|
-
<p>error: <b>{//lib-url/@error}</b></p>
|
|
152
|
-
</if>
|
|
153
|
-
check the link:
|
|
154
|
-
<a href="{//lib-url}"> lib-root/embed-lib.html#embed-relative-file </a>
|
|
155
|
-
<custom-element src="lib-root/embed-lib.html#embed-relative-file">
|
|
156
|
-
failed to load
|
|
157
|
-
</custom-element>
|
|
158
|
-
</template>
|
|
159
|
-
</custom-element>
|
|
124
|
+
<iframe src="/demo/module-url-sb-5.html"
|
|
125
|
+
data-testid="fr"
|
|
126
|
+
style="height:22rem;width: 80vw;"></iframe>
|
|
160
127
|
`}
|
|
161
128
|
, play: async ({canvasElement}) =>
|
|
162
129
|
{
|
|
163
130
|
const canvas = within(canvasElement);
|
|
164
131
|
await canvas.findByText(HashWithinLib.args!.title as string);
|
|
132
|
+
const frCanvas = await frameCanvas('fr',canvas);
|
|
165
133
|
|
|
166
|
-
await expect(await
|
|
167
|
-
await expect(await
|
|
168
|
-
await expect(await
|
|
169
|
-
await expect(await
|
|
170
|
-
await expect(await
|
|
134
|
+
await expect(await frCanvas.findByText('lib-root/embed-lib.html#embed-relative-file')).toBeInTheDocument();
|
|
135
|
+
await expect(await frCanvas.findByText('👍 from embed-relative-file invoking')).toBeInTheDocument();
|
|
136
|
+
await expect(await frCanvas.findByText('embed-1.html')).toBeInTheDocument();
|
|
137
|
+
await expect(await frCanvas.findByText('embed-1.html')).toBeInTheDocument();
|
|
138
|
+
await expect(await frCanvas.findByText('🖖')).toBeInTheDocument();
|
|
171
139
|
},
|
|
172
140
|
};
|
|
173
141
|
|
|
@@ -0,0 +1,492 @@
|
|
|
1
|
+
// noinspection DuplicatedCode
|
|
2
|
+
|
|
3
|
+
import type { StoryObj } from '@storybook/web-components';
|
|
4
|
+
import { expect, userEvent, within } from '@storybook/test';
|
|
5
|
+
|
|
6
|
+
import '../custom-element/custom-element.js';
|
|
7
|
+
|
|
8
|
+
type TProps = { title: string; tag: string; template: string; payload: string };
|
|
9
|
+
|
|
10
|
+
type Story = StoryObj<TProps>;
|
|
11
|
+
|
|
12
|
+
function sleep(ms: number) { return new Promise((resolve) => setTimeout(resolve, ms)); }
|
|
13
|
+
|
|
14
|
+
function render(args: TProps) {
|
|
15
|
+
const { title, tag, template, payload } = args;
|
|
16
|
+
return `
|
|
17
|
+
<fieldset>
|
|
18
|
+
<legend>${title}</legend>
|
|
19
|
+
<custom-element tag="${tag}" hidden>
|
|
20
|
+
<template>
|
|
21
|
+
${template}
|
|
22
|
+
</template>
|
|
23
|
+
</custom-element>
|
|
24
|
+
${payload}
|
|
25
|
+
</fieldset>
|
|
26
|
+
`;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const meta = {
|
|
30
|
+
title: 'xslt-conditionals',
|
|
31
|
+
render
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export default meta;
|
|
35
|
+
|
|
36
|
+
export const IfTrue: Story = {
|
|
37
|
+
args: {
|
|
38
|
+
title: 'xsl:if - condition is true',
|
|
39
|
+
tag: 'if-true-test',
|
|
40
|
+
template: `
|
|
41
|
+
<attribute name="show-message"></attribute>
|
|
42
|
+
<if test="//@show-message">
|
|
43
|
+
<span data-testid="result">Message is visible</span>
|
|
44
|
+
</if>
|
|
45
|
+
`,
|
|
46
|
+
payload: `<if-true-test show-message="yes"></if-true-test>`
|
|
47
|
+
},
|
|
48
|
+
play: async ({ canvasElement }) => {
|
|
49
|
+
const canvas = within(canvasElement);
|
|
50
|
+
await sleep(50);
|
|
51
|
+
const result = await canvas.findByTestId('result');
|
|
52
|
+
expect(result).toBeInTheDocument();
|
|
53
|
+
expect(result).toHaveTextContent('Message is visible');
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const IfFalse: Story = {
|
|
58
|
+
args: {
|
|
59
|
+
title: 'xsl:if - condition is false',
|
|
60
|
+
tag: 'if-false-test',
|
|
61
|
+
template: `
|
|
62
|
+
<attribute name="show-message"></attribute>
|
|
63
|
+
<if test="//@show-message = 'yes'">
|
|
64
|
+
<span data-testid="hidden-result">Should not appear</span>
|
|
65
|
+
</if>
|
|
66
|
+
<span data-testid="fallback">Fallback content</span>
|
|
67
|
+
`,
|
|
68
|
+
payload: `<if-false-test show-message="no"></if-false-test>`
|
|
69
|
+
},
|
|
70
|
+
play: async ({ canvasElement }) => {
|
|
71
|
+
const canvas = within(canvasElement);
|
|
72
|
+
await sleep(50);
|
|
73
|
+
const fallback = await canvas.findByTestId('fallback');
|
|
74
|
+
expect(fallback).toBeInTheDocument();
|
|
75
|
+
expect(canvasElement.querySelector('[data-testid="hidden-result"]')).toBeNull();
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export const IfNotExists: Story = {
|
|
80
|
+
args: {
|
|
81
|
+
title: 'xsl:if - attribute not exists',
|
|
82
|
+
tag: 'if-not-exists-test',
|
|
83
|
+
template: `
|
|
84
|
+
<attribute name="optional"></attribute>
|
|
85
|
+
<if test="not(//attributes/@optional)">
|
|
86
|
+
<span data-testid="result">No attribute provided</span>
|
|
87
|
+
</if>
|
|
88
|
+
<if test="//attributes/@optional">
|
|
89
|
+
<span data-testid="has-attr">Attribute exists</span>
|
|
90
|
+
</if>
|
|
91
|
+
`,
|
|
92
|
+
payload: `<if-not-exists-test></if-not-exists-test>`
|
|
93
|
+
},
|
|
94
|
+
play: async ({ canvasElement }) => {
|
|
95
|
+
const canvas = within(canvasElement);
|
|
96
|
+
await sleep(50);
|
|
97
|
+
const result = await canvas.findByTestId('result');
|
|
98
|
+
expect(result).toBeInTheDocument();
|
|
99
|
+
expect(result).toHaveTextContent('No attribute provided');
|
|
100
|
+
expect(canvasElement.querySelector('[data-testid="has-attr"]')).toBeNull();
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
export const ChooseWhenOtherwise: Story = {
|
|
105
|
+
args: {
|
|
106
|
+
title: 'xsl:choose/when/otherwise - basic switch',
|
|
107
|
+
tag: 'choose-basic-test',
|
|
108
|
+
template: `
|
|
109
|
+
<attribute name="status"></attribute>
|
|
110
|
+
<choose>
|
|
111
|
+
<when test="//attributes/@status = 'success'">
|
|
112
|
+
<span data-testid="result" class="success">Operation succeeded</span>
|
|
113
|
+
</when>
|
|
114
|
+
<when test="//attributes/@status = 'error'">
|
|
115
|
+
<span data-testid="result" class="error">Operation failed</span>
|
|
116
|
+
</when>
|
|
117
|
+
<otherwise>
|
|
118
|
+
<span data-testid="result" class="unknown">Unknown status</span>
|
|
119
|
+
</otherwise>
|
|
120
|
+
</choose>
|
|
121
|
+
`,
|
|
122
|
+
payload: `<choose-basic-test status="success"></choose-basic-test>`
|
|
123
|
+
},
|
|
124
|
+
play: async ({ canvasElement }) => {
|
|
125
|
+
const canvas = within(canvasElement);
|
|
126
|
+
await sleep(50);
|
|
127
|
+
const result = await canvas.findByTestId('result');
|
|
128
|
+
expect(result).toBeInTheDocument();
|
|
129
|
+
expect(result).toHaveTextContent('Operation succeeded');
|
|
130
|
+
expect(result).toHaveClass('success');
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
export const ChooseSecondWhen: Story = {
|
|
135
|
+
args: {
|
|
136
|
+
title: 'xsl:choose - second when branch',
|
|
137
|
+
tag: 'choose-second-test',
|
|
138
|
+
template: `
|
|
139
|
+
<attribute name="status"></attribute>
|
|
140
|
+
<choose>
|
|
141
|
+
<when test="//attributes/@status = 'success'">
|
|
142
|
+
<span data-testid="result" class="success">Operation succeeded</span>
|
|
143
|
+
</when>
|
|
144
|
+
<when test="//attributes/@status = 'error'">
|
|
145
|
+
<span data-testid="result" class="error">Operation failed</span>
|
|
146
|
+
</when>
|
|
147
|
+
<otherwise>
|
|
148
|
+
<span data-testid="result" class="unknown">Unknown status</span>
|
|
149
|
+
</otherwise>
|
|
150
|
+
</choose>
|
|
151
|
+
`,
|
|
152
|
+
payload: `<choose-second-test status="error"></choose-second-test>`
|
|
153
|
+
},
|
|
154
|
+
play: async ({ canvasElement }) => {
|
|
155
|
+
const canvas = within(canvasElement);
|
|
156
|
+
await sleep(50);
|
|
157
|
+
const result = await canvas.findByTestId('result');
|
|
158
|
+
expect(result).toBeInTheDocument();
|
|
159
|
+
expect(result).toHaveTextContent('Operation failed');
|
|
160
|
+
expect(result).toHaveClass('error');
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
export const ChooseOtherwise: Story = {
|
|
165
|
+
args: {
|
|
166
|
+
title: 'xsl:choose - otherwise fallback',
|
|
167
|
+
tag: 'choose-otherwise-test',
|
|
168
|
+
template: `
|
|
169
|
+
<attribute name="status"></attribute>
|
|
170
|
+
<choose>
|
|
171
|
+
<when test="//attributes/@status = 'success'">
|
|
172
|
+
<span data-testid="result" class="success">Operation succeeded</span>
|
|
173
|
+
</when>
|
|
174
|
+
<when test="//attributes/@status = 'error'">
|
|
175
|
+
<span data-testid="result" class="error">Operation failed</span>
|
|
176
|
+
</when>
|
|
177
|
+
<otherwise>
|
|
178
|
+
<span data-testid="result" class="unknown">Unknown status</span>
|
|
179
|
+
</otherwise>
|
|
180
|
+
</choose>
|
|
181
|
+
`,
|
|
182
|
+
payload: `<choose-otherwise-test status="pending"></choose-otherwise-test>`
|
|
183
|
+
},
|
|
184
|
+
play: async ({ canvasElement }) => {
|
|
185
|
+
const canvas = within(canvasElement);
|
|
186
|
+
await sleep(50);
|
|
187
|
+
const result = await canvas.findByTestId('result');
|
|
188
|
+
expect(result).toBeInTheDocument();
|
|
189
|
+
expect(result).toHaveTextContent('Unknown status');
|
|
190
|
+
expect(result).toHaveClass('unknown');
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
export const ChooseNoAttribute: Story = {
|
|
195
|
+
args: {
|
|
196
|
+
title: 'xsl:choose - no attribute provided',
|
|
197
|
+
tag: 'choose-no-attr-test',
|
|
198
|
+
template: `
|
|
199
|
+
<attribute name="level"></attribute>
|
|
200
|
+
<choose>
|
|
201
|
+
<when test="//attributes/@level = 'high'">
|
|
202
|
+
<span data-testid="result">High priority</span>
|
|
203
|
+
</when>
|
|
204
|
+
<when test="//attributes/@level = 'low'">
|
|
205
|
+
<span data-testid="result">Low priority</span>
|
|
206
|
+
</when>
|
|
207
|
+
<otherwise>
|
|
208
|
+
<span data-testid="result">Default priority</span>
|
|
209
|
+
</otherwise>
|
|
210
|
+
</choose>
|
|
211
|
+
`,
|
|
212
|
+
payload: `<choose-no-attr-test></choose-no-attr-test>`
|
|
213
|
+
},
|
|
214
|
+
play: async ({ canvasElement }) => {
|
|
215
|
+
const canvas = within(canvasElement);
|
|
216
|
+
await sleep(50);
|
|
217
|
+
const result = await canvas.findByTestId('result');
|
|
218
|
+
expect(result).toBeInTheDocument();
|
|
219
|
+
expect(result).toHaveTextContent('Default priority');
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
export const NestedConditions: Story = {
|
|
224
|
+
args: {
|
|
225
|
+
title: 'Nested conditionals',
|
|
226
|
+
tag: 'nested-cond-test',
|
|
227
|
+
template: `
|
|
228
|
+
<attribute name="type"></attribute>
|
|
229
|
+
<attribute name="active"></attribute>
|
|
230
|
+
<choose>
|
|
231
|
+
<when test="//attributes/@type = 'user'">
|
|
232
|
+
<if test="//attributes/@active = 'true'">
|
|
233
|
+
<span data-testid="result">Active user</span>
|
|
234
|
+
</if>
|
|
235
|
+
<if test="//attributes/@active != 'true'">
|
|
236
|
+
<span data-testid="result">Inactive user</span>
|
|
237
|
+
</if>
|
|
238
|
+
</when>
|
|
239
|
+
<otherwise>
|
|
240
|
+
<span data-testid="result">Not a user</span>
|
|
241
|
+
</otherwise>
|
|
242
|
+
</choose>
|
|
243
|
+
`,
|
|
244
|
+
payload: `<nested-cond-test type="user" active="true"></nested-cond-test>`
|
|
245
|
+
},
|
|
246
|
+
play: async ({ canvasElement }) => {
|
|
247
|
+
const canvas = within(canvasElement);
|
|
248
|
+
await sleep(50);
|
|
249
|
+
const result = await canvas.findByTestId('result');
|
|
250
|
+
expect(result).toBeInTheDocument();
|
|
251
|
+
expect(result).toHaveTextContent('Active user');
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
export const NestedConditionsInactive: Story = {
|
|
256
|
+
args: {
|
|
257
|
+
title: 'Nested conditionals - inactive user',
|
|
258
|
+
tag: 'nested-cond-inactive-test',
|
|
259
|
+
template: `
|
|
260
|
+
<attribute name="type"></attribute>
|
|
261
|
+
<attribute name="active"></attribute>
|
|
262
|
+
<choose>
|
|
263
|
+
<when test="//attributes/@type = 'user'">
|
|
264
|
+
<if test="//attributes/@active = 'true'">
|
|
265
|
+
<span data-testid="result">Active user</span>
|
|
266
|
+
</if>
|
|
267
|
+
<if test="//attributes/@active != 'true'">
|
|
268
|
+
<span data-testid="result">Inactive user</span>
|
|
269
|
+
</if>
|
|
270
|
+
</when>
|
|
271
|
+
<otherwise>
|
|
272
|
+
<span data-testid="result">Not a user</span>
|
|
273
|
+
</otherwise>
|
|
274
|
+
</choose>
|
|
275
|
+
`,
|
|
276
|
+
payload: `<nested-cond-inactive-test type="user" active="false"></nested-cond-inactive-test>`
|
|
277
|
+
},
|
|
278
|
+
play: async ({ canvasElement }) => {
|
|
279
|
+
const canvas = within(canvasElement);
|
|
280
|
+
await sleep(50);
|
|
281
|
+
const result = await canvas.findByTestId('result');
|
|
282
|
+
expect(result).toBeInTheDocument();
|
|
283
|
+
expect(result).toHaveTextContent('Inactive user');
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
export const NumericComparison: Story = {
|
|
288
|
+
args: {
|
|
289
|
+
title: 'Numeric comparison in conditions',
|
|
290
|
+
tag: 'numeric-cond-test',
|
|
291
|
+
template: `
|
|
292
|
+
<attribute name="count"></attribute>
|
|
293
|
+
<choose>
|
|
294
|
+
<when test="//attributes/@count > 10">
|
|
295
|
+
<span data-testid="result">Many items</span>
|
|
296
|
+
</when>
|
|
297
|
+
<when test="//attributes/@count > 0">
|
|
298
|
+
<span data-testid="result">Some items</span>
|
|
299
|
+
</when>
|
|
300
|
+
<otherwise>
|
|
301
|
+
<span data-testid="result">No items</span>
|
|
302
|
+
</otherwise>
|
|
303
|
+
</choose>
|
|
304
|
+
`,
|
|
305
|
+
payload: `<numeric-cond-test count="15"></numeric-cond-test>`
|
|
306
|
+
},
|
|
307
|
+
play: async ({ canvasElement }) => {
|
|
308
|
+
const canvas = within(canvasElement);
|
|
309
|
+
await sleep(50);
|
|
310
|
+
const result = await canvas.findByTestId('result');
|
|
311
|
+
expect(result).toBeInTheDocument();
|
|
312
|
+
expect(result).toHaveTextContent('Many items');
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
export const NumericComparisonLow: Story = {
|
|
317
|
+
args: {
|
|
318
|
+
title: 'Numeric comparison - low value',
|
|
319
|
+
tag: 'numeric-cond-low-test',
|
|
320
|
+
template: `
|
|
321
|
+
<attribute name="count"></attribute>
|
|
322
|
+
<choose>
|
|
323
|
+
<when test="//attributes/@count > 10">
|
|
324
|
+
<span data-testid="result">Many items</span>
|
|
325
|
+
</when>
|
|
326
|
+
<when test="//attributes/@count > 0">
|
|
327
|
+
<span data-testid="result">Some items</span>
|
|
328
|
+
</when>
|
|
329
|
+
<otherwise>
|
|
330
|
+
<span data-testid="result">No items</span>
|
|
331
|
+
</otherwise>
|
|
332
|
+
</choose>
|
|
333
|
+
`,
|
|
334
|
+
payload: `<numeric-cond-low-test count="5"></numeric-cond-low-test>`
|
|
335
|
+
},
|
|
336
|
+
play: async ({ canvasElement }) => {
|
|
337
|
+
const canvas = within(canvasElement);
|
|
338
|
+
await sleep(50);
|
|
339
|
+
const result = await canvas.findByTestId('result');
|
|
340
|
+
expect(result).toBeInTheDocument();
|
|
341
|
+
expect(result).toHaveTextContent('Some items');
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
|
|
345
|
+
export const BooleanAndCondition: Story = {
|
|
346
|
+
args: {
|
|
347
|
+
title: 'Boolean AND condition',
|
|
348
|
+
tag: 'and-cond-test',
|
|
349
|
+
template: `
|
|
350
|
+
<attribute name="logged-in"></attribute>
|
|
351
|
+
<attribute name="admin"></attribute>
|
|
352
|
+
<if test="//attributes/@logged-in = 'true' and //attributes/@admin = 'true'">
|
|
353
|
+
<span data-testid="result">Admin panel access granted</span>
|
|
354
|
+
</if>
|
|
355
|
+
<if test="not(//attributes/@logged-in = 'true' and //attributes/@admin = 'true')">
|
|
356
|
+
<span data-testid="result">Access denied</span>
|
|
357
|
+
</if>
|
|
358
|
+
`,
|
|
359
|
+
payload: `<and-cond-test logged-in="true" admin="true"></and-cond-test>`
|
|
360
|
+
},
|
|
361
|
+
play: async ({ canvasElement }) => {
|
|
362
|
+
const canvas = within(canvasElement);
|
|
363
|
+
await sleep(50);
|
|
364
|
+
const result = await canvas.findByTestId('result');
|
|
365
|
+
expect(result).toBeInTheDocument();
|
|
366
|
+
expect(result).toHaveTextContent('Admin panel access granted');
|
|
367
|
+
}
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
export const BooleanOrCondition: Story = {
|
|
371
|
+
args: {
|
|
372
|
+
title: 'Boolean OR condition',
|
|
373
|
+
tag: 'or-cond-test',
|
|
374
|
+
template: `
|
|
375
|
+
<attribute name="role"></attribute>
|
|
376
|
+
<if test="//attributes/@role = 'admin' or //attributes/@role = 'moderator'">
|
|
377
|
+
<span data-testid="result">Elevated privileges</span>
|
|
378
|
+
</if>
|
|
379
|
+
<if test="not(//attributes/@role = 'admin' or //attributes/@role = 'moderator')">
|
|
380
|
+
<span data-testid="result">Standard user</span>
|
|
381
|
+
</if>
|
|
382
|
+
`,
|
|
383
|
+
payload: `<or-cond-test role="moderator"></or-cond-test>`
|
|
384
|
+
},
|
|
385
|
+
play: async ({ canvasElement }) => {
|
|
386
|
+
const canvas = within(canvasElement);
|
|
387
|
+
await sleep(50);
|
|
388
|
+
const result = await canvas.findByTestId('result');
|
|
389
|
+
expect(result).toBeInTheDocument();
|
|
390
|
+
expect(result).toHaveTextContent('Elevated privileges');
|
|
391
|
+
}
|
|
392
|
+
};
|
|
393
|
+
|
|
394
|
+
export const MultipleInstances: Story = {
|
|
395
|
+
args: {
|
|
396
|
+
title: 'Multiple instances with different conditions',
|
|
397
|
+
tag: 'multi-instance-test',
|
|
398
|
+
template: `
|
|
399
|
+
<attribute name="data-testid"></attribute>
|
|
400
|
+
<attribute name="variant"></attribute>
|
|
401
|
+
<choose>
|
|
402
|
+
<when test="//attributes/@variant = 'primary'">
|
|
403
|
+
<button data-testid="{$data-testid}-primary" class="primary">Primary Button</button>
|
|
404
|
+
</when>
|
|
405
|
+
<when test="//attributes/@variant = 'secondary'">
|
|
406
|
+
<button data-testid="{$data-testid}-secondary" class="secondary">Secondary Button</button>
|
|
407
|
+
</when>
|
|
408
|
+
<otherwise>
|
|
409
|
+
<button data-testid="{$data-testid}-otherwise" class="default">Default Button</button>
|
|
410
|
+
</otherwise>
|
|
411
|
+
</choose>
|
|
412
|
+
`,
|
|
413
|
+
payload: `
|
|
414
|
+
<multi-instance-test data-testid="btn1" variant="primary"></multi-instance-test>
|
|
415
|
+
<multi-instance-test data-testid="btn2" variant="secondary"></multi-instance-test>
|
|
416
|
+
<multi-instance-test data-testid="btn3" variant="unknown"></multi-instance-test>
|
|
417
|
+
`
|
|
418
|
+
},
|
|
419
|
+
play: async ({ canvasElement }) => {
|
|
420
|
+
const canvas = within(canvasElement);
|
|
421
|
+
await sleep(50);
|
|
422
|
+
|
|
423
|
+
const btn1 = await canvas.findByTestId('btn1-primary');
|
|
424
|
+
expect(btn1).toHaveTextContent('Primary Button');
|
|
425
|
+
expect(btn1).toHaveClass('primary');
|
|
426
|
+
|
|
427
|
+
const btn2 = await canvas.findByTestId('btn2-secondary');
|
|
428
|
+
expect(btn2).toHaveTextContent('Secondary Button');
|
|
429
|
+
expect(btn2).toHaveClass('secondary');
|
|
430
|
+
|
|
431
|
+
const btn3 = await canvas.findByTestId('btn3-otherwise');
|
|
432
|
+
expect(btn3).toHaveTextContent('Default Button');
|
|
433
|
+
expect(btn3).toHaveClass('default');
|
|
434
|
+
}
|
|
435
|
+
};
|
|
436
|
+
|
|
437
|
+
|
|
438
|
+
export const MultipleIfOrderingIssue: Story = {
|
|
439
|
+
args: {
|
|
440
|
+
title: 'KNOWN ISSUE: Multiple IF blocks - out of order',
|
|
441
|
+
tag: 'multi-if-order-issue',
|
|
442
|
+
template: `
|
|
443
|
+
<div data-testid="whole-text">
|
|
444
|
+
<label><input type="checkbox" data-testid="toggle-a" slice="show-a" value="AA" /> A</label>
|
|
445
|
+
|
|
446
|
+
<hr/>
|
|
447
|
+
▶
|
|
448
|
+
<if test="//show-a = 'AA'">
|
|
449
|
+
!A
|
|
450
|
+
</if>
|
|
451
|
+
◀
|
|
452
|
+
</div>
|
|
453
|
+
<if test="//show-a = 'AA'">
|
|
454
|
+
<div data-testid="t-1">T1</div>
|
|
455
|
+
</if>
|
|
456
|
+
`,
|
|
457
|
+
payload: `
|
|
458
|
+
<multi-if-order-issue></multi-if-order-issue>
|
|
459
|
+
`
|
|
460
|
+
},
|
|
461
|
+
play: async ({ canvasElement }) => {
|
|
462
|
+
const canvas = within(canvasElement);
|
|
463
|
+
|
|
464
|
+
// Initially ▶\s+◀ should be visible, !A should not
|
|
465
|
+
const container = await canvas.findByTestId('whole-text');
|
|
466
|
+
expect(container.textContent).to.toMatch(/▶\s+◀/);
|
|
467
|
+
|
|
468
|
+
// check A - show !A
|
|
469
|
+
const toggleA = await canvas.findByTestId('toggle-a');
|
|
470
|
+
debugger;
|
|
471
|
+
await userEvent.click(toggleA);
|
|
472
|
+
|
|
473
|
+
expect( await await canvas.findByTestId('t-1')).toBeInTheDocument();
|
|
474
|
+
// !A is rendered
|
|
475
|
+
expect(container.textContent).to.toMatch(/\!A/);
|
|
476
|
+
// !A afer ▶
|
|
477
|
+
expect(container.textContent).to.toMatch(/▶\s+\!A/);
|
|
478
|
+
// !A before ◀
|
|
479
|
+
expect(container.textContent).to.toMatch(/\!A\s+◀/);
|
|
480
|
+
}
|
|
481
|
+
};
|
|
482
|
+
|
|
483
|
+
//#region unit tests
|
|
484
|
+
/* istanbul ignore else -- @preserve */
|
|
485
|
+
if ('test' === import.meta.env.MODE &&
|
|
486
|
+
!import.meta.url.includes('skiptest')) {
|
|
487
|
+
const mod = await import('./xslt-conditionals.test.stories.ts?skiptest');
|
|
488
|
+
const { testStoryBook } = await import('./testStoryBook');
|
|
489
|
+
const { describe } = await import('vitest');
|
|
490
|
+
describe(meta.title, () => testStoryBook(mod, meta));
|
|
491
|
+
}
|
|
492
|
+
//#endregion
|