@dooboostore/simple-web-component 1.0.18 → 1.0.21
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 +2065 -164
- package/dist/cjs/config/config.js +2 -0
- package/dist/cjs/config/config.js.map +2 -2
- package/dist/cjs/decorators/addEventListener.js +8 -8
- package/dist/cjs/decorators/addEventListener.js.map +2 -2
- package/dist/cjs/decorators/appendChild.js +53 -9
- package/dist/cjs/decorators/appendChild.js.map +2 -2
- package/dist/cjs/decorators/attribute.js +141 -0
- package/dist/cjs/decorators/attribute.js.map +7 -0
- package/dist/cjs/decorators/changedAttribute.js +5 -5
- package/dist/cjs/decorators/changedAttribute.js.map +2 -2
- package/dist/cjs/decorators/classList.js +104 -0
- package/dist/cjs/decorators/classList.js.map +7 -0
- package/dist/cjs/decorators/elementDefine.js +334 -425
- package/dist/cjs/decorators/elementDefine.js.map +3 -3
- package/dist/cjs/decorators/emitCustomEvent.js +65 -13
- package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
- package/dist/cjs/decorators/index.js +4 -0
- package/dist/cjs/decorators/index.js.map +2 -2
- package/dist/cjs/decorators/lifecycles.js +4 -4
- package/dist/cjs/decorators/lifecycles.js.map +2 -2
- package/dist/cjs/decorators/onConnectedInnerHtml.js +4 -4
- package/dist/cjs/decorators/onConnectedInnerHtml.js.map +2 -2
- package/dist/cjs/decorators/query.js +60 -36
- package/dist/cjs/decorators/query.js.map +2 -2
- package/dist/cjs/decorators/queryAll.js +47 -23
- package/dist/cjs/decorators/queryAll.js.map +2 -2
- package/dist/cjs/decorators/replaceChildren.js +32 -6
- package/dist/cjs/decorators/replaceChildren.js.map +2 -2
- package/dist/cjs/decorators/setAttribute.js +64 -10
- package/dist/cjs/decorators/setAttribute.js.map +2 -2
- package/dist/cjs/decorators/style.js +88 -0
- package/dist/cjs/decorators/style.js.map +7 -0
- package/dist/cjs/elements/SwcAppEngine.js +30 -15
- package/dist/cjs/elements/SwcAppEngine.js.map +3 -3
- package/dist/cjs/elements/SwcAppMixin.js +79 -0
- package/dist/cjs/elements/SwcAppMixin.js.map +7 -0
- package/dist/cjs/elements/SwcAsync.js +58 -123
- package/dist/cjs/elements/SwcAsync.js.map +3 -3
- package/dist/cjs/elements/SwcChoose.js +52 -76
- package/dist/cjs/elements/SwcChoose.js.map +3 -3
- package/dist/cjs/elements/SwcIf.js +66 -94
- package/dist/cjs/elements/SwcIf.js.map +3 -3
- package/dist/cjs/elements/SwcLoop.js +73 -174
- package/dist/cjs/elements/SwcLoop.js.map +3 -3
- package/dist/cjs/elements/SwcSubTemplates.js +12 -37
- package/dist/cjs/elements/SwcSubTemplates.js.map +3 -3
- package/dist/cjs/elements/index.js +1 -8
- package/dist/cjs/elements/index.js.map +2 -2
- package/dist/cjs/elements/register.js +831 -0
- package/dist/cjs/elements/register.js.map +7 -0
- package/dist/cjs/index.js +14 -3
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/router/ElementRouter.js +7 -7
- package/dist/cjs/router/ElementRouter.js.map +2 -2
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/utils/TemplateUtils.js +103 -0
- package/dist/cjs/utils/TemplateUtils.js.map +7 -0
- package/dist/cjs/utils/Utils.js +10 -7
- package/dist/cjs/utils/Utils.js.map +2 -2
- package/dist/esm/config/config.js +2 -0
- package/dist/esm/config/config.js.map +2 -2
- package/dist/esm/decorators/addEventListener.js +5 -5
- package/dist/esm/decorators/addEventListener.js.map +2 -2
- package/dist/esm/decorators/appendChild.js +52 -8
- package/dist/esm/decorators/appendChild.js.map +2 -2
- package/dist/esm/decorators/attribute.js +122 -0
- package/dist/esm/decorators/attribute.js.map +7 -0
- package/dist/esm/decorators/changedAttribute.js +1 -1
- package/dist/esm/decorators/changedAttribute.js.map +1 -1
- package/dist/esm/decorators/classList.js +85 -0
- package/dist/esm/decorators/classList.js.map +7 -0
- package/dist/esm/decorators/elementDefine.js +334 -425
- package/dist/esm/decorators/elementDefine.js.map +3 -3
- package/dist/esm/decorators/emitCustomEvent.js +62 -10
- package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
- package/dist/esm/decorators/index.js +4 -0
- package/dist/esm/decorators/index.js.map +2 -2
- package/dist/esm/decorators/lifecycles.js +1 -1
- package/dist/esm/decorators/lifecycles.js.map +1 -1
- package/dist/esm/decorators/onConnectedInnerHtml.js +1 -1
- package/dist/esm/decorators/onConnectedInnerHtml.js.map +1 -1
- package/dist/esm/decorators/query.js +58 -34
- package/dist/esm/decorators/query.js.map +2 -2
- package/dist/esm/decorators/queryAll.js +45 -21
- package/dist/esm/decorators/queryAll.js.map +2 -2
- package/dist/esm/decorators/replaceChildren.js +28 -2
- package/dist/esm/decorators/replaceChildren.js.map +2 -2
- package/dist/esm/decorators/setAttribute.js +62 -8
- package/dist/esm/decorators/setAttribute.js.map +2 -2
- package/dist/esm/decorators/style.js +69 -0
- package/dist/esm/decorators/style.js.map +7 -0
- package/dist/esm/elements/SwcAppEngine.js +27 -12
- package/dist/esm/elements/SwcAppEngine.js.map +2 -2
- package/dist/esm/elements/SwcAppMixin.js +60 -0
- package/dist/esm/elements/SwcAppMixin.js.map +7 -0
- package/dist/esm/elements/SwcAsync.js +58 -123
- package/dist/esm/elements/SwcAsync.js.map +3 -3
- package/dist/esm/elements/SwcChoose.js +52 -76
- package/dist/esm/elements/SwcChoose.js.map +3 -3
- package/dist/esm/elements/SwcIf.js +66 -94
- package/dist/esm/elements/SwcIf.js.map +3 -3
- package/dist/esm/elements/SwcLoop.js +72 -173
- package/dist/esm/elements/SwcLoop.js.map +3 -3
- package/dist/esm/elements/SwcSubTemplates.js +12 -37
- package/dist/esm/elements/SwcSubTemplates.js.map +3 -3
- package/dist/esm/elements/index.js +1 -8
- package/dist/esm/elements/index.js.map +2 -2
- package/dist/esm/elements/register.js +812 -0
- package/dist/esm/elements/register.js.map +7 -0
- package/dist/esm/index.js +14 -3
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/router/ElementRouter.js +2 -2
- package/dist/esm/router/ElementRouter.js.map +1 -1
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/utils/TemplateUtils.js +84 -0
- package/dist/esm/utils/TemplateUtils.js.map +7 -0
- package/dist/esm/utils/Utils.js +6 -3
- package/dist/esm/utils/Utils.js.map +2 -2
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +4910 -7463
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
- package/dist/types/config/config.d.ts +1 -0
- package/dist/types/config/config.d.ts.map +1 -1
- package/dist/types/decorators/addEventListener.d.ts +11 -11
- package/dist/types/decorators/addEventListener.d.ts.map +1 -1
- package/dist/types/decorators/appendChild.d.ts +1 -1
- package/dist/types/decorators/appendChild.d.ts.map +1 -1
- package/dist/types/decorators/attribute.d.ts +23 -0
- package/dist/types/decorators/attribute.d.ts.map +1 -0
- package/dist/types/decorators/classList.d.ts +34 -0
- package/dist/types/decorators/classList.d.ts.map +1 -0
- package/dist/types/decorators/elementDefine.d.ts +9 -5
- package/dist/types/decorators/elementDefine.d.ts.map +1 -1
- package/dist/types/decorators/emitCustomEvent.d.ts +7 -4
- package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
- package/dist/types/decorators/index.d.ts +4 -0
- package/dist/types/decorators/index.d.ts.map +1 -1
- package/dist/types/decorators/query.d.ts +7 -8
- package/dist/types/decorators/query.d.ts.map +1 -1
- package/dist/types/decorators/queryAll.d.ts +5 -9
- package/dist/types/decorators/queryAll.d.ts.map +1 -1
- package/dist/types/decorators/replaceChildren.d.ts.map +1 -1
- package/dist/types/decorators/setAttribute.d.ts +16 -3
- package/dist/types/decorators/setAttribute.d.ts.map +1 -1
- package/dist/types/decorators/style.d.ts +24 -0
- package/dist/types/decorators/style.d.ts.map +1 -0
- package/dist/types/elements/SwcAppEngine.d.ts +6 -5
- package/dist/types/elements/SwcAppEngine.d.ts.map +1 -1
- package/dist/types/elements/SwcAppMixin.d.ts +364 -0
- package/dist/types/elements/SwcAppMixin.d.ts.map +1 -0
- package/dist/types/elements/SwcAsync.d.ts +2 -6
- package/dist/types/elements/SwcAsync.d.ts.map +1 -1
- package/dist/types/elements/SwcChoose.d.ts +2 -1
- package/dist/types/elements/SwcChoose.d.ts.map +1 -1
- package/dist/types/elements/SwcIf.d.ts +5 -6
- package/dist/types/elements/SwcIf.d.ts.map +1 -1
- package/dist/types/elements/SwcLoop.d.ts +4 -10
- package/dist/types/elements/SwcLoop.d.ts.map +1 -1
- package/dist/types/elements/SwcSubTemplates.d.ts.map +1 -1
- package/dist/types/elements/index.d.ts +1 -8
- package/dist/types/elements/index.d.ts.map +1 -1
- package/dist/types/elements/register.d.ts +2 -0
- package/dist/types/elements/register.d.ts.map +1 -0
- package/dist/types/index.d.ts +8 -3
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/router/ElementRouter.d.ts +1 -1
- package/dist/types/router/ElementRouter.d.ts.map +1 -1
- package/dist/types/types.d.ts +8 -2
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils/TemplateUtils.d.ts +54 -0
- package/dist/types/utils/TemplateUtils.d.ts.map +1 -0
- package/dist/types/utils/Utils.d.ts.map +1 -1
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +4910 -7463
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
- package/package.json +11 -6
- package/src/config/config.ts +2 -0
- package/src/decorators/addEventListener.ts +13 -12
- package/src/decorators/appendChild.ts +53 -9
- package/src/decorators/attribute.ts +158 -0
- package/src/decorators/changedAttribute.ts +1 -1
- package/src/decorators/classList.ts +117 -0
- package/src/decorators/elementDefine.ts +371 -425
- package/src/decorators/emitCustomEvent.ts +77 -13
- package/src/decorators/index.ts +4 -0
- package/src/decorators/lifecycles.ts +1 -1
- package/src/decorators/onConnectedInnerHtml.ts +1 -1
- package/src/decorators/query.ts +58 -38
- package/src/decorators/queryAll.ts +45 -29
- package/src/decorators/replaceChildren.ts +31 -2
- package/src/decorators/setAttribute.ts +86 -12
- package/src/decorators/style.ts +89 -0
- package/src/elements/SwcAppEngine.ts +34 -18
- package/src/elements/SwcAppMixin.ts +65 -0
- package/src/elements/SwcAsync.ts +58 -128
- package/src/elements/SwcChoose.ts +51 -77
- package/src/elements/SwcIf.ts +64 -86
- package/src/elements/SwcLoop.ts +71 -168
- package/src/elements/SwcSubTemplates.ts +0 -13
- package/src/elements/index.ts +1 -8
- package/src/elements/register.ts +735 -0
- package/src/index.ts +17 -5
- package/src/router/ElementRouter.ts +2 -2
- package/src/types.ts +15 -6
- package/src/utils/TemplateUtils.ts +83 -0
- package/src/utils/Utils.ts +6 -3
- package/dist/cjs/elements/SwcApp.js +0 -55
- package/dist/cjs/elements/SwcApp.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppAnchor.js +0 -55
- package/dist/cjs/elements/is/SwcAppAnchor.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppArea.js +0 -55
- package/dist/cjs/elements/is/SwcAppArea.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppAudio.js +0 -55
- package/dist/cjs/elements/is/SwcAppAudio.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppBase.js +0 -55
- package/dist/cjs/elements/is/SwcAppBase.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppBody.js +0 -55
- package/dist/cjs/elements/is/SwcAppBody.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppButton.js +0 -55
- package/dist/cjs/elements/is/SwcAppButton.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppCanvas.js +0 -55
- package/dist/cjs/elements/is/SwcAppCanvas.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppData.js +0 -55
- package/dist/cjs/elements/is/SwcAppData.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppDataList.js +0 -55
- package/dist/cjs/elements/is/SwcAppDataList.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppDetails.js +0 -55
- package/dist/cjs/elements/is/SwcAppDetails.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppDialog.js +0 -55
- package/dist/cjs/elements/is/SwcAppDialog.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppDiv.js +0 -55
- package/dist/cjs/elements/is/SwcAppDiv.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppDl.js +0 -55
- package/dist/cjs/elements/is/SwcAppDl.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppEmbed.js +0 -55
- package/dist/cjs/elements/is/SwcAppEmbed.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppFieldSet.js +0 -55
- package/dist/cjs/elements/is/SwcAppFieldSet.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppForm.js +0 -55
- package/dist/cjs/elements/is/SwcAppForm.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppHeading.js +0 -55
- package/dist/cjs/elements/is/SwcAppHeading.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppHr.js +0 -55
- package/dist/cjs/elements/is/SwcAppHr.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppIFrame.js +0 -55
- package/dist/cjs/elements/is/SwcAppIFrame.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppImage.js +0 -55
- package/dist/cjs/elements/is/SwcAppImage.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppInput.js +0 -55
- package/dist/cjs/elements/is/SwcAppInput.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppLabel.js +0 -55
- package/dist/cjs/elements/is/SwcAppLabel.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppLegend.js +0 -55
- package/dist/cjs/elements/is/SwcAppLegend.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppLi.js +0 -55
- package/dist/cjs/elements/is/SwcAppLi.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppLink.js +0 -55
- package/dist/cjs/elements/is/SwcAppLink.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppMap.js +0 -55
- package/dist/cjs/elements/is/SwcAppMap.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppMeta.js +0 -55
- package/dist/cjs/elements/is/SwcAppMeta.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppMeter.js +0 -55
- package/dist/cjs/elements/is/SwcAppMeter.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppMod.js +0 -55
- package/dist/cjs/elements/is/SwcAppMod.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppObject.js +0 -55
- package/dist/cjs/elements/is/SwcAppObject.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppOl.js +0 -55
- package/dist/cjs/elements/is/SwcAppOl.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppOptGroup.js +0 -55
- package/dist/cjs/elements/is/SwcAppOptGroup.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppOption.js +0 -55
- package/dist/cjs/elements/is/SwcAppOption.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppOutput.js +0 -55
- package/dist/cjs/elements/is/SwcAppOutput.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppParagraph.js +0 -55
- package/dist/cjs/elements/is/SwcAppParagraph.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppParam.js +0 -55
- package/dist/cjs/elements/is/SwcAppParam.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppPicture.js +0 -55
- package/dist/cjs/elements/is/SwcAppPicture.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppPre.js +0 -55
- package/dist/cjs/elements/is/SwcAppPre.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppProgress.js +0 -55
- package/dist/cjs/elements/is/SwcAppProgress.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppQuote.js +0 -55
- package/dist/cjs/elements/is/SwcAppQuote.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppScript.js +0 -55
- package/dist/cjs/elements/is/SwcAppScript.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppSelect.js +0 -55
- package/dist/cjs/elements/is/SwcAppSelect.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppSlot.js +0 -55
- package/dist/cjs/elements/is/SwcAppSlot.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppSource.js +0 -55
- package/dist/cjs/elements/is/SwcAppSource.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppSpan.js +0 -55
- package/dist/cjs/elements/is/SwcAppSpan.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppStyle.js +0 -55
- package/dist/cjs/elements/is/SwcAppStyle.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppTable.js +0 -55
- package/dist/cjs/elements/is/SwcAppTable.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppTableCell.js +0 -55
- package/dist/cjs/elements/is/SwcAppTableCell.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppTableRow.js +0 -55
- package/dist/cjs/elements/is/SwcAppTableRow.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppTableSection.js +0 -55
- package/dist/cjs/elements/is/SwcAppTableSection.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppTemplate.js +0 -55
- package/dist/cjs/elements/is/SwcAppTemplate.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppTextArea.js +0 -55
- package/dist/cjs/elements/is/SwcAppTextArea.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppTime.js +0 -55
- package/dist/cjs/elements/is/SwcAppTime.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppTitle.js +0 -55
- package/dist/cjs/elements/is/SwcAppTitle.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppTrack.js +0 -55
- package/dist/cjs/elements/is/SwcAppTrack.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppUl.js +0 -55
- package/dist/cjs/elements/is/SwcAppUl.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppVideo.js +0 -55
- package/dist/cjs/elements/is/SwcAppVideo.js.map +0 -7
- package/dist/cjs/elements/is/index.js +0 -74
- package/dist/cjs/elements/is/index.js.map +0 -7
- package/dist/esm/elements/SwcApp.js +0 -36
- package/dist/esm/elements/SwcApp.js.map +0 -7
- package/dist/esm/elements/is/SwcAppAnchor.js +0 -36
- package/dist/esm/elements/is/SwcAppAnchor.js.map +0 -7
- package/dist/esm/elements/is/SwcAppArea.js +0 -36
- package/dist/esm/elements/is/SwcAppArea.js.map +0 -7
- package/dist/esm/elements/is/SwcAppAudio.js +0 -36
- package/dist/esm/elements/is/SwcAppAudio.js.map +0 -7
- package/dist/esm/elements/is/SwcAppBase.js +0 -36
- package/dist/esm/elements/is/SwcAppBase.js.map +0 -7
- package/dist/esm/elements/is/SwcAppBody.js +0 -36
- package/dist/esm/elements/is/SwcAppBody.js.map +0 -7
- package/dist/esm/elements/is/SwcAppButton.js +0 -36
- package/dist/esm/elements/is/SwcAppButton.js.map +0 -7
- package/dist/esm/elements/is/SwcAppCanvas.js +0 -36
- package/dist/esm/elements/is/SwcAppCanvas.js.map +0 -7
- package/dist/esm/elements/is/SwcAppData.js +0 -36
- package/dist/esm/elements/is/SwcAppData.js.map +0 -7
- package/dist/esm/elements/is/SwcAppDataList.js +0 -36
- package/dist/esm/elements/is/SwcAppDataList.js.map +0 -7
- package/dist/esm/elements/is/SwcAppDetails.js +0 -36
- package/dist/esm/elements/is/SwcAppDetails.js.map +0 -7
- package/dist/esm/elements/is/SwcAppDialog.js +0 -36
- package/dist/esm/elements/is/SwcAppDialog.js.map +0 -7
- package/dist/esm/elements/is/SwcAppDiv.js +0 -36
- package/dist/esm/elements/is/SwcAppDiv.js.map +0 -7
- package/dist/esm/elements/is/SwcAppDl.js +0 -36
- package/dist/esm/elements/is/SwcAppDl.js.map +0 -7
- package/dist/esm/elements/is/SwcAppEmbed.js +0 -36
- package/dist/esm/elements/is/SwcAppEmbed.js.map +0 -7
- package/dist/esm/elements/is/SwcAppFieldSet.js +0 -36
- package/dist/esm/elements/is/SwcAppFieldSet.js.map +0 -7
- package/dist/esm/elements/is/SwcAppForm.js +0 -36
- package/dist/esm/elements/is/SwcAppForm.js.map +0 -7
- package/dist/esm/elements/is/SwcAppHeading.js +0 -36
- package/dist/esm/elements/is/SwcAppHeading.js.map +0 -7
- package/dist/esm/elements/is/SwcAppHr.js +0 -36
- package/dist/esm/elements/is/SwcAppHr.js.map +0 -7
- package/dist/esm/elements/is/SwcAppIFrame.js +0 -36
- package/dist/esm/elements/is/SwcAppIFrame.js.map +0 -7
- package/dist/esm/elements/is/SwcAppImage.js +0 -36
- package/dist/esm/elements/is/SwcAppImage.js.map +0 -7
- package/dist/esm/elements/is/SwcAppInput.js +0 -36
- package/dist/esm/elements/is/SwcAppInput.js.map +0 -7
- package/dist/esm/elements/is/SwcAppLabel.js +0 -36
- package/dist/esm/elements/is/SwcAppLabel.js.map +0 -7
- package/dist/esm/elements/is/SwcAppLegend.js +0 -36
- package/dist/esm/elements/is/SwcAppLegend.js.map +0 -7
- package/dist/esm/elements/is/SwcAppLi.js +0 -36
- package/dist/esm/elements/is/SwcAppLi.js.map +0 -7
- package/dist/esm/elements/is/SwcAppLink.js +0 -36
- package/dist/esm/elements/is/SwcAppLink.js.map +0 -7
- package/dist/esm/elements/is/SwcAppMap.js +0 -36
- package/dist/esm/elements/is/SwcAppMap.js.map +0 -7
- package/dist/esm/elements/is/SwcAppMeta.js +0 -36
- package/dist/esm/elements/is/SwcAppMeta.js.map +0 -7
- package/dist/esm/elements/is/SwcAppMeter.js +0 -36
- package/dist/esm/elements/is/SwcAppMeter.js.map +0 -7
- package/dist/esm/elements/is/SwcAppMod.js +0 -36
- package/dist/esm/elements/is/SwcAppMod.js.map +0 -7
- package/dist/esm/elements/is/SwcAppObject.js +0 -36
- package/dist/esm/elements/is/SwcAppObject.js.map +0 -7
- package/dist/esm/elements/is/SwcAppOl.js +0 -36
- package/dist/esm/elements/is/SwcAppOl.js.map +0 -7
- package/dist/esm/elements/is/SwcAppOptGroup.js +0 -36
- package/dist/esm/elements/is/SwcAppOptGroup.js.map +0 -7
- package/dist/esm/elements/is/SwcAppOption.js +0 -36
- package/dist/esm/elements/is/SwcAppOption.js.map +0 -7
- package/dist/esm/elements/is/SwcAppOutput.js +0 -36
- package/dist/esm/elements/is/SwcAppOutput.js.map +0 -7
- package/dist/esm/elements/is/SwcAppParagraph.js +0 -36
- package/dist/esm/elements/is/SwcAppParagraph.js.map +0 -7
- package/dist/esm/elements/is/SwcAppParam.js +0 -36
- package/dist/esm/elements/is/SwcAppParam.js.map +0 -7
- package/dist/esm/elements/is/SwcAppPicture.js +0 -36
- package/dist/esm/elements/is/SwcAppPicture.js.map +0 -7
- package/dist/esm/elements/is/SwcAppPre.js +0 -36
- package/dist/esm/elements/is/SwcAppPre.js.map +0 -7
- package/dist/esm/elements/is/SwcAppProgress.js +0 -36
- package/dist/esm/elements/is/SwcAppProgress.js.map +0 -7
- package/dist/esm/elements/is/SwcAppQuote.js +0 -36
- package/dist/esm/elements/is/SwcAppQuote.js.map +0 -7
- package/dist/esm/elements/is/SwcAppScript.js +0 -36
- package/dist/esm/elements/is/SwcAppScript.js.map +0 -7
- package/dist/esm/elements/is/SwcAppSelect.js +0 -36
- package/dist/esm/elements/is/SwcAppSelect.js.map +0 -7
- package/dist/esm/elements/is/SwcAppSlot.js +0 -36
- package/dist/esm/elements/is/SwcAppSlot.js.map +0 -7
- package/dist/esm/elements/is/SwcAppSource.js +0 -36
- package/dist/esm/elements/is/SwcAppSource.js.map +0 -7
- package/dist/esm/elements/is/SwcAppSpan.js +0 -36
- package/dist/esm/elements/is/SwcAppSpan.js.map +0 -7
- package/dist/esm/elements/is/SwcAppStyle.js +0 -36
- package/dist/esm/elements/is/SwcAppStyle.js.map +0 -7
- package/dist/esm/elements/is/SwcAppTable.js +0 -36
- package/dist/esm/elements/is/SwcAppTable.js.map +0 -7
- package/dist/esm/elements/is/SwcAppTableCell.js +0 -36
- package/dist/esm/elements/is/SwcAppTableCell.js.map +0 -7
- package/dist/esm/elements/is/SwcAppTableRow.js +0 -36
- package/dist/esm/elements/is/SwcAppTableRow.js.map +0 -7
- package/dist/esm/elements/is/SwcAppTableSection.js +0 -36
- package/dist/esm/elements/is/SwcAppTableSection.js.map +0 -7
- package/dist/esm/elements/is/SwcAppTemplate.js +0 -36
- package/dist/esm/elements/is/SwcAppTemplate.js.map +0 -7
- package/dist/esm/elements/is/SwcAppTextArea.js +0 -36
- package/dist/esm/elements/is/SwcAppTextArea.js.map +0 -7
- package/dist/esm/elements/is/SwcAppTime.js +0 -36
- package/dist/esm/elements/is/SwcAppTime.js.map +0 -7
- package/dist/esm/elements/is/SwcAppTitle.js +0 -36
- package/dist/esm/elements/is/SwcAppTitle.js.map +0 -7
- package/dist/esm/elements/is/SwcAppTrack.js +0 -36
- package/dist/esm/elements/is/SwcAppTrack.js.map +0 -7
- package/dist/esm/elements/is/SwcAppUl.js +0 -36
- package/dist/esm/elements/is/SwcAppUl.js.map +0 -7
- package/dist/esm/elements/is/SwcAppVideo.js +0 -36
- package/dist/esm/elements/is/SwcAppVideo.js.map +0 -7
- package/dist/esm/elements/is/index.js +0 -58
- package/dist/esm/elements/is/index.js.map +0 -7
- package/dist/types/elements/SwcApp.d.ts +0 -9
- package/dist/types/elements/SwcApp.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppAnchor.d.ts +0 -9
- package/dist/types/elements/is/SwcAppAnchor.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppArea.d.ts +0 -9
- package/dist/types/elements/is/SwcAppArea.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppAudio.d.ts +0 -9
- package/dist/types/elements/is/SwcAppAudio.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppBase.d.ts +0 -9
- package/dist/types/elements/is/SwcAppBase.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppBody.d.ts +0 -9
- package/dist/types/elements/is/SwcAppBody.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppButton.d.ts +0 -9
- package/dist/types/elements/is/SwcAppButton.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppCanvas.d.ts +0 -9
- package/dist/types/elements/is/SwcAppCanvas.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppData.d.ts +0 -9
- package/dist/types/elements/is/SwcAppData.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppDataList.d.ts +0 -9
- package/dist/types/elements/is/SwcAppDataList.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppDetails.d.ts +0 -9
- package/dist/types/elements/is/SwcAppDetails.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppDialog.d.ts +0 -9
- package/dist/types/elements/is/SwcAppDialog.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppDiv.d.ts +0 -9
- package/dist/types/elements/is/SwcAppDiv.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppDl.d.ts +0 -9
- package/dist/types/elements/is/SwcAppDl.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppEmbed.d.ts +0 -9
- package/dist/types/elements/is/SwcAppEmbed.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppFieldSet.d.ts +0 -9
- package/dist/types/elements/is/SwcAppFieldSet.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppForm.d.ts +0 -9
- package/dist/types/elements/is/SwcAppForm.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppHeading.d.ts +0 -9
- package/dist/types/elements/is/SwcAppHeading.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppHr.d.ts +0 -9
- package/dist/types/elements/is/SwcAppHr.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppIFrame.d.ts +0 -9
- package/dist/types/elements/is/SwcAppIFrame.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppImage.d.ts +0 -9
- package/dist/types/elements/is/SwcAppImage.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppInput.d.ts +0 -9
- package/dist/types/elements/is/SwcAppInput.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppLabel.d.ts +0 -9
- package/dist/types/elements/is/SwcAppLabel.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppLegend.d.ts +0 -9
- package/dist/types/elements/is/SwcAppLegend.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppLi.d.ts +0 -9
- package/dist/types/elements/is/SwcAppLi.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppLink.d.ts +0 -9
- package/dist/types/elements/is/SwcAppLink.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppMap.d.ts +0 -9
- package/dist/types/elements/is/SwcAppMap.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppMeta.d.ts +0 -9
- package/dist/types/elements/is/SwcAppMeta.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppMeter.d.ts +0 -9
- package/dist/types/elements/is/SwcAppMeter.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppMod.d.ts +0 -9
- package/dist/types/elements/is/SwcAppMod.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppObject.d.ts +0 -9
- package/dist/types/elements/is/SwcAppObject.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppOl.d.ts +0 -9
- package/dist/types/elements/is/SwcAppOl.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppOptGroup.d.ts +0 -9
- package/dist/types/elements/is/SwcAppOptGroup.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppOption.d.ts +0 -9
- package/dist/types/elements/is/SwcAppOption.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppOutput.d.ts +0 -9
- package/dist/types/elements/is/SwcAppOutput.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppParagraph.d.ts +0 -9
- package/dist/types/elements/is/SwcAppParagraph.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppParam.d.ts +0 -9
- package/dist/types/elements/is/SwcAppParam.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppPicture.d.ts +0 -9
- package/dist/types/elements/is/SwcAppPicture.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppPre.d.ts +0 -9
- package/dist/types/elements/is/SwcAppPre.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppProgress.d.ts +0 -9
- package/dist/types/elements/is/SwcAppProgress.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppQuote.d.ts +0 -9
- package/dist/types/elements/is/SwcAppQuote.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppScript.d.ts +0 -9
- package/dist/types/elements/is/SwcAppScript.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppSelect.d.ts +0 -9
- package/dist/types/elements/is/SwcAppSelect.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppSlot.d.ts +0 -9
- package/dist/types/elements/is/SwcAppSlot.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppSource.d.ts +0 -9
- package/dist/types/elements/is/SwcAppSource.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppSpan.d.ts +0 -9
- package/dist/types/elements/is/SwcAppSpan.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppStyle.d.ts +0 -9
- package/dist/types/elements/is/SwcAppStyle.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppTable.d.ts +0 -9
- package/dist/types/elements/is/SwcAppTable.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppTableCell.d.ts +0 -9
- package/dist/types/elements/is/SwcAppTableCell.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppTableRow.d.ts +0 -9
- package/dist/types/elements/is/SwcAppTableRow.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppTableSection.d.ts +0 -9
- package/dist/types/elements/is/SwcAppTableSection.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppTemplate.d.ts +0 -9
- package/dist/types/elements/is/SwcAppTemplate.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppTextArea.d.ts +0 -9
- package/dist/types/elements/is/SwcAppTextArea.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppTime.d.ts +0 -9
- package/dist/types/elements/is/SwcAppTime.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppTitle.d.ts +0 -9
- package/dist/types/elements/is/SwcAppTitle.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppTrack.d.ts +0 -9
- package/dist/types/elements/is/SwcAppTrack.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppUl.d.ts +0 -9
- package/dist/types/elements/is/SwcAppUl.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppVideo.d.ts +0 -9
- package/dist/types/elements/is/SwcAppVideo.d.ts.map +0 -1
- package/dist/types/elements/is/index.d.ts +0 -58
- package/dist/types/elements/is/index.d.ts.map +0 -1
- package/src/elements/SwcApp.ts +0 -26
- package/src/elements/is/SwcAppAnchor.ts +0 -26
- package/src/elements/is/SwcAppArea.ts +0 -26
- package/src/elements/is/SwcAppAudio.ts +0 -26
- package/src/elements/is/SwcAppBase.ts +0 -26
- package/src/elements/is/SwcAppBody.ts +0 -26
- package/src/elements/is/SwcAppButton.ts +0 -26
- package/src/elements/is/SwcAppCanvas.ts +0 -26
- package/src/elements/is/SwcAppData.ts +0 -26
- package/src/elements/is/SwcAppDataList.ts +0 -26
- package/src/elements/is/SwcAppDetails.ts +0 -26
- package/src/elements/is/SwcAppDialog.ts +0 -26
- package/src/elements/is/SwcAppDiv.ts +0 -26
- package/src/elements/is/SwcAppDl.ts +0 -26
- package/src/elements/is/SwcAppEmbed.ts +0 -26
- package/src/elements/is/SwcAppFieldSet.ts +0 -26
- package/src/elements/is/SwcAppForm.ts +0 -26
- package/src/elements/is/SwcAppHeading.ts +0 -26
- package/src/elements/is/SwcAppHr.ts +0 -26
- package/src/elements/is/SwcAppIFrame.ts +0 -26
- package/src/elements/is/SwcAppImage.ts +0 -26
- package/src/elements/is/SwcAppInput.ts +0 -26
- package/src/elements/is/SwcAppLabel.ts +0 -26
- package/src/elements/is/SwcAppLegend.ts +0 -26
- package/src/elements/is/SwcAppLi.ts +0 -26
- package/src/elements/is/SwcAppLink.ts +0 -26
- package/src/elements/is/SwcAppMap.ts +0 -26
- package/src/elements/is/SwcAppMeta.ts +0 -26
- package/src/elements/is/SwcAppMeter.ts +0 -26
- package/src/elements/is/SwcAppMod.ts +0 -26
- package/src/elements/is/SwcAppObject.ts +0 -26
- package/src/elements/is/SwcAppOl.ts +0 -26
- package/src/elements/is/SwcAppOptGroup.ts +0 -26
- package/src/elements/is/SwcAppOption.ts +0 -26
- package/src/elements/is/SwcAppOutput.ts +0 -26
- package/src/elements/is/SwcAppParagraph.ts +0 -26
- package/src/elements/is/SwcAppParam.ts +0 -26
- package/src/elements/is/SwcAppPicture.ts +0 -26
- package/src/elements/is/SwcAppPre.ts +0 -26
- package/src/elements/is/SwcAppProgress.ts +0 -26
- package/src/elements/is/SwcAppQuote.ts +0 -26
- package/src/elements/is/SwcAppScript.ts +0 -26
- package/src/elements/is/SwcAppSelect.ts +0 -26
- package/src/elements/is/SwcAppSlot.ts +0 -26
- package/src/elements/is/SwcAppSource.ts +0 -26
- package/src/elements/is/SwcAppSpan.ts +0 -26
- package/src/elements/is/SwcAppStyle.ts +0 -26
- package/src/elements/is/SwcAppTable.ts +0 -26
- package/src/elements/is/SwcAppTableCell.ts +0 -26
- package/src/elements/is/SwcAppTableRow.ts +0 -26
- package/src/elements/is/SwcAppTableSection.ts +0 -26
- package/src/elements/is/SwcAppTemplate.ts +0 -26
- package/src/elements/is/SwcAppTextArea.ts +0 -26
- package/src/elements/is/SwcAppTime.ts +0 -26
- package/src/elements/is/SwcAppTitle.ts +0 -26
- package/src/elements/is/SwcAppTrack.ts +0 -26
- package/src/elements/is/SwcAppUl.ts +0 -26
- package/src/elements/is/SwcAppVideo.ts +0 -26
- package/src/elements/is/index.ts +0 -57
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { ReflectUtils } from '@dooboostore/core
|
|
1
|
+
import { ReflectUtils } from '@dooboostore/core';
|
|
2
|
+
import { SpecialSelector, SwcQueryOptions } from '../types';
|
|
3
|
+
import { ensureInit, getElementConfig } from './elementDefine';
|
|
4
|
+
import { SwcUtils } from '../utils/Utils';
|
|
2
5
|
|
|
3
|
-
export interface
|
|
4
|
-
type: string;
|
|
6
|
+
export interface EmitCustomEventBaseOptions {
|
|
5
7
|
attributeName?: string;
|
|
6
8
|
bubbles?: boolean;
|
|
7
9
|
composed?: boolean;
|
|
@@ -10,28 +12,90 @@ export interface EmitCustomEventOptions {
|
|
|
10
12
|
|
|
11
13
|
export interface EmitCustomEventMetadata {
|
|
12
14
|
propertyKey: string | symbol;
|
|
13
|
-
|
|
15
|
+
selector: string;
|
|
16
|
+
type: string;
|
|
17
|
+
options: EmitCustomEventBaseOptions & SwcQueryOptions;
|
|
14
18
|
}
|
|
15
19
|
|
|
16
20
|
export const EMIT_CUSTOM_EVENT_METADATA_KEY = Symbol('simple-web-component:emit-custom-event');
|
|
21
|
+
export function emitCustomEvent(target: SpecialSelector, type: string, options?: EmitCustomEventBaseOptions): MethodDecorator;
|
|
22
|
+
export function emitCustomEvent(selector: string, type: string, options?: EmitCustomEventBaseOptions & SwcQueryOptions): MethodDecorator;
|
|
23
|
+
/**
|
|
24
|
+
* @emitCustomEvent decorator to dispatch custom events to a target.
|
|
25
|
+
*/
|
|
26
|
+
export function emitCustomEvent(selectorOrTarget: string, type: string, options: any = {}): MethodDecorator {
|
|
27
|
+
return (targetObj: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {
|
|
28
|
+
const constructor = targetObj.constructor;
|
|
17
29
|
|
|
18
|
-
|
|
19
|
-
return (target: Object, propertyKey: string | symbol) => {
|
|
20
|
-
const constructor = target.constructor;
|
|
21
|
-
const options: EmitCustomEventOptions = typeof typeOrOptions === 'string' ? { type: typeOrOptions } : typeOrOptions;
|
|
30
|
+
const fullOptions: any = { ...options, type };
|
|
22
31
|
|
|
23
|
-
if (!
|
|
24
|
-
|
|
32
|
+
if (!fullOptions.attributeName) {
|
|
33
|
+
fullOptions.attributeName = `swc-on-${type}`;
|
|
25
34
|
}
|
|
26
|
-
if (
|
|
27
|
-
if (
|
|
35
|
+
if (fullOptions.bubbles === undefined) fullOptions.bubbles = true;
|
|
36
|
+
if (fullOptions.composed === undefined) fullOptions.composed = true;
|
|
28
37
|
|
|
29
38
|
let list = ReflectUtils.getMetadata<EmitCustomEventMetadata[]>(EMIT_CUSTOM_EVENT_METADATA_KEY, constructor);
|
|
30
39
|
if (!list) {
|
|
31
40
|
list = [];
|
|
32
41
|
ReflectUtils.defineMetadata(EMIT_CUSTOM_EVENT_METADATA_KEY, list, constructor);
|
|
33
42
|
}
|
|
34
|
-
list.push({ propertyKey, options });
|
|
43
|
+
list.push({ propertyKey, selector: selectorOrTarget, type, options: fullOptions });
|
|
44
|
+
|
|
45
|
+
const original = descriptor.value;
|
|
46
|
+
descriptor.value = async function (...args: any[]) {
|
|
47
|
+
ensureInit(this);
|
|
48
|
+
const detail = await original.apply(this, args);
|
|
49
|
+
const event = new CustomEvent(type, {
|
|
50
|
+
detail,
|
|
51
|
+
bubbles: fullOptions.bubbles,
|
|
52
|
+
composed: fullOptions.composed,
|
|
53
|
+
cancelable: fullOptions.cancelable
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const hostSet = SwcUtils.getHostSet(this as any);
|
|
57
|
+
const conf = getElementConfig(this);
|
|
58
|
+
const currentWin = (this as any)._resolveWindow?.(conf) || ((typeof window !== 'undefined' ? window : undefined) as Window);
|
|
59
|
+
|
|
60
|
+
const eventTargets: EventTarget[] = [];
|
|
61
|
+
if (selectorOrTarget === ':window') eventTargets.push(currentWin);
|
|
62
|
+
else if (selectorOrTarget === ':document') eventTargets.push(currentWin.document);
|
|
63
|
+
else if (selectorOrTarget === ':parentHost') {
|
|
64
|
+
if (hostSet.$parentHost) eventTargets.push(hostSet.$parentHost);
|
|
65
|
+
} else if (selectorOrTarget === ':appHost') {
|
|
66
|
+
if (hostSet.$appHost) eventTargets.push(hostSet.$appHost);
|
|
67
|
+
} else if (selectorOrTarget === ':firstHost') {
|
|
68
|
+
if (hostSet.$firstHost) eventTargets.push(hostSet.$firstHost);
|
|
69
|
+
} else if (selectorOrTarget === ':lastHost') {
|
|
70
|
+
if (hostSet.$lastHost) eventTargets.push(hostSet.$lastHost);
|
|
71
|
+
} else if (selectorOrTarget === ':firstAppHost') {
|
|
72
|
+
if (hostSet.$firstAppHost) eventTargets.push(hostSet.$firstAppHost);
|
|
73
|
+
} else if (selectorOrTarget === ':lastAppHost') {
|
|
74
|
+
if (hostSet.$lastAppHost) eventTargets.push(hostSet.$lastAppHost);
|
|
75
|
+
} else if (selectorOrTarget === ':hosts') {
|
|
76
|
+
hostSet.$hosts.forEach(h => eventTargets.push(h));
|
|
77
|
+
} else if (selectorOrTarget === ':appHosts') {
|
|
78
|
+
hostSet.$appHosts.forEach(h => eventTargets.push(h));
|
|
79
|
+
} else if (selectorOrTarget === ':host' || !selectorOrTarget) eventTargets.push(this as any);
|
|
80
|
+
else {
|
|
81
|
+
const r = fullOptions.root || 'auto';
|
|
82
|
+
const searchRoots: (HTMLElement | ShadowRoot)[] = [];
|
|
83
|
+
if (r === 'auto') searchRoots.push(this.shadowRoot || (this as any));
|
|
84
|
+
else if (r === 'light') searchRoots.push(this as any);
|
|
85
|
+
else if (r === 'shadow' && this.shadowRoot) searchRoots.push(this.shadowRoot);
|
|
86
|
+
else if (r === 'all') {
|
|
87
|
+
searchRoots.push(this as any);
|
|
88
|
+
if (this.shadowRoot) searchRoots.push(this.shadowRoot);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
searchRoots.forEach(sr => {
|
|
92
|
+
sr.querySelectorAll(selectorOrTarget).forEach(el => eventTargets.push(el));
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
eventTargets.forEach(t => t.dispatchEvent(event));
|
|
97
|
+
return detail;
|
|
98
|
+
};
|
|
35
99
|
};
|
|
36
100
|
}
|
|
37
101
|
|
package/src/decorators/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * from './addEventListener';
|
|
2
|
+
export * from './attribute';
|
|
2
3
|
export * from './elementDefine';
|
|
3
4
|
export * from './changedAttribute';
|
|
4
5
|
export * from './setAttribute';
|
|
@@ -8,3 +9,6 @@ export * from './appendChild';
|
|
|
8
9
|
export * from './lifecycles';
|
|
9
10
|
export * from './query';
|
|
10
11
|
export * from './queryAll';
|
|
12
|
+
export * from './onConnectedInnerHtml';
|
|
13
|
+
export * from './classList';
|
|
14
|
+
export * from './style';
|
package/src/decorators/query.ts
CHANGED
|
@@ -1,81 +1,101 @@
|
|
|
1
|
-
import { ReflectUtils } from '@dooboostore/core
|
|
2
|
-
import { getElementConfig } from './elementDefine';
|
|
1
|
+
import { ReflectUtils } from '@dooboostore/core';
|
|
2
|
+
import { getElementConfig, ensureInit } from './elementDefine';
|
|
3
3
|
import { SwcUtils } from '../utils/Utils';
|
|
4
|
+
import { SpecialSelector, SwcQueryOptions } from '../types';
|
|
4
5
|
|
|
5
|
-
export
|
|
6
|
-
root?: 'light' | 'shadow' | 'all' | 'auto';
|
|
7
|
-
}
|
|
6
|
+
export type QueryOptions = { root?: 'light' | 'shadow' | 'all' | 'auto' };
|
|
8
7
|
|
|
9
8
|
export interface QueryMetadata {
|
|
10
|
-
selector: string;
|
|
11
|
-
options: QueryOptions;
|
|
12
9
|
propertyKey: string | symbol;
|
|
10
|
+
selector: string;
|
|
11
|
+
options: SwcQueryOptions;
|
|
13
12
|
}
|
|
14
13
|
|
|
15
14
|
export const QUERY_METADATA_KEY = Symbol('simple-web-component:query');
|
|
16
15
|
|
|
16
|
+
export function query(target: SpecialSelector): PropertyDecorator;
|
|
17
|
+
export function query(selector: string, options?: SwcQueryOptions): PropertyDecorator;
|
|
17
18
|
/**
|
|
18
19
|
* @query decorator to inject a single element into a class property.
|
|
19
20
|
*/
|
|
20
|
-
export function query(
|
|
21
|
-
return (
|
|
21
|
+
export function query(selectorOrTarget: string, options: any = {}): PropertyDecorator {
|
|
22
|
+
return (targetObj: Object, propertyKey: string | symbol, descriptor?: never): void => {
|
|
22
23
|
if (descriptor !== undefined) {
|
|
23
24
|
throw new Error(`@query decorator cannot be used on methods. (Method: ${String(propertyKey)})`);
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
const constructor =
|
|
27
|
+
const constructor = targetObj.constructor;
|
|
27
28
|
let queries = ReflectUtils.getMetadata<QueryMetadata[]>(QUERY_METADATA_KEY, constructor);
|
|
28
29
|
if (!queries) {
|
|
29
30
|
queries = [];
|
|
30
31
|
ReflectUtils.defineMetadata(QUERY_METADATA_KEY, queries, constructor);
|
|
31
32
|
}
|
|
32
|
-
queries.push({ selector, options
|
|
33
|
+
queries.push({ propertyKey, selector: selectorOrTarget, options });
|
|
33
34
|
|
|
34
|
-
|
|
35
|
+
// const propertyType = Reflect.getMetadata("design:type", targetObj, propertyKey);
|
|
36
|
+
// console.log(`Property ${String(propertyKey)} type is:`, propertyType.name);
|
|
37
|
+
Object.defineProperty(targetObj, propertyKey, {
|
|
35
38
|
get(this: HTMLElement) {
|
|
39
|
+
ensureInit(this);
|
|
40
|
+
const selector = selectorOrTarget;
|
|
41
|
+
|
|
42
|
+
const r = options.root || 'auto';
|
|
43
|
+
const applyRoot = (t: any) => {
|
|
44
|
+
if (!t || !(t instanceof HTMLElement)) return t;
|
|
45
|
+
if (r === 'auto') return t.shadowRoot || t;
|
|
46
|
+
if (r === 'shadow') return t.shadowRoot;
|
|
47
|
+
if (r === 'light') return t;
|
|
48
|
+
if (r === 'all') return t.shadowRoot || t; // query only returns one, so shadow preferred
|
|
49
|
+
return t;
|
|
50
|
+
};
|
|
51
|
+
|
|
36
52
|
// --- Special Selectors: HostSet ---
|
|
37
53
|
const hostSet = SwcUtils.getHostSet(this);
|
|
38
|
-
if (selector === ':parentHost') return hostSet.$parentHost;
|
|
39
|
-
if (selector === ':appHost') return hostSet.$appHost;
|
|
40
|
-
if (selector === ':firstHost') return hostSet.$firstHost;
|
|
41
|
-
if (selector === ':lastHost') return hostSet.$lastHost;
|
|
42
|
-
if (selector === ':firstAppHost') return hostSet.$firstAppHost;
|
|
43
|
-
if (selector === ':lastAppHost') return hostSet.$lastAppHost;
|
|
54
|
+
if (selector === ':parentHost') return applyRoot(hostSet.$parentHost);
|
|
55
|
+
if (selector === ':appHost') return applyRoot(hostSet.$appHost);
|
|
56
|
+
if (selector === ':firstHost') return applyRoot(hostSet.$firstHost);
|
|
57
|
+
if (selector === ':lastHost') return applyRoot(hostSet.$lastHost);
|
|
58
|
+
if (selector === ':firstAppHost') return applyRoot(hostSet.$firstAppHost);
|
|
59
|
+
if (selector === ':lastAppHost') return applyRoot(hostSet.$lastAppHost);
|
|
44
60
|
|
|
45
61
|
// --- Special Selectors: Env ---
|
|
46
62
|
const config = getElementConfig(this);
|
|
47
63
|
const win = config?.window || window;
|
|
48
|
-
const doc = win.document;
|
|
49
|
-
|
|
50
64
|
if (selector === ':window') return win;
|
|
51
|
-
if (selector === ':document') return
|
|
52
|
-
if (
|
|
65
|
+
if (selector === ':document') return win.document;
|
|
66
|
+
if (selector === ':host') return applyRoot(this);
|
|
53
67
|
|
|
54
68
|
// --- Standard Selectors ---
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if (r === 'shadow') {
|
|
58
|
-
return this.shadowRoot ? this.shadowRoot.querySelector(selector) : null;
|
|
59
|
-
}
|
|
60
|
-
if (r === 'light') {
|
|
61
|
-
return this.querySelector(selector);
|
|
62
|
-
}
|
|
69
|
+
if (r === 'shadow') return this.shadowRoot ? this.shadowRoot.querySelector(selector) : null;
|
|
70
|
+
if (r === 'light') return this.querySelector(selector);
|
|
63
71
|
if (r === 'all') {
|
|
64
|
-
|
|
72
|
+
const shadowMatch = this.shadowRoot ? this.shadowRoot.querySelector(selector) : null;
|
|
73
|
+
return shadowMatch || this.querySelector(selector);
|
|
65
74
|
}
|
|
66
|
-
// auto
|
|
67
75
|
return (this.shadowRoot || this).querySelector(selector);
|
|
68
76
|
},
|
|
69
77
|
set(this: HTMLElement, nv: any) {
|
|
78
|
+
ensureInit(this);
|
|
70
79
|
if (nv === null || nv === undefined) {
|
|
80
|
+
const selector = selectorOrTarget;
|
|
81
|
+
if (selector.startsWith(':') && selector !== ':host') return;
|
|
82
|
+
|
|
71
83
|
const r = options.root || 'auto';
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
else
|
|
84
|
+
const targets: Element[] = [];
|
|
85
|
+
|
|
86
|
+
if (r === 'shadow') {
|
|
87
|
+
if (this.shadowRoot?.querySelector(selector)) targets.push(this.shadowRoot.querySelector(selector)!);
|
|
88
|
+
} else if (r === 'light') {
|
|
89
|
+
if (this.querySelector(selector)) targets.push(this.querySelector(selector)!);
|
|
90
|
+
} else if (r === 'all') {
|
|
91
|
+
if (this.shadowRoot?.querySelector(selector)) targets.push(this.shadowRoot.querySelector(selector)!);
|
|
92
|
+
if (this.querySelector(selector)) targets.push(this.querySelector(selector)!);
|
|
93
|
+
} else {
|
|
94
|
+
const el = (this.shadowRoot || this).querySelector(selector);
|
|
95
|
+
if (el) targets.push(el);
|
|
96
|
+
}
|
|
77
97
|
|
|
78
|
-
|
|
98
|
+
targets.forEach(t => t.remove());
|
|
79
99
|
}
|
|
80
100
|
},
|
|
81
101
|
enumerable: true,
|
|
@@ -1,72 +1,88 @@
|
|
|
1
|
-
import { ReflectUtils } from '@dooboostore/core
|
|
2
|
-
import { getElementConfig } from './elementDefine';
|
|
1
|
+
import { ReflectUtils } from '@dooboostore/core';
|
|
2
|
+
import { getElementConfig, ensureInit } from './elementDefine';
|
|
3
3
|
import { SwcUtils } from '../utils/Utils';
|
|
4
|
-
|
|
5
|
-
export interface QueryAllOptions {
|
|
6
|
-
root?: 'light' | 'shadow' | 'all' | 'auto';
|
|
7
|
-
}
|
|
4
|
+
import { SpecialSelector, SwcQueryOptions } from '../types';
|
|
8
5
|
|
|
9
6
|
export interface QueryAllMetadata {
|
|
10
|
-
selector: string;
|
|
11
|
-
options: QueryAllOptions;
|
|
12
7
|
propertyKey: string | symbol;
|
|
8
|
+
selector: string;
|
|
9
|
+
options: SwcQueryOptions;
|
|
13
10
|
}
|
|
14
11
|
|
|
15
12
|
export const QUERY_ALL_METADATA_KEY = Symbol('simple-web-component:query-all');
|
|
16
13
|
|
|
14
|
+
export function queryAll(target: SpecialSelector): PropertyDecorator;
|
|
15
|
+
export function queryAll(selector: string, options?: SwcQueryOptions): PropertyDecorator;
|
|
17
16
|
/**
|
|
18
17
|
* @queryAll decorator to inject a list of elements into a class property.
|
|
19
18
|
*/
|
|
20
|
-
export function queryAll(
|
|
21
|
-
return (
|
|
19
|
+
export function queryAll(selectorOrTarget: string, options: any = {}): PropertyDecorator {
|
|
20
|
+
return (targetObj: Object, propertyKey: string | symbol, descriptor?: never): void => {
|
|
22
21
|
if (descriptor !== undefined) {
|
|
23
22
|
throw new Error(`@queryAll decorator cannot be used on methods. (Method: ${String(propertyKey)})`);
|
|
24
23
|
}
|
|
25
24
|
|
|
26
|
-
const constructor =
|
|
25
|
+
const constructor = targetObj.constructor;
|
|
27
26
|
let queries = ReflectUtils.getMetadata<QueryAllMetadata[]>(QUERY_ALL_METADATA_KEY, constructor);
|
|
28
27
|
if (!queries) {
|
|
29
28
|
queries = [];
|
|
30
29
|
ReflectUtils.defineMetadata(QUERY_ALL_METADATA_KEY, queries, constructor);
|
|
31
30
|
}
|
|
32
|
-
queries.push({ selector, options
|
|
31
|
+
queries.push({ propertyKey, selector: selectorOrTarget, options });
|
|
33
32
|
|
|
34
|
-
Object.defineProperty(
|
|
33
|
+
Object.defineProperty(targetObj, propertyKey, {
|
|
35
34
|
get(this: HTMLElement) {
|
|
35
|
+
ensureInit(this);
|
|
36
|
+
const selector = selectorOrTarget;
|
|
37
|
+
|
|
38
|
+
const r = options.root || 'auto';
|
|
39
|
+
const applyRoot = (t: any): any[] => {
|
|
40
|
+
if (!t) return [];
|
|
41
|
+
const items = Array.isArray(t) ? t : [t];
|
|
42
|
+
const results: any[] = [];
|
|
43
|
+
items.forEach(it => {
|
|
44
|
+
if (!(it instanceof HTMLElement)) {
|
|
45
|
+
results.push(it);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (r === 'auto') results.push(it.shadowRoot || it);
|
|
49
|
+
else {
|
|
50
|
+
if (r === 'light' || r === 'all') results.push(it);
|
|
51
|
+
if ((r === 'shadow' || r === 'all') && it.shadowRoot) results.push(it.shadowRoot);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
return results;
|
|
55
|
+
};
|
|
56
|
+
|
|
36
57
|
// --- Special Selectors: HostSet ---
|
|
37
58
|
const hostSet = SwcUtils.getHostSet(this);
|
|
38
|
-
if (selector === ':hosts') return hostSet.$hosts;
|
|
39
|
-
if (selector === ':appHosts') return hostSet.$appHosts;
|
|
59
|
+
if (selector === ':hosts') return applyRoot(hostSet.$hosts);
|
|
60
|
+
if (selector === ':appHosts') return applyRoot(hostSet.$appHosts);
|
|
40
61
|
|
|
41
62
|
// --- Special Selectors: Env ---
|
|
42
63
|
const config = getElementConfig(this);
|
|
43
64
|
const win = config?.window || window;
|
|
44
|
-
const doc = win.document;
|
|
45
|
-
|
|
46
65
|
if (selector === ':window') return [win];
|
|
47
|
-
if (selector === ':document') return [
|
|
48
|
-
if (
|
|
66
|
+
if (selector === ':document') return [win.document];
|
|
67
|
+
if (selector === ':host') return applyRoot(this);
|
|
49
68
|
|
|
50
69
|
// --- Standard Selectors ---
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if (r === 'shadow') {
|
|
54
|
-
return this.shadowRoot ? this.shadowRoot.querySelectorAll(selector) : [];
|
|
55
|
-
}
|
|
56
|
-
if (r === 'light') {
|
|
57
|
-
return this.querySelectorAll(selector);
|
|
58
|
-
}
|
|
70
|
+
if (r === 'shadow') return this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];
|
|
71
|
+
if (r === 'light') return Array.from(this.querySelectorAll(selector));
|
|
59
72
|
if (r === 'all') {
|
|
60
73
|
const sNodes = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];
|
|
61
74
|
const lNodes = Array.from(this.querySelectorAll(selector));
|
|
62
75
|
return [...sNodes, ...lNodes];
|
|
63
76
|
}
|
|
64
|
-
// auto
|
|
65
77
|
const root = this.shadowRoot || this;
|
|
66
|
-
return root.querySelectorAll(selector);
|
|
78
|
+
return Array.from(root.querySelectorAll(selector));
|
|
67
79
|
},
|
|
68
80
|
set(this: HTMLElement, nv: any) {
|
|
81
|
+
ensureInit(this);
|
|
69
82
|
if (nv === null || nv === undefined || (Array.isArray(nv) && nv.length === 0)) {
|
|
83
|
+
const selector = selectorOrTarget;
|
|
84
|
+
if (selector.startsWith(':') && selector !== ':host') return;
|
|
85
|
+
|
|
70
86
|
const r = options.root || 'auto';
|
|
71
87
|
let targets: (Element | Node)[] = [];
|
|
72
88
|
if (r === 'shadow') targets = this.shadowRoot ? Array.from(this.shadowRoot.querySelectorAll(selector)) : [];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ReflectUtils } from '@dooboostore/core
|
|
1
|
+
import { ReflectUtils } from '@dooboostore/core';
|
|
2
|
+
import { ensureInit, getElementConfig } from './elementDefine';
|
|
2
3
|
|
|
3
4
|
export const REPLACE_CHILDREN_METADATA_KEY = Symbol('simple-web-component:replace-children');
|
|
4
5
|
|
|
@@ -7,7 +8,7 @@ export const REPLACE_CHILDREN_METADATA_KEY = Symbol('simple-web-component:replac
|
|
|
7
8
|
* Usage: @replaceChildren('#container') renderPart() { return '<div>New Content</div>'; }
|
|
8
9
|
*/
|
|
9
10
|
export function replaceChildren(selector: string): MethodDecorator {
|
|
10
|
-
return (target: Object, propertyKey: string | symbol) => {
|
|
11
|
+
return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {
|
|
11
12
|
const constructor = target.constructor;
|
|
12
13
|
let meta = ReflectUtils.getOwnMetadata(REPLACE_CHILDREN_METADATA_KEY, constructor) as Map<string | symbol, string>;
|
|
13
14
|
if (!meta) {
|
|
@@ -15,6 +16,34 @@ export function replaceChildren(selector: string): MethodDecorator {
|
|
|
15
16
|
ReflectUtils.defineMetadata(REPLACE_CHILDREN_METADATA_KEY, meta, constructor);
|
|
16
17
|
}
|
|
17
18
|
meta.set(propertyKey, selector);
|
|
19
|
+
|
|
20
|
+
const original = descriptor.value;
|
|
21
|
+
descriptor.value = async function (...args: any[]) {
|
|
22
|
+
ensureInit(this);
|
|
23
|
+
const res = await original.apply(this, args);
|
|
24
|
+
if (res !== undefined) {
|
|
25
|
+
const conf = getElementConfig(this);
|
|
26
|
+
const currentWin = (this as any)._resolveWindow?.(conf) || ((typeof window !== 'undefined' ? window : undefined) as Window);
|
|
27
|
+
const currentDoc = currentWin.document;
|
|
28
|
+
|
|
29
|
+
let targetEl: Element | null = null;
|
|
30
|
+
if (selector === ':host' || !selector) {
|
|
31
|
+
targetEl = this as any;
|
|
32
|
+
} else {
|
|
33
|
+
targetEl = (this.shadowRoot || (this as any)).querySelector(selector);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (targetEl) {
|
|
37
|
+
if (typeof res === 'string') {
|
|
38
|
+
targetEl.textContent = res;
|
|
39
|
+
} else {
|
|
40
|
+
const nodes: Node[] = Array.isArray(res) ? res.map(n => (typeof n === 'string' ? currentDoc.createTextNode(n) : n)) : [res as Node];
|
|
41
|
+
(targetEl as any).replaceChildren(...nodes);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return res;
|
|
46
|
+
};
|
|
18
47
|
};
|
|
19
48
|
}
|
|
20
49
|
|
|
@@ -1,27 +1,101 @@
|
|
|
1
|
-
import { ReflectUtils } from '@dooboostore/core
|
|
1
|
+
import { ReflectUtils } from '@dooboostore/core';
|
|
2
|
+
import { ensureInit, getElementConfig } from './elementDefine';
|
|
3
|
+
import { SwcUtils } from '../utils/Utils';
|
|
4
|
+
import { SwcQueryOptions } from '../types';
|
|
5
|
+
|
|
6
|
+
export interface SetAttributeMetadata {
|
|
7
|
+
propertyKey: string | symbol;
|
|
8
|
+
selector: string;
|
|
9
|
+
name: string;
|
|
10
|
+
options: SwcQueryOptions;
|
|
11
|
+
}
|
|
2
12
|
|
|
3
13
|
export const SET_ATTRIBUTE_METADATA_KEY = Symbol('simple-web-component:set-attribute');
|
|
4
14
|
|
|
5
|
-
|
|
6
|
-
|
|
15
|
+
/**
|
|
16
|
+
* @setAttribute decorator to surgically update an attribute of a target element.
|
|
17
|
+
* Usage: @setAttribute(':host', 'count')
|
|
18
|
+
* Usage: @setAttribute('#child', 'disabled')
|
|
19
|
+
*/
|
|
20
|
+
export function setAttribute(selector: string, name: string): MethodDecorator;
|
|
21
|
+
export function setAttribute(selector: string, name: string, options?: SwcQueryOptions): MethodDecorator;
|
|
22
|
+
export function setAttribute(selector: string, name: string, options: SwcQueryOptions = {}): MethodDecorator {
|
|
23
|
+
return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {
|
|
7
24
|
const constructor = target.constructor;
|
|
8
|
-
let
|
|
9
|
-
if (!
|
|
10
|
-
|
|
11
|
-
ReflectUtils.defineMetadata(SET_ATTRIBUTE_METADATA_KEY,
|
|
25
|
+
let metaList = ReflectUtils.getOwnMetadata(SET_ATTRIBUTE_METADATA_KEY, constructor) as Map<string | symbol, SetAttributeMetadata>;
|
|
26
|
+
if (!metaList) {
|
|
27
|
+
metaList = new Map<string | symbol, SetAttributeMetadata>();
|
|
28
|
+
ReflectUtils.defineMetadata(SET_ATTRIBUTE_METADATA_KEY, metaList, constructor);
|
|
12
29
|
}
|
|
13
|
-
|
|
30
|
+
metaList.set(propertyKey, { propertyKey, selector, name, options });
|
|
31
|
+
|
|
32
|
+
const original = descriptor.value;
|
|
33
|
+
descriptor.value = async function (...args: any[]) {
|
|
34
|
+
ensureInit(this);
|
|
35
|
+
const res = await original.apply(this, args);
|
|
36
|
+
if (res !== undefined) {
|
|
37
|
+
const hostSet = SwcUtils.getHostSet(this as any);
|
|
38
|
+
const conf = getElementConfig(this);
|
|
39
|
+
const currentWin = (this as any)._resolveWindow?.(conf) || ((typeof window !== 'undefined' ? window : undefined) as Window);
|
|
40
|
+
|
|
41
|
+
const targetEls: any[] = [];
|
|
42
|
+
const r = options.root || 'auto';
|
|
43
|
+
|
|
44
|
+
const applyRoot = (t: any) => {
|
|
45
|
+
if (!t) return;
|
|
46
|
+
if (r === 'auto') {
|
|
47
|
+
targetEls.push((t as any).shadowRoot || t);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (r === 'light' || r === 'all') targetEls.push(t);
|
|
51
|
+
if ((r === 'shadow' || r === 'all') && (t as any).shadowRoot) targetEls.push((t as any).shadowRoot);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
if (selector === ':window') targetEls.push(currentWin);
|
|
55
|
+
else if (selector === ':document') targetEls.push(currentWin.document as any);
|
|
56
|
+
else if (selector === ':parentHost') applyRoot(hostSet.$parentHost);
|
|
57
|
+
else if (selector === ':appHost') applyRoot(hostSet.$appHost);
|
|
58
|
+
else if (selector === ':firstHost') applyRoot(hostSet.$firstHost);
|
|
59
|
+
else if (selector === ':lastHost') applyRoot(hostSet.$lastHost);
|
|
60
|
+
else if (selector === ':firstAppHost') applyRoot(hostSet.$firstAppHost);
|
|
61
|
+
else if (selector === ':lastAppHost') applyRoot(hostSet.$lastAppHost);
|
|
62
|
+
else if (selector === ':hosts') hostSet.$hosts.forEach(applyRoot);
|
|
63
|
+
else if (selector === ':appHosts') hostSet.$appHosts.forEach(applyRoot);
|
|
64
|
+
else if (selector === ':host' || !selector) applyRoot(this);
|
|
65
|
+
else {
|
|
66
|
+
const roots: any[] = [];
|
|
67
|
+
if (r === 'shadow') {
|
|
68
|
+
if ((this as any).shadowRoot) roots.push((this as any).shadowRoot);
|
|
69
|
+
} else if (r === 'light') {
|
|
70
|
+
roots.push(this as any);
|
|
71
|
+
} else if (r === 'all') {
|
|
72
|
+
roots.push(this as any);
|
|
73
|
+
if ((this as any).shadowRoot) roots.push((this as any).shadowRoot);
|
|
74
|
+
} else {
|
|
75
|
+
roots.push((this as any).shadowRoot || (this as any));
|
|
76
|
+
}
|
|
77
|
+
roots.forEach(root => targetEls.push(...root.querySelectorAll(selector)));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
targetEls.forEach(targetEl => {
|
|
81
|
+
if (!targetEl || typeof (targetEl as any).setAttribute !== 'function') return;
|
|
82
|
+
if (res === null) (targetEl as any).removeAttribute(name);
|
|
83
|
+
else (targetEl as any).setAttribute(name, String(res));
|
|
84
|
+
})
|
|
85
|
+
}
|
|
86
|
+
return res;
|
|
87
|
+
};
|
|
14
88
|
};
|
|
15
89
|
}
|
|
16
90
|
|
|
17
|
-
export const getSetAttributeMetadata = (target: any): Map<string
|
|
91
|
+
export const getSetAttributeMetadata = (target: any): Map<string | symbol, SetAttributeMetadata> | undefined => {
|
|
18
92
|
const constructor = target instanceof Function ? target : target.constructor;
|
|
19
93
|
return ReflectUtils.getMetadata(SET_ATTRIBUTE_METADATA_KEY, constructor);
|
|
20
94
|
};
|
|
21
95
|
|
|
22
|
-
export const findAllSetAttributeMetadata = (target: any): Map<string
|
|
23
|
-
const result = new Map<string
|
|
24
|
-
const maps = ReflectUtils.findAllMetadata<
|
|
96
|
+
export const findAllSetAttributeMetadata = (target: any): Map<string | symbol, SetAttributeMetadata> => {
|
|
97
|
+
const result = new Map<string | symbol, SetAttributeMetadata>();
|
|
98
|
+
const maps = ReflectUtils.findAllMetadata<Map<string | symbol, SetAttributeMetadata>>(SET_ATTRIBUTE_METADATA_KEY, target);
|
|
25
99
|
maps.forEach(map => {
|
|
26
100
|
if (map instanceof Map) {
|
|
27
101
|
map.forEach((v, k) => result.set(k, v));
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { ReflectUtils } from '@dooboostore/core';
|
|
2
|
+
import { ensureInit } from './elementDefine';
|
|
3
|
+
import { SwcUtils } from '../utils/Utils';
|
|
4
|
+
|
|
5
|
+
export type StyleAction = 'set' | 'update' | 'remove';
|
|
6
|
+
|
|
7
|
+
export interface StyleMetadata {
|
|
8
|
+
propertyKey: string | symbol;
|
|
9
|
+
selector: string;
|
|
10
|
+
action: StyleAction;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const STYLE_METADATA_KEY = Symbol('simple-web-component:style');
|
|
14
|
+
|
|
15
|
+
function createStyleDecorator(action: StyleAction) {
|
|
16
|
+
return (selector: string): MethodDecorator => {
|
|
17
|
+
return (target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {
|
|
18
|
+
const constructor = target.constructor;
|
|
19
|
+
let metaList = ReflectUtils.getOwnMetadata(STYLE_METADATA_KEY, constructor) as Map<string | symbol, StyleMetadata>;
|
|
20
|
+
if (!metaList) {
|
|
21
|
+
metaList = new Map<string | symbol, StyleMetadata>();
|
|
22
|
+
ReflectUtils.defineMetadata(STYLE_METADATA_KEY, metaList, constructor);
|
|
23
|
+
}
|
|
24
|
+
metaList.set(propertyKey, { propertyKey, selector, action });
|
|
25
|
+
|
|
26
|
+
const original = descriptor.value;
|
|
27
|
+
descriptor.value = async function (...args: any[]) {
|
|
28
|
+
ensureInit(this);
|
|
29
|
+
const res = await original.apply(this, args);
|
|
30
|
+
if (res !== undefined) {
|
|
31
|
+
const hostSet = SwcUtils.getHostSet(this as any);
|
|
32
|
+
let targetEl: HTMLElement | null = null;
|
|
33
|
+
if (selector === ':host' || !selector) targetEl = this as any;
|
|
34
|
+
else if (selector === ':parentHost') targetEl = hostSet.$parentHost;
|
|
35
|
+
else if (selector === ':appHost') targetEl = hostSet.$appHost;
|
|
36
|
+
else targetEl = (this.shadowRoot || (this as any)).querySelector(selector);
|
|
37
|
+
|
|
38
|
+
if (targetEl) {
|
|
39
|
+
if (action === 'set') {
|
|
40
|
+
targetEl.style.cssText = '';
|
|
41
|
+
if (typeof res === 'object' && res !== null) {
|
|
42
|
+
Object.assign(targetEl.style, res);
|
|
43
|
+
} else if (typeof res === 'string') {
|
|
44
|
+
targetEl.style.cssText = res;
|
|
45
|
+
}
|
|
46
|
+
} else if (action === 'update') {
|
|
47
|
+
if (typeof res === 'object' && res !== null) {
|
|
48
|
+
Object.assign(targetEl.style, res);
|
|
49
|
+
}
|
|
50
|
+
} else if (action === 'remove') {
|
|
51
|
+
const props = Array.isArray(res) ? res : [res];
|
|
52
|
+
props.forEach(p => targetEl!.style.removeProperty(String(p)));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return res;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* @setStyle decorator to surgically set styles on a target element (replaces all existing styles).
|
|
64
|
+
* Usage: @setStyle('#box') getStyles() { return { color: 'red', display: 'block' }; }
|
|
65
|
+
*/
|
|
66
|
+
export const setStyle = createStyleDecorator('set');
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* @updateStyle decorator to surgically update styles on a target element (merges with existing styles).
|
|
70
|
+
* Usage: @updateStyle('#box') updateStyles() { return { color: 'blue' }; }
|
|
71
|
+
*/
|
|
72
|
+
export const updateStyle = createStyleDecorator('update');
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* @removeStyle decorator to surgically remove styles from a target element.
|
|
76
|
+
* Usage: @removeStyle('#box') clearStyles() { return ['color', 'display']; }
|
|
77
|
+
*/
|
|
78
|
+
export const removeStyle = createStyleDecorator('remove');
|
|
79
|
+
|
|
80
|
+
export const findAllStyleMetadata = (target: any): Map<string | symbol, StyleMetadata> => {
|
|
81
|
+
const result = new Map<string | symbol, StyleMetadata>();
|
|
82
|
+
const maps = ReflectUtils.findAllMetadata<Map<string | symbol, StyleMetadata>>(STYLE_METADATA_KEY, target);
|
|
83
|
+
maps.forEach(map => {
|
|
84
|
+
if (map instanceof Map) {
|
|
85
|
+
map.forEach((v, k) => result.set(k, v));
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
return result;
|
|
89
|
+
};
|