@kerfjs/ui 5.0.0-beta.122 → 5.0.0-beta.124
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 +28 -5
- package/ai/application-ui-diagnostic-ids-v1.json +25 -1
- package/ai/application-ui-profile-sync.cjs +16 -8
- package/ai/application-ui-profile.d.ts +2 -0
- package/ai/application-ui-profile.defaults.json +6 -2
- package/ai/application-ui-profile.mjs +16 -8
- package/ai/application-ui-profile.schema.json +133 -38
- package/ai/component-catalog.json +1501 -218
- package/ai/component-catalog.schema.json +19 -0
- package/ai/component-composition-rules.json +18 -2
- package/ai/component-composition.d.ts +13 -0
- package/ai/component-composition.json +684 -27
- package/ai/component-composition.schema.json +58 -0
- package/ai/component-props-overlay.json +952 -0
- package/ai/component-props-overlay.schema.json +68 -0
- package/ai/component-props.json +29624 -0
- package/ai/component-props.schema.json +401 -0
- package/ai/components/README.md +12 -5
- package/ai/components/application-tabs.md +2 -2
- package/ai/components/backdrop-image.md +2 -1
- package/ai/components/button.md +12 -6
- package/ai/components/checkbox-group.md +2 -0
- package/ai/components/checkbox.md +2 -0
- package/ai/components/chip.md +2 -0
- package/ai/components/choice-chips.md +5 -1
- package/ai/components/color-field.md +2 -0
- package/ai/components/color-picker.md +2 -0
- package/ai/components/color-swatches.md +2 -0
- package/ai/components/column-explorer.md +89 -0
- package/ai/components/column-track.md +3 -2
- package/ai/components/combobox.md +2 -0
- package/ai/components/content-item.md +7 -2
- package/ai/components/disclosure.md +2 -0
- package/ai/components/file-picker.md +5 -2
- package/ai/components/form.md +86 -0
- package/ai/components/foundation.md +1 -1
- package/ai/components/list-action-row.md +2 -0
- package/ai/components/list-detail-dialog.md +2 -0
- package/ai/components/list-header.md +2 -0
- package/ai/components/list-item.md +4 -0
- package/ai/components/list.md +6 -2
- package/ai/components/message-composer.md +3 -1
- package/ai/components/nav-stack.md +2 -0
- package/ai/components/paged-view.md +89 -0
- package/ai/components/pane.md +4 -1
- package/ai/components/popup-menu.md +5 -2
- package/ai/components/radio-group.md +2 -0
- package/ai/components/recipe-composer-form.md +2 -2
- package/ai/components/scroll-effect.md +84 -0
- package/ai/components/search-field.md +2 -0
- package/ai/components/segmented-control.md +2 -0
- package/ai/components/select.md +4 -0
- package/ai/components/sized-region.md +86 -0
- package/ai/components/slider.md +2 -0
- package/ai/components/split-button.md +3 -1
- package/ai/components/split-view.md +1 -1
- package/ai/components/state-banner.md +2 -0
- package/ai/components/summary-row.md +14 -8
- package/ai/components/surface-scaffold.md +5 -3
- package/ai/components/switch.md +2 -0
- package/ai/components/tab-bar.md +5 -2
- package/ai/components/tab-navigator.md +2 -0
- package/ai/components/tab-panel.md +84 -0
- package/ai/components/tabs.md +9 -6
- package/ai/components/tag-field.md +2 -0
- package/ai/components/text-field.md +2 -0
- package/ai/components/text.md +3 -0
- package/ai/components/toolbar-control-group.md +10 -3
- package/ai/components/toolbar-text.md +2 -0
- package/ai/components/toolbar.md +4 -3
- package/ai/components/tree-list.md +95 -0
- package/ai/components/wa-accordion-item.md +2 -0
- package/ai/components/wa-breadcrumb-item.md +2 -0
- package/ai/components/wa-button.md +2 -0
- package/ai/components/wa-carousel.md +2 -0
- package/ai/components/wa-checkbox.md +2 -0
- package/ai/components/wa-color-picker.md +2 -0
- package/ai/components/wa-comparison.md +2 -0
- package/ai/components/wa-copy-button.md +2 -0
- package/ai/components/wa-details.md +2 -0
- package/ai/components/wa-dialog.md +2 -0
- package/ai/components/wa-drawer.md +2 -0
- package/ai/components/wa-dropdown-item.md +2 -0
- package/ai/components/wa-input.md +2 -0
- package/ai/components/wa-known-date.md +2 -0
- package/ai/components/wa-number-input.md +2 -0
- package/ai/components/wa-otp-input.md +2 -0
- package/ai/components/wa-pagination.md +2 -0
- package/ai/components/wa-radio.md +2 -0
- package/ai/components/wa-rating.md +2 -0
- package/ai/components/wa-select.md +2 -0
- package/ai/components/wa-slider.md +2 -0
- package/ai/components/wa-switch.md +2 -0
- package/ai/components/wa-tab-panel.md +5 -5
- package/ai/components/wa-tab.md +2 -0
- package/ai/components/wa-tag-input.md +2 -0
- package/ai/components/wa-textarea.md +2 -0
- package/ai/components/wa-time-input.md +2 -0
- package/ai/components/wa-tree-item.md +12 -5
- package/ai/components/wa-tree.md +10 -5
- package/ai/components/wa-zoomable-frame.md +2 -0
- package/ai/components/workbench-dialog.md +2 -0
- package/ai/public-api-signatures-v1.md +1251 -132
- package/ai/skill.md +107 -40
- package/ai/view-document.schema.json +360 -0
- package/ai/webawesome-jsx-signatures-v1.md +1 -1
- package/analyzer/index.mjs +89 -1
- package/dist/anchor-name-BZ1rpxaw.d.ts +4 -0
- package/dist/backdrop-image.d.ts +6 -2
- package/dist/backdrop-image.js +2 -1
- package/dist/badge.js +1 -1
- package/dist/browser/backdrop-image.js +1 -0
- package/dist/browser/catalog.js +1 -1
- package/dist/browser/collapsible-panel.js +1 -0
- package/dist/browser/column-explorer.js +9 -0
- package/dist/browser/content-item.js +1 -0
- package/dist/browser/editor.js +45 -0
- package/dist/browser/form.js +3 -0
- package/dist/browser/list-detail-dialog.js +1 -0
- package/dist/browser/nav-stack.js +1 -0
- package/dist/browser/paged-view.js +3 -0
- package/dist/browser/scroll-effect.js +3 -0
- package/dist/browser/sized-region.js +3 -0
- package/dist/browser/split-view.js +1 -0
- package/dist/browser/tab-panel.js +3 -0
- package/dist/browser/toolbar-control-group.js +1 -0
- package/dist/browser/tree-list.js +7 -0
- package/dist/browser/workbench-dialog.js +1 -0
- package/dist/browser/workbench.js +1 -0
- package/dist/button.d.ts +54 -13
- package/dist/button.js +2 -1
- package/dist/catalog-resources.d.ts +3 -2
- package/dist/catalog.d.ts +3 -2
- package/dist/catalog.js +21 -17
- package/dist/catalog.js.map +1 -1
- package/dist/checkbox-group.js +1 -1
- package/dist/checkbox.js +1 -1
- package/dist/chip.js +1 -1
- package/dist/choice-chips.d.ts +21 -2
- package/dist/choice-chips.js +2 -1
- package/dist/{chunk-3WWX2O4G.js → chunk-2E7S5C4D.js} +5 -46
- package/dist/chunk-2E7S5C4D.js.map +1 -0
- package/dist/{chunk-QYMJHS4K.js → chunk-34FWYJX6.js} +9 -3
- package/dist/chunk-34FWYJX6.js.map +1 -0
- package/dist/{chunk-OUCHU7JB.js → chunk-3JOEJT2Z.js} +7 -7
- package/dist/{chunk-OUCHU7JB.js.map → chunk-3JOEJT2Z.js.map} +1 -1
- package/dist/chunk-3S3WXAZ5.js +207 -0
- package/dist/chunk-3S3WXAZ5.js.map +1 -0
- package/dist/{chunk-AN5IWMTM.js → chunk-3TBMGGTA.js} +6 -3
- package/dist/chunk-3TBMGGTA.js.map +1 -0
- package/dist/{chunk-3Z7N2NAZ.js → chunk-3XSY5LAB.js} +4 -4
- package/dist/{chunk-3Z7N2NAZ.js.map → chunk-3XSY5LAB.js.map} +1 -1
- package/dist/chunk-44AOBT2F.js +16 -0
- package/dist/chunk-44AOBT2F.js.map +1 -0
- package/dist/{chunk-7AK5I7U7.js → chunk-4IXG6XCT.js} +18 -3
- package/dist/chunk-4IXG6XCT.js.map +1 -0
- package/dist/chunk-4K7XXSOX.js +21 -0
- package/dist/chunk-4K7XXSOX.js.map +1 -0
- package/dist/{chunk-LZUUUHNH.js → chunk-4Z4QSTRF.js} +20 -3
- package/dist/chunk-4Z4QSTRF.js.map +1 -0
- package/dist/{chunk-QH5KOFNS.js → chunk-5KWXM5O7.js} +15 -3
- package/dist/chunk-5KWXM5O7.js.map +1 -0
- package/dist/{chunk-EYDXFOSH.js → chunk-5SFHBYEY.js} +2 -2
- package/dist/chunk-5SFHBYEY.js.map +1 -0
- package/dist/{chunk-HU5IHXCI.js → chunk-6BXPN5SC.js} +3 -3
- package/dist/{chunk-HU5IHXCI.js.map → chunk-6BXPN5SC.js.map} +1 -1
- package/dist/{chunk-6VVIW7VB.js → chunk-73LC3JAL.js} +13 -4
- package/dist/chunk-73LC3JAL.js.map +1 -0
- package/dist/{chunk-IO27YTL3.js → chunk-76VCWWUA.js} +2 -2
- package/dist/{chunk-IO27YTL3.js.map → chunk-76VCWWUA.js.map} +1 -1
- package/dist/{chunk-ETFP7HAR.js → chunk-7AUZG5EW.js} +13 -4
- package/dist/chunk-7AUZG5EW.js.map +1 -0
- package/dist/{chunk-3V4OCDTL.js → chunk-7DIWVGGA.js} +2 -14
- package/dist/chunk-7DIWVGGA.js.map +1 -0
- package/dist/chunk-7KN5OQVN.js +157 -0
- package/dist/chunk-7KN5OQVN.js.map +1 -0
- package/dist/chunk-7QQ3HE47.js +17 -0
- package/dist/chunk-7QQ3HE47.js.map +1 -0
- package/dist/{chunk-HJWFHJ3Z.js → chunk-ADMWT7FX.js} +28 -82
- package/dist/chunk-ADMWT7FX.js.map +1 -0
- package/dist/{chunk-LMHN2TJL.js → chunk-BCHK33XL.js} +2 -2
- package/dist/{chunk-LMHN2TJL.js.map → chunk-BCHK33XL.js.map} +1 -1
- package/dist/chunk-BCO673YW.js +123 -0
- package/dist/chunk-BCO673YW.js.map +1 -0
- package/dist/{chunk-OQP3PFKQ.js → chunk-BZXA5SSA.js} +90 -33
- package/dist/chunk-BZXA5SSA.js.map +1 -0
- package/dist/{chunk-LTBVP6VN.js → chunk-C4FBYP2D.js} +2 -2
- package/dist/{chunk-LTBVP6VN.js.map → chunk-C4FBYP2D.js.map} +1 -1
- package/dist/{chunk-AMIHGFLP.js → chunk-CCPWJDRW.js} +4 -2
- package/dist/chunk-CCPWJDRW.js.map +1 -0
- package/dist/{chunk-S4Y3YTAI.js → chunk-CJAKN2KZ.js} +2 -2
- package/dist/{chunk-S4Y3YTAI.js.map → chunk-CJAKN2KZ.js.map} +1 -1
- package/dist/chunk-CKPI4WIN.js +58 -0
- package/dist/chunk-CKPI4WIN.js.map +1 -0
- package/dist/{chunk-HJXVVFBT.js → chunk-CMG4OZPV.js} +13 -2
- package/dist/chunk-CMG4OZPV.js.map +1 -0
- package/dist/{chunk-KH4KEMSP.js → chunk-COQI4OMZ.js} +1 -1
- package/dist/chunk-COQI4OMZ.js.map +1 -0
- package/dist/{chunk-G3J7JDP6.js → chunk-CPTQABDQ.js} +10 -3
- package/dist/chunk-CPTQABDQ.js.map +1 -0
- package/dist/{chunk-TI2GV36S.js → chunk-CRHKWHTA.js} +4 -4
- package/dist/{chunk-TI2GV36S.js.map → chunk-CRHKWHTA.js.map} +1 -1
- package/dist/{chunk-3KFMLOTH.js → chunk-DBP3N6E5.js} +8 -5
- package/dist/chunk-DBP3N6E5.js.map +1 -0
- package/dist/chunk-DJ65XFVN.js +231 -0
- package/dist/chunk-DJ65XFVN.js.map +1 -0
- package/dist/chunk-DKPYHVIV.js +13 -0
- package/dist/chunk-DKPYHVIV.js.map +1 -0
- package/dist/{chunk-ITUQC4FW.js → chunk-DV6GE57V.js} +31 -3
- package/dist/chunk-DV6GE57V.js.map +1 -0
- package/dist/{chunk-S3ECMF23.js → chunk-E7Q6UNCB.js} +11 -3
- package/dist/chunk-E7Q6UNCB.js.map +1 -0
- package/dist/{chunk-C26Q6P4Q.js → chunk-E7ZRBMVQ.js} +3 -3
- package/dist/{chunk-C26Q6P4Q.js.map → chunk-E7ZRBMVQ.js.map} +1 -1
- package/dist/chunk-ECVTRAXN.js +37 -0
- package/dist/chunk-ECVTRAXN.js.map +1 -0
- package/dist/{chunk-EIET4QLK.js → chunk-EHR7R7YP.js} +14 -3
- package/dist/chunk-EHR7R7YP.js.map +1 -0
- package/dist/{chunk-5J6Z4BWY.js → chunk-EXGDKG7B.js} +127 -5
- package/dist/chunk-EXGDKG7B.js.map +1 -0
- package/dist/{chunk-7K6U6FCN.js → chunk-F34LHBQI.js} +47 -12
- package/dist/chunk-F34LHBQI.js.map +1 -0
- package/dist/{chunk-IIQ2XIMU.js → chunk-F3PZGFEA.js} +32 -11
- package/dist/chunk-F3PZGFEA.js.map +1 -0
- package/dist/{chunk-3OP66VXU.js → chunk-FJMABKKV.js} +5 -3
- package/dist/chunk-FJMABKKV.js.map +1 -0
- package/dist/{chunk-B53PS2LE.js → chunk-FNJA4S6J.js} +7 -3
- package/dist/chunk-FNJA4S6J.js.map +1 -0
- package/dist/{chunk-YMUIQRWK.js → chunk-FQETQ7CM.js} +6 -2
- package/dist/chunk-FQETQ7CM.js.map +1 -0
- package/dist/{chunk-KCS6NJ3O.js → chunk-FR5G77K5.js} +2 -2
- package/dist/{chunk-KCS6NJ3O.js.map → chunk-FR5G77K5.js.map} +1 -1
- package/dist/chunk-GVII4JSD.js +153 -0
- package/dist/chunk-GVII4JSD.js.map +1 -0
- package/dist/chunk-HPOXLOVC.js +184 -0
- package/dist/chunk-HPOXLOVC.js.map +1 -0
- package/dist/{chunk-EKHDLBRP.js → chunk-JAC6AVZN.js} +21 -3
- package/dist/chunk-JAC6AVZN.js.map +1 -0
- package/dist/{chunk-CTQUDCY5.js → chunk-JG4ONAOI.js} +4 -2
- package/dist/{chunk-CTQUDCY5.js.map → chunk-JG4ONAOI.js.map} +1 -1
- package/dist/{chunk-K67XBCHG.js → chunk-JHUEYWWI.js} +6 -4
- package/dist/chunk-JHUEYWWI.js.map +1 -0
- package/dist/{chunk-GS2QD3N7.js → chunk-JZZVWTUB.js} +2 -2
- package/dist/{chunk-GS2QD3N7.js.map → chunk-JZZVWTUB.js.map} +1 -1
- package/dist/{chunk-XRZSK2WC.js → chunk-KACJOE2N.js} +16 -5
- package/dist/chunk-KACJOE2N.js.map +1 -0
- package/dist/chunk-KELWWCMX.js +426 -0
- package/dist/chunk-KELWWCMX.js.map +1 -0
- package/dist/{chunk-KDQZ3E5C.js → chunk-KLR3DCHH.js} +58 -4
- package/dist/chunk-KLR3DCHH.js.map +1 -0
- package/dist/{chunk-S3DCRI2M.js → chunk-LD6A6PYB.js} +43 -5
- package/dist/chunk-LD6A6PYB.js.map +1 -0
- package/dist/{chunk-BKUMG2KB.js → chunk-LET362AM.js} +13 -3
- package/dist/chunk-LET362AM.js.map +1 -0
- package/dist/{chunk-C2ZO3OZZ.js → chunk-LOW7J7SE.js} +4 -4
- package/dist/chunk-LOW7J7SE.js.map +1 -0
- package/dist/{chunk-ITENVZ6Q.js → chunk-M72QLDUO.js} +13 -4
- package/dist/chunk-M72QLDUO.js.map +1 -0
- package/dist/{chunk-OHPYT2BH.js → chunk-MLDO7WLA.js} +2 -2
- package/dist/{chunk-OHPYT2BH.js.map → chunk-MLDO7WLA.js.map} +1 -1
- package/dist/{chunk-D5RGM3XA.js → chunk-NA4LKVPX.js} +12 -2
- package/dist/chunk-NA4LKVPX.js.map +1 -0
- package/dist/chunk-NR3ZO4LK.js +67 -0
- package/dist/chunk-NR3ZO4LK.js.map +1 -0
- package/dist/{chunk-YPAQFBMN.js → chunk-NYNNNEAU.js} +44 -10
- package/dist/chunk-NYNNNEAU.js.map +1 -0
- package/dist/chunk-OKZTLRGG.js +34 -0
- package/dist/chunk-OKZTLRGG.js.map +1 -0
- package/dist/{chunk-ZX2QQJXD.js → chunk-PVKAIVKE.js} +95 -61
- package/dist/chunk-PVKAIVKE.js.map +1 -0
- package/dist/{chunk-Y6KT7ZTR.js → chunk-Q2CLQ3IJ.js} +21 -3
- package/dist/chunk-Q2CLQ3IJ.js.map +1 -0
- package/dist/{chunk-2J7XKAZX.js → chunk-Q2SLOMN6.js} +7 -6
- package/dist/chunk-Q2SLOMN6.js.map +1 -0
- package/dist/{chunk-S2XULQEK.js → chunk-Q5BPZPCO.js} +2 -2
- package/dist/{chunk-S2XULQEK.js.map → chunk-Q5BPZPCO.js.map} +1 -1
- package/dist/{chunk-BSNKDW4X.js → chunk-Q7RILH2D.js} +14 -9
- package/dist/chunk-Q7RILH2D.js.map +1 -0
- package/dist/chunk-QR7MGGOM.js +49 -0
- package/dist/chunk-QR7MGGOM.js.map +1 -0
- package/dist/{chunk-PS24PVR6.js → chunk-QXXLDY6I.js} +50 -10
- package/dist/chunk-QXXLDY6I.js.map +1 -0
- package/dist/chunk-QY77Q7RY.js +129 -0
- package/dist/chunk-QY77Q7RY.js.map +1 -0
- package/dist/{chunk-4OV272LF.js → chunk-R6FIXYAE.js} +4 -4
- package/dist/{chunk-4OV272LF.js.map → chunk-R6FIXYAE.js.map} +1 -1
- package/dist/{chunk-N2K3QGSX.js → chunk-RGB4DPMN.js} +16 -3
- package/dist/chunk-RGB4DPMN.js.map +1 -0
- package/dist/{chunk-TKNVL53O.js → chunk-RPJOLDSR.js} +11 -3
- package/dist/chunk-RPJOLDSR.js.map +1 -0
- package/dist/chunk-SBCXWGNP.js +256 -0
- package/dist/chunk-SBCXWGNP.js.map +1 -0
- package/dist/{chunk-WPNIKZMJ.js → chunk-SJBMKA4X.js} +2 -2
- package/dist/{chunk-WPNIKZMJ.js.map → chunk-SJBMKA4X.js.map} +1 -1
- package/dist/{chunk-RMWNO6BA.js → chunk-SNUDT6AX.js} +2 -2
- package/dist/{chunk-RMWNO6BA.js.map → chunk-SNUDT6AX.js.map} +1 -1
- package/dist/{chunk-NR6O74ST.js → chunk-SPI6VMIY.js} +14 -10
- package/dist/chunk-SPI6VMIY.js.map +1 -0
- package/dist/{chunk-ZN7KUMPY.js → chunk-SWXWLSUD.js} +17 -3
- package/dist/chunk-SWXWLSUD.js.map +1 -0
- package/dist/chunk-TBVSPSGX.js +14 -0
- package/dist/chunk-TBVSPSGX.js.map +1 -0
- package/dist/{chunk-UMNHJSIO.js → chunk-TPLVC5BE.js} +2 -2
- package/dist/{chunk-UMNHJSIO.js.map → chunk-TPLVC5BE.js.map} +1 -1
- package/dist/chunk-TRJS7M2H.js +39 -0
- package/dist/chunk-TRJS7M2H.js.map +1 -0
- package/dist/chunk-TXBNPEIJ.js +31 -0
- package/dist/chunk-TXBNPEIJ.js.map +1 -0
- package/dist/{chunk-VEME3D7K.js → chunk-UD5KHQOH.js} +27 -3
- package/dist/chunk-UD5KHQOH.js.map +1 -0
- package/dist/{chunk-5CLMV5YU.js → chunk-UPHPFKAD.js} +54 -18
- package/dist/chunk-UPHPFKAD.js.map +1 -0
- package/dist/{chunk-WVS6CUCT.js → chunk-V3IXAI4L.js} +6 -2
- package/dist/chunk-V3IXAI4L.js.map +1 -0
- package/dist/{chunk-CVD5IZGB.js → chunk-VBXKYT4O.js} +7 -2
- package/dist/chunk-VBXKYT4O.js.map +1 -0
- package/dist/{chunk-OZ6X76G5.js → chunk-VNT4MXR5.js} +4 -3
- package/dist/chunk-VNT4MXR5.js.map +1 -0
- package/dist/{chunk-K57NINLH.js → chunk-VPDSPD76.js} +54 -1
- package/dist/chunk-VPDSPD76.js.map +1 -0
- package/dist/chunk-VX3YF2UD.js +77 -0
- package/dist/chunk-VX3YF2UD.js.map +1 -0
- package/dist/chunk-WCMGPAY2.js +103 -0
- package/dist/chunk-WCMGPAY2.js.map +1 -0
- package/dist/{chunk-DZJ4GBSP.js → chunk-WSPXSWFG.js} +21 -4
- package/dist/chunk-WSPXSWFG.js.map +1 -0
- package/dist/{chunk-NB6POCFH.js → chunk-WVQDIOD7.js} +56 -11
- package/dist/chunk-WVQDIOD7.js.map +1 -0
- package/dist/{chunk-F653O57X.js → chunk-Y4VR6VNM.js} +6 -3
- package/dist/chunk-Y4VR6VNM.js.map +1 -0
- package/dist/{chunk-CEJ5FK6G.js → chunk-YHRJNKD5.js} +2 -2
- package/dist/{chunk-CEJ5FK6G.js.map → chunk-YHRJNKD5.js.map} +1 -1
- package/dist/{chunk-XWNXGFX3.js → chunk-Z3T24FX3.js} +2 -2
- package/dist/{chunk-XWNXGFX3.js.map → chunk-Z3T24FX3.js.map} +1 -1
- package/dist/collapsible-panel.d.ts +10 -3
- package/dist/collapsible-panel.js +45 -5
- package/dist/collapsible-panel.js.map +1 -1
- package/dist/color-field.js +2 -2
- package/dist/color-picker.js +1 -1
- package/dist/color-swatches.js +1 -1
- package/dist/column-explorer.d.ts +67 -0
- package/dist/column-explorer.js +140 -0
- package/dist/column-explorer.js.map +1 -0
- package/dist/column-track.d.ts +12 -3
- package/dist/column-track.js +1 -1
- package/dist/combobox.d.ts +5 -1
- package/dist/combobox.js +2 -1
- package/dist/content-item.d.ts +14 -4
- package/dist/content-item.js +2 -1
- package/dist/content-swap.d.ts +5 -1
- package/dist/content-swap.js +2 -1
- package/dist/corner-status.d.ts +5 -1
- package/dist/corner-status.js +2 -1
- package/dist/device-class.js +1 -101
- package/dist/device-class.js.map +1 -1
- package/dist/disclosure-arrow.d.ts +5 -1
- package/dist/disclosure-arrow.js +2 -1
- package/dist/disclosure.js +2 -2
- package/dist/edge-activity-indicator.d.ts +5 -1
- package/dist/edge-activity-indicator.js +2 -1
- package/dist/editor.d.ts +344 -0
- package/dist/editor.js +10076 -0
- package/dist/editor.js.map +1 -0
- package/dist/empty-state.d.ts +5 -1
- package/dist/empty-state.js +2 -1
- package/dist/{extension-attributes-mu8MFUl0.d.ts → extension-attributes-IJ4decoa.d.ts} +7 -1
- package/dist/file-picker.d.ts +25 -4
- package/dist/file-picker.js +2 -1
- package/dist/floating-toolbar.d.ts +5 -1
- package/dist/floating-toolbar.js +2 -1
- package/dist/form.d.ts +45 -0
- package/dist/form.js +4 -0
- package/dist/form.js.map +1 -0
- package/dist/framed-list.js +1 -1
- package/dist/grid.js +1 -1
- package/dist/index.d.ts +14 -7
- package/dist/index.js +82 -70
- package/dist/list-action-row.d.ts +1 -1
- package/dist/list-action-row.js +2 -1
- package/dist/list-detail-dialog.d.ts +10 -3
- package/dist/list-detail-dialog.js +15 -11
- package/dist/list-detail-dialog.js.map +1 -1
- package/dist/list-header.d.ts +11 -3
- package/dist/list-header.js +1 -1
- package/dist/list-inset-control.d.ts +5 -1
- package/dist/list-inset-control.js +2 -1
- package/dist/list-inset-text.js +1 -1
- package/dist/list-item.js +3 -1
- package/dist/list.d.ts +130 -11
- package/dist/list.js +1 -1
- package/dist/loading-spinner.d.ts +5 -1
- package/dist/loading-spinner.js +2 -1
- package/dist/lucide-icon.d.ts +5 -1
- package/dist/lucide-icon.js +2 -1
- package/dist/message-composer.js +1 -1
- package/dist/{nav-stack-CrZF95VO.d.ts → nav-stack-DwxpXxqJ.d.ts} +13 -2
- package/dist/nav-stack.d.ts +3 -2
- package/dist/nav-stack.js +4 -1
- package/dist/paged-view.d.ts +47 -0
- package/dist/paged-view.js +86 -0
- package/dist/paged-view.js.map +1 -0
- package/dist/pane.d.ts +42 -5
- package/dist/pane.js +2 -1
- package/dist/popup-menu-register.js +1 -1
- package/dist/popup-menu.d.ts +42 -2
- package/dist/popup-menu.js +2 -1
- package/dist/progress-bar.js +1 -1
- package/dist/progress-ring.js +1 -1
- package/dist/radio-group.js +1 -1
- package/dist/resizable-region.d.ts +5 -1
- package/dist/resizable-region.js +2 -1
- package/dist/row.d.ts +7 -2
- package/dist/row.js +1 -1
- package/dist/scroll-effect.d.ts +86 -0
- package/dist/scroll-effect.js +5 -0
- package/dist/scroll-effect.js.map +1 -0
- package/dist/{search-field-CrGTN5sa.d.ts → search-field-5lNIszda.d.ts} +5 -1
- package/dist/search-field-model.d.ts +2 -1
- package/dist/search-field.d.ts +2 -1
- package/dist/search-field.js +2 -1
- package/dist/segmented-control.d.ts +5 -1
- package/dist/segmented-control.js +2 -1
- package/dist/select-register.js +9 -2
- package/dist/select-register.js.map +1 -1
- package/dist/select.d.ts +22 -1
- package/dist/select.js +1 -1
- package/dist/sized-region.d.ts +44 -0
- package/dist/sized-region.js +4 -0
- package/dist/sized-region.js.map +1 -0
- package/dist/skeleton.d.ts +5 -1
- package/dist/skeleton.js +2 -1
- package/dist/slider.js +1 -1
- package/dist/spacer.d.ts +5 -1
- package/dist/spacer.js +2 -1
- package/dist/split-button.js +1 -1
- package/dist/split-view.d.ts +7 -3
- package/dist/split-view.js +4 -1
- package/dist/state-banner.d.ts +7 -0
- package/dist/state-banner.js +1 -1
- package/dist/styles/backdrop-image.css +136 -70
- package/dist/styles/badge.css +31 -0
- package/dist/styles/button.css +103 -0
- package/dist/styles/choice-chips.css +45 -0
- package/dist/styles/column-explorer.css +6 -0
- package/dist/styles/components/actions/button/button.css +103 -0
- package/dist/styles/components/actions/popup-menu/popup-menu.css +154 -1
- package/dist/styles/components/actions/toolbar/toolbar.css +19 -11
- package/dist/styles/components/actions/toolbar-control-group/toolbar-control-group.css +38 -200
- package/dist/styles/components/collections/column-explorer/column-explorer.css +6 -0
- package/dist/styles/components/collections/list/list.css +6 -0
- package/dist/styles/components/collections/list-header/list-header.css +11 -25
- package/dist/styles/components/collections/list-item/list-item.css +68 -2
- package/dist/styles/components/collections/summary-row/summary-row.css +39 -6
- package/dist/styles/components/collections/tree-list/tree-list.css +7 -0
- package/dist/styles/components/data-display/value-table/value-table.css +1 -1
- package/dist/styles/components/feedback/badge/badge.css +31 -0
- package/dist/styles/components/feedback/state-banner/state-banner.css +12 -7
- package/dist/styles/components/forms/choice-chips/choice-chips.css +45 -0
- package/dist/styles/components/forms/file-picker/file-picker.css +13 -2
- package/dist/styles/components/forms/form/form.css +6 -0
- package/dist/styles/components/forms/select/select.css +85 -2
- package/dist/styles/components/forms/text-field/text-field.css +44 -0
- package/dist/styles/components/layout/pane/pane.css +16 -0
- package/dist/styles/components/layout/resizable-region/resizable-region.css +0 -10
- package/dist/styles/components/layout/sized-region/sized-region.css +22 -0
- package/dist/styles/components/layout/workbench/workbench.css +0 -21
- package/dist/styles/components/navigation/nav-stack/nav-stack.css +2 -0
- package/dist/styles/components/navigation/paged-view/paged-view.css +160 -0
- package/dist/styles/components/navigation/tab-bar/tab-bar.css +24 -17
- package/dist/styles/components/navigation/tab-bar-item/tab-bar-item.css +111 -60
- package/dist/styles/components/navigation/tab-panel/tab-panel.css +7 -0
- package/dist/styles/components/surfaces/backdrop-image/backdrop-image.css +14 -70
- package/dist/styles/components/surfaces/scroll-effect/scroll-effect.css +121 -0
- package/dist/styles/components/surfaces/surface-scaffold/surface-scaffold.css +77 -29
- package/dist/styles/components/typography/text/text.css +4 -4
- package/dist/styles/content-item.css +551 -3
- package/dist/styles/document.css +1 -6
- package/dist/styles/editor/editor.css +530 -0
- package/dist/styles/editor.css +4 -0
- package/dist/styles/file-picker.css +13 -2
- package/dist/styles/form.css +6 -0
- package/dist/styles/foundation.css +55 -1
- package/dist/styles/list-header.css +11 -25
- package/dist/styles/list-item.css +68 -2
- package/dist/styles/list.css +6 -0
- package/dist/styles/nav-stack.css +2 -0
- package/dist/styles/overlay-sheet.css +7 -7
- package/dist/styles/paged-view.css +160 -0
- package/dist/styles/pane.css +16 -0
- package/dist/styles/popup-menu.css +154 -1
- package/dist/styles/resizable-region.css +0 -10
- package/dist/styles/scroll-effect.css +121 -0
- package/dist/styles/select.css +85 -2
- package/dist/styles/sized-region.css +22 -0
- package/dist/styles/state-banner.css +12 -7
- package/dist/styles/styles.css +11 -0
- package/dist/styles/summary-row.css +39 -6
- package/dist/styles/surface-scaffold.css +77 -29
- package/dist/styles/tab-bar-item.css +111 -60
- package/dist/styles/tab-bar.css +24 -17
- package/dist/styles/tab-panel.css +7 -0
- package/dist/styles/text-field.css +44 -0
- package/dist/styles/text.css +4 -4
- package/dist/styles/toolbar-control-group.css +38 -200
- package/dist/styles/toolbar.css +19 -11
- package/dist/styles/tree-list.css +7 -0
- package/dist/styles/value-table.css +1 -1
- package/dist/styles/webawesome.css +350 -6
- package/dist/styles/workbench.css +0 -21
- package/dist/summary-row.d.ts +9 -1
- package/dist/summary-row.js +1 -1
- package/dist/sunken-panel.d.ts +5 -1
- package/dist/sunken-panel.js +2 -1
- package/dist/surface-scaffold-register.js +1 -1
- package/dist/surface-scaffold.d.ts +37 -6
- package/dist/surface-scaffold.js +3 -2
- package/dist/switch.js +1 -1
- package/dist/tab-bar-item.d.ts +9 -5
- package/dist/tab-bar-item.js +1 -1
- package/dist/tab-bar.d.ts +16 -3
- package/dist/tab-bar.js +2 -1
- package/dist/tab-navigator.d.ts +25 -3
- package/dist/tab-navigator.js +42 -19
- package/dist/tab-navigator.js.map +1 -1
- package/dist/tab-panel.d.ts +35 -0
- package/dist/tab-panel.js +4 -0
- package/dist/tab-panel.js.map +1 -0
- package/dist/tag-field.d.ts +5 -1
- package/dist/tag-field.js +2 -1
- package/dist/text-field.d.ts +22 -4
- package/dist/text-field.js +1 -1
- package/dist/text.d.ts +37 -5
- package/dist/text.js +2 -1
- package/dist/toolbar-control-group.d.ts +83 -3
- package/dist/toolbar-control-group.js +4 -1
- package/dist/toolbar-text.d.ts +9 -1
- package/dist/toolbar-text.js +2 -1
- package/dist/toolbar.d.ts +6 -1
- package/dist/toolbar.js +2 -1
- package/dist/tree-list.d.ts +42 -0
- package/dist/tree-list.js +12 -0
- package/dist/tree-list.js.map +1 -0
- package/dist/tree-rows-eHnnGLGM.d.ts +65 -0
- package/dist/value-preview.d.ts +5 -1
- package/dist/value-preview.js +2 -1
- package/dist/value-table.d.ts +9 -2
- package/dist/value-table.js +2 -1
- package/dist/wire-catalog.d.ts +3 -2
- package/dist/wire-catalog.js +4 -3
- package/dist/wire-catalog.js.map +1 -1
- package/dist/wire-choice-chips.d.ts +3 -1
- package/dist/wire-choice-chips.js +1 -1
- package/dist/wire-color-fields.js +2 -73
- package/dist/wire-color-fields.js.map +1 -1
- package/dist/wire-color-pickers.js +1 -1
- package/dist/wire-column-explorer.d.ts +13 -0
- package/dist/wire-column-explorer.js +94 -0
- package/dist/wire-column-explorer.js.map +1 -0
- package/dist/wire-content-items.d.ts +10 -1
- package/dist/wire-content-items.js +1 -293
- package/dist/wire-content-items.js.map +1 -1
- package/dist/wire-forms.d.ts +14 -0
- package/dist/wire-forms.js +3 -0
- package/dist/wire-forms.js.map +1 -0
- package/dist/wire-nav-stack.js +1 -423
- package/dist/wire-nav-stack.js.map +1 -1
- package/dist/wire-paged-views.d.ts +27 -0
- package/dist/wire-paged-views.js +186 -0
- package/dist/wire-paged-views.js.map +1 -0
- package/dist/wire-resizable-regions.js +2 -1
- package/dist/wire-scroll-dividers.js +1 -1
- package/dist/wire-search-fields.d.ts +2 -1
- package/dist/wire-search-fields.js +2 -1
- package/dist/wire-sidebar.js +1 -229
- package/dist/wire-sidebar.js.map +1 -1
- package/dist/wire-sliders.js +1 -29
- package/dist/wire-sliders.js.map +1 -1
- package/dist/wire-summary-rows.d.ts +18 -0
- package/dist/wire-summary-rows.js +4 -0
- package/dist/wire-summary-rows.js.map +1 -0
- package/dist/wire-tab-bars.d.ts +1 -0
- package/dist/wire-tab-bars.js +1 -1
- package/dist/wire-tab-navigator.js +1 -151
- package/dist/wire-tab-navigator.js.map +1 -1
- package/dist/wire-tag-fields.js +3 -252
- package/dist/wire-tag-fields.js.map +1 -1
- package/dist/wire-tree-list.d.ts +53 -0
- package/dist/wire-tree-list.js +3 -0
- package/dist/wire-tree-list.js.map +1 -0
- package/dist/wire-workbench.js +2 -1
- package/dist/workbench-dialog.d.ts +10 -3
- package/dist/workbench-dialog.js +13 -9
- package/dist/workbench-dialog.js.map +1 -1
- package/dist/workbench.d.ts +7 -3
- package/dist/workbench.js +4 -1
- package/docs/accessibility.md +52 -9
- package/docs/app-layouts.md +70 -1
- package/docs/backdrop-image.md +10 -0
- package/docs/button.md +30 -2
- package/docs/column-explorer.md +75 -0
- package/docs/component-contract.md +44 -15
- package/docs/component-selection.md +161 -126
- package/docs/data-tables-and-lists.md +1 -1
- package/docs/design/sketch/Kerf-UI.sketch +0 -0
- package/docs/design/sketch/README.md +73 -0
- package/docs/design/sketch/advanced/README.md +75 -0
- package/docs/design/sketch/button/README.md +270 -0
- package/docs/design/sketch/content/README.md +70 -0
- package/docs/design/sketch/coverage.md +159 -0
- package/docs/design/sketch/forms/README.md +97 -0
- package/docs/design/sketch/lists/README.md +65 -0
- package/docs/design/sketch/toolbar/README.md +73 -0
- package/docs/design/sketch/unified/README.md +69 -0
- package/docs/design/sketch/unified/pages/advanced.png +0 -0
- package/docs/design/sketch/unified/pages/button.png +0 -0
- package/docs/design/sketch/unified/pages/content.png +0 -0
- package/docs/design/sketch/unified/pages/forms.png +0 -0
- package/docs/design/sketch/unified/pages/lists.png +0 -0
- package/docs/design/sketch/unified/pages/toolbar.png +0 -0
- package/docs/design/sketch-runner.md +87 -0
- package/docs/design/templates/button/emphasis-dark.svg +1 -1
- package/docs/design/templates/button/emphasis.svg +1 -1
- package/docs/design/templates/button-dark.svg +1 -1
- package/docs/design/templates/button.svg +1 -1
- package/docs/design/templates/list-header/action-dark.svg +1 -1
- package/docs/design/templates/list-header/action.svg +1 -1
- package/docs/design/templates/list-header/toggle-collapsed-dark.svg +1 -1
- package/docs/design/templates/list-header/toggle-collapsed.svg +1 -1
- package/docs/design/templates/list-header/toggle-expanded-dark.svg +1 -1
- package/docs/design/templates/list-header/toggle-expanded.svg +1 -1
- package/docs/design/templates/list-header-dark.svg +1 -1
- package/docs/design/templates/list-header.svg +1 -1
- package/docs/design/templates/tab-bar/workspace-tabs-dark.svg +1 -1
- package/docs/design/templates/tab-bar/workspace-tabs.svg +1 -1
- package/docs/design/templates/tab-bar-dark.svg +1 -1
- package/docs/design/templates/tab-bar.svg +1 -1
- package/docs/design/templates/tree-list/files-dark.svg +1 -0
- package/docs/design/templates/tree-list/files.svg +1 -0
- package/docs/design/templates/tree-list/outline-dark.svg +1 -0
- package/docs/design/templates/tree-list/outline.svg +1 -0
- package/docs/design/templates/tree-list-dark.svg +1 -0
- package/docs/design/templates/tree-list.svg +1 -0
- package/docs/design/templates.md +10 -1
- package/docs/document-baseline.md +6 -3
- package/docs/editor-host.md +299 -0
- package/docs/forms-and-validation.md +39 -0
- package/docs/interaction-conventions.md +2 -1
- package/docs/layout.md +94 -10
- package/docs/list-detail-dialog.md +5 -0
- package/docs/manual-test-plan.md +32 -0
- package/docs/nav-stack.md +2 -1
- package/docs/paged-view.md +89 -0
- package/docs/scroll-effect.md +127 -0
- package/docs/split-view.md +4 -1
- package/docs/surface-scaffold.md +32 -2
- package/docs/tab-navigator.md +5 -4
- package/docs/tree-list.md +134 -0
- package/docs/ui-analyzer.md +43 -25
- package/docs/ui-doctor.md +4 -1
- package/docs/ui-evaluator.md +2 -0
- package/docs/ux-demo.md +1 -1
- package/docs/webawesome-migration.md +32 -31
- package/docs/webawesome-theme.md +27 -17
- package/docs/workbench-dialog.md +4 -0
- package/evaluator/index.mjs +14 -2
- package/llms.txt +162 -21
- package/package.json +104 -6
- package/props/cli.d.mts +1 -0
- package/props/cli.mjs +116 -0
- package/props/component-props.d.mts +177 -0
- package/props/component-props.mjs +1208 -0
- package/scripts/lib/json-schema-subset.mjs +137 -0
- package/ux-demo/recipes/app-shell.tsx +20 -22
- package/ux-demo/recipes/collapsible-sidebar.tsx +2 -2
- package/ux-demo/recipes/compact-toolbar.tsx +26 -29
- package/ux-demo/recipes/composer-form.tsx +6 -5
- package/ux-demo/recipes/list-workspace-states.tsx +39 -39
- package/ux-demo/recipes/loading-inspector.tsx +8 -6
- package/ux-demo/recipes/media-detail.tsx +29 -15
- package/ux-demo/recipes/navigation-sidebar.tsx +18 -19
- package/ux-demo/recipes/navigation-stack.tsx +2 -2
- package/ux-demo/recipes/workspace-header.tsx +16 -16
- package/view/cli.d.mts +18 -0
- package/view/cli.mjs +262 -0
- package/view/contract.mjs +342 -0
- package/view/generate.mjs +639 -0
- package/view/index.d.mts +411 -0
- package/view/index.mjs +40 -0
- package/view/interpret.mjs +271 -0
- package/view/validate-move.mjs +317 -0
- package/view/validate.mjs +1864 -0
- package/vite-editor.d.mts +130 -0
- package/vite-editor.mjs +314 -0
- package/dist/chunk-2J7XKAZX.js.map +0 -1
- package/dist/chunk-3KFMLOTH.js.map +0 -1
- package/dist/chunk-3OP66VXU.js.map +0 -1
- package/dist/chunk-3V4OCDTL.js.map +0 -1
- package/dist/chunk-3WWX2O4G.js.map +0 -1
- package/dist/chunk-5CLMV5YU.js.map +0 -1
- package/dist/chunk-5J6Z4BWY.js.map +0 -1
- package/dist/chunk-6VVIW7VB.js.map +0 -1
- package/dist/chunk-7AK5I7U7.js.map +0 -1
- package/dist/chunk-7K6U6FCN.js.map +0 -1
- package/dist/chunk-AMIHGFLP.js.map +0 -1
- package/dist/chunk-AN5IWMTM.js.map +0 -1
- package/dist/chunk-B53PS2LE.js.map +0 -1
- package/dist/chunk-BKUMG2KB.js.map +0 -1
- package/dist/chunk-BSNKDW4X.js.map +0 -1
- package/dist/chunk-C2ZO3OZZ.js.map +0 -1
- package/dist/chunk-CVD5IZGB.js.map +0 -1
- package/dist/chunk-D5RGM3XA.js.map +0 -1
- package/dist/chunk-DZJ4GBSP.js.map +0 -1
- package/dist/chunk-EIET4QLK.js.map +0 -1
- package/dist/chunk-EKHDLBRP.js.map +0 -1
- package/dist/chunk-ETFP7HAR.js.map +0 -1
- package/dist/chunk-EYDXFOSH.js.map +0 -1
- package/dist/chunk-F653O57X.js.map +0 -1
- package/dist/chunk-G3J7JDP6.js.map +0 -1
- package/dist/chunk-HJWFHJ3Z.js.map +0 -1
- package/dist/chunk-HJXVVFBT.js.map +0 -1
- package/dist/chunk-IIQ2XIMU.js.map +0 -1
- package/dist/chunk-ITENVZ6Q.js.map +0 -1
- package/dist/chunk-ITUQC4FW.js.map +0 -1
- package/dist/chunk-K57NINLH.js.map +0 -1
- package/dist/chunk-K67XBCHG.js.map +0 -1
- package/dist/chunk-KDQZ3E5C.js.map +0 -1
- package/dist/chunk-KH4KEMSP.js.map +0 -1
- package/dist/chunk-LZUUUHNH.js.map +0 -1
- package/dist/chunk-N2K3QGSX.js.map +0 -1
- package/dist/chunk-NB6POCFH.js.map +0 -1
- package/dist/chunk-NR6O74ST.js.map +0 -1
- package/dist/chunk-OQP3PFKQ.js.map +0 -1
- package/dist/chunk-OZ6X76G5.js.map +0 -1
- package/dist/chunk-PS24PVR6.js.map +0 -1
- package/dist/chunk-QH5KOFNS.js.map +0 -1
- package/dist/chunk-QYMJHS4K.js.map +0 -1
- package/dist/chunk-S3DCRI2M.js.map +0 -1
- package/dist/chunk-S3ECMF23.js.map +0 -1
- package/dist/chunk-TKNVL53O.js.map +0 -1
- package/dist/chunk-VEME3D7K.js.map +0 -1
- package/dist/chunk-WVS6CUCT.js.map +0 -1
- package/dist/chunk-XRZSK2WC.js.map +0 -1
- package/dist/chunk-Y6KT7ZTR.js.map +0 -1
- package/dist/chunk-YMUIQRWK.js.map +0 -1
- package/dist/chunk-YPAQFBMN.js.map +0 -1
- package/dist/chunk-ZN7KUMPY.js.map +0 -1
- package/dist/chunk-ZX2QQJXD.js.map +0 -1
|
@@ -0,0 +1,1208 @@
|
|
|
1
|
+
// Structured per-component prop schema (ui/ai/component-props.json): reads
|
|
2
|
+
// the published component types with the TypeScript JS API and projects each
|
|
3
|
+
// component's props into a small JSON type grammar that editors, validators,
|
|
4
|
+
// and generated view contracts can consume without parsing TypeScript.
|
|
5
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
6
|
+
import { relative, resolve, sep } from 'node:path';
|
|
7
|
+
|
|
8
|
+
import ts from 'typescript';
|
|
9
|
+
|
|
10
|
+
export const COMPONENT_PROPS_SCHEMA_ID = 'kerf-ui-component-props/v1';
|
|
11
|
+
|
|
12
|
+
// Type aliases that render application content rather than a configured value.
|
|
13
|
+
const CONTENT_ALIASES = new Set([
|
|
14
|
+
'SafeHtml',
|
|
15
|
+
'KerfUiContent',
|
|
16
|
+
'JSXChildren',
|
|
17
|
+
'JSXChild',
|
|
18
|
+
]);
|
|
19
|
+
// css-values brands and token unions; each is authored through a builder or
|
|
20
|
+
// a token name, never a raw string (docs/22-ui-css-authoring.md).
|
|
21
|
+
const CSS_VALUE_ALIAS =
|
|
22
|
+
/^(Css[A-Z]\w*|Ui(Color|ForegroundColor|Gap|GapValue|SpaceName|ColorName|ForegroundColorName))$/;
|
|
23
|
+
// Anonymous object literals inline up to this depth; named ones become
|
|
24
|
+
// shared definitions, so recursion and repetition stay bounded.
|
|
25
|
+
const MAX_INLINE_DEPTH = 5;
|
|
26
|
+
const PRINT_FLAGS =
|
|
27
|
+
ts.TypeFormatFlags.NoTruncation |
|
|
28
|
+
ts.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope;
|
|
29
|
+
|
|
30
|
+
/** Creates a TypeScript program over declaration files. */
|
|
31
|
+
export function createDeclarationProgram(files, options = {}) {
|
|
32
|
+
return ts.createProgram(files, {
|
|
33
|
+
target: ts.ScriptTarget.ES2022,
|
|
34
|
+
module: ts.ModuleKind.ESNext,
|
|
35
|
+
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
36
|
+
strict: true,
|
|
37
|
+
skipLibCheck: true,
|
|
38
|
+
types: [],
|
|
39
|
+
...options,
|
|
40
|
+
noEmit: true,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Compiler options from a package's own tsconfig.json (JSX settings, paths),
|
|
46
|
+
* for reading component source files; empty when it has none.
|
|
47
|
+
*/
|
|
48
|
+
function packageCompilerOptions(root) {
|
|
49
|
+
const configPath = ts.findConfigFile(
|
|
50
|
+
root,
|
|
51
|
+
ts.sys.fileExists,
|
|
52
|
+
'tsconfig.json',
|
|
53
|
+
);
|
|
54
|
+
if (!configPath || !configPath.startsWith(root)) return {};
|
|
55
|
+
const parsed = ts.getParsedCommandLineOfConfigFile(
|
|
56
|
+
configPath,
|
|
57
|
+
{},
|
|
58
|
+
{
|
|
59
|
+
...ts.sys,
|
|
60
|
+
onUnRecoverableConfigFileDiagnostic: () => undefined,
|
|
61
|
+
},
|
|
62
|
+
);
|
|
63
|
+
return parsed?.options ?? {};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** A root-relative ESM import for a source file (`src/x.tsx` → `./src/x.js`). */
|
|
67
|
+
function sourceImport(root, file) {
|
|
68
|
+
const path = relative(root, file).split(sep).join('/');
|
|
69
|
+
return `./${path.replace(/\.(?:tsx?|jsx?|mts|cts)$/, '.js')}`;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Extraction state for one program: the checker, the shared `definitions`
|
|
74
|
+
* table, and the directory whose declarations count as the package's own
|
|
75
|
+
* (props declared elsewhere are inherited native attributes).
|
|
76
|
+
*/
|
|
77
|
+
export function createPropsContext(checker, ownDirectory) {
|
|
78
|
+
return {
|
|
79
|
+
checker,
|
|
80
|
+
ownDirectory: ownDirectory.endsWith(sep)
|
|
81
|
+
? ownDirectory
|
|
82
|
+
: ownDirectory + sep,
|
|
83
|
+
definitions: new Map(),
|
|
84
|
+
definitionNames: new Map(),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// The printer can overflow the stack on a recursive alias (JSX child trees)
|
|
89
|
+
// when truncation is off; fall back to the truncating printer for those.
|
|
90
|
+
function printType(checker, type) {
|
|
91
|
+
try {
|
|
92
|
+
return checker.typeToString(type, undefined, PRINT_FLAGS);
|
|
93
|
+
} catch {
|
|
94
|
+
return checker.typeToString(type);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function documentation(checker, symbol) {
|
|
99
|
+
if (!symbol) return '';
|
|
100
|
+
return ts
|
|
101
|
+
.displayPartsToString(symbol.getDocumentationComment(checker))
|
|
102
|
+
.trim();
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function jsDocTag(symbol, name) {
|
|
106
|
+
const tag = symbol?.getJsDocTags().find((item) => item.name === name);
|
|
107
|
+
if (!tag) return undefined;
|
|
108
|
+
return ts.displayPartsToString(tag.text ?? []).trim();
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** Literal value a single-literal type carries, or undefined. */
|
|
112
|
+
function literalOf(type) {
|
|
113
|
+
if (type.isStringLiteral() || type.isNumberLiteral()) return type.value;
|
|
114
|
+
if (type.flags & ts.TypeFlags.BooleanLiteral) {
|
|
115
|
+
return type.intrinsicName === 'true';
|
|
116
|
+
}
|
|
117
|
+
return undefined;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const isNullish = (type) =>
|
|
121
|
+
(type.flags &
|
|
122
|
+
(ts.TypeFlags.Undefined | ts.TypeFlags.Null | ts.TypeFlags.Void)) !==
|
|
123
|
+
0;
|
|
124
|
+
|
|
125
|
+
const membersOf = (type) => (type.isUnion() ? type.types : [type]);
|
|
126
|
+
|
|
127
|
+
const isObjectLike = (type) =>
|
|
128
|
+
(type.flags & ts.TypeFlags.Object) !== 0 || type.isIntersection();
|
|
129
|
+
|
|
130
|
+
// TypeScript's own utility types say nothing about the shape they produce,
|
|
131
|
+
// so a type named by one stays anonymous (inlined, not a definition).
|
|
132
|
+
const UTILITY_NAMES = new Set([
|
|
133
|
+
'Readonly',
|
|
134
|
+
'ReadonlyArray',
|
|
135
|
+
'Record',
|
|
136
|
+
'Partial',
|
|
137
|
+
'Required',
|
|
138
|
+
'Pick',
|
|
139
|
+
'Omit',
|
|
140
|
+
'Exclude',
|
|
141
|
+
'Extract',
|
|
142
|
+
'NonNullable',
|
|
143
|
+
]);
|
|
144
|
+
const SIGNAL_NAMES = new Set(['Signal', 'ReadonlySignal']);
|
|
145
|
+
|
|
146
|
+
/** A user-facing name for an object or union type, or undefined. */
|
|
147
|
+
function nameOf(type) {
|
|
148
|
+
const alias = type.aliasSymbol?.getName();
|
|
149
|
+
if (alias && !UTILITY_NAMES.has(alias)) return alias;
|
|
150
|
+
const symbol = type.getSymbol()?.getName();
|
|
151
|
+
return symbol && !symbol.startsWith('__') && !UTILITY_NAMES.has(symbol)
|
|
152
|
+
? symbol
|
|
153
|
+
: undefined;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const isSafeHtml = (type) => type.getSymbol()?.getName() === 'SafeHtml';
|
|
157
|
+
const isPrimitive = (type) =>
|
|
158
|
+
(type.flags &
|
|
159
|
+
(ts.TypeFlags.StringLike |
|
|
160
|
+
ts.TypeFlags.NumberLike |
|
|
161
|
+
ts.TypeFlags.BooleanLike)) !==
|
|
162
|
+
0;
|
|
163
|
+
|
|
164
|
+
// Content that also takes a plain string or number (ButtonLabel, TextContent)
|
|
165
|
+
// says so; bare `KerfUiContent` rejects arbitrary text (docs/21's compile-time
|
|
166
|
+
// contracts), so a document must give it markup instead.
|
|
167
|
+
const TEXT_FLAGS = ts.TypeFlags.StringLike | ts.TypeFlags.NumberLike;
|
|
168
|
+
function contentOf(members, text) {
|
|
169
|
+
return members.some((member) => member.flags & TEXT_FLAGS)
|
|
170
|
+
? { kind: 'content', acceptsText: true, text }
|
|
171
|
+
: { kind: 'content', text };
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Described members that are all content, text, or numbers (a branded
|
|
176
|
+
* SafeHtml, an alias of content, or one prop's type in each variant) are one
|
|
177
|
+
* content slot (KF-24G2KV); undefined for any other set.
|
|
178
|
+
*/
|
|
179
|
+
function contentOfDescribed(members, text) {
|
|
180
|
+
if (
|
|
181
|
+
!members.some((member) => member.kind === 'content') ||
|
|
182
|
+
!members.every((member) =>
|
|
183
|
+
['content', 'string', 'number'].includes(member.kind),
|
|
184
|
+
)
|
|
185
|
+
)
|
|
186
|
+
return undefined;
|
|
187
|
+
return members.some(
|
|
188
|
+
(member) => member.kind !== 'content' || member.acceptsText,
|
|
189
|
+
)
|
|
190
|
+
? { kind: 'content', acceptsText: true, text }
|
|
191
|
+
: { kind: 'content', text };
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Text, numbers, rendered markup, or lists of them: application content for
|
|
196
|
+
* a slot.
|
|
197
|
+
*/
|
|
198
|
+
function isContentUnion(checker, members) {
|
|
199
|
+
return (
|
|
200
|
+
members.some(isSafeHtml) &&
|
|
201
|
+
members.every(
|
|
202
|
+
(member) =>
|
|
203
|
+
isSafeHtml(member) ||
|
|
204
|
+
isPrimitive(member) ||
|
|
205
|
+
checker.isArrayType(member),
|
|
206
|
+
)
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Registers a named type in the shared table and returns a reference to it.
|
|
212
|
+
* Two different types that share a name get distinct `Name`, `Name#2` keys.
|
|
213
|
+
*/
|
|
214
|
+
function reference(ctx, type, name, text, build) {
|
|
215
|
+
let key = ctx.definitionNames.get(type);
|
|
216
|
+
if (!key) {
|
|
217
|
+
key = name;
|
|
218
|
+
for (let index = 2; ctx.definitions.has(key); index += 1) {
|
|
219
|
+
key = `${name}#${index}`;
|
|
220
|
+
}
|
|
221
|
+
ctx.definitionNames.set(type, key);
|
|
222
|
+
ctx.definitions.set(key, { kind: 'pending', text });
|
|
223
|
+
ctx.definitions.set(key, { ...build(), text });
|
|
224
|
+
}
|
|
225
|
+
return { kind: 'ref', ref: key, text };
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Describes a type in the component-props type grammar. Every descriptor
|
|
230
|
+
* carries the printed TypeScript `text`; `kind` narrows it for tooling.
|
|
231
|
+
*/
|
|
232
|
+
export function describeType(ctx, type, depth = 0) {
|
|
233
|
+
const text = printType(ctx.checker, type);
|
|
234
|
+
const all = membersOf(type);
|
|
235
|
+
const members = all.filter((member) => !isNullish(member));
|
|
236
|
+
const nullable = members.length !== all.length;
|
|
237
|
+
const described = describeNonNull(ctx, type, members, text, depth);
|
|
238
|
+
return nullable ? { ...described, nullable: true } : described;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
function describeNonNull(ctx, type, members, text, depth) {
|
|
242
|
+
if (members.length === 0) return { kind: 'never', text };
|
|
243
|
+
const named = type.aliasSymbol?.getName();
|
|
244
|
+
if (named && CONTENT_ALIASES.has(named)) return contentOf(members, text);
|
|
245
|
+
// A css-values alias that also takes token names (`UiGapValue` is
|
|
246
|
+
// `UiSpaceName | CssLength`) keeps its tokens as literals beside the
|
|
247
|
+
// builder, as it reads once `| undefined` drops the alias, so a nested
|
|
248
|
+
// `{ column: 'm' }` validates (KF-VA14AP).
|
|
249
|
+
if (named && CSS_VALUE_ALIAS.test(named)) {
|
|
250
|
+
if (!members.some((member) => typeof literalOf(member) === 'string'))
|
|
251
|
+
return { kind: 'css-value', grammar: named, text };
|
|
252
|
+
}
|
|
253
|
+
if (isContentUnion(ctx.checker, members)) return contentOf(members, text);
|
|
254
|
+
if (members.length === 1) return describeSingle(ctx, members[0], depth);
|
|
255
|
+
|
|
256
|
+
const literals = members.map(literalOf);
|
|
257
|
+
if (literals.every((value) => typeof value === 'boolean')) {
|
|
258
|
+
return { kind: 'boolean', text };
|
|
259
|
+
}
|
|
260
|
+
if (literals.every((value) => value !== undefined)) {
|
|
261
|
+
const declared = type.aliasSymbol?.declarations?.[0];
|
|
262
|
+
return {
|
|
263
|
+
kind: 'enum',
|
|
264
|
+
values: inDeclaredOrder(
|
|
265
|
+
ctx.checker,
|
|
266
|
+
literals,
|
|
267
|
+
declared && 'type' in declared ? declared.type : undefined,
|
|
268
|
+
),
|
|
269
|
+
text,
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
const build = () => {
|
|
273
|
+
// `true` | `false` print as separate members; fold them back into
|
|
274
|
+
// boolean. A lone `true` (a Button's dot badge) stays that literal, so
|
|
275
|
+
// nothing offers the `false` the type excludes (KF-FY62FK).
|
|
276
|
+
const booleans = members.filter(
|
|
277
|
+
(member) => member.flags & ts.TypeFlags.BooleanLiteral,
|
|
278
|
+
);
|
|
279
|
+
const folded = [];
|
|
280
|
+
let sawBoolean = false;
|
|
281
|
+
for (const member of members) {
|
|
282
|
+
if (member.flags & ts.TypeFlags.BooleanLiteral) {
|
|
283
|
+
if (!sawBoolean)
|
|
284
|
+
folded.push(
|
|
285
|
+
booleans.length === 1
|
|
286
|
+
? describeType(ctx, member, depth + 1)
|
|
287
|
+
: { kind: 'boolean', text: 'boolean' },
|
|
288
|
+
);
|
|
289
|
+
sawBoolean = true;
|
|
290
|
+
continue;
|
|
291
|
+
}
|
|
292
|
+
folded.push(describeType(ctx, member, depth + 1));
|
|
293
|
+
}
|
|
294
|
+
// Text and markup TypeScript kept apart are still one content slot.
|
|
295
|
+
const content = contentOfDescribed(folded, text);
|
|
296
|
+
if (content) return content;
|
|
297
|
+
const union = { kind: 'union', members: folded };
|
|
298
|
+
const discriminant = discriminantOf(ctx.checker, members);
|
|
299
|
+
if (discriminant) union.discriminant = discriminant;
|
|
300
|
+
return union;
|
|
301
|
+
};
|
|
302
|
+
if (named && members.some(isObjectLike)) {
|
|
303
|
+
return reference(ctx, type, named, text, build);
|
|
304
|
+
}
|
|
305
|
+
return { ...build(), text };
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
function describeSingle(ctx, type, depth) {
|
|
309
|
+
const { checker } = ctx;
|
|
310
|
+
const text = printType(checker, type);
|
|
311
|
+
const name = nameOf(type);
|
|
312
|
+
if (name && CONTENT_ALIASES.has(name)) return { kind: 'content', text };
|
|
313
|
+
if (name && SIGNAL_NAMES.has(name)) return { kind: 'signal', text };
|
|
314
|
+
if (name && CSS_VALUE_ALIAS.test(name)) {
|
|
315
|
+
return { kind: 'css-value', grammar: name, text };
|
|
316
|
+
}
|
|
317
|
+
const literal = literalOf(type);
|
|
318
|
+
if (literal !== undefined) return { kind: 'literal', value: literal, text };
|
|
319
|
+
// `NoInfer<T>` is a substitution type; describe what it wraps.
|
|
320
|
+
if (type.flags & ts.TypeFlags.Substitution && type.baseType) {
|
|
321
|
+
return { ...describeType(ctx, type.baseType, depth), text };
|
|
322
|
+
}
|
|
323
|
+
if (type.flags & ts.TypeFlags.TypeParameter) {
|
|
324
|
+
const constraint = type.getConstraint();
|
|
325
|
+
const described = constraint
|
|
326
|
+
? describeType(ctx, constraint, depth)
|
|
327
|
+
: { kind: 'unknown' };
|
|
328
|
+
return { ...described, typeParameter: type.getSymbol()?.getName(), text };
|
|
329
|
+
}
|
|
330
|
+
if (type.flags & ts.TypeFlags.StringLike) return { kind: 'string', text };
|
|
331
|
+
if (type.flags & ts.TypeFlags.NumberLike) return { kind: 'number', text };
|
|
332
|
+
if (type.flags & ts.TypeFlags.BooleanLike) return { kind: 'boolean', text };
|
|
333
|
+
if (type.flags & ts.TypeFlags.Never) return { kind: 'never', text };
|
|
334
|
+
if (type.getCallSignatures().length > 0) return { kind: 'function', text };
|
|
335
|
+
if (checker.isArrayType(type) || checker.isTupleType(type)) {
|
|
336
|
+
const [item] = checker.getTypeArguments(type);
|
|
337
|
+
return {
|
|
338
|
+
kind: 'array',
|
|
339
|
+
items: item ? describeType(ctx, item, depth + 1) : { kind: 'unknown' },
|
|
340
|
+
text,
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
if (isObjectLike(type)) {
|
|
344
|
+
if (/^(HTML\w*Element|Element|Node)$/.test(name ?? '')) {
|
|
345
|
+
return { kind: 'element', text };
|
|
346
|
+
}
|
|
347
|
+
if (
|
|
348
|
+
checker.getIndexInfosOfType(type).length > 0 &&
|
|
349
|
+
checker.getPropertiesOfType(type).length === 0
|
|
350
|
+
) {
|
|
351
|
+
return { kind: 'record', text };
|
|
352
|
+
}
|
|
353
|
+
const build = () => {
|
|
354
|
+
const object = {
|
|
355
|
+
kind: 'object',
|
|
356
|
+
props: describeProps(ctx, type, depth + 1).props,
|
|
357
|
+
};
|
|
358
|
+
const index = indexOf(ctx, type, depth);
|
|
359
|
+
if (index) object.index = index;
|
|
360
|
+
return object;
|
|
361
|
+
};
|
|
362
|
+
if (name) return reference(ctx, type, name, text, build);
|
|
363
|
+
if (depth >= MAX_INLINE_DEPTH) return { kind: 'object', text };
|
|
364
|
+
return { ...build(), text };
|
|
365
|
+
}
|
|
366
|
+
return { kind: 'unknown', text };
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* An object's string index signature (`Record<\`data-${string}\`, string>`
|
|
371
|
+
* behind `rootAttributes`), as the key prefix it allows and its value type.
|
|
372
|
+
* Returns undefined when the object has none.
|
|
373
|
+
*/
|
|
374
|
+
function indexOf(ctx, type, depth) {
|
|
375
|
+
const info = ctx.checker
|
|
376
|
+
.getIndexInfosOfType(type)
|
|
377
|
+
.find(
|
|
378
|
+
(item) =>
|
|
379
|
+
item.keyType.flags &
|
|
380
|
+
(ts.TypeFlags.String | ts.TypeFlags.TemplateLiteral),
|
|
381
|
+
);
|
|
382
|
+
if (!info) return undefined;
|
|
383
|
+
const prefix =
|
|
384
|
+
info.keyType.flags & ts.TypeFlags.TemplateLiteral
|
|
385
|
+
? info.keyType.texts[0]
|
|
386
|
+
: '';
|
|
387
|
+
return { keyPrefix: prefix, value: describeType(ctx, info.type, depth + 1) };
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* The props that distinguish union members: present in every member, each a
|
|
392
|
+
* single literal, and not all equal. Returns their names, or undefined.
|
|
393
|
+
*/
|
|
394
|
+
function discriminantOf(checker, members) {
|
|
395
|
+
if (members.length < 2 || !members.every(isObjectLike)) return undefined;
|
|
396
|
+
const names = checker
|
|
397
|
+
.getPropertiesOfType(members[0])
|
|
398
|
+
.map((symbol) => symbol.getName())
|
|
399
|
+
.filter((name) => {
|
|
400
|
+
const values = members.map((member) => {
|
|
401
|
+
const property = member.getProperty(name);
|
|
402
|
+
if (!property) return undefined;
|
|
403
|
+
const typed = membersOf(checker.getTypeOfSymbol(property)).filter(
|
|
404
|
+
(item) => !isNullish(item),
|
|
405
|
+
);
|
|
406
|
+
return typed.length === 1 ? literalOf(typed[0]) : undefined;
|
|
407
|
+
});
|
|
408
|
+
return (
|
|
409
|
+
values.every((value) => value !== undefined) && new Set(values).size > 1
|
|
410
|
+
);
|
|
411
|
+
});
|
|
412
|
+
return names.length > 0 ? names : undefined;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
/** Literal values a type node spells out, in source order (aliases followed). */
|
|
416
|
+
function declaredLiterals(checker, node, seen = new Set()) {
|
|
417
|
+
if (!node || seen.has(node)) return [];
|
|
418
|
+
seen.add(node);
|
|
419
|
+
if (ts.isParenthesizedTypeNode(node)) {
|
|
420
|
+
return declaredLiterals(checker, node.type, seen);
|
|
421
|
+
}
|
|
422
|
+
if (ts.isUnionTypeNode(node)) {
|
|
423
|
+
return node.types.flatMap((item) => declaredLiterals(checker, item, seen));
|
|
424
|
+
}
|
|
425
|
+
if (ts.isTypeReferenceNode(node) && !node.typeArguments) {
|
|
426
|
+
let target = checker.getSymbolAtLocation(node.typeName);
|
|
427
|
+
if (target && target.getFlags() & ts.SymbolFlags.Alias) {
|
|
428
|
+
target = checker.getAliasedSymbol(target);
|
|
429
|
+
}
|
|
430
|
+
const declaration = target?.declarations?.[0];
|
|
431
|
+
return declaration && ts.isTypeAliasDeclaration(declaration)
|
|
432
|
+
? declaredLiterals(checker, declaration.type, seen)
|
|
433
|
+
: [];
|
|
434
|
+
}
|
|
435
|
+
if (ts.isLiteralTypeNode(node)) {
|
|
436
|
+
const { literal } = node;
|
|
437
|
+
if (ts.isStringLiteral(literal)) return [literal.text];
|
|
438
|
+
if (ts.isNumericLiteral(literal)) return [Number(literal.text)];
|
|
439
|
+
if (literal.kind === ts.SyntaxKind.TrueKeyword) return [true];
|
|
440
|
+
if (literal.kind === ts.SyntaxKind.FalseKeyword) return [false];
|
|
441
|
+
}
|
|
442
|
+
return [];
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* TypeScript orders union members by internal type id, which shifts when
|
|
447
|
+
* unrelated declarations change; source order is stable and is what an
|
|
448
|
+
* inspector should show. Values the node does not spell out keep their place
|
|
449
|
+
* after the declared ones.
|
|
450
|
+
*/
|
|
451
|
+
function inDeclaredOrder(checker, values, node) {
|
|
452
|
+
const order = declaredLiterals(checker, node);
|
|
453
|
+
if (order.length === 0) return values;
|
|
454
|
+
const rank = (value) => {
|
|
455
|
+
const index = order.indexOf(value);
|
|
456
|
+
return index === -1 ? order.length : index;
|
|
457
|
+
};
|
|
458
|
+
return [...values].sort((a, b) => rank(a) - rank(b));
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
const isOptional = (symbol) =>
|
|
462
|
+
(symbol.getFlags() & ts.SymbolFlags.Optional) !== 0;
|
|
463
|
+
|
|
464
|
+
/** Parses a JSDoc default from `@default`, "(default `x`)", or "`x` (default)". */
|
|
465
|
+
export function parseDocumentedDefault(text, tagValue) {
|
|
466
|
+
if (tagValue) return tagValue.replace(/^['"`]|['"`]$/g, '');
|
|
467
|
+
if (!text) return undefined;
|
|
468
|
+
const patterns = [
|
|
469
|
+
/\(default:?\s+`([^`]+)`/i,
|
|
470
|
+
/\bdefaults? (?:to|is) `([^`]+)`/i,
|
|
471
|
+
/`([^`]+)`\s+\((?:the )?default\)/i,
|
|
472
|
+
// A boolean's default often goes unquoted: "(default true)", "Defaults
|
|
473
|
+
// to true.", "Default false." (KF-YNEMFD).
|
|
474
|
+
/\bdefaults?(?:\s+(?:to|is))?:?\s+(true|false)\b/i,
|
|
475
|
+
];
|
|
476
|
+
for (const pattern of patterns) {
|
|
477
|
+
const match = pattern.exec(text);
|
|
478
|
+
if (match) return match[1].replace(/^['"]|['"]$/g, '');
|
|
479
|
+
}
|
|
480
|
+
return undefined;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
/** Coerces a documented default to the prop's type, or drops it. */
|
|
484
|
+
export function coerceDefault(raw, descriptor) {
|
|
485
|
+
if (raw === undefined) return undefined;
|
|
486
|
+
switch (descriptor.kind) {
|
|
487
|
+
case 'boolean':
|
|
488
|
+
return raw === 'true' ? true : raw === 'false' ? false : undefined;
|
|
489
|
+
case 'number': {
|
|
490
|
+
const value = Number(raw);
|
|
491
|
+
return raw.trim() !== '' && Number.isFinite(value) ? value : undefined;
|
|
492
|
+
}
|
|
493
|
+
case 'enum':
|
|
494
|
+
return descriptor.values.find((value) => String(value) === raw);
|
|
495
|
+
case 'string':
|
|
496
|
+
return raw;
|
|
497
|
+
default:
|
|
498
|
+
return undefined;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
/** Documentation on the aliases a property's declared type names. */
|
|
503
|
+
function declaredTypeDocs(checker, symbol) {
|
|
504
|
+
const node = symbol.valueDeclaration ?? symbol.declarations?.[0];
|
|
505
|
+
const typeNode = node && 'type' in node ? node.type : undefined;
|
|
506
|
+
if (!typeNode) return [];
|
|
507
|
+
const references = ts.isUnionTypeNode(typeNode) ? typeNode.types : [typeNode];
|
|
508
|
+
return references
|
|
509
|
+
.filter((item) => ts.isTypeReferenceNode(item))
|
|
510
|
+
.map((item) => {
|
|
511
|
+
let target = checker.getSymbolAtLocation(item.typeName);
|
|
512
|
+
if (target && target.getFlags() & ts.SymbolFlags.Alias) {
|
|
513
|
+
target = checker.getAliasedSymbol(target);
|
|
514
|
+
}
|
|
515
|
+
return documentation(checker, target);
|
|
516
|
+
})
|
|
517
|
+
.filter(Boolean);
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
function isNative(ctx, symbol) {
|
|
521
|
+
const declarations = symbol.declarations ?? [];
|
|
522
|
+
// A package's own declarations live under its directory, never in a
|
|
523
|
+
// dependency's node_modules beneath it.
|
|
524
|
+
const own = (fileName) =>
|
|
525
|
+
fileName.startsWith(ctx.ownDirectory) &&
|
|
526
|
+
!fileName.slice(ctx.ownDirectory.length).includes('node_modules/');
|
|
527
|
+
return (
|
|
528
|
+
declarations.length > 0 &&
|
|
529
|
+
declarations.every((item) => !own(item.getSourceFile().fileName))
|
|
530
|
+
);
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
function describeProperty(ctx, symbol, depth) {
|
|
534
|
+
const { checker } = ctx;
|
|
535
|
+
const type = checker.getTypeOfSymbol(symbol);
|
|
536
|
+
const descriptor = describeType(ctx, type, depth);
|
|
537
|
+
const description = documentation(checker, symbol);
|
|
538
|
+
if (descriptor.kind === 'enum') {
|
|
539
|
+
const node = symbol.valueDeclaration ?? symbol.declarations?.[0];
|
|
540
|
+
if (node && 'type' in node && node.type) {
|
|
541
|
+
descriptor.values = inDeclaredOrder(
|
|
542
|
+
checker,
|
|
543
|
+
descriptor.values,
|
|
544
|
+
node.type,
|
|
545
|
+
);
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
const prop = {
|
|
549
|
+
name: symbol.getName(),
|
|
550
|
+
type: descriptor,
|
|
551
|
+
required: !isOptional(symbol) && descriptor.kind !== 'never',
|
|
552
|
+
};
|
|
553
|
+
const documented =
|
|
554
|
+
parseDocumentedDefault(description, jsDocTag(symbol, 'default')) ??
|
|
555
|
+
declaredTypeDocs(checker, symbol)
|
|
556
|
+
.map((doc) => parseDocumentedDefault(doc))
|
|
557
|
+
.find((value) => value !== undefined);
|
|
558
|
+
const fallback = coerceDefault(documented, descriptor);
|
|
559
|
+
if (fallback !== undefined) prop.default = fallback;
|
|
560
|
+
if (description) prop.description = description;
|
|
561
|
+
if (jsDocTag(symbol, 'deprecated') !== undefined) prop.deprecated = true;
|
|
562
|
+
// Lucide icon data is a nested array no document can spell as a literal;
|
|
563
|
+
// marking it lets documents name the icon instead (`$icon`).
|
|
564
|
+
if (ICON_DATA.test(descriptor.text ?? '')) prop.iconSource = 'lucide';
|
|
565
|
+
return prop;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
const ICON_DATA = /^(IconNode|LucideNode)( \| undefined)?$/;
|
|
569
|
+
|
|
570
|
+
/** Splits an object type's properties into own props and native attributes. */
|
|
571
|
+
function describeProps(ctx, type, depth) {
|
|
572
|
+
const props = [];
|
|
573
|
+
const nativeAttributes = [];
|
|
574
|
+
for (const symbol of ctx.checker.getPropertiesOfType(type)) {
|
|
575
|
+
if (isNative(ctx, symbol)) nativeAttributes.push(symbol.getName());
|
|
576
|
+
else props.push(describeProperty(ctx, symbol, depth));
|
|
577
|
+
}
|
|
578
|
+
return { props, nativeAttributes };
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
function mergeMemberProps(memberProps, memberCount) {
|
|
582
|
+
const byName = new Map();
|
|
583
|
+
for (const props of memberProps) {
|
|
584
|
+
for (const prop of props) {
|
|
585
|
+
const seen = byName.get(prop.name);
|
|
586
|
+
if (!seen) {
|
|
587
|
+
byName.set(prop.name, {
|
|
588
|
+
prop: { ...prop },
|
|
589
|
+
present: 1,
|
|
590
|
+
required: prop.required ? 1 : 0,
|
|
591
|
+
types: [prop.type],
|
|
592
|
+
});
|
|
593
|
+
continue;
|
|
594
|
+
}
|
|
595
|
+
seen.present += 1;
|
|
596
|
+
if (prop.required) seen.required += 1;
|
|
597
|
+
if (!seen.types.some((item) => item.text === prop.type.text)) {
|
|
598
|
+
seen.types.push(prop.type);
|
|
599
|
+
}
|
|
600
|
+
if (!seen.prop.description && prop.description) {
|
|
601
|
+
seen.prop.description = prop.description;
|
|
602
|
+
}
|
|
603
|
+
if (seen.prop.default === undefined && prop.default !== undefined) {
|
|
604
|
+
seen.prop.default = prop.default;
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
return [...byName.values()].map(({ prop, present, required, types }) => {
|
|
609
|
+
const usable = types.filter((item) => item.kind !== 'never');
|
|
610
|
+
let type = usable[0] ?? prop.type;
|
|
611
|
+
const literals = usable.map((item) =>
|
|
612
|
+
item.kind === 'literal' ? item.value : undefined,
|
|
613
|
+
);
|
|
614
|
+
// `boolean` beside `true` / `false` (Badge's `ariaHidden?: boolean` plus
|
|
615
|
+
// the `false` / `true` of its labeled and hidden variants) is still one
|
|
616
|
+
// boolean, so the editor offers a switch rather than a two-item select.
|
|
617
|
+
if (
|
|
618
|
+
usable.length > 1 &&
|
|
619
|
+
usable.every(
|
|
620
|
+
(item, index) =>
|
|
621
|
+
item.kind === 'boolean' || typeof literals[index] === 'boolean',
|
|
622
|
+
)
|
|
623
|
+
) {
|
|
624
|
+
type = { kind: 'boolean', text: 'boolean' };
|
|
625
|
+
} else if (
|
|
626
|
+
usable.length > 1 &&
|
|
627
|
+
literals.every((value) => value !== undefined)
|
|
628
|
+
) {
|
|
629
|
+
type = {
|
|
630
|
+
kind: 'enum',
|
|
631
|
+
values: literals,
|
|
632
|
+
text: usable.map((item) => item.text).join(' | '),
|
|
633
|
+
};
|
|
634
|
+
} else if (usable.length > 1) {
|
|
635
|
+
const text = usable.map((item) => item.text).join(' | ');
|
|
636
|
+
type = contentOfDescribed(usable, text) ?? {
|
|
637
|
+
kind: 'union',
|
|
638
|
+
members: usable,
|
|
639
|
+
text,
|
|
640
|
+
};
|
|
641
|
+
}
|
|
642
|
+
const merged = { ...prop, type, required: required === memberCount };
|
|
643
|
+
if (present < memberCount || usable.length !== types.length) {
|
|
644
|
+
merged.variantOnly = true;
|
|
645
|
+
}
|
|
646
|
+
return merged;
|
|
647
|
+
});
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
/**
|
|
651
|
+
* Projects a props type into `{ props, nativeAttributes, variants? }`. A
|
|
652
|
+
* union props type (Button's labeled-or-icon-only content, ListHeader's
|
|
653
|
+
* toggle mode) lists every prop once, marks the ones only some members allow
|
|
654
|
+
* as `variantOnly`, and records each member's required and forbidden props
|
|
655
|
+
* as a variant.
|
|
656
|
+
*/
|
|
657
|
+
export function describePropsType(ctx, type) {
|
|
658
|
+
const members = membersOf(type).filter((member) => !isNullish(member));
|
|
659
|
+
if (members.length <= 1) {
|
|
660
|
+
return members.length
|
|
661
|
+
? describeProps(ctx, members[0], 0)
|
|
662
|
+
: { props: [], nativeAttributes: [] };
|
|
663
|
+
}
|
|
664
|
+
const described = members.map((member) => describeProps(ctx, member, 0));
|
|
665
|
+
const props = mergeMemberProps(
|
|
666
|
+
described.map((item) => item.props),
|
|
667
|
+
members.length,
|
|
668
|
+
);
|
|
669
|
+
const nativeAttributes = [
|
|
670
|
+
...new Set(described.flatMap((item) => item.nativeAttributes)),
|
|
671
|
+
];
|
|
672
|
+
const discriminant = discriminantOf(ctx.checker, members);
|
|
673
|
+
const seen = new Set();
|
|
674
|
+
const variants = [];
|
|
675
|
+
for (const { props: list } of described) {
|
|
676
|
+
const variant = {};
|
|
677
|
+
if (discriminant) {
|
|
678
|
+
variant.when = Object.fromEntries(
|
|
679
|
+
discriminant.map((name) => [
|
|
680
|
+
name,
|
|
681
|
+
list.find((prop) => prop.name === name)?.type.value,
|
|
682
|
+
]),
|
|
683
|
+
);
|
|
684
|
+
}
|
|
685
|
+
variant.required = list
|
|
686
|
+
.filter((prop) => prop.required)
|
|
687
|
+
.map((prop) => prop.name);
|
|
688
|
+
variant.forbidden = list
|
|
689
|
+
.filter((prop) => prop.type.kind === 'never')
|
|
690
|
+
.map((prop) => prop.name);
|
|
691
|
+
const key = JSON.stringify(variant);
|
|
692
|
+
if (!seen.has(key)) {
|
|
693
|
+
seen.add(key);
|
|
694
|
+
variants.push(variant);
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
if (variants.length < 2) return { props, nativeAttributes };
|
|
698
|
+
return {
|
|
699
|
+
props,
|
|
700
|
+
nativeAttributes,
|
|
701
|
+
variants,
|
|
702
|
+
...(discriminant ? { discriminant } : {}),
|
|
703
|
+
};
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
function exportSymbol(checker, sourceFile, name) {
|
|
707
|
+
const moduleSymbol = checker.getSymbolAtLocation(sourceFile);
|
|
708
|
+
if (!moduleSymbol) return undefined;
|
|
709
|
+
const found = checker
|
|
710
|
+
.getExportsOfModule(moduleSymbol)
|
|
711
|
+
.find((symbol) => symbol.getName() === name);
|
|
712
|
+
if (!found) return undefined;
|
|
713
|
+
return found.getFlags() & ts.SymbolFlags.Alias
|
|
714
|
+
? checker.getAliasedSymbol(found)
|
|
715
|
+
: found;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
/**
|
|
719
|
+
* How a component carries application `data-*` attributes to its root (the
|
|
720
|
+
* Kerf UI editor's node marker and row keys): a `rootAttributes` prop, native
|
|
721
|
+
* `data-*` passthrough (a `data-${string}` index signature on the props), or
|
|
722
|
+
* none.
|
|
723
|
+
*/
|
|
724
|
+
function dataChannelOf(checker, type, props) {
|
|
725
|
+
if (props.some((prop) => prop.name === 'rootAttributes'))
|
|
726
|
+
return 'rootAttributes';
|
|
727
|
+
const members = type
|
|
728
|
+
? membersOf(type).filter((member) => !isNullish(member))
|
|
729
|
+
: [];
|
|
730
|
+
const native =
|
|
731
|
+
members.length > 0 &&
|
|
732
|
+
members.every((member) =>
|
|
733
|
+
checker
|
|
734
|
+
.getIndexInfosOfType(member)
|
|
735
|
+
.some(
|
|
736
|
+
(info) =>
|
|
737
|
+
info.keyType.flags & ts.TypeFlags.TemplateLiteral &&
|
|
738
|
+
info.keyType.texts[0] === 'data-',
|
|
739
|
+
),
|
|
740
|
+
);
|
|
741
|
+
return native ? 'native' : 'none';
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
/**
|
|
745
|
+
* Reads one exported component function: its props (from the first
|
|
746
|
+
* parameter), type parameters, and documentation. Returns undefined for an
|
|
747
|
+
* export that is not a component (a type, a wiring helper, a non-SafeHtml
|
|
748
|
+
* function).
|
|
749
|
+
*/
|
|
750
|
+
export function readComponentExport(ctx, sourceFile, name) {
|
|
751
|
+
const { checker } = ctx;
|
|
752
|
+
if (!/^[A-Z]/.test(name)) return undefined;
|
|
753
|
+
const symbol = exportSymbol(checker, sourceFile, name);
|
|
754
|
+
if (!symbol || !(symbol.getFlags() & ts.SymbolFlags.Function))
|
|
755
|
+
return undefined;
|
|
756
|
+
const [signature] = checker.getTypeOfSymbol(symbol).getCallSignatures();
|
|
757
|
+
if (!signature) return undefined;
|
|
758
|
+
if (!/SafeHtml$/.test(checker.typeToString(signature.getReturnType()))) {
|
|
759
|
+
return undefined;
|
|
760
|
+
}
|
|
761
|
+
const [parameter] = signature.getParameters();
|
|
762
|
+
const result = parameter
|
|
763
|
+
? describePropsType(ctx, checker.getTypeOfSymbol(parameter))
|
|
764
|
+
: { props: [], nativeAttributes: [] };
|
|
765
|
+
result.dataChannel = dataChannelOf(
|
|
766
|
+
checker,
|
|
767
|
+
parameter && checker.getTypeOfSymbol(parameter),
|
|
768
|
+
result.props,
|
|
769
|
+
);
|
|
770
|
+
const typeParameters = (signature.getTypeParameters() ?? []).map((item) => {
|
|
771
|
+
const constraint = item.getConstraint();
|
|
772
|
+
return {
|
|
773
|
+
name: item.getSymbol()?.getName(),
|
|
774
|
+
...(constraint ? { constraint: printType(checker, constraint) } : {}),
|
|
775
|
+
};
|
|
776
|
+
});
|
|
777
|
+
const description = documentation(checker, symbol);
|
|
778
|
+
return {
|
|
779
|
+
export: name,
|
|
780
|
+
...(description ? { description } : {}),
|
|
781
|
+
...(typeParameters.length ? { typeParameters } : {}),
|
|
782
|
+
...result,
|
|
783
|
+
};
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
const QUOTED = /^(['"])(.*)\1$/;
|
|
787
|
+
|
|
788
|
+
function customElementDefault(raw, type) {
|
|
789
|
+
if (raw === undefined) return undefined;
|
|
790
|
+
const quoted = QUOTED.exec(raw);
|
|
791
|
+
let value;
|
|
792
|
+
if (quoted) value = quoted[2];
|
|
793
|
+
else if (raw === 'true' || raw === 'false') value = raw === 'true';
|
|
794
|
+
else if (/^-?\d+(\.\d+)?$/.test(raw)) value = Number(raw);
|
|
795
|
+
if (value === undefined || value === '') return undefined;
|
|
796
|
+
if (type.kind === 'enum' && !type.values.includes(value)) return undefined;
|
|
797
|
+
return value;
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
/** Projects a Web Awesome `custom-elements.json` declaration into props. */
|
|
801
|
+
export function describeCustomElement(declaration) {
|
|
802
|
+
const props = (declaration.attributes ?? []).map((attribute) => {
|
|
803
|
+
const text = (attribute.type?.text ?? 'string')
|
|
804
|
+
.replace(/\s+/g, ' ')
|
|
805
|
+
.replace(/^\| /, '');
|
|
806
|
+
const parts = text
|
|
807
|
+
.split('|')
|
|
808
|
+
.map((part) => part.trim())
|
|
809
|
+
.filter((part) => part !== 'undefined' && part !== 'null');
|
|
810
|
+
const quoted = parts.filter((part) => QUOTED.test(part));
|
|
811
|
+
const values = quoted.map((part) => QUOTED.exec(part)[2]);
|
|
812
|
+
let type;
|
|
813
|
+
if (parts.length > 0 && quoted.length === parts.length) {
|
|
814
|
+
type = { kind: 'enum', values, text };
|
|
815
|
+
} else if (
|
|
816
|
+
quoted.length > 0 &&
|
|
817
|
+
quoted.length === parts.length - 1 &&
|
|
818
|
+
parts.includes('string')
|
|
819
|
+
) {
|
|
820
|
+
type = { kind: 'string', suggestions: values, text };
|
|
821
|
+
} else if (
|
|
822
|
+
parts.length === 1 &&
|
|
823
|
+
['string', 'number', 'boolean'].includes(parts[0])
|
|
824
|
+
) {
|
|
825
|
+
type = { kind: parts[0], text };
|
|
826
|
+
} else {
|
|
827
|
+
type = { kind: 'unknown', text };
|
|
828
|
+
}
|
|
829
|
+
const prop = { name: attribute.name, type, required: false };
|
|
830
|
+
if (attribute.fieldName && attribute.fieldName !== attribute.name) {
|
|
831
|
+
prop.property = attribute.fieldName;
|
|
832
|
+
}
|
|
833
|
+
const fallback = customElementDefault(attribute.default, type);
|
|
834
|
+
if (fallback !== undefined) prop.default = fallback;
|
|
835
|
+
if (attribute.description) prop.description = attribute.description;
|
|
836
|
+
if (attribute.deprecated) prop.deprecated = true;
|
|
837
|
+
return prop;
|
|
838
|
+
});
|
|
839
|
+
const slots = (declaration.slots ?? []).map((slot) => ({
|
|
840
|
+
name: slot.name === '' ? 'default' : slot.name,
|
|
841
|
+
...(slot.description ? { description: slot.description } : {}),
|
|
842
|
+
}));
|
|
843
|
+
return { props, slots };
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
const qualify = (pkg, id) => `${pkg}:${id}`;
|
|
847
|
+
|
|
848
|
+
function dtsFor(root, browserImport, pkg) {
|
|
849
|
+
return resolve(root, 'dist', `${browserImport.slice(pkg.length + 1)}.d.ts`);
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
/** Marks zone props (composition catalog) and css-value grammars (catalog). */
|
|
853
|
+
export function applyCrossReferences(
|
|
854
|
+
component,
|
|
855
|
+
{ zones = [], cssValueProps = [] },
|
|
856
|
+
) {
|
|
857
|
+
const zoneByProp = new Map(
|
|
858
|
+
zones.filter((zone) => zone.jsx?.prop).map((zone) => [zone.jsx.prop, zone]),
|
|
859
|
+
);
|
|
860
|
+
const cssByPath = new Map(cssValueProps.map((item) => [item.path, item]));
|
|
861
|
+
for (const prop of component.props) {
|
|
862
|
+
const zone = zoneByProp.get(prop.name);
|
|
863
|
+
if (zone) prop.zone = zone.id;
|
|
864
|
+
const css = cssByPath.get(prop.name);
|
|
865
|
+
if (css) {
|
|
866
|
+
prop.cssValue = {
|
|
867
|
+
grammar: css.grammar,
|
|
868
|
+
helpers: css.helpers,
|
|
869
|
+
rawPolicy: css.rawPolicy,
|
|
870
|
+
};
|
|
871
|
+
}
|
|
872
|
+
// Content with no curated zone is still a slot an editor can fill.
|
|
873
|
+
if (!prop.zone && prop.type.kind === 'content') prop.slot = true;
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
// Plumbing props an inspector never shows by default: inner styling hooks,
|
|
878
|
+
// slot placement, and attribute bags the editor owns (the node marker). The
|
|
879
|
+
// overlay can still give any of them a visible control.
|
|
880
|
+
const HIDDEN_PROP = /^(\w+ClassName|slot|rootAttributes|triggerAttributes)$/;
|
|
881
|
+
// A component's own class list is an advanced field, not a main prop
|
|
882
|
+
// (KF-X8X8VX: an author sets `className`, such as an appearance scope).
|
|
883
|
+
const CLASSES_PROP = /^(class|className)$/;
|
|
884
|
+
|
|
885
|
+
/** Generated inspector defaults, applied before the curated overlay. */
|
|
886
|
+
export function applyControlDefaults(component) {
|
|
887
|
+
for (const prop of component.props) {
|
|
888
|
+
if (HIDDEN_PROP.test(prop.name)) prop.control = 'hidden';
|
|
889
|
+
else if (CLASSES_PROP.test(prop.name)) prop.control = 'classes';
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
/** Merges curated overlay fields; unknown component or prop keys are problems. */
|
|
894
|
+
export function applyOverlay(component, overlay, problems) {
|
|
895
|
+
const curated = overlay?.components?.[component.key];
|
|
896
|
+
if (!curated) return;
|
|
897
|
+
for (const [name, fields] of Object.entries(curated.props ?? {})) {
|
|
898
|
+
const prop = component.props.find((item) => item.name === name);
|
|
899
|
+
if (prop) Object.assign(prop, fields);
|
|
900
|
+
else
|
|
901
|
+
problems.push(`${component.key}: overlay names unknown prop "${name}"`);
|
|
902
|
+
}
|
|
903
|
+
// KF-H1X3S7: a value's options list names a sibling list prop.
|
|
904
|
+
for (const prop of component.props) {
|
|
905
|
+
if (
|
|
906
|
+
prop.choicesFrom !== undefined &&
|
|
907
|
+
!component.props.some((item) => item.name === prop.choicesFrom)
|
|
908
|
+
)
|
|
909
|
+
problems.push(
|
|
910
|
+
`${component.key}: prop "${prop.name}" takes choices from unknown prop "${prop.choicesFrom}"`,
|
|
911
|
+
);
|
|
912
|
+
}
|
|
913
|
+
if (curated.groups) component.groups = curated.groups;
|
|
914
|
+
for (const [name, fields] of Object.entries(curated.props ?? {})) {
|
|
915
|
+
if (fields.group && !curated.groups?.includes(fields.group)) {
|
|
916
|
+
problems.push(
|
|
917
|
+
`${component.key}: prop "${name}" names undeclared group "${fields.group}"`,
|
|
918
|
+
);
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
/**
|
|
924
|
+
* Reads the components a set of catalog entries declare. Each spec names an
|
|
925
|
+
* entry's id and display name, the declaration file and import specifier of
|
|
926
|
+
* its public module, its export names, and its zones and css-value props.
|
|
927
|
+
*/
|
|
928
|
+
function readComponentEntries(ctx, program, pkg, specs, source, problems) {
|
|
929
|
+
const components = [];
|
|
930
|
+
for (const spec of specs) {
|
|
931
|
+
const sourceFile = spec.file && program.getSourceFile(spec.file);
|
|
932
|
+
if (!sourceFile) {
|
|
933
|
+
problems.push(
|
|
934
|
+
`${spec.id}: no declarations for ${spec.import ?? '(no import)'}`,
|
|
935
|
+
);
|
|
936
|
+
continue;
|
|
937
|
+
}
|
|
938
|
+
const found = spec.exports
|
|
939
|
+
.map((name) => readComponentExport(ctx, sourceFile, name))
|
|
940
|
+
.filter(Boolean);
|
|
941
|
+
// An entry of imperative helpers only (openAnchoredSurface) has no
|
|
942
|
+
// component; an entry whose uppercase exports all fail to resolve does.
|
|
943
|
+
if (found.length === 0) {
|
|
944
|
+
if (
|
|
945
|
+
spec.exports.some(
|
|
946
|
+
(name) =>
|
|
947
|
+
/^[A-Z]/.test(name) &&
|
|
948
|
+
exportSymbol(ctx.checker, sourceFile, name)?.getFlags() &
|
|
949
|
+
ts.SymbolFlags.Function,
|
|
950
|
+
)
|
|
951
|
+
) {
|
|
952
|
+
problems.push(
|
|
953
|
+
`${spec.id}: no SafeHtml component among ${spec.exports.join(', ')}`,
|
|
954
|
+
);
|
|
955
|
+
}
|
|
956
|
+
continue;
|
|
957
|
+
}
|
|
958
|
+
const primary = found.find((item) => item.export === spec.name) ?? found[0];
|
|
959
|
+
for (const item of found) {
|
|
960
|
+
const isPrimary = item === primary;
|
|
961
|
+
const component = {
|
|
962
|
+
key: isPrimary
|
|
963
|
+
? qualify(pkg, spec.id)
|
|
964
|
+
: `${qualify(pkg, spec.id)}#${item.export}`,
|
|
965
|
+
id: spec.id,
|
|
966
|
+
source,
|
|
967
|
+
import: spec.import,
|
|
968
|
+
...item,
|
|
969
|
+
};
|
|
970
|
+
applyCrossReferences(component, {
|
|
971
|
+
zones: isPrimary ? spec.zones : [],
|
|
972
|
+
cssValueProps: isPrimary ? spec.cssValueProps : [],
|
|
973
|
+
});
|
|
974
|
+
components.push(component);
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
return components;
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
function readKerfEntries(ctx, program, root, catalog, composition, problems) {
|
|
981
|
+
const pkg = catalog.package;
|
|
982
|
+
const zones = new Map(
|
|
983
|
+
(composition.entries ?? []).map((entry) => [entry.id, entry.zones ?? []]),
|
|
984
|
+
);
|
|
985
|
+
const specs = catalog.entries
|
|
986
|
+
.filter((entry) => entry.source === 'kerf' && entry.kind === 'component')
|
|
987
|
+
.map((entry) => {
|
|
988
|
+
const browserImport = entry.delivery?.browserImport;
|
|
989
|
+
return {
|
|
990
|
+
id: entry.id,
|
|
991
|
+
name: entry.name,
|
|
992
|
+
import: browserImport,
|
|
993
|
+
file: browserImport && dtsFor(root, browserImport, pkg),
|
|
994
|
+
exports: entry.publicExports ?? [],
|
|
995
|
+
zones: zones.get(entry.id) ?? [],
|
|
996
|
+
cssValueProps: entry.cssValueProps ?? [],
|
|
997
|
+
};
|
|
998
|
+
});
|
|
999
|
+
return readComponentEntries(ctx, program, pkg, specs, 'kerf', problems);
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
function readWebAwesomeEntries(catalog, customElements, problems) {
|
|
1003
|
+
const declarations = new Map(
|
|
1004
|
+
(customElements?.modules ?? [])
|
|
1005
|
+
.flatMap((module) => module.declarations ?? [])
|
|
1006
|
+
.filter((declaration) => declaration.tagName)
|
|
1007
|
+
.map((declaration) => [declaration.tagName, declaration]),
|
|
1008
|
+
);
|
|
1009
|
+
const components = [];
|
|
1010
|
+
for (const entry of catalog.entries) {
|
|
1011
|
+
if (entry.source !== 'webawesome') continue;
|
|
1012
|
+
const declaration = declarations.get(entry.id);
|
|
1013
|
+
if (!declaration) {
|
|
1014
|
+
problems.push(`${entry.id}: not in Web Awesome custom-elements.json`);
|
|
1015
|
+
continue;
|
|
1016
|
+
}
|
|
1017
|
+
components.push({
|
|
1018
|
+
key: qualify(catalog.package, entry.id),
|
|
1019
|
+
id: entry.id,
|
|
1020
|
+
source: 'webawesome',
|
|
1021
|
+
tagName: entry.id,
|
|
1022
|
+
import: entry.delivery?.registrationImport,
|
|
1023
|
+
...describeCustomElement(declaration),
|
|
1024
|
+
});
|
|
1025
|
+
}
|
|
1026
|
+
return components;
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
/**
|
|
1030
|
+
* Builds the component-props document from the catalog, composition catalog,
|
|
1031
|
+
* curated overlay, built declarations under `<root>/dist`, and Web Awesome's
|
|
1032
|
+
* manifest. Returns `{ document, problems }`; the sync script fails on any
|
|
1033
|
+
* problem (an unresolved component, an overlay key that names nothing).
|
|
1034
|
+
*/
|
|
1035
|
+
export function buildComponentProps({
|
|
1036
|
+
root,
|
|
1037
|
+
catalog,
|
|
1038
|
+
composition,
|
|
1039
|
+
overlay,
|
|
1040
|
+
customElements,
|
|
1041
|
+
}) {
|
|
1042
|
+
const problems = [];
|
|
1043
|
+
const pkg = catalog.package;
|
|
1044
|
+
const files = catalog.entries
|
|
1045
|
+
.filter((entry) => entry.source === 'kerf' && entry.delivery?.browserImport)
|
|
1046
|
+
.map((entry) => dtsFor(root, entry.delivery.browserImport, pkg));
|
|
1047
|
+
const program = createDeclarationProgram([...new Set(files)]);
|
|
1048
|
+
const ctx = createPropsContext(
|
|
1049
|
+
program.getTypeChecker(),
|
|
1050
|
+
resolve(root, 'dist'),
|
|
1051
|
+
);
|
|
1052
|
+
const components = [
|
|
1053
|
+
...readKerfEntries(ctx, program, root, catalog, composition, problems),
|
|
1054
|
+
...readWebAwesomeEntries(catalog, customElements, problems),
|
|
1055
|
+
];
|
|
1056
|
+
for (const component of components) {
|
|
1057
|
+
applyControlDefaults(component);
|
|
1058
|
+
applyOverlay(component, overlay, problems);
|
|
1059
|
+
}
|
|
1060
|
+
const known = new Set(components.map((component) => component.key));
|
|
1061
|
+
for (const key of Object.keys(overlay?.components ?? {})) {
|
|
1062
|
+
if (!known.has(key))
|
|
1063
|
+
problems.push(`overlay names unknown component "${key}"`);
|
|
1064
|
+
}
|
|
1065
|
+
const byKey = (a, b) => (a < b ? -1 : a > b ? 1 : 0);
|
|
1066
|
+
components.sort((a, b) => byKey(a.key, b.key));
|
|
1067
|
+
const definitions = Object.fromEntries(
|
|
1068
|
+
[...ctx.definitions.entries()].sort(([a], [b]) => byKey(a, b)),
|
|
1069
|
+
);
|
|
1070
|
+
return {
|
|
1071
|
+
document: {
|
|
1072
|
+
$schema: './component-props.schema.json',
|
|
1073
|
+
schema: COMPONENT_PROPS_SCHEMA_ID,
|
|
1074
|
+
package: pkg,
|
|
1075
|
+
description:
|
|
1076
|
+
'Generated per-component prop schema for Kerf UI: each public component function and Web Awesome element with its props (type grammar, required, default, enum values, zones and slots, discriminated variants, css-value grammars). Regenerate with `npm run props:sync`; do not edit.',
|
|
1077
|
+
components,
|
|
1078
|
+
definitions,
|
|
1079
|
+
},
|
|
1080
|
+
problems,
|
|
1081
|
+
};
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
/** The declaration file a package export condition points to. */
|
|
1085
|
+
function declarationsFor(root, target) {
|
|
1086
|
+
const path =
|
|
1087
|
+
typeof target === 'string'
|
|
1088
|
+
? target.replace(/\.(m?)js$/, '.d.$1ts')
|
|
1089
|
+
: (target?.types ??
|
|
1090
|
+
(target?.import ? declarationsFor(root, target.import) : undefined));
|
|
1091
|
+
return path ? resolve(root, path) : undefined;
|
|
1092
|
+
}
|
|
1093
|
+
|
|
1094
|
+
/**
|
|
1095
|
+
* Builds a component package's `component-props.json` (KF-B8TGP4: component
|
|
1096
|
+
* packages ship the same prop schema as @kerfjs/ui). Components and zones come
|
|
1097
|
+
* from the package's composition catalog (`package.json#kerfComponentCatalog
|
|
1098
|
+
* .output`, written by create-kerf-component); each component's declarations
|
|
1099
|
+
* come from the `types` of the package export its `publicExports` name (a
|
|
1100
|
+
* named subpath before `.`). Run after the package's build. Returns
|
|
1101
|
+
* `{ document, problems }`.
|
|
1102
|
+
*/
|
|
1103
|
+
export function buildPackageComponentProps({
|
|
1104
|
+
root,
|
|
1105
|
+
packageJson,
|
|
1106
|
+
composition,
|
|
1107
|
+
overlay,
|
|
1108
|
+
}) {
|
|
1109
|
+
const problems = [];
|
|
1110
|
+
const pkg = packageJson.name;
|
|
1111
|
+
const exportMap =
|
|
1112
|
+
typeof packageJson.exports === 'string' || packageJson.exports?.types
|
|
1113
|
+
? { '.': packageJson.exports }
|
|
1114
|
+
: (packageJson.exports ?? {});
|
|
1115
|
+
const specs = [];
|
|
1116
|
+
let usesSource = false;
|
|
1117
|
+
for (const entry of composition.entries ?? []) {
|
|
1118
|
+
if (entry.kind !== 'component' || (entry.package && entry.package !== pkg))
|
|
1119
|
+
continue;
|
|
1120
|
+
const exported = (entry.publicExports ?? []).map((item) =>
|
|
1121
|
+
typeof item === 'string' ? { name: item, subpath: '.' } : item,
|
|
1122
|
+
);
|
|
1123
|
+
const subpaths = [...new Set(exported.map((item) => item.subpath ?? '.'))];
|
|
1124
|
+
const subpath = subpaths.find((item) => item !== '.') ?? subpaths[0] ?? '.';
|
|
1125
|
+
const declarations = declarationsFor(root, exportMap[subpath]);
|
|
1126
|
+
// A component that lives in app source has no package export: read its
|
|
1127
|
+
// source file and import it by a root-relative path, which view tools
|
|
1128
|
+
// rewrite relative to each document (KF-7JP509: app-source catalogs).
|
|
1129
|
+
const source =
|
|
1130
|
+
entry.source && existsSync(resolve(root, entry.source))
|
|
1131
|
+
? resolve(root, entry.source)
|
|
1132
|
+
: undefined;
|
|
1133
|
+
const fromSource = !(declarations && existsSync(declarations)) && source;
|
|
1134
|
+
const file = fromSource ? source : declarations;
|
|
1135
|
+
if (fromSource) usesSource = true;
|
|
1136
|
+
specs.push({
|
|
1137
|
+
id: entry.id,
|
|
1138
|
+
name: entry.name,
|
|
1139
|
+
import: fromSource
|
|
1140
|
+
? sourceImport(root, source)
|
|
1141
|
+
: subpath === '.'
|
|
1142
|
+
? pkg
|
|
1143
|
+
: `${pkg}${subpath.slice(1)}`,
|
|
1144
|
+
file: file && existsSync(file) ? file : undefined,
|
|
1145
|
+
exports: [
|
|
1146
|
+
...new Set(
|
|
1147
|
+
exported
|
|
1148
|
+
.filter((item) => (item.subpath ?? '.') === subpath)
|
|
1149
|
+
.map((item) => item.name),
|
|
1150
|
+
),
|
|
1151
|
+
],
|
|
1152
|
+
zones: entry.zones ?? [],
|
|
1153
|
+
cssValueProps: entry.cssValueProps ?? [],
|
|
1154
|
+
});
|
|
1155
|
+
}
|
|
1156
|
+
const program = createDeclarationProgram(
|
|
1157
|
+
[...new Set(specs.map((spec) => spec.file).filter(Boolean))],
|
|
1158
|
+
usesSource ? packageCompilerOptions(root) : {},
|
|
1159
|
+
);
|
|
1160
|
+
const ctx = createPropsContext(program.getTypeChecker(), root);
|
|
1161
|
+
const components = readComponentEntries(
|
|
1162
|
+
ctx,
|
|
1163
|
+
program,
|
|
1164
|
+
pkg,
|
|
1165
|
+
specs,
|
|
1166
|
+
'package',
|
|
1167
|
+
problems,
|
|
1168
|
+
);
|
|
1169
|
+
for (const component of components) {
|
|
1170
|
+
applyControlDefaults(component);
|
|
1171
|
+
applyOverlay(component, overlay, problems);
|
|
1172
|
+
}
|
|
1173
|
+
const known = new Set(components.map((component) => component.key));
|
|
1174
|
+
for (const key of Object.keys(overlay?.components ?? {})) {
|
|
1175
|
+
if (!known.has(key))
|
|
1176
|
+
problems.push(`overlay names unknown component "${key}"`);
|
|
1177
|
+
}
|
|
1178
|
+
const byKey = (a, b) => (a < b ? -1 : a > b ? 1 : 0);
|
|
1179
|
+
components.sort((a, b) => byKey(a.key, b.key));
|
|
1180
|
+
return {
|
|
1181
|
+
document: {
|
|
1182
|
+
$schema:
|
|
1183
|
+
'https://raw.githubusercontent.com/brianwestphal/kerf/main/ui/ai/component-props.schema.json',
|
|
1184
|
+
schema: COMPONENT_PROPS_SCHEMA_ID,
|
|
1185
|
+
package: pkg,
|
|
1186
|
+
description: `Generated prop schema for ${pkg}'s Kerf components. Regenerate with \`kerf-ui-props --write\` after a build; do not edit.`,
|
|
1187
|
+
components,
|
|
1188
|
+
definitions: Object.fromEntries(
|
|
1189
|
+
[...ctx.definitions.entries()].sort(([a], [b]) => byKey(a, b)),
|
|
1190
|
+
),
|
|
1191
|
+
},
|
|
1192
|
+
problems,
|
|
1193
|
+
};
|
|
1194
|
+
}
|
|
1195
|
+
|
|
1196
|
+
/** Reads the JSON inputs relative to the ui package root. */
|
|
1197
|
+
export function readComponentPropsInputs(root) {
|
|
1198
|
+
const json = (path) => JSON.parse(readFileSync(resolve(root, path), 'utf8'));
|
|
1199
|
+
return {
|
|
1200
|
+
root,
|
|
1201
|
+
catalog: json('ai/component-catalog.json'),
|
|
1202
|
+
composition: json('ai/component-composition.json'),
|
|
1203
|
+
overlay: json('ai/component-props-overlay.json'),
|
|
1204
|
+
customElements: json(
|
|
1205
|
+
'node_modules/@awesome.me/webawesome/dist/custom-elements.json',
|
|
1206
|
+
),
|
|
1207
|
+
};
|
|
1208
|
+
}
|