@tmorrow/cre8-wc 2.0.6 → 2.0.8
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/a2ui/catalog +5 -5
- package/a2ui/catalog-kg.json +156 -20
- package/a2ui/catalog.json +394 -35
- package/a2ui/catalog.svg +2445 -2445
- package/a2ui/examples/compound-families.json +298 -0
- package/a2ui/examples/llm-observability.json +678 -650
- package/a2ui/generate-catalog.mjs +116 -3
- package/a2ui/inert-props.json +32 -0
- package/a2ui/render-audit.mjs +294 -0
- package/a2ui/renderer.d.ts +2 -1
- package/a2ui/renderer.js +1 -1
- package/a2ui/renderer.ts +1 -1
- package/a2ui/smoke-test.mjs +3 -3
- package/a2ui/stream/diff-test.mjs +299 -0
- package/a2ui/stream/diff.d.ts +28 -0
- package/a2ui/stream/diff.js +130 -0
- package/a2ui/stream/diff.ts +145 -0
- package/a2ui/stream/index.d.ts +11 -0
- package/a2ui/stream/index.js +11 -0
- package/a2ui/stream/index.ts +43 -0
- package/a2ui/stream/model.d.ts +66 -0
- package/a2ui/stream/model.js +429 -0
- package/a2ui/stream/model.ts +472 -0
- package/a2ui/stream/pointer.d.ts +34 -0
- package/a2ui/stream/pointer.js +146 -0
- package/a2ui/stream/pointer.ts +147 -0
- package/a2ui/stream/renderer.d.ts +51 -0
- package/a2ui/stream/renderer.js +282 -0
- package/a2ui/stream/renderer.ts +291 -0
- package/a2ui/stream/stream-test.mjs +592 -0
- package/a2ui/stream/types.d.ts +173 -0
- package/a2ui/stream/types.js +17 -0
- package/a2ui/stream/types.ts +127 -0
- package/cdn/cre8-wc.esm.js +3528 -3227
- package/cdn/cre8-wc.esm.js.map +1 -1
- package/cdn/cre8-wc.min.js +290 -290
- package/cdn/cre8-wc.min.js.map +1 -1
- package/dist/assets/{Changelog-Documentation-BguNswiM.js → Changelog-Documentation-CeOetLxK.js} +1 -1
- package/dist/assets/{Code-Guidelines-BM3dZyzL.js → Code-Guidelines-BjdezAjj.js} +1 -1
- package/dist/assets/{Color-6AOWCN3U-C4AEGNk3.js → Color-6AOWCN3U-DPFGZitI.js} +1 -1
- package/dist/assets/{Contributing-Guidelines-DZURVehh.js → Contributing-Guidelines-B1M2V1hW.js} +1 -1
- package/dist/assets/{DocsRenderer-JROSPFPF-DeZmCI9u.js → DocsRenderer-JROSPFPF-BBy8KWNl.js} +1 -1
- package/dist/assets/{Tokens-Documentation-ZecGbtQg.js → Tokens-Documentation-CdTxFDLe.js} +1 -1
- package/dist/assets/{WithTooltip-7X4HQR7L-2Hfrkir-.js → WithTooltip-7X4HQR7L-DZzTNMQ7.js} +1 -1
- package/dist/assets/{accordion-item.stories-D-MjrX5G.js → accordion-item.stories-Bl26JlHp.js} +1 -9
- package/dist/assets/{accordion.stories-icgNa1dl.js → accordion.stories-DjoLApQw.js} +3 -11
- package/dist/assets/{alert.stories-BzDaXtj-.js → alert.stories-pO1y3YCQ.js} +15 -31
- package/dist/assets/{badge-C5wOWgyg.js → badge-BTxW3bN2.js} +3 -11
- package/dist/assets/{badge.stories-5GfB4jVI.js → badge.stories-vqh63RJ2.js} +1 -1
- package/dist/assets/{band.stories-DhXaP_kL.js → band.stories-CjKRppSb.js} +1 -9
- package/dist/assets/{blocks-DhUVut8Z.js → blocks-1be_-L6v.js} +5 -5
- package/dist/assets/{breadcrumbs.stories-CrPUBVk1.js → breadcrumbs.stories-Doyfy3V9.js} +2 -18
- package/dist/assets/{button-CJL8yzAT.js → button-CgaWukz0.js} +1 -9
- package/dist/assets/{button-group-BgwgtSFC.js → button-group-G7qN4MwM.js} +1 -9
- package/dist/assets/{button-group.stories-W-07gO63.js → button-group.stories-cL3Kay6M.js} +1 -1
- package/dist/assets/{button.stories-BPzJ-sCv.js → button.stories-C9HSpxWb.js} +6 -6
- package/dist/assets/{card.stories-mlFGY2Xn.js → card.stories-BbU8YymD.js} +3 -11
- package/dist/assets/{chart.stories-C8yuHHeK.js → chart.stories-BL4FxIA_.js} +1 -1
- package/dist/assets/{checkbox-field-item-iHcdmTNw.js → checkbox-field-item-DIMHcWM0.js} +1 -9
- package/dist/assets/{checkbox-field-item.stories-D1aVLDXn.js → checkbox-field-item.stories-XbB4x_lO.js} +1 -1
- package/dist/assets/{checkbox-field.stories-BoVB2jCx.js → checkbox-field.stories-YnqFUI4K.js} +2 -10
- package/dist/assets/{cre8-element-DfmMtHJO.js → cre8-element-B35i4Lyg.js} +1 -1
- package/dist/assets/{cre8-form-element-bQpK8UYN.js → cre8-form-element-Cfc5VeYV.js} +1 -1
- package/dist/assets/{danger-button.stories-Cb4ljnhQ.js → danger-button.stories-xh25hmfd.js} +1 -9
- package/dist/assets/{date-picker.stories-Cje3qk8D.js → date-picker.stories-DD_ctzEF.js} +1 -49
- package/dist/assets/{divider-B_PXBGWD.js → divider-xZ2KARHf.js} +2 -10
- package/dist/assets/{divider.stories-CtfeBqVV.js → divider.stories-Bk9oF-OV.js} +1 -1
- package/dist/assets/{dropdown-Cgwne34I.js → dropdown-BEP5x3CW.js} +6 -22
- package/dist/assets/{dropdown-item.stories-pXkDLRuv.js → dropdown-item.stories-Iaw_UrEP.js} +1 -1
- package/dist/assets/{dropdown.stories-DZnmHieY.js → dropdown.stories-B0OlKD7h.js} +1 -1
- package/dist/assets/{example-drug-card.stories-DTzLXTFx.js → example-drug-card.stories-Bp5JIeE_.js} +1 -1
- package/dist/assets/{f-po-C2WpbOFJ.js → f-po-BdPzDRD-.js} +1 -1
- package/dist/assets/{feature.stories-DffXdJch.js → feature.stories-DYE1Js70.js} +1 -9
- package/dist/assets/{field-DzYRqQb2.js → field-BpUYyRW1.js} +1 -9
- package/dist/assets/{field-note-DKXZiXLU.js → field-note-fccBckVl.js} +3 -11
- package/dist/assets/{field-note.stories-DS_0bQul.js → field-note.stories-BH9AZMbF.js} +1 -1
- package/dist/assets/{field.stories-BvXn0oG6.js → field.stories-BQPtmziK.js} +1 -1
- package/dist/assets/{footer.stories-C3ZibisU.js → footer.stories-DCWEciqD.js} +1 -9
- package/dist/assets/{form-example.stories-C-TuOeF2.js → form-example.stories-9IDC0AgX.js} +1 -1
- package/dist/assets/{formatter-L2YTDE3Q-CJVnxOUW.js → formatter-L2YTDE3Q-B9u1AOWn.js} +1 -1
- package/dist/assets/{global-nav-item-xQL7wVjY.js → global-nav-item-T4htN-yO.js} +6 -14
- package/dist/assets/{global-nav-item.stories-Dp9TE3aR.js → global-nav-item.stories-2dWRfCXv.js} +1 -1
- package/dist/assets/{global-nav.stories-B5Nk8JZ0.js → global-nav.stories-Fh1gScqg.js} +2 -10
- package/dist/assets/{grid-DYgnZBsd.js → grid-C5CKMXNe.js} +3 -19
- package/dist/assets/{grid.stories-BFiXTq2C.js → grid.stories-BLmCNdeA.js} +1 -1
- package/dist/assets/{header.stories-D1f7xhjV.js → header.stories-BkDrjJtj.js} +1 -9
- package/dist/assets/{heading-485Jz7JZ.js → heading-Dbka33DK.js} +2 -10
- package/dist/assets/{heading.stories-gPF_SmTc.js → heading.stories-Be40_bmG.js} +1 -1
- package/dist/assets/{hero.stories-BHlFNdvF.js → hero.stories-vRu7PZG9.js} +1 -9
- package/dist/assets/{icon-DeTLDzTS.js → icon-ChfRWXWy.js} +2 -10
- package/dist/assets/{icon-description-o-YaiEjK.js → icon-description-BBSwDykJ.js} +1 -1
- package/dist/assets/{icon-description.stories-BdPRvEwe.js → icon-description.stories-Cg6ekOme.js} +1 -1
- package/dist/assets/{icon.stories-BxWpqxT5.js → icon.stories-Cj4U7L5G.js} +1 -1
- package/dist/assets/if-defined-Bxnzk64Q.js +1 -0
- package/dist/assets/{iframe-dHvya7sk.js → iframe-BNJP6ovU.js} +35 -35
- package/dist/assets/{inline-alert.stories-FH0bQ0jh.js → inline-alert.stories-CygBYI02.js} +1 -9
- package/dist/assets/{layout-container.stories-D6Z6Kx78.js → layout-container.stories-TMyIJteJ.js} +2 -10
- package/dist/assets/{layout.stories-CNYuwC_r.js → layout.stories-ylRM-ANL.js} +7 -23
- package/dist/assets/{linelength-container.stories-pCRXZvxS.js → linelength-container.stories-Br2v8jXE.js} +1 -9
- package/dist/assets/{link-BpCiLxNW.js → link-CRE0Eqdo.js} +1 -9
- package/dist/assets/{link-list.stories-12vsAa1P.js → link-list.stories--y-urrVo.js} +7 -23
- package/dist/assets/{link.stories-DAoQtY4_.js → link.stories-C3WQOgkY.js} +2 -2
- package/dist/assets/{list.stories-D0N3yBIf.js → list.stories-Bd2bxkxn.js} +7 -23
- package/dist/assets/{loading-spinner-g6iJajXH.js → loading-spinner-C52KNq6y.js} +4 -12
- package/dist/assets/{loading-spinner.stories-B6_mgPxB.js → loading-spinner.stories-DPRGEeHT.js} +1 -1
- package/dist/assets/{logo.stories-BvMwN2qg.js → logo.stories-2LBqqraT.js} +1 -9
- package/dist/assets/{main.stories-pL4zefbs.js → main.stories-BQzD7iWD.js} +2 -10
- package/dist/assets/{medication-card.stories-DK1XGJic.js → medication-card.stories-Wc-hA0-s.js} +5 -5
- package/dist/assets/{medication-form.stories-Bj5dLp5S.js → medication-form.stories-DfFOCDaU.js} +1 -1
- package/dist/assets/{modal-CO0M4e_8.js → modal-CCfbY4fF.js} +1 -9
- package/dist/assets/{modal-BNu8xy08.js → modal-GglWRNJp.js} +1 -1
- package/dist/assets/{modal.stories-CHYBrq_E.js → modal.stories-CpybCs79.js} +1 -1
- package/dist/assets/{multi-select.stories-C9XXsWio.js → multi-select.stories-BhzEKRui.js} +1 -9
- package/dist/assets/{nav-container.stories-DU9fhvDu.js → nav-container.stories-Be1YlegP.js} +3 -11
- package/dist/assets/{page-header.stories-BrstKiEY.js → page-header.stories-BOVLQ0YF.js} +1 -9
- package/dist/assets/{pagination.stories-Bw2M2iOn.js → pagination.stories-D62sa_1K.js} +9 -25
- package/dist/assets/{percent-bar.stories-UQRXYUqd.js → percent-bar.stories-CYi4El7T.js} +1 -9
- package/dist/assets/{popover.stories-ZkwrRFpR.js → popover.stories-B9O8F4yv.js} +1 -9
- package/dist/assets/{primary-nav.stories-wqOKwgQn.js → primary-nav.stories-Bt-o7h45.js} +1 -17
- package/dist/assets/{progress-meter-TzASasu0.js → progress-meter-Dit59091.js} +1 -9
- package/dist/assets/{progress-meter.stories-qfJALZf8.js → progress-meter.stories-CYnOCmjo.js} +1 -1
- package/dist/assets/{progress-steps-item-KvW1d_7L.js → progress-steps-item-CWJsad0s.js} +1 -9
- package/dist/assets/{progress-steps-item.stories-uOn6tJ1W.js → progress-steps-item.stories-ePn_6bPn.js} +1 -1
- package/dist/assets/{progress-steps.stories-CKFPx8D0.js → progress-steps.stories-CblrEcXF.js} +1 -9
- package/dist/assets/{radio-field-item-CTaR50XR.js → radio-field-item-Bm-0RWPe.js} +5 -21
- package/dist/assets/{radio-field-item.stories-DQSLj8W1.js → radio-field-item.stories-y_TrTRIW.js} +1 -1
- package/dist/assets/{radio-field.stories-Btmc_Iep.js → radio-field.stories-CSWrbUrn.js} +1 -1
- package/dist/assets/{remove-tag-BSEZ7VT8.js → remove-tag-lCr57c5r.js} +1 -9
- package/dist/assets/{remove-tag.stories-diRKi7Ua.js → remove-tag.stories-CDfwCdvZ.js} +1 -1
- package/dist/assets/{request-prescription.stories-DQvra7ia.js → request-prescription.stories-O4zqokfb.js} +1 -1
- package/dist/assets/{sample-modal.stories-deE1EBfZ.js → sample-modal.stories-BZ4N2R2Z.js} +1 -1
- package/dist/assets/{section.stories-DF4mcy2O.js → section.stories-D_1InThX.js} +1 -9
- package/dist/assets/{select-tile-D-C8oSrm.js → select-tile-BqqB3ZtE.js} +2 -10
- package/dist/assets/{select-tile-list.stories-vsBQUIcl.js → select-tile-list.stories-Di4ILgV8.js} +1 -9
- package/dist/assets/{select-tile.stories-CqHzN5fc.js → select-tile.stories-D3h_6zlV.js} +6 -6
- package/dist/assets/{select.stories-8aOGxTtr.js → select.stories-BB2phP9A.js} +1 -9
- package/dist/assets/{skeleton-loader.stories-CwR2-aC5.js → skeleton-loader.stories-y4uml_kV.js} +5 -13
- package/dist/assets/{split-button.stories-CyfdrK4u.js → split-button.stories-C_82I4ME.js} +2 -10
- package/dist/assets/{spread-BPiNgQQF.js → spread-CnPic3C2.js} +1 -1
- package/dist/assets/state-DkQhleoO.js +1 -0
- package/dist/assets/{submenu.stories-CDhNzZzh.js → submenu.stories-UDtaREr1.js} +2 -18
- package/dist/assets/{syntaxhighlighter-T5IQBZDB-BzI6WxUR.js → syntaxhighlighter-T5IQBZDB-D-I_s_yD.js} +1 -1
- package/dist/assets/{table-header-CfcchoYz.js → table-header-2837i43H.js} +3 -51
- package/dist/assets/{table-object.stories-Bd5qdfMU.js → table-object.stories-D4KoI-wA.js} +1 -9
- package/dist/assets/{table.stories-DxuBe9dJ.js → table.stories-DUJDibEp.js} +1 -1
- package/dist/assets/{tabs.stories-Cpc3OHJx.js → tabs.stories-C06SngOF.js} +5 -29
- package/dist/assets/{tag-list.stories-BmyCmrTF.js → tag-list.stories-Du-IoYzu.js} +2 -10
- package/dist/assets/{tag-vQFuZneb.js → tag-oHGdclJl.js} +1 -9
- package/dist/assets/{tag.stories-DGzrNUbb.js → tag.stories-C5D5IbuK.js} +1 -1
- package/dist/assets/{tertiary-nav.stories-D4q5K-am.js → tertiary-nav.stories-B1GU8Zi4.js} +3 -19
- package/dist/assets/{text-link-4qLRIeJB.js → text-link-B3m3KEqY.js} +1 -9
- package/dist/assets/{text-link.stories-D6BRm2I5.js → text-link.stories-4O6qn82H.js} +1 -1
- package/dist/assets/{text-passage-DGaI5i2I.js → text-passage-xQVosjOr.js} +3 -19
- package/dist/assets/{text-passage.stories-DkmXVUhH.js → text-passage.stories-Da1nspwG.js} +1 -1
- package/dist/assets/{tooltip.stories-B7ADDq7o.js → tooltip.stories-DLKyyeKn.js} +6 -14
- package/dist/assets/{utility-nav.stories-ffXVvyLp.js → utility-nav.stories-B6xBFe7z.js} +5 -21
- package/dist/design-tokens/brands/cre8/css/tokens_brand.css +1 -1
- package/dist/design-tokens/core/scss/theming/component.css +1 -1
- package/dist/design-tokens/core/scss/theming/variables.css +1 -7
- package/dist/design-tokens/core/scss/theming/variables.scss +0 -11
- package/dist/icons/cre8-icons.svg +1 -1
- package/dist/iframe.html +1 -24
- package/dist/index.html +25 -77
- package/dist/project.json +1 -1
- package/lib/a2ui/renderer.d.ts +2 -1
- package/lib/a2ui/renderer.d.ts.map +1 -1
- package/lib/a2ui/renderer.js +1 -1
- package/lib/a2ui/renderer.js.map +1 -1
- package/lib/a2ui/stream/diff.d.ts +29 -0
- package/lib/a2ui/stream/diff.d.ts.map +1 -0
- package/lib/a2ui/stream/diff.js +131 -0
- package/lib/a2ui/stream/diff.js.map +1 -0
- package/lib/a2ui/stream/index.d.ts +12 -0
- package/lib/a2ui/stream/index.d.ts.map +1 -0
- package/lib/a2ui/stream/index.js +12 -0
- package/lib/a2ui/stream/index.js.map +1 -0
- package/lib/a2ui/stream/model.d.ts +67 -0
- package/lib/a2ui/stream/model.d.ts.map +1 -0
- package/lib/a2ui/stream/model.js +423 -0
- package/lib/a2ui/stream/model.js.map +1 -0
- package/lib/a2ui/stream/pointer.d.ts +35 -0
- package/lib/a2ui/stream/pointer.d.ts.map +1 -0
- package/lib/a2ui/stream/pointer.js +147 -0
- package/lib/a2ui/stream/pointer.js.map +1 -0
- package/lib/a2ui/stream/renderer.d.ts +52 -0
- package/lib/a2ui/stream/renderer.d.ts.map +1 -0
- package/lib/a2ui/stream/renderer.js +279 -0
- package/lib/a2ui/stream/renderer.js.map +1 -0
- package/lib/a2ui/stream/types.d.ts +174 -0
- package/lib/a2ui/stream/types.d.ts.map +1 -0
- package/lib/a2ui/stream/types.js +18 -0
- package/lib/a2ui/stream/types.js.map +1 -0
- package/lib/components/accordion/accordion.d.ts +15 -0
- package/lib/components/accordion/accordion.d.ts.map +1 -1
- package/lib/components/accordion/accordion.js +23 -0
- package/lib/components/accordion/accordion.js.map +1 -1
- package/lib/components/badge/badge.d.ts +5 -18
- package/lib/components/badge/badge.d.ts.map +1 -1
- package/lib/components/badge/badge.js +0 -15
- package/lib/components/badge/badge.js.map +1 -1
- package/lib/components/breadcrumbs/breadcrumbs.d.ts +14 -0
- package/lib/components/breadcrumbs/breadcrumbs.d.ts.map +1 -1
- package/lib/components/breadcrumbs/breadcrumbs.js +21 -0
- package/lib/components/breadcrumbs/breadcrumbs.js.map +1 -1
- package/lib/components/chart/chart.d.ts +3 -3
- package/lib/components/chart/chart.js +6 -6
- package/lib/components/chart/chart.js.map +1 -1
- package/lib/components/checkbox-field/checkbox-field.d.ts +19 -0
- package/lib/components/checkbox-field/checkbox-field.d.ts.map +1 -1
- package/lib/components/checkbox-field/checkbox-field.js +28 -0
- package/lib/components/checkbox-field/checkbox-field.js.map +1 -1
- package/lib/components/cre8-element.d.ts +19 -0
- package/lib/components/cre8-element.d.ts.map +1 -1
- package/lib/components/cre8-element.js +51 -2
- package/lib/components/cre8-element.js.map +1 -1
- package/lib/components/divider/divider.d.ts +1 -1
- package/lib/components/divider/divider.d.ts.map +1 -1
- package/lib/components/divider/divider.js.map +1 -1
- package/lib/components/dropdown/dropdown.d.ts +13 -0
- package/lib/components/dropdown/dropdown.d.ts.map +1 -1
- package/lib/components/dropdown/dropdown.js +19 -0
- package/lib/components/dropdown/dropdown.js.map +1 -1
- package/lib/components/dropdown-item/dropdown-item.d.ts +1 -1
- package/lib/components/dropdown-item/dropdown-item.js +2 -2
- package/lib/components/dropdown-item/dropdown-item.js.map +1 -1
- package/lib/components/heading/heading.d.ts +3 -5
- package/lib/components/heading/heading.d.ts.map +1 -1
- package/lib/components/heading/heading.js +2 -4
- package/lib/components/heading/heading.js.map +1 -1
- package/lib/components/icon/icon.d.ts +4 -4
- package/lib/components/icon/icon.js +6 -6
- package/lib/components/icon/icon.js.map +1 -1
- package/lib/components/link-list/link-list.d.ts +19 -0
- package/lib/components/link-list/link-list.d.ts.map +1 -1
- package/lib/components/link-list/link-list.js +19 -0
- package/lib/components/link-list/link-list.js.map +1 -1
- package/lib/components/list/list.d.ts +13 -0
- package/lib/components/list/list.d.ts.map +1 -1
- package/lib/components/list/list.js +15 -0
- package/lib/components/list/list.js.map +1 -1
- package/lib/components/modal/modal.d.ts +2 -2
- package/lib/components/modal/modal.js +2 -2
- package/lib/components/modal/modal.js.map +1 -1
- package/lib/components/multi-select/multi-select.d.ts +2 -2
- package/lib/components/multi-select/multi-select.js +5 -5
- package/lib/components/multi-select/multi-select.js.map +1 -1
- package/lib/components/pagination/pagination.d.ts +1 -1
- package/lib/components/pagination/pagination.js +2 -2
- package/lib/components/pagination/pagination.js.map +1 -1
- package/lib/components/percent-bar/percent-bar.d.ts +2 -0
- package/lib/components/percent-bar/percent-bar.d.ts.map +1 -1
- package/lib/components/percent-bar/percent-bar.js +3 -1
- package/lib/components/percent-bar/percent-bar.js.map +1 -1
- package/lib/components/popover/popover.d.ts +6 -7
- package/lib/components/popover/popover.d.ts.map +1 -1
- package/lib/components/popover/popover.js +4 -4
- package/lib/components/popover/popover.js.map +1 -1
- package/lib/components/progress-meter/progress-meter.d.ts +0 -8
- package/lib/components/progress-meter/progress-meter.d.ts.map +1 -1
- package/lib/components/progress-meter/progress-meter.js +0 -7
- package/lib/components/progress-meter/progress-meter.js.map +1 -1
- package/lib/components/progress-steps/progress-steps.d.ts +16 -0
- package/lib/components/progress-steps/progress-steps.d.ts.map +1 -1
- package/lib/components/progress-steps/progress-steps.js +25 -0
- package/lib/components/progress-steps/progress-steps.js.map +1 -1
- package/lib/components/progress-steps-item/progress-steps-item.d.ts +1 -3
- package/lib/components/progress-steps-item/progress-steps-item.d.ts.map +1 -1
- package/lib/components/progress-steps-item/progress-steps-item.js +0 -1
- package/lib/components/progress-steps-item/progress-steps-item.js.map +1 -1
- package/lib/components/radio-field/radio-field.d.ts +33 -0
- package/lib/components/radio-field/radio-field.d.ts.map +1 -1
- package/lib/components/radio-field/radio-field.js +62 -0
- package/lib/components/radio-field/radio-field.js.map +1 -1
- package/lib/components/remove-tag/remove-tag.d.ts +1 -1
- package/lib/components/remove-tag/remove-tag.js +3 -3
- package/lib/components/remove-tag/remove-tag.js.map +1 -1
- package/lib/components/split-button/split-button.d.ts +3 -0
- package/lib/components/split-button/split-button.d.ts.map +1 -1
- package/lib/components/split-button/split-button.js +5 -2
- package/lib/components/split-button/split-button.js.map +1 -1
- package/lib/components/tab/tab.d.ts +1 -1
- package/lib/components/tab/tab.js +3 -3
- package/lib/components/tab/tab.js.map +1 -1
- package/lib/components/table/table.d.ts +36 -0
- package/lib/components/table/table.d.ts.map +1 -1
- package/lib/components/table/table.js +55 -0
- package/lib/components/table/table.js.map +1 -1
- package/lib/components/tabs/tabs.d.ts +20 -3
- package/lib/components/tabs/tabs.d.ts.map +1 -1
- package/lib/components/tabs/tabs.js +33 -5
- package/lib/components/tabs/tabs.js.map +1 -1
- package/lib/components/tag-list/tag-list.d.ts +17 -0
- package/lib/components/tag-list/tag-list.d.ts.map +1 -1
- package/lib/components/tag-list/tag-list.js +25 -0
- package/lib/components/tag-list/tag-list.js.map +1 -1
- package/lib/components/tooltip/tooltip.d.ts +2 -2
- package/lib/components/tooltip/tooltip.js +4 -4
- package/lib/components/tooltip/tooltip.js.map +1 -1
- package/lib/components/utils/light-children.d.ts +40 -0
- package/lib/components/utils/light-children.d.ts.map +1 -0
- package/lib/components/utils/light-children.js +100 -0
- package/lib/components/utils/light-children.js.map +1 -0
- package/lib/design-tokens/brands/cre8/css/tokens_brand.css +1 -1
- package/lib/directives/if-truthy.d.ts +1 -1
- package/lib/icons/cre8-icons.svg +1 -1
- package/lib/light-children-TlEXev5S.js +39 -0
- package/lib/scripts/generate-react-wrappers.d.ts +8 -1
- package/lib/scripts/generate-react-wrappers.d.ts.map +1 -1
- package/lib/scripts/generate-react-wrappers.js +45 -1
- package/lib/scripts/generate-react-wrappers.js.map +1 -1
- package/mcp-manifest.json +163 -53
- package/package.json +11 -4
- package/react-manifest.json +154 -48
- package/dist/assets/if-defined-HKKhGupN.js +0 -1
- package/dist/assets/iframe-CWwoGI65.css +0 -1
- package/dist/assets/state-CfuknrX8.js +0 -1
- package/dist/fonts/PlusJakartaSans-Bold.woff2 +0 -0
- package/dist/fonts/PlusJakartaSans-Medium.woff2 +0 -0
- package/dist/fonts/PlusJakartaSans-Regular.woff2 +0 -0
- package/dist/fonts/PlusJakartaSans-SemiBold.woff2 +0 -0
- package/dist/logo.svg +0 -1
- package/dist/sb-addons/storybook-4/manager-bundle.js +0 -8
- /package/dist/icons/{express-scripts copy.svg → pharmacy copy.svg} +0 -0
- /package/dist/icons/{express-scripts.svg → pharmacy.svg} +0 -0
- /package/lib/icons/{express-scripts copy.svg → pharmacy copy.svg} +0 -0
- /package/lib/icons/{express-scripts.svg → pharmacy.svg} +0 -0
|
@@ -8,6 +8,7 @@ import { html, } from 'lit';
|
|
|
8
8
|
import { property } from 'lit/decorators.js';
|
|
9
9
|
import { nanoid } from 'nanoid';
|
|
10
10
|
import { Cre8Element } from '../cre8-element';
|
|
11
|
+
import { syncLightChildren } from '../utils/light-children';
|
|
11
12
|
import styles from './tag-list.styles.js';
|
|
12
13
|
/**
|
|
13
14
|
* Tag List must have children which are Tag components that are of type `checkbox` or `radio`.
|
|
@@ -23,6 +24,27 @@ export class Cre8TagList extends Cre8Element {
|
|
|
23
24
|
_initializeAria() {
|
|
24
25
|
this.fieldId = this.fieldId || nanoid();
|
|
25
26
|
}
|
|
27
|
+
/** The composition the data property stands for. */
|
|
28
|
+
buildComposition() {
|
|
29
|
+
if (!this.tags)
|
|
30
|
+
return null;
|
|
31
|
+
return this.tags.map((tag) => ({
|
|
32
|
+
tag: 'cre8-tag',
|
|
33
|
+
props: {
|
|
34
|
+
text: tag.text,
|
|
35
|
+
variant: tag.variant,
|
|
36
|
+
shape: tag.shape,
|
|
37
|
+
type: tag.type,
|
|
38
|
+
disabled: tag.disabled,
|
|
39
|
+
name: this.fieldId,
|
|
40
|
+
},
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
updated(changed) {
|
|
44
|
+
if (['tags', 'fieldId'].some((key) => changed.has(key))) {
|
|
45
|
+
syncLightChildren(this, this.buildComposition());
|
|
46
|
+
}
|
|
47
|
+
}
|
|
26
48
|
render() {
|
|
27
49
|
const componentClassNames = this.componentClassNames('cre8-c-tag-list', {});
|
|
28
50
|
return html `
|
|
@@ -42,6 +64,9 @@ __decorate([
|
|
|
42
64
|
__decorate([
|
|
43
65
|
property()
|
|
44
66
|
], Cre8TagList.prototype, "fieldId", void 0);
|
|
67
|
+
__decorate([
|
|
68
|
+
property({ type: Array })
|
|
69
|
+
], Cre8TagList.prototype, "tags", void 0);
|
|
45
70
|
if (customElements.get('cre8-tag-list') === undefined) {
|
|
46
71
|
customElements.define('cre8-tag-list', Cre8TagList);
|
|
47
72
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tag-list.js","sourceRoot":"","sources":["../../../components/tag-list/tag-list.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,GAAI,MAAM,KAAK,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,MAAM,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"tag-list.js","sourceRoot":"","sources":["../../../components/tag-list/tag-list.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,GAAI,MAAM,KAAK,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAkB,MAAM,yBAAyB,CAAC;AAC5E,OAAO,MAAM,MAAM,sBAAsB,CAAC;AAW1C;;;;;;GAMG;AAEH,MAAM,OAAO,WAAY,SAAQ,WAAW;IAgB1C,YAAY;QACR,IAAI,CAAC,eAAe,EAAE,CAAC;IAC3B,CAAC;IAEO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G,CAAC,eAAe,CAAC,KAAK,SAAS,EAAE,CAAC;IACpD,cAAc,CAAC,MAAM,CAAC,eAAe,EAAE,WAAW,CAAC,CAAC;AACxD,CAAC;AAQD,eAAe,WAAW,CAAC","sourcesContent":["import { html, } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { nanoid } from 'nanoid';\nimport { Cre8Element } from '../cre8-element';\nimport { syncLightChildren, type ChildSpec } from '../utils/light-children';\nimport styles from './tag-list.styles.js';\n\n/** One tag in a data-driven tag list. */\nexport interface Cre8TagData {\n text: string;\n variant?: 'neutral' | 'branded' | 'neutral-hybrid';\n shape?: 'square' | 'round';\n type?: 'checkbox' | 'radio';\n disabled?: boolean;\n}\n\n/**\n * Tag List must have children which are Tag components that are of type `checkbox` or `radio`.\n * The Tags must use the `neutral` variant and the `round` shape when they are inside a Tag List.\n * Tag List has a label that should be used to describe the purpose of the list.\n *\n * @slot - The `cre8-tag` children of the list\n */\n\nexport class Cre8TagList extends Cre8Element {\n static styles = [styles];\n\n /**\n * Tag list legend label\n */\n @property()\n label?: string;\n\n /**\n * The unique id of the select\n * @attr {string}\n */\n @property()\n fieldId?: string;\n\n firstUpdated() {\n this._initializeAria();\n }\n\n private _initializeAria() {\n this.fieldId = this.fieldId || nanoid();\n }\n /**\n * Tags for a data-driven tag list. Set this and the list builds its own\n * `cre8-tag` children in the light DOM. Leave it unset to compose them\n * yourself.\n */\n @property({ type: Array })\n tags?: Cre8TagData[];\n\n /** The composition the data property stands for. */\n private buildComposition(): ChildSpec[] | null {\n if (!this.tags) return null;\n return this.tags.map((tag) => ({\n tag: 'cre8-tag',\n props: {\n text: tag.text,\n variant: tag.variant,\n shape: tag.shape,\n type: tag.type,\n disabled: tag.disabled,\n name: this.fieldId,\n },\n }));\n }\n\n protected updated(changed: Map<string, unknown>): void {\n if (['tags', 'fieldId'].some((key) => changed.has(key))) {\n syncLightChildren(this, this.buildComposition());\n }\n }\n\n\n render() {\n const componentClassNames = this.componentClassNames('cre8-c-tag-list', { });\n\n return html`\n <fieldset class=\"${componentClassNames}\">\n <legend class=\"cre8-c-tag-list__legend\">${this.label}</legend>\n <div class=\"cre8-c-tag-list__list\" role=\"list\"> \n <slot></slot>\n </div>\n </fieldset>\n `;\n }\n}\n\nif (customElements.get('cre8-tag-list') === undefined) {\n customElements.define('cre8-tag-list', Cre8TagList);\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'cre8-tag-list': Cre8TagList;\n }\n}\n\nexport default Cre8TagList;\n"]}
|
|
@@ -33,8 +33,8 @@ import { Cre8Element } from '../cre8-element';
|
|
|
33
33
|
* @slot default - Default, unnamed slot container for Tooltip text
|
|
34
34
|
* @slot trigger - Named slot container for Tooltip element to trigger showing/hiding the Tooltip text
|
|
35
35
|
*
|
|
36
|
-
* @fires open - Fires when the tooltip is shown. `event.detail.isActive` is `true`.
|
|
37
|
-
* @fires close - Fires when the tooltip is hidden. `event.detail.isActive` is `false`.
|
|
36
|
+
* @fires tooltip-open - Fires when the tooltip is shown. `event.detail.isActive` is `true`.
|
|
37
|
+
* @fires tooltip-close - Fires when the tooltip is hidden. `event.detail.isActive` is `false`.
|
|
38
38
|
*/
|
|
39
39
|
export declare class Cre8Tooltip extends Cre8Element {
|
|
40
40
|
static styles: import("lit").CSSResult[];
|
|
@@ -44,8 +44,8 @@ import styles from './tooltip.styles.js';
|
|
|
44
44
|
* @slot default - Default, unnamed slot container for Tooltip text
|
|
45
45
|
* @slot trigger - Named slot container for Tooltip element to trigger showing/hiding the Tooltip text
|
|
46
46
|
*
|
|
47
|
-
* @fires open - Fires when the tooltip is shown. `event.detail.isActive` is `true`.
|
|
48
|
-
* @fires close - Fires when the tooltip is hidden. `event.detail.isActive` is `false`.
|
|
47
|
+
* @fires tooltip-open - Fires when the tooltip is shown. `event.detail.isActive` is `true`.
|
|
48
|
+
* @fires tooltip-close - Fires when the tooltip is hidden. `event.detail.isActive` is `false`.
|
|
49
49
|
*/
|
|
50
50
|
export class Cre8Tooltip extends Cre8Element {
|
|
51
51
|
constructor() {
|
|
@@ -201,13 +201,13 @@ export class Cre8Tooltip extends Cre8Element {
|
|
|
201
201
|
setTimeout(() => {
|
|
202
202
|
this.dynamicPosition();
|
|
203
203
|
}, 1);
|
|
204
|
-
this.
|
|
204
|
+
this.dispatchWithLegacyAlias(new CustomEvent('tooltip-open', {
|
|
205
205
|
detail: { isActive: this.isActive }, bubbles: true, composed: true,
|
|
206
206
|
}));
|
|
207
207
|
}
|
|
208
208
|
else {
|
|
209
209
|
/* 3 */
|
|
210
|
-
this.
|
|
210
|
+
this.dispatchWithLegacyAlias(new CustomEvent('tooltip-close', {
|
|
211
211
|
detail: { isActive: this.isActive }, bubbles: true, composed: true,
|
|
212
212
|
}));
|
|
213
213
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip.js","sourceRoot":"","sources":["../../../components/tooltip/tooltip.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,GAAI,MAAM,KAAK,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,MAAM,MAAM,qBAAqB,CAAC;AAEzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,MAAM,OAAO,WAAY,SAAQ,WAAW;IAA5C;;QAyEE;;WAEG;QAEC,qBAAgB,GAAY,CAAC,CAAC;QAqMlC;;;WAGG;QACH,iBAAY,GAAG,GAAG,EAAE;YAChB,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;gBAChB,IAAI,CAAC,YAAY,EAAE,CAAC;YACxB,CAAC;QACL,CAAC,CAAC;IAwCJ,CAAC;IAjOC;;;OAGG;IACH,IAAI,KAAK;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C,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;qDACO;AAM9B;IADH,QAAQ,EAAE;sDACoB;AAM3B;IADH,KAAK,CAAC,iBAAiB,CAAC;iDACK;AAM1B;IADH,KAAK,CAAC,wBAAwB,CAAC;sDACG;AAqOrC,IAAI,cAAc,CAAC,GAAG,CAAC,cAAc,CAAC,KAAK,SAAS,EAAE,CAAC;IACnD,cAAc,CAAC,MAAM,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;AACvD,CAAC;AAQD,eAAe,WAAW,CAAC","sourcesContent":["import { html, } from 'lit';\nimport { property, query } from 'lit/decorators.js';\nimport { nanoid } from 'nanoid';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { Cre8Element } from '../cre8-element';\nimport styles from './tooltip.styles.js';\n\n/**\n * The purpose of tooltips is to provide a tip or hint about what a tool, icon, link, or other interaction does.\n * If you need to present a call to action with perhaps a button for the user to click, then use\n * [Popover](/docs/cre8-components-popover--docs) instead.\n *\n * ##Tooltip Styles\n * There are 4 alignment options for Tooltips: Top, Bottom, Right, and Left. Default placement is Bottom, below the\n * element it is describing. Top or Bottom alignment are the the preferred placement, particularly on screens that\n * have a more narrow viewport. Tooltips utilize Global styles and are not affected by brand themes.\n *\n * **With icon**\n * - **iconRotateDegree** & **iconFlipDirection** props are optional.\n * - They are used to set up the correct dirrection for icons, for example,\n * arrows, caret up or caret down.\n *\n * ##Usability Considerations\n * With the exception of icons - which should always have alt text at a minimum - the UI should never rely on\n * Tooltips for clarity, especially because they are not always discovered by the user. If the user cannot\n * intuitively understand the interface without Tooltips, the interface should be redesigned.\n *\n * ##How to use\n * - Use Tooltips to clarify the UI element the user is interacting with, not to add additional content on the page.\n * Also, do not simply restate content on the page, for example, the title of the field.\n * - Tooltips should be short and to the point. Example: \"Click X to do X\" or \"Icon Description.\" If a succinct\n * description is not possible, the interaction element should be redesigned.\n * - In a mouse-driven UI, Tooltips are triggered on hover (mouseover) and dismissed (disappear)\n * when the user mouses away from the element. In touch UIs, a Tooltip is triggered by tapping\n * and holding an item. The Tooltip is displayed as long as the user continues to hold the element.\n * Tap and hold is a more advanced user behavior, and further reason for not relying on Tooltips.\n * A novice user may never discover tap and hold for Tooltips.\n *\n * @slot default - Default, unnamed slot container for Tooltip text\n * @slot trigger - Named slot container for Tooltip element to trigger showing/hiding the Tooltip text\n *\n * @fires open - Fires when the tooltip is shown. `event.detail.isActive` is `true`.\n * @fires close - Fires when the tooltip is hidden. `event.detail.isActive` is `false`.\n */\n\nexport class Cre8Tooltip extends Cre8Element {\n static styles = [styles];\n\n /**\n * Positions the tooltip panel absolutely to the icon. Position overrides `isDynamic`.\n * @type {\"default\"|\"top\"|\"left\"|\"right\"}\n * @attr {string}\n * - **default** positions the tooltip panel below the trigger element\n * - **top** positions the tooltip panel above the trigger element\n * - **left** positions the tooltip panel left of the trigger element\n * - **right** positions the tooltip panel right of the trigger element\n */\n @property()\n position?: 'top' | 'left' | 'right';\n\n /**\n * The knockout variant for the tooltip\n * @attr {boolean}\n * 1. If is true, the tooltip background is white\n * 2. If is false, the tooltip background is gray\n */\n @property({ type: Boolean, reflect: true })\n knockout?: boolean;\n\n /**\n * The dynamic state for the tooltip. Position overrides isDynamic.\n * @attr {boolean}\n * - If true, the tooltip panel placement is determined by its position in the viewport\n * - If false, the tooltip panel placement will be placed according to the position value\n */\n @property({ type: Boolean, reflect: true })\n isDynamic?: boolean;\n\n /**\n * The dynamic active state\n * @attr {boolean}\n * <br/><br/> _*This property is dynamically set_\n */\n @property({ type: Boolean })\n isActiveDynamic?: boolean;\n\n /**\n * The active state for the tooltip\n * @attr {boolean}\n * - If true, the tooltip panel is visible\n * - If false, the tooltip panel is hidden\n * <br/><br/> _*This property is dynamically set_\n */\n @property({ type: Boolean, reflect: true })\n isActive?: boolean;\n\n /**\n * Accepts the ID string of the item the tooltip is referencing\n * @attr {string}\n * Dynmically appends its own ID to the aria-describedby attribute on the referenced element\n */\n @property({ type: String })\n ariaDescribes?: string;\n\n /**\n * Internal unique id used to associate the trigger with the tooltip text. Generated automatically.\n */\n @property({ type: String })\n _uniqueId?: string;\n\n /**\n * svg as a raw string\n * - The icon is defined by this prop.\n * - Pass in a raw svg as a String for using <cre8-icon>\n */\n @property()\n svg?: string;\n\n /**\n * iconRotateDegree is used for <cre8-icon> to set the arrow in the correct direction\n */\n @property({ type: Number })\n iconRotateDegree?: number = 0;\n\n /**\n * iconFlipDirection is used for <cre8-icon> to set the icon in the correct direction\n */\n @property()\n iconFlipDirection?: string;\n\n /**\n * Query the tooltip panel element\n */\n @query('.cre8-c-tooltip')\n _Cre8Tooltip: HTMLElement;\n\n /**\n * Query the tooltip panel element\n */\n @query('.cre8-c-tooltip__panel')\n _Cre8TooltipPanel: HTMLElement;\n\n /**\n * Query the document direction value\n * <br/><br/> _*This property is dynamically set_\n */\n get isRTL() {\n return document.dir === 'rtl';\n }\n\n /**\n * updated Callback Lifecycle\n * 1. Find the second slot\n * 2. Create a string from joining the textContent of the textnodes\n * 3. Set the textContent of the tip generated in the firstUpdated lifecycle callback\n * */\n updated() {\n /* 1 & 2 */\n const tipContent = this.shadowRoot.querySelectorAll('slot')[1]\n .assignedNodes()\n .reduce(\n ((str, item) => `${str}${item.textContent.replace(/\\n/g, '').trim()}`),\n ''\n );\n /* 3 */\n if (document.getElementById(this._uniqueId)) {\n document.getElementById(this._uniqueId).textContent = tipContent;\n }\n }\n\n /**\n * firstUpdated Callback Lifecycle\n * 1. If ariaDescribes is set\n * a. create an ID and assign it to the property _uniqueId\n * b. Generate an empty div, assign it the _uniqueId and the tooltip role\n * 2. Set the aria-describedby on the ariaDescribes target\n */\n firstUpdated() {\n if (this.ariaDescribes) { /* 1 */\n this._uniqueId = this._uniqueId || nanoid(); /* 1.a */\n const idMatcher = new RegExp(`\\\\b${this._uniqueId}\\\\b`); // prevents dupes from reconnects below\n /* 1.b */\n const a11yProxy = document.createElement('div');\n a11yProxy.setAttribute('role', 'tooltip');\n a11yProxy.setAttribute('style', 'position:fixed; left: -1000px; top: -1000px;');\n a11yProxy.id = this._uniqueId;\n const describedEl = document.getElementById(this.ariaDescribes);\n describedEl.parentNode.insertBefore(a11yProxy, describedEl);\n const idList = describedEl?.getAttribute('aria-describedBy');\n /* 2 */\n describedEl?.setAttribute(\n 'aria-describedby',\n `${idList ? `${idList.replace(idMatcher, '')} ` : ''}${this._uniqueId}`.trim()\n );\n }\n }\n\n /**\n * Connected Callback Lifecycle\n * 1. Add window mouseover event listener\n * 2. Add window mouseout event listener\n * 3. Add mousedown event listener\n * 4. Set the id and aria-describedby\n */\n connectedCallback() {\n super.connectedCallback();\n this.addEventListener('mouseover', this.toggleActive); /* 1 */\n this.addEventListener('mouseout', this.removeActive); /* 2 */\n }\n\n /**\n * Disconnected Callback Lifecycle\n * 1. Remove window mouseover event listener\n * 2. Remove window mouseout event listener\n */\n disconnectedCallback() {\n super.disconnectedCallback();\n this.removeEventListener('mouseover', this.toggleActive); /* 1 */\n this.removeEventListener('mouseout', this.removeActive); /* 2 */\n }\n\n /**\n * Handle all dynamic placement\n */\n dynamicPosition() {\n // TODO: Temporarily keep eslint complexity as warning. Update during specific story for this rule.\n /* eslint complexity: [\"warn\", 10] */\n if (this.isDynamic && this._Cre8TooltipPanel) {\n const body = document.querySelector('body').getBoundingClientRect();\n const tooltipPanel = this._Cre8TooltipPanel.getBoundingClientRect();\n const tooltipHeight = this._Cre8Tooltip.clientHeight + tooltipPanel.height + tooltipPanel.top;\n\n /**\n * If tooltip panel breaks out the left side of the window, position it to the right\n */\n if (tooltipPanel.left < 0) {\n this.position = this.isRTL ? 'left' : 'right';\n }\n\n /**\n * If tooltip panel breaks out the right side of the window, position it to the left\n */\n if (tooltipPanel.right >= body.width) {\n this.position = this.isRTL ? 'right' : 'left';\n }\n\n /**\n * If tooltip panel breaks out the top side of the window only, position it to the bottom center\n */\n if (tooltipPanel.top < 0 && tooltipPanel.left > 0 && tooltipPanel.right < body.width) {\n this.position = null;\n }\n\n /**\n * If tooltip panel breaks out the bottom side of the window only, position it to the top center\n */\n if (\n tooltipHeight >= window.innerHeight\n && tooltipPanel.bottom >= window.innerHeight\n && tooltipPanel.left >= 0\n && tooltipPanel.right <= body.width\n ) {\n this.position = 'top';\n }\n }\n }\n\n /**\n * Handle Keydown\n * 1. If escape or tab key is struck when the tooltip is active, close it\n * 2. If enter or escape is keyed, toggle the tooltip open or close.\n * We need these since the click event is on a div so that accessibility reads this aloud to a user\n */\n private _handleKeydown(e: KeyboardEvent) {\n if (this.isActive) {\n if (e.code === 'Escape' || e.code === 'Tab') {\n this.toggleActive(); /* 1 */\n }\n }\n if (e.code === 'Enter' || e.code === 'Space') {\n this.toggleActive(); /* 2 */\n }\n }\n\n /**\n * Set Tooltip Active State\n * 1. Toggle the active state between true and false\n * 2. If is active, set the dynamic position and custom event.\n * 3. If is not active, remove fire the close custom event.\n * 4. Toggle the active state for dynamic. This prevents a flash of the tooltip in the orginal position.\n */\n toggleActive() {\n this.isActive = !this.isActive; /* 1 */\n\n if (this.isActive) {\n /* 2 */\n setTimeout(() => {\n this.dynamicPosition();\n }, 1);\n this.dispatchEvent(new CustomEvent('open', {\n detail: { isActive: this.isActive }, bubbles: true, composed: true,\n }));\n } else {\n /* 3 */\n this.dispatchEvent(new CustomEvent('close', {\n detail: { isActive: this.isActive }, bubbles: true, composed: true,\n }));\n }\n\n /* 4 */\n setTimeout(() => {\n if (this.isActive && this.isDynamic) {\n this.isActiveDynamic = true;\n } else {\n this.isActiveDynamic = false;\n }\n }, 2);\n }\n\n /**\n * Remove Active State\n * 1. If a specific event is fired, remove the active state.\n */\n removeActive = () => {\n if (this.isActive) {\n this.toggleActive();\n }\n };\n\n render() {\n const componentClassNames = this.componentClassNames('cre8-c-tooltip', {\n 'cre8-c-tooltip--top': this.position === 'top',\n 'cre8-c-tooltip--left': this.position === 'left',\n 'cre8-c-tooltip--right': this.position === 'right',\n 'cre8-c-tooltip--knockout': this.knockout,\n 'cre8-is-active': this.isActive,\n 'cre8-is-dynamic': this.isDynamic,\n 'cre8-is-dynamic-active': this.isActiveDynamic,\n });\n\n return html`\n <div class=\"${componentClassNames}\">\n <div \n class=\"cre8-c-tooltip__trigger\"\n tabindex=\"0\"\n @focus=${this.toggleActive}\n @keydown=${this._handleKeydown}\n >\n ${this.svg\n ? html`\n <slot name=\"trigger\">\n <cre8-icon svg='${this.svg}' rotate=\"${Number(this.iconRotateDegree)}\" \n flip=\"${this.iconFlipDirection}\" aria-hidden=\"true\"></cre8-icon>\n </slot>`\n : html`<slot name=\"trigger\"></slot>`\n}\n </div>\n <dialog\n id=${ifDefined(this._uniqueId)}\n aria-labelledby=${this.ariaDescribes}\n class=\"cre8-c-tooltip__panel\"\n role=\"tooltip\">\n <slot></slot>\n </dialog>\n </div>\n `;\n }\n}\n\nif (customElements.get('cre8-tooltip') === undefined) {\n customElements.define('cre8-tooltip', Cre8Tooltip);\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'cre8-tooltip': Cre8Tooltip;\n }\n}\n\nexport default Cre8Tooltip;\n"]}
|
|
1
|
+
{"version":3,"file":"tooltip.js","sourceRoot":"","sources":["../../../components/tooltip/tooltip.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,GAAI,MAAM,KAAK,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,MAAM,MAAM,qBAAqB,CAAC;AAEzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,MAAM,OAAO,WAAY,SAAQ,WAAW;IAA5C;;QAyEE;;WAEG;QAEC,qBAAgB,GAAY,CAAC,CAAC;QAqMlC;;;WAGG;QACH,iBAAY,GAAG,GAAG,EAAE;YAChB,IAAI,IA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E,MAAM,EAAE,CAAC;kDACA;AAMvB;IADH,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CACJ;AAQnB;IADH,QAAQ,EAAE;wCACM;AAMb;IADH,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;qDACO;AAM9B;IADH,QAAQ,EAAE;sDACoB;AAM3B;IADH,KAAK,CAAC,iBAAiB,CAAC;iDACK;AAM1B;IADH,KAAK,CAAC,wBAAwB,CAAC;sDACG;AAqOrC,IAAI,cAAc,CAAC,GAAG,CAAC,cAAc,CAAC,KAAK,SAAS,EAAE,CAAC;IACnD,cAAc,CAAC,MAAM,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;AACvD,CAAC;AAQD,eAAe,WAAW,CAAC","sourcesContent":["import { html, } from 'lit';\nimport { property, query } from 'lit/decorators.js';\nimport { nanoid } from 'nanoid';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { Cre8Element } from '../cre8-element';\nimport styles from './tooltip.styles.js';\n\n/**\n * The purpose of tooltips is to provide a tip or hint about what a tool, icon, link, or other interaction does.\n * If you need to present a call to action with perhaps a button for the user to click, then use\n * [Popover](/docs/cre8-components-popover--docs) instead.\n *\n * ##Tooltip Styles\n * There are 4 alignment options for Tooltips: Top, Bottom, Right, and Left. Default placement is Bottom, below the\n * element it is describing. Top or Bottom alignment are the the preferred placement, particularly on screens that\n * have a more narrow viewport. Tooltips utilize Global styles and are not affected by brand themes.\n *\n * **With icon**\n * - **iconRotateDegree** & **iconFlipDirection** props are optional.\n * - They are used to set up the correct dirrection for icons, for example,\n * arrows, caret up or caret down.\n *\n * ##Usability Considerations\n * With the exception of icons - which should always have alt text at a minimum - the UI should never rely on\n * Tooltips for clarity, especially because they are not always discovered by the user. If the user cannot\n * intuitively understand the interface without Tooltips, the interface should be redesigned.\n *\n * ##How to use\n * - Use Tooltips to clarify the UI element the user is interacting with, not to add additional content on the page.\n * Also, do not simply restate content on the page, for example, the title of the field.\n * - Tooltips should be short and to the point. Example: \"Click X to do X\" or \"Icon Description.\" If a succinct\n * description is not possible, the interaction element should be redesigned.\n * - In a mouse-driven UI, Tooltips are triggered on hover (mouseover) and dismissed (disappear)\n * when the user mouses away from the element. In touch UIs, a Tooltip is triggered by tapping\n * and holding an item. The Tooltip is displayed as long as the user continues to hold the element.\n * Tap and hold is a more advanced user behavior, and further reason for not relying on Tooltips.\n * A novice user may never discover tap and hold for Tooltips.\n *\n * @slot default - Default, unnamed slot container for Tooltip text\n * @slot trigger - Named slot container for Tooltip element to trigger showing/hiding the Tooltip text\n *\n * @fires tooltip-open - Fires when the tooltip is shown. `event.detail.isActive` is `true`.\n * @fires tooltip-close - Fires when the tooltip is hidden. `event.detail.isActive` is `false`.\n */\n\nexport class Cre8Tooltip extends Cre8Element {\n static styles = [styles];\n\n /**\n * Positions the tooltip panel absolutely to the icon. Position overrides `isDynamic`.\n * @type {\"default\"|\"top\"|\"left\"|\"right\"}\n * @attr {string}\n * - **default** positions the tooltip panel below the trigger element\n * - **top** positions the tooltip panel above the trigger element\n * - **left** positions the tooltip panel left of the trigger element\n * - **right** positions the tooltip panel right of the trigger element\n */\n @property()\n position?: 'top' | 'left' | 'right';\n\n /**\n * The knockout variant for the tooltip\n * @attr {boolean}\n * 1. If is true, the tooltip background is white\n * 2. If is false, the tooltip background is gray\n */\n @property({ type: Boolean, reflect: true })\n knockout?: boolean;\n\n /**\n * The dynamic state for the tooltip. Position overrides isDynamic.\n * @attr {boolean}\n * - If true, the tooltip panel placement is determined by its position in the viewport\n * - If false, the tooltip panel placement will be placed according to the position value\n */\n @property({ type: Boolean, reflect: true })\n isDynamic?: boolean;\n\n /**\n * The dynamic active state\n * @attr {boolean}\n * <br/><br/> _*This property is dynamically set_\n */\n @property({ type: Boolean })\n isActiveDynamic?: boolean;\n\n /**\n * The active state for the tooltip\n * @attr {boolean}\n * - If true, the tooltip panel is visible\n * - If false, the tooltip panel is hidden\n * <br/><br/> _*This property is dynamically set_\n */\n @property({ type: Boolean, reflect: true })\n isActive?: boolean;\n\n /**\n * Accepts the ID string of the item the tooltip is referencing\n * @attr {string}\n * Dynmically appends its own ID to the aria-describedby attribute on the referenced element\n */\n @property({ type: String })\n ariaDescribes?: string;\n\n /**\n * Internal unique id used to associate the trigger with the tooltip text. Generated automatically.\n */\n @property({ type: String })\n _uniqueId?: string;\n\n /**\n * svg as a raw string\n * - The icon is defined by this prop.\n * - Pass in a raw svg as a String for using <cre8-icon>\n */\n @property()\n svg?: string;\n\n /**\n * iconRotateDegree is used for <cre8-icon> to set the arrow in the correct direction\n */\n @property({ type: Number })\n iconRotateDegree?: number = 0;\n\n /**\n * iconFlipDirection is used for <cre8-icon> to set the icon in the correct direction\n */\n @property()\n iconFlipDirection?: string;\n\n /**\n * Query the tooltip panel element\n */\n @query('.cre8-c-tooltip')\n _Cre8Tooltip: HTMLElement;\n\n /**\n * Query the tooltip panel element\n */\n @query('.cre8-c-tooltip__panel')\n _Cre8TooltipPanel: HTMLElement;\n\n /**\n * Query the document direction value\n * <br/><br/> _*This property is dynamically set_\n */\n get isRTL() {\n return document.dir === 'rtl';\n }\n\n /**\n * updated Callback Lifecycle\n * 1. Find the second slot\n * 2. Create a string from joining the textContent of the textnodes\n * 3. Set the textContent of the tip generated in the firstUpdated lifecycle callback\n * */\n updated() {\n /* 1 & 2 */\n const tipContent = this.shadowRoot.querySelectorAll('slot')[1]\n .assignedNodes()\n .reduce(\n ((str, item) => `${str}${item.textContent.replace(/\\n/g, '').trim()}`),\n ''\n );\n /* 3 */\n if (document.getElementById(this._uniqueId)) {\n document.getElementById(this._uniqueId).textContent = tipContent;\n }\n }\n\n /**\n * firstUpdated Callback Lifecycle\n * 1. If ariaDescribes is set\n * a. create an ID and assign it to the property _uniqueId\n * b. Generate an empty div, assign it the _uniqueId and the tooltip role\n * 2. Set the aria-describedby on the ariaDescribes target\n */\n firstUpdated() {\n if (this.ariaDescribes) { /* 1 */\n this._uniqueId = this._uniqueId || nanoid(); /* 1.a */\n const idMatcher = new RegExp(`\\\\b${this._uniqueId}\\\\b`); // prevents dupes from reconnects below\n /* 1.b */\n const a11yProxy = document.createElement('div');\n a11yProxy.setAttribute('role', 'tooltip');\n a11yProxy.setAttribute('style', 'position:fixed; left: -1000px; top: -1000px;');\n a11yProxy.id = this._uniqueId;\n const describedEl = document.getElementById(this.ariaDescribes);\n describedEl.parentNode.insertBefore(a11yProxy, describedEl);\n const idList = describedEl?.getAttribute('aria-describedBy');\n /* 2 */\n describedEl?.setAttribute(\n 'aria-describedby',\n `${idList ? `${idList.replace(idMatcher, '')} ` : ''}${this._uniqueId}`.trim()\n );\n }\n }\n\n /**\n * Connected Callback Lifecycle\n * 1. Add window mouseover event listener\n * 2. Add window mouseout event listener\n * 3. Add mousedown event listener\n * 4. Set the id and aria-describedby\n */\n connectedCallback() {\n super.connectedCallback();\n this.addEventListener('mouseover', this.toggleActive); /* 1 */\n this.addEventListener('mouseout', this.removeActive); /* 2 */\n }\n\n /**\n * Disconnected Callback Lifecycle\n * 1. Remove window mouseover event listener\n * 2. Remove window mouseout event listener\n */\n disconnectedCallback() {\n super.disconnectedCallback();\n this.removeEventListener('mouseover', this.toggleActive); /* 1 */\n this.removeEventListener('mouseout', this.removeActive); /* 2 */\n }\n\n /**\n * Handle all dynamic placement\n */\n dynamicPosition() {\n // TODO: Temporarily keep eslint complexity as warning. Update during specific story for this rule.\n /* eslint complexity: [\"warn\", 10] */\n if (this.isDynamic && this._Cre8TooltipPanel) {\n const body = document.querySelector('body').getBoundingClientRect();\n const tooltipPanel = this._Cre8TooltipPanel.getBoundingClientRect();\n const tooltipHeight = this._Cre8Tooltip.clientHeight + tooltipPanel.height + tooltipPanel.top;\n\n /**\n * If tooltip panel breaks out the left side of the window, position it to the right\n */\n if (tooltipPanel.left < 0) {\n this.position = this.isRTL ? 'left' : 'right';\n }\n\n /**\n * If tooltip panel breaks out the right side of the window, position it to the left\n */\n if (tooltipPanel.right >= body.width) {\n this.position = this.isRTL ? 'right' : 'left';\n }\n\n /**\n * If tooltip panel breaks out the top side of the window only, position it to the bottom center\n */\n if (tooltipPanel.top < 0 && tooltipPanel.left > 0 && tooltipPanel.right < body.width) {\n this.position = null;\n }\n\n /**\n * If tooltip panel breaks out the bottom side of the window only, position it to the top center\n */\n if (\n tooltipHeight >= window.innerHeight\n && tooltipPanel.bottom >= window.innerHeight\n && tooltipPanel.left >= 0\n && tooltipPanel.right <= body.width\n ) {\n this.position = 'top';\n }\n }\n }\n\n /**\n * Handle Keydown\n * 1. If escape or tab key is struck when the tooltip is active, close it\n * 2. If enter or escape is keyed, toggle the tooltip open or close.\n * We need these since the click event is on a div so that accessibility reads this aloud to a user\n */\n private _handleKeydown(e: KeyboardEvent) {\n if (this.isActive) {\n if (e.code === 'Escape' || e.code === 'Tab') {\n this.toggleActive(); /* 1 */\n }\n }\n if (e.code === 'Enter' || e.code === 'Space') {\n this.toggleActive(); /* 2 */\n }\n }\n\n /**\n * Set Tooltip Active State\n * 1. Toggle the active state between true and false\n * 2. If is active, set the dynamic position and custom event.\n * 3. If is not active, remove fire the close custom event.\n * 4. Toggle the active state for dynamic. This prevents a flash of the tooltip in the orginal position.\n */\n toggleActive() {\n this.isActive = !this.isActive; /* 1 */\n\n if (this.isActive) {\n /* 2 */\n setTimeout(() => {\n this.dynamicPosition();\n }, 1);\n this.dispatchWithLegacyAlias(new CustomEvent('tooltip-open', {\n detail: { isActive: this.isActive }, bubbles: true, composed: true,\n }));\n } else {\n /* 3 */\n this.dispatchWithLegacyAlias(new CustomEvent('tooltip-close', {\n detail: { isActive: this.isActive }, bubbles: true, composed: true,\n }));\n }\n\n /* 4 */\n setTimeout(() => {\n if (this.isActive && this.isDynamic) {\n this.isActiveDynamic = true;\n } else {\n this.isActiveDynamic = false;\n }\n }, 2);\n }\n\n /**\n * Remove Active State\n * 1. If a specific event is fired, remove the active state.\n */\n removeActive = () => {\n if (this.isActive) {\n this.toggleActive();\n }\n };\n\n render() {\n const componentClassNames = this.componentClassNames('cre8-c-tooltip', {\n 'cre8-c-tooltip--top': this.position === 'top',\n 'cre8-c-tooltip--left': this.position === 'left',\n 'cre8-c-tooltip--right': this.position === 'right',\n 'cre8-c-tooltip--knockout': this.knockout,\n 'cre8-is-active': this.isActive,\n 'cre8-is-dynamic': this.isDynamic,\n 'cre8-is-dynamic-active': this.isActiveDynamic,\n });\n\n return html`\n <div class=\"${componentClassNames}\">\n <div \n class=\"cre8-c-tooltip__trigger\"\n tabindex=\"0\"\n @focus=${this.toggleActive}\n @keydown=${this._handleKeydown}\n >\n ${this.svg\n ? html`\n <slot name=\"trigger\">\n <cre8-icon svg='${this.svg}' rotate=\"${Number(this.iconRotateDegree)}\" \n flip=\"${this.iconFlipDirection}\" aria-hidden=\"true\"></cre8-icon>\n </slot>`\n : html`<slot name=\"trigger\"></slot>`\n}\n </div>\n <dialog\n id=${ifDefined(this._uniqueId)}\n aria-labelledby=${this.ariaDescribes}\n class=\"cre8-c-tooltip__panel\"\n role=\"tooltip\">\n <slot></slot>\n </dialog>\n </div>\n `;\n }\n}\n\nif (customElements.get('cre8-tooltip') === undefined) {\n customElements.define('cre8-tooltip', Cre8Tooltip);\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'cre8-tooltip': Cre8Tooltip;\n }\n}\n\nexport default Cre8Tooltip;\n"]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build a component's light-DOM children from a data property.
|
|
3
|
+
*
|
|
4
|
+
* Compound families in this system are composed by hand: a table is a table
|
|
5
|
+
* wrapping a header wrapping a row wrapping cells, five levels deep, and
|
|
6
|
+
* `docs/kb/01-components.md` warns that skipping a level renders but is subtly
|
|
7
|
+
* wrong. That is a lot of ceremony for "here are my columns and rows", and it is
|
|
8
|
+
* the single most error-prone thing an agent generates.
|
|
9
|
+
*
|
|
10
|
+
* So the flattened props build that composition for you. They build it in the
|
|
11
|
+
* **light DOM**, not the shadow root, and that is the whole trick: the result is
|
|
12
|
+
* byte-for-byte the DOM you would have written by hand, so every existing
|
|
13
|
+
* `::slotted()` rule, every behaviour, and every consumer keeps working. The
|
|
14
|
+
* flattened API is sugar, never a second rendering path.
|
|
15
|
+
*
|
|
16
|
+
* Elements this creates are marked, and only marked elements are ever touched —
|
|
17
|
+
* hand-written children are left exactly where they are.
|
|
18
|
+
*/
|
|
19
|
+
/** Marks an element as owned by a data property rather than by the author. */
|
|
20
|
+
export declare const GENERATED_ATTR = "data-cre8-generated";
|
|
21
|
+
export interface ChildSpec {
|
|
22
|
+
tag: string;
|
|
23
|
+
/** Set as properties when the value is not a string, as attributes otherwise. */
|
|
24
|
+
props?: Record<string, unknown>;
|
|
25
|
+
/** Text content. Mutually exclusive with `children`. */
|
|
26
|
+
text?: string;
|
|
27
|
+
/** `slot` attribute to place this child in a named slot of its parent. */
|
|
28
|
+
slot?: string;
|
|
29
|
+
children?: ChildSpec[];
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Make `host`'s generated light children match `specs`.
|
|
33
|
+
*
|
|
34
|
+
* Passing `null` removes them, which is how clearing a data property hands the
|
|
35
|
+
* component back to hand-written children.
|
|
36
|
+
*/
|
|
37
|
+
export declare function syncLightChildren(host: HTMLElement, specs: ChildSpec[] | null | undefined): void;
|
|
38
|
+
/** True when the author has put their own children in — data props defer to none. */
|
|
39
|
+
export declare function hasAuthoredChildren(host: HTMLElement): boolean;
|
|
40
|
+
//# sourceMappingURL=light-children.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"light-children.d.ts","sourceRoot":"","sources":["../../../components/utils/light-children.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,8EAA8E;AAC9E,eAAO,MAAM,cAAc,wBAAwB,CAAC;AAEpD,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,iFAAiF;IACjF,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,wDAAwD;IACxD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,0EAA0E;IAC1E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,SAAS,EAAE,CAAC;CACxB;AAgED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,CAIhG;AAED,qFAAqF;AACrF,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAE9D"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build a component's light-DOM children from a data property.
|
|
3
|
+
*
|
|
4
|
+
* Compound families in this system are composed by hand: a table is a table
|
|
5
|
+
* wrapping a header wrapping a row wrapping cells, five levels deep, and
|
|
6
|
+
* `docs/kb/01-components.md` warns that skipping a level renders but is subtly
|
|
7
|
+
* wrong. That is a lot of ceremony for "here are my columns and rows", and it is
|
|
8
|
+
* the single most error-prone thing an agent generates.
|
|
9
|
+
*
|
|
10
|
+
* So the flattened props build that composition for you. They build it in the
|
|
11
|
+
* **light DOM**, not the shadow root, and that is the whole trick: the result is
|
|
12
|
+
* byte-for-byte the DOM you would have written by hand, so every existing
|
|
13
|
+
* `::slotted()` rule, every behaviour, and every consumer keeps working. The
|
|
14
|
+
* flattened API is sugar, never a second rendering path.
|
|
15
|
+
*
|
|
16
|
+
* Elements this creates are marked, and only marked elements are ever touched —
|
|
17
|
+
* hand-written children are left exactly where they are.
|
|
18
|
+
*/
|
|
19
|
+
/** Marks an element as owned by a data property rather than by the author. */
|
|
20
|
+
export const GENERATED_ATTR = 'data-cre8-generated';
|
|
21
|
+
function applyProps(el, props = {}) {
|
|
22
|
+
for (const [key, value] of Object.entries(props)) {
|
|
23
|
+
if (value === undefined || value === null || value === false) {
|
|
24
|
+
el.removeAttribute(key);
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
if (value === true) {
|
|
28
|
+
el.setAttribute(key, '');
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
if (typeof value === 'object') {
|
|
32
|
+
// Arrays and objects cannot survive an attribute; hand them over directly.
|
|
33
|
+
el[key] = value;
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
el.setAttribute(key, String(value));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Reconcile in place rather than rebuilding.
|
|
41
|
+
*
|
|
42
|
+
* Rebuilding would be three lines shorter and would throw away element identity
|
|
43
|
+
* on every data change — losing focus, scroll position, and any animation in
|
|
44
|
+
* flight, which is exactly what a live-updating table must not do. So an
|
|
45
|
+
* existing generated element whose tag still matches is reused and updated.
|
|
46
|
+
*/
|
|
47
|
+
function reconcile(parent, specs, doc) {
|
|
48
|
+
const generated = [...parent.children].filter((child) => child.hasAttribute(GENERATED_ATTR));
|
|
49
|
+
specs.forEach((spec, index) => {
|
|
50
|
+
let el = generated[index];
|
|
51
|
+
if (!el || el.tagName.toLowerCase() !== spec.tag.toLowerCase()) {
|
|
52
|
+
const created = doc.createElement(spec.tag);
|
|
53
|
+
created.setAttribute(GENERATED_ATTR, '');
|
|
54
|
+
if (el)
|
|
55
|
+
parent.replaceChild(created, el);
|
|
56
|
+
else
|
|
57
|
+
parent.appendChild(created);
|
|
58
|
+
el = created;
|
|
59
|
+
}
|
|
60
|
+
// Clear props this element no longer has, so a removed value does not stick.
|
|
61
|
+
for (const attr of [...el.attributes]) {
|
|
62
|
+
if (attr.name === GENERATED_ATTR || attr.name === 'slot')
|
|
63
|
+
continue;
|
|
64
|
+
if (!spec.props || !(attr.name in spec.props))
|
|
65
|
+
el.removeAttribute(attr.name);
|
|
66
|
+
}
|
|
67
|
+
applyProps(el, spec.props);
|
|
68
|
+
if (spec.slot)
|
|
69
|
+
el.setAttribute('slot', spec.slot);
|
|
70
|
+
else
|
|
71
|
+
el.removeAttribute('slot');
|
|
72
|
+
if (spec.children) {
|
|
73
|
+
reconcile(el, spec.children, doc);
|
|
74
|
+
}
|
|
75
|
+
else if (spec.text !== undefined) {
|
|
76
|
+
if (el.textContent !== spec.text)
|
|
77
|
+
el.textContent = spec.text;
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
// Anything generated beyond the new length is gone.
|
|
81
|
+
for (let i = specs.length; i < generated.length; i++)
|
|
82
|
+
generated[i].remove();
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Make `host`'s generated light children match `specs`.
|
|
86
|
+
*
|
|
87
|
+
* Passing `null` removes them, which is how clearing a data property hands the
|
|
88
|
+
* component back to hand-written children.
|
|
89
|
+
*/
|
|
90
|
+
export function syncLightChildren(host, specs) {
|
|
91
|
+
const doc = host.ownerDocument;
|
|
92
|
+
if (!doc)
|
|
93
|
+
return;
|
|
94
|
+
reconcile(host, specs ?? [], doc);
|
|
95
|
+
}
|
|
96
|
+
/** True when the author has put their own children in — data props defer to none. */
|
|
97
|
+
export function hasAuthoredChildren(host) {
|
|
98
|
+
return [...host.children].some((child) => !child.hasAttribute(GENERATED_ATTR));
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=light-children.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"light-children.js","sourceRoot":"","sources":["../../../components/utils/light-children.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,8EAA8E;AAC9E,MAAM,CAAC,MAAM,cAAc,GAAG,qBAAqB,CAAC;AAapD,SAAS,UAAU,CAAC,EAAe,EAAE,QAAiC,EAAE;IACtE,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACjD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,KAAK,EAAE,CAAC;YAC7D,EAAE,CAAC,eAAe,CAAC,GAA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I,EAAE,EAAE,GAAG,CAAC,CAAC;AACpC,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,mBAAmB,CAAC,IAAiB;IACnD,OAAO,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC,CAAC;AACjF,CAAC","sourcesContent":["/**\n * Build a component's light-DOM children from a data property.\n *\n * Compound families in this system are composed by hand: a table is a table\n * wrapping a header wrapping a row wrapping cells, five levels deep, and\n * `docs/kb/01-components.md` warns that skipping a level renders but is subtly\n * wrong. That is a lot of ceremony for \"here are my columns and rows\", and it is\n * the single most error-prone thing an agent generates.\n *\n * So the flattened props build that composition for you. They build it in the\n * **light DOM**, not the shadow root, and that is the whole trick: the result is\n * byte-for-byte the DOM you would have written by hand, so every existing\n * `::slotted()` rule, every behaviour, and every consumer keeps working. The\n * flattened API is sugar, never a second rendering path.\n *\n * Elements this creates are marked, and only marked elements are ever touched —\n * hand-written children are left exactly where they are.\n */\n\n/** Marks an element as owned by a data property rather than by the author. */\nexport const GENERATED_ATTR = 'data-cre8-generated';\n\nexport interface ChildSpec {\n tag: string;\n /** Set as properties when the value is not a string, as attributes otherwise. */\n props?: Record<string, unknown>;\n /** Text content. Mutually exclusive with `children`. */\n text?: string;\n /** `slot` attribute to place this child in a named slot of its parent. */\n slot?: string;\n children?: ChildSpec[];\n}\n\nfunction applyProps(el: HTMLElement, props: Record<string, unknown> = {}): void {\n for (const [key, value] of Object.entries(props)) {\n if (value === undefined || value === null || value === false) {\n el.removeAttribute(key);\n continue;\n }\n if (value === true) {\n el.setAttribute(key, '');\n continue;\n }\n if (typeof value === 'object') {\n // Arrays and objects cannot survive an attribute; hand them over directly.\n (el as unknown as Record<string, unknown>)[key] = value;\n continue;\n }\n el.setAttribute(key, String(value));\n }\n}\n\n/**\n * Reconcile in place rather than rebuilding.\n *\n * Rebuilding would be three lines shorter and would throw away element identity\n * on every data change — losing focus, scroll position, and any animation in\n * flight, which is exactly what a live-updating table must not do. So an\n * existing generated element whose tag still matches is reused and updated.\n */\nfunction reconcile(parent: Element, specs: ChildSpec[], doc: Document): void {\n const generated = [...parent.children].filter((child) => child.hasAttribute(GENERATED_ATTR));\n\n specs.forEach((spec, index) => {\n let el = generated[index] as HTMLElement | undefined;\n\n if (!el || el.tagName.toLowerCase() !== spec.tag.toLowerCase()) {\n const created = doc.createElement(spec.tag);\n created.setAttribute(GENERATED_ATTR, '');\n if (el) parent.replaceChild(created, el);\n else parent.appendChild(created);\n el = created;\n }\n\n // Clear props this element no longer has, so a removed value does not stick.\n for (const attr of [...el.attributes]) {\n if (attr.name === GENERATED_ATTR || attr.name === 'slot') continue;\n if (!spec.props || !(attr.name in spec.props)) el.removeAttribute(attr.name);\n }\n applyProps(el, spec.props);\n\n if (spec.slot) el.setAttribute('slot', spec.slot);\n else el.removeAttribute('slot');\n\n if (spec.children) {\n reconcile(el, spec.children, doc);\n } else if (spec.text !== undefined) {\n if (el.textContent !== spec.text) el.textContent = spec.text;\n }\n });\n\n // Anything generated beyond the new length is gone.\n for (let i = specs.length; i < generated.length; i++) generated[i].remove();\n}\n\n/**\n * Make `host`'s generated light children match `specs`.\n *\n * Passing `null` removes them, which is how clearing a data property hands the\n * component back to hand-written children.\n */\nexport function syncLightChildren(host: HTMLElement, specs: ChildSpec[] | null | undefined): void {\n const doc = host.ownerDocument;\n if (!doc) return;\n reconcile(host, specs ?? [], doc);\n}\n\n/** True when the author has put their own children in — data props defer to none. */\nexport function hasAuthoredChildren(host: HTMLElement): boolean {\n return [...host.children].some((child) => !child.hasAttribute(GENERATED_ATTR));\n}\n"]}
|
|
@@ -2,7 +2,7 @@ import { noChange } from 'lit';
|
|
|
2
2
|
import { Directive, PartInfo, AttributePart, DirectiveParameters } from 'lit-html/directive.js';
|
|
3
3
|
declare class IfTruthyDirective extends Directive {
|
|
4
4
|
constructor(partInfo: PartInfo);
|
|
5
|
-
update(part: AttributePart, [value]: DirectiveParameters<this>): typeof noChange
|
|
5
|
+
update(part: AttributePart, [value]: DirectiveParameters<this>): string[] | typeof noChange;
|
|
6
6
|
render([value]: string[]): string;
|
|
7
7
|
}
|
|
8
8
|
export declare const ifTruthy: (values_0: string[]) => import("lit-html/directive").DirectiveResult<typeof IfTruthyDirective>;
|
package/lib/icons/cre8-icons.svg
CHANGED
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
<path d="M12 1.875C9.99747 1.875 8.0399 2.46882 6.37486 3.58137C4.70981 4.69392 3.41206 6.27523 2.64572 8.12533C1.87939 9.97543 1.67888 12.0112 2.06955 13.9753C2.46023 15.9393 3.42454 17.7435 4.84055 19.1595C6.25656 20.5755 8.06066 21.5398 10.0247 21.9305C11.9888 22.3211 14.0246 22.1206 15.8747 21.3543C17.7248 20.5879 19.3061 19.2902 20.4186 17.6251C21.5312 15.9601 22.125 14.0025 22.125 12C22.122 9.3156 21.0543 6.74199 19.1562 4.84383C17.258 2.94567 14.6844 1.87798 12 1.875ZM12 19.875C10.4425 19.875 8.91993 19.4131 7.62489 18.5478C6.32985 17.6825 5.32049 16.4526 4.72445 15.0136C4.12841 13.5747 3.97246 11.9913 4.27632 10.4637C4.58018 8.93606 5.3302 7.53287 6.43154 6.43153C7.53288 5.3302 8.93607 4.58017 10.4637 4.27632C11.9913 3.97246 13.5747 4.12841 15.0136 4.72445C16.4526 5.32049 17.6825 6.32985 18.5478 7.62488C19.4131 8.91992 19.875 10.4425 19.875 12C19.8728 14.0879 19.0424 16.0896 17.566 17.566C16.0896 19.0424 14.0879 19.8728 12 19.875ZM10.875 12.375V7.5C10.875 7.20163 10.9935 6.91548 11.2045 6.7045C11.4155 6.49353 11.7016 6.375 12 6.375C12.2984 6.375 12.5845 6.49353 12.7955 6.7045C13.0065 6.91548 13.125 7.20163 13.125 7.5V12.375C13.125 12.6734 13.0065 12.9595 12.7955 13.1705C12.5845 13.3815 12.2984 13.5 12 13.5C11.7016 13.5 11.4155 13.3815 11.2045 13.1705C10.9935 12.9595 10.875 12.6734 10.875 12.375ZM13.5 16.125C13.5 16.4217 13.412 16.7117 13.2472 16.9584C13.0824 17.205 12.8481 17.3973 12.574 17.5108C12.2999 17.6244 11.9983 17.6541 11.7074 17.5962C11.4164 17.5383 11.1491 17.3954 10.9393 17.1857C10.7296 16.9759 10.5867 16.7086 10.5288 16.4176C10.4709 16.1267 10.5007 15.8251 10.6142 15.551C10.7277 15.2769 10.92 15.0426 11.1666 14.8778C11.4133 14.713 11.7033 14.625 12 14.625C12.3978 14.625 12.7794 14.783 13.0607 15.0643C13.342 15.3456 13.5 15.7272 13.5 16.125Z"/>
|
|
105
105
|
|
|
106
106
|
</symbol>
|
|
107
|
-
<symbol id="
|
|
107
|
+
<symbol id="pharmacy" viewBox="0 0 45 24">
|
|
108
108
|
<path d="M6.5 6.03516V18.0139H15.0511V16.3152H8.33659V12.8007H13.817V11.1459H8.33659V7.68992H14.8014V6.03516H6.5Z"/>
|
|
109
109
|
<path d="M31.2126 7.69285H33.8132C35.6351 7.69285 36.6489 8.5422 36.6489 10.0652C36.6489 11.6614 35.6939 12.5107 33.9014 12.5107H31.2126V7.69285ZM36.4285 6.53598C35.7086 6.19916 34.8564 6.02344 33.8132 6.02344H29.3613V18.0168H31.2126V14.1508H33.9161C35.4735 14.1508 36.6636 13.7701 37.4423 12.9793C38.1476 12.2764 38.5002 11.2953 38.5002 10.0505C38.5002 8.42505 37.7802 7.19495 36.4285 6.53598Z"/>
|
|
110
110
|
<path d="M26.7284 6.00542L22.6974 10.0231L24.3596 11.6798L28.3907 7.66218L26.7284 6.00542Z"/>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const a = "data-cre8-generated";
|
|
2
|
+
function s(n, l = {}) {
|
|
3
|
+
for (const [i, o] of Object.entries(l)) {
|
|
4
|
+
if (o == null || o === !1) {
|
|
5
|
+
n.removeAttribute(i);
|
|
6
|
+
continue;
|
|
7
|
+
}
|
|
8
|
+
if (o === !0) {
|
|
9
|
+
n.setAttribute(i, "");
|
|
10
|
+
continue;
|
|
11
|
+
}
|
|
12
|
+
if (typeof o == "object") {
|
|
13
|
+
n[i] = o;
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
n.setAttribute(i, String(o));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function f(n, l, i) {
|
|
20
|
+
const o = [...n.children].filter((t) => t.hasAttribute(a));
|
|
21
|
+
l.forEach((t, u) => {
|
|
22
|
+
let e = o[u];
|
|
23
|
+
if (!e || e.tagName.toLowerCase() !== t.tag.toLowerCase()) {
|
|
24
|
+
const r = i.createElement(t.tag);
|
|
25
|
+
r.setAttribute(a, ""), e ? n.replaceChild(r, e) : n.appendChild(r), e = r;
|
|
26
|
+
}
|
|
27
|
+
for (const r of [...e.attributes])
|
|
28
|
+
r.name === a || r.name === "slot" || (!t.props || !(r.name in t.props)) && e.removeAttribute(r.name);
|
|
29
|
+
s(e, t.props), t.slot ? e.setAttribute("slot", t.slot) : e.removeAttribute("slot"), t.children ? f(e, t.children, i) : t.text !== void 0 && e.textContent !== t.text && (e.textContent = t.text);
|
|
30
|
+
});
|
|
31
|
+
for (let t = l.length; t < o.length; t++) o[t].remove();
|
|
32
|
+
}
|
|
33
|
+
function c(n, l) {
|
|
34
|
+
const i = n.ownerDocument;
|
|
35
|
+
i && f(n, l ?? [], i);
|
|
36
|
+
}
|
|
37
|
+
export {
|
|
38
|
+
c as s
|
|
39
|
+
};
|
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* The flattened data type a prop refers to, if any — `Cre8TagData[]` → `Cre8TagData`.
|
|
3
|
+
*
|
|
4
|
+
* The manifest writes an optional property's type as `Cre8TagData[] | undefined`,
|
|
5
|
+
* so the `| undefined` has to come off before matching. Missing that is why the
|
|
6
|
+
* first cut of this silently produced `any` for every one of them.
|
|
7
|
+
*/
|
|
8
|
+
export declare function flattenedTypeOf(type: string | undefined): string | null;
|
|
2
9
|
//# sourceMappingURL=generate-react-wrappers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-react-wrappers.d.ts","sourceRoot":"","sources":["../../scripts/generate-react-wrappers.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"generate-react-wrappers.d.ts","sourceRoot":"","sources":["../../scripts/generate-react-wrappers.ts"],"names":[],"mappings":"AAwGA;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAQvE"}
|
|
@@ -36,9 +36,44 @@ function toPascalCase(str) {
|
|
|
36
36
|
.map((part) => part.charAt(0).toUpperCase() + part.slice(1))
|
|
37
37
|
.join('');
|
|
38
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Types the wrapper re-exports rather than flattening to `any`.
|
|
41
|
+
*
|
|
42
|
+
* The flattened compound APIs (`columns`, `rows`, `items`, `steps`, `tags`) are
|
|
43
|
+
* the whole reason a React consumer would reach for them, and a prop typed
|
|
44
|
+
* `any` gives no autocomplete and catches no mistakes — which for a data-driven
|
|
45
|
+
* table is most of the value. These interfaces are exported from the component
|
|
46
|
+
* module the element class already comes from, so importing them is free.
|
|
47
|
+
*/
|
|
48
|
+
const FLATTENED_DATA_TYPES = new Set([
|
|
49
|
+
'Cre8TableColumn', 'Cre8TableRowData', 'Cre8TabItemData', 'Cre8AccordionItemData',
|
|
50
|
+
'Cre8ListItemData', 'Cre8LinkData', 'Cre8BreadcrumbData', 'Cre8TagData',
|
|
51
|
+
'Cre8CheckboxItemData', 'Cre8RadioItemData', 'Cre8ProgressStepData', 'Cre8DropdownItemData',
|
|
52
|
+
]);
|
|
53
|
+
/**
|
|
54
|
+
* The flattened data type a prop refers to, if any — `Cre8TagData[]` → `Cre8TagData`.
|
|
55
|
+
*
|
|
56
|
+
* The manifest writes an optional property's type as `Cre8TagData[] | undefined`,
|
|
57
|
+
* so the `| undefined` has to come off before matching. Missing that is why the
|
|
58
|
+
* first cut of this silently produced `any` for every one of them.
|
|
59
|
+
*/
|
|
60
|
+
export function flattenedTypeOf(type) {
|
|
61
|
+
if (!type)
|
|
62
|
+
return null;
|
|
63
|
+
const bare = type
|
|
64
|
+
.split('|')
|
|
65
|
+
.map((part) => part.trim())
|
|
66
|
+
.find((part) => part !== 'undefined' && part !== 'null');
|
|
67
|
+
const match = bare ? /^(Cre8[A-Za-z]+)\[\]$/.exec(bare) : null;
|
|
68
|
+
return match && FLATTENED_DATA_TYPES.has(match[1]) ? match[1] : null;
|
|
69
|
+
}
|
|
39
70
|
function getReactPropType(type) {
|
|
40
71
|
if (!type)
|
|
41
72
|
return 'any';
|
|
73
|
+
// Keep the flattened data types intact; they are the point of the React layer.
|
|
74
|
+
const flattened = flattenedTypeOf(type);
|
|
75
|
+
if (flattened)
|
|
76
|
+
return `${flattened}[]`;
|
|
42
77
|
// Handle truncated types (e.g., "... 5 more ...")
|
|
43
78
|
if (type.includes('...') && type.includes('more')) {
|
|
44
79
|
return 'string';
|
|
@@ -128,10 +163,19 @@ function generateReactWrapper(tag) {
|
|
|
128
163
|
}
|
|
129
164
|
}
|
|
130
165
|
const allProps = [...propsLines, ...eventProps].join('\n');
|
|
166
|
+
const dataTypes = [
|
|
167
|
+
...new Set((tag.attributes ?? [])
|
|
168
|
+
.map((attr) => flattenedTypeOf(attr.type))
|
|
169
|
+
.filter((name) => Boolean(name))),
|
|
170
|
+
];
|
|
171
|
+
const dataTypeImport = dataTypes.length
|
|
172
|
+
? `\nexport type { ${dataTypes.join(', ')} } from '@tmorrow/cre8-wc/lib/components/${importPath}';`
|
|
173
|
+
: '';
|
|
131
174
|
// Generate the component
|
|
132
175
|
return `import { createComponent } from '@lit/react';
|
|
133
176
|
import { ${elementClassName} as ${elementClassName}Element } from '@tmorrow/cre8-wc/lib/components/${importPath}';
|
|
134
|
-
import
|
|
177
|
+
import type { ${dataTypes.join(', ')} } from '@tmorrow/cre8-wc/lib/components/${importPath}';
|
|
178
|
+
import React from 'react';${dataTypeImport}`.replace(dataTypes.length ? '' : `import type { } from '@tmorrow/cre8-wc/lib/components/${importPath}';\n`, '') + `
|
|
135
179
|
|
|
136
180
|
export interface ${componentName}Props {
|
|
137
181
|
${allProps}
|