@tmorrow/cre8-wc 2.0.7 → 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 +393 -34
- 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 +3527 -3226
- package/cdn/cre8-wc.esm.js.map +1 -1
- package/cdn/cre8-wc.min.js +289 -289
- 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 +4 -17
- 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/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/directives/if-truthy.d.ts +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 +162 -52
- package/package.json +11 -4
- package/react-manifest.json +153 -47
- 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
|
@@ -8,6 +8,7 @@ import { html, } from 'lit';
|
|
|
8
8
|
import { property, query, queryAssignedElements, state, } 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 './tabs.styles.js';
|
|
12
13
|
let tabId = 1;
|
|
13
14
|
/**
|
|
@@ -36,6 +37,8 @@ let tabId = 1;
|
|
|
36
37
|
*
|
|
37
38
|
* @slot default - Default, unnamed slot container for each `cre8-tab` button
|
|
38
39
|
* @slot panel - Container for each `cre8-tab-panel` content item
|
|
40
|
+
*
|
|
41
|
+
* @fires tab-change - Fires when the active tab changes. `event.detail` is `{ value, activeTabIndex }`.
|
|
39
42
|
*/
|
|
40
43
|
export class Cre8Tabs extends Cre8Element {
|
|
41
44
|
/**
|
|
@@ -125,6 +128,11 @@ export class Cre8Tabs extends Cre8Element {
|
|
|
125
128
|
* If the new value doesn't equal the old value, activate the proper tab
|
|
126
129
|
*/
|
|
127
130
|
async updated(changedProperties) {
|
|
131
|
+
// Generated tabs and panels must exist before the existing logic below
|
|
132
|
+
// wires up indices and active state, so this runs first.
|
|
133
|
+
if (changedProperties.has('items')) {
|
|
134
|
+
syncLightChildren(this, this.buildComposition());
|
|
135
|
+
}
|
|
128
136
|
changedProperties.forEach(async (oldValue, propName) => {
|
|
129
137
|
if (propName === 'activeIndex' && this.activeIndex !== oldValue) {
|
|
130
138
|
await this.updateComplete;
|
|
@@ -260,7 +268,7 @@ export class Cre8Tabs extends Cre8Element {
|
|
|
260
268
|
* 2. If tab is active, make the previous selected tab inactive.
|
|
261
269
|
* 3. Set the clicked tab active.
|
|
262
270
|
* 4. Emit the custom event.
|
|
263
|
-
* @fires
|
|
271
|
+
* @fires tab-select
|
|
264
272
|
*/
|
|
265
273
|
handleTabSelected(event) {
|
|
266
274
|
const { target } = event;
|
|
@@ -331,7 +339,7 @@ export class Cre8Tabs extends Cre8Element {
|
|
|
331
339
|
* 2. If current activeIndex is in first position then move the tab focus to last tab.
|
|
332
340
|
* 3. Set the active tab and focus.
|
|
333
341
|
* 4. Emit custom event.
|
|
334
|
-
* @fires
|
|
342
|
+
* @fires tab-change
|
|
335
343
|
*/
|
|
336
344
|
setSelectedToPreviousTab(currentTab) {
|
|
337
345
|
/* 1 */
|
|
@@ -360,7 +368,7 @@ export class Cre8Tabs extends Cre8Element {
|
|
|
360
368
|
* 2. If current activeIndex is in last position then move the tab focus to first tab.
|
|
361
369
|
* 3. Set the active tab and focus.
|
|
362
370
|
* 4. Emit custom event.
|
|
363
|
-
* @fires
|
|
371
|
+
* @fires tab-change
|
|
364
372
|
*/
|
|
365
373
|
setSelectedToNextTab(currentTab) {
|
|
366
374
|
/* 1 */
|
|
@@ -401,7 +409,7 @@ export class Cre8Tabs extends Cre8Element {
|
|
|
401
409
|
* Emit custom event
|
|
402
410
|
*/
|
|
403
411
|
emitEvent() {
|
|
404
|
-
const customEvent = new CustomEvent('
|
|
412
|
+
const customEvent = new CustomEvent('tab-change', {
|
|
405
413
|
detail: {
|
|
406
414
|
value: this.activeTab,
|
|
407
415
|
activeTabIndex: this.activeIndex,
|
|
@@ -409,7 +417,24 @@ export class Cre8Tabs extends Cre8Element {
|
|
|
409
417
|
bubbles: true,
|
|
410
418
|
composed: true,
|
|
411
419
|
});
|
|
412
|
-
this.
|
|
420
|
+
this.dispatchWithLegacyAlias(customEvent);
|
|
421
|
+
}
|
|
422
|
+
/** The composition the data property stands for. */
|
|
423
|
+
buildComposition() {
|
|
424
|
+
if (!this.items)
|
|
425
|
+
return null;
|
|
426
|
+
const tabs = this.items.map((item, index) => ({
|
|
427
|
+
tag: 'cre8-tab',
|
|
428
|
+
props: { index },
|
|
429
|
+
text: item.label,
|
|
430
|
+
}));
|
|
431
|
+
const panels = this.items.map((item, index) => ({
|
|
432
|
+
tag: 'cre8-tab-panel',
|
|
433
|
+
props: { index },
|
|
434
|
+
slot: 'panel',
|
|
435
|
+
text: item.content ?? '',
|
|
436
|
+
}));
|
|
437
|
+
return [...tabs, ...panels];
|
|
413
438
|
}
|
|
414
439
|
render() {
|
|
415
440
|
const componentClassNames = this.componentClassNames('cre8-c-tabs', {
|
|
@@ -469,6 +494,9 @@ __decorate([
|
|
|
469
494
|
__decorate([
|
|
470
495
|
query('.cre8-c-tabs__list')
|
|
471
496
|
], Cre8Tabs.prototype, "_Cre8TabsHeaderList", void 0);
|
|
497
|
+
__decorate([
|
|
498
|
+
property({ type: Array })
|
|
499
|
+
], Cre8Tabs.prototype, "items", void 0);
|
|
472
500
|
if (customElements.get('cre8-tabs') === undefined) {
|
|
473
501
|
customElements.define('cre8-tabs', Cre8Tabs);
|
|
474
502
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tabs.js","sourceRoot":"","sources":["../../../components/tabs/tabs.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,GAAG,MAAM,KAAK,CAAC;AAC5B,OAAO,EACH,QAAQ,EAAE,KAAK,EAAE,qBAAqB,EAAE,KAAK,GAChD,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG9C,OAAO,MAAM,MAAM,kBAAkB,CAAC;AAEtC,IAAI,KAAK,GAAG,CAAC,CAAC;AAEd;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,MAAM,OAAO,QAAS,SAAQ,WAAW;IAoFrC;;;;OAIG;IACH,IAAI,KAAK;QACL,OAAO,QAAQ,CAAC,GAAG,KAAK,KAAK,CAAC;IAClC,CAAC;IAED;;OAEG;IACH;QACI,KAAK,EAAE,CAAC;QAtEZ;;;WAGG;QAEH,gBA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AAI,CAAC,SAAS;SAC5C,CAAC,CAAC;QAEH,OAAO,IAAI,CAAA;sBACG,mBAAmB;;;;;;8BAMX,IAAI,CAAC,YAAY;+BAChB,IAAI,CAAC,aAAa;6BACpB,IAAI,CAAC,iBAAiB;;;;;;;;;KAS9C,CAAC;IACF,CAAC;;AAnfM,eAAM,GAAG,CAAC,MAAM,CAAC,AAAX,CAAY;AAUzB;IADC,QAAQ,EAAE;sCACC;AAOZ;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;2CACvB;AAcpB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CACF;AAQzB;IADC,KAAK,EAAE;2CACY;AASpB;IADC,KAAK,EAAE;yCACiB;AASzB;IADC,KAAK,EAAE;uCACgB;AAMxB;IADC,qBAAqB,EAAE;+CACM;AAM9B;IADC,qBAAqB,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;gDACL;AAMpC;IADC,KAAK,CAAC,sBAAsB,CAAC;iDACD;AAM7B;IADC,KAAK,CAAC,oBAAoB,CAAC;qDACK;AAqarC,IAAI,cAAc,CAAC,GAAG,CAAC,WAAW,CAAC,KAAK,SAAS,EAAE,CAAC;IAChD,cAAc,CAAC,MAAM,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;AACjD,CAAC;AAQD,eAAe,QAAQ,CAAC","sourcesContent":["import { html, } from 'lit';\nimport {\n property, query, queryAssignedElements, state,\n} from 'lit/decorators.js';\nimport { nanoid } from 'nanoid';\nimport { Cre8Element } from '../cre8-element';\nimport { Cre8TabPanel } from '../tab-panel/tab-panel';\nimport { Cre8Tab } from '../tab/tab';\nimport styles from './tabs.styles.js';\n\nlet tabId = 1;\n\n/**\n * Tabs are used to quickly navigate back and forth between views.\n * The Tab design and interaction varies depending on the requirements for your organization and project.\n * Standardizing on the best individual controls will improve usability and reduce development and QA time.\n *\n * Create a standard set of Tab controls:\n * Primary Tabs (for system navigation), Secondary Tabs (for sub navigation within a screen).\n *\n * ## Usability Guidelines\n * - The selected Tab should be visually differentiated from the other Tabs.\n * The deselected Tabs should still look enabled.\n * Dimming the other Tabs decreases the legibility of items that are actually active and clickable.\n * - There must be a minimum of 2 Tabs.\n * - Showing status in a Tab is non-standard (such as 0%, 10%).\n * - Tab labels and content should be parallel, with the exception of a Summary or Overview Tab\n * which can be a rollup of content across other Tabs.\n * - Keep the font size of the Tabs the same.\n * If the Tabs are a fixed width and one of the labels is too long,\n * don't resize the text to fit and consider wrapping text to a second line.\n * - If possible, don't truncate text because it makes it harder to understand what's in the Tab.\n * - Try not to use more than six Tabs to keep the UI uncluttered.\n * - Do not stack Tabs on top of each other, and do not nest Tabs within Tabs.\n * Find alternate ways of navigating page hierarchy.\n *\n * @slot default - Default, unnamed slot container for each `cre8-tab` button\n * @slot panel - Container for each `cre8-tab-panel` content item\n */\n\nexport class Cre8Tabs extends Cre8Element {\n static styles = [styles];\n\n /**\n * Tab sizes\n * - **default** displays the cre8-tab text with cre8-typography-label-default\n * - **sm** displays the cre8-tab text with cre8-typography-label-small\n * @type {\"sm\"}\n * @attr\n */\n @property()\n size?: 'sm';\n\n /**\n * Displays a set of tabs with a spanning the width of the element\n * @attr {boolean}\n */\n @property({ type: Boolean, reflect: true })\n fullWidth?: boolean;\n\n /**\n * Auto Increment id to sync tab and tab panel\n *\n * _*This property is dynamically set_\n */\n tabId: string;\n\n /**\n * Sets the initial active tab (e.g. 0 sets the first tab, 1 sets the second tab, etc.)\n * @attr {number}\n */\n @property({ type: Number })\n activeIndex?: number = 0;\n\n /**\n * The active tab\n *\n * _*This property is dynamically set_\n */\n @state()\n activeTab?: Cre8Tab;\n\n /**\n * If position from left is greater than 0, set isStart to false. Otherwise set isStart to true.\n *\n * _*This property is dynamically set_\n * @attr {boolean}\n */\n @state()\n isStart?: boolean = true;\n\n /**\n * If last child is fully in the viewport, set isEnd to true. Otherwise, set isEnd to false.\n *\n * _*This property is dynamically set_\n * @attr {boolean}\n */\n @state()\n isEnd?: boolean = false;\n\n /**\n * Query all the tab items\n */\n @queryAssignedElements()\n _Cre8TabItems: Array<Cre8Tab>;\n\n /**\n * Query all the tab panels\n */\n @queryAssignedElements({ slot: 'panel' })\n _Cre8TabPanels: Array<Cre8TabPanel>;\n\n /**\n * Query the tabs header element\n */\n @query('.cre8-c-tabs__header')\n _Cre8TabsHeader: HTMLElement;\n\n /**\n * Query the tabs header list element\n */\n @query('.cre8-c-tabs__list')\n _Cre8TabsHeaderList: HTMLElement;\n\n /**\n * Query the document direction value\n *\n * _*This property is dynamically set_\n */\n get isRTL() {\n return document.dir === 'rtl';\n }\n\n /**\n * Initialize Functions\n */\n constructor() {\n super();\n this.handleScroll = this.handleScroll.bind(this);\n this.handleResize = this.handleResize.bind(this);\n this.setIsStart = this.setIsStart.bind(this);\n this.setIsEnd = this.setIsEnd.bind(this);\n this.emitEvent = this.emitEvent.bind(this);\n\n /**\n * Set the tab id.\n */\n this.tabId = `cre8-tabpanel-${tabId}`;\n tabId += 1;\n }\n\n /**\n * Connected Callback Lifecycle\n * 1. Fires each time a custom element is appended into a document-connected element.\n */\n connectedCallback() {\n super.connectedCallback();\n window.addEventListener('resize', this.handleResize);\n }\n\n /**\n * Disconnected Callback Lifecycle\n * 1. Removes the event listeners to ensure that any memory allocated by your component\n * will be cleaned up when your component is destroyed or disconnected from the page.\n */\n disconnectedCallback() {\n super.disconnectedCallback();\n window.removeEventListener('resize', this.handleResize);\n }\n\n /**\n * First Updated Lifecycle Hook\n * 1. Sets the `aria-labelledby` prop for accessible tabs if user doesn't define the `ariaLabelledBy` prop.\n * 2. Sets the active tab if activeIndex is defined. Otherwise, set the first tab as active by default.\n * 3. Initialize isStart and isEnd.\n * 4. Set the varaint on the cre8-tab according to the cre8-tabs variant.\n */\n async firstUpdated() {\n /* 1 */\n this.setTabAttributes();\n await this.updateComplete;\n\n /* 2 */\n this.activeTab = this._Cre8TabItems[this.activeIndex] || this._Cre8TabItems[0];\n this.setActiveTab();\n\n /* 3 */\n this.setIsStart();\n this.setIsEnd();\n\n /* 4 */\n this.setTabVariant();\n }\n\n /**\n * Updated Lifecycle Hook\n * 1. remove selected state from previously selected tab\n * 2. Checks to see if the old `activeIndex` property has been updated.\n * If the new value doesn't equal the old value, activate the proper tab\n */\n async updated(changedProperties: Map<string, unknown>) {\n changedProperties.forEach(async (oldValue, propName) => {\n if (propName === 'activeIndex' && this.activeIndex !== oldValue) {\n await this.updateComplete;\n\n if (this.activeTab) {\n this.removePreviousActiveTab(); /* 1 */\n }\n\n this.activeTab = this._Cre8TabItems[this.activeIndex];\n this.setActiveTab(); /* 2 */\n }\n });\n }\n\n /**\n * Handle Resize\n * 1. On resize, if position from left is greater than 0, set isStart to false. Otherwise set isStart to true.\n * 2. On resize, If last child is fully in the viewport, set isEnd to true. Otherwise, set isEnd to false.\n * @fires resize\n */\n handleResize() {\n this.setIsStart(); /* 1 */\n this.setIsEnd(); /* 2 */\n }\n\n /**\n * Handle Scroll\n * 1. On scroll, if position from left is greater than 0, set isStart to false. Otherwise set isStart to true.\n * 2. On scroll, If last child is fully in the viewport, set isEnd to true. Otherwise, set isEnd to false.\n * @fires scroll\n */\n handleScroll() {\n this.setIsStart(); /* 1 */\n this.setIsEnd(); /* 2 */\n }\n\n /**\n * Set isStart State\n * 1. If position from left is greater than 0, set isStart to false. Otherwise set isStart to true.\n */\n setIsStart() {\n if (this.isRTL) {\n if (this._Cre8TabsHeaderList.scrollLeft > 0) {\n this.isStart = true;\n } else {\n this.isStart = false;\n }\n } else if (this._Cre8TabsHeaderList.scrollLeft > 0) {\n this.isStart = false;\n } else {\n this.isStart = true;\n }\n }\n\n /**\n * Set isEnd State\n * 1. If last child is fully in the viewport, set isEnd to true. Otherwise, set isEnd to false.\n */\n setIsEnd() {\n if (this.isInViewport() === true) {\n this.isEnd = true;\n } else {\n this.isEnd = false;\n }\n }\n\n /**\n * Check if last overflow list item is in the viewport\n * 1. Get children of the overflow list inner container and get bounding client rectangle of last child\n * 2. Return true if the left property is greater than or equal to 0 and if the right property is less\n * than or equal to the window inner width or document client width\n */\n isInViewport() {\n const lastChild = this._Cre8TabItems[this._Cre8TabItems.length - 1];\n const tabElement = lastChild.shadowRoot?.querySelector('.cre8-c-tab');\n if (!tabElement) {\n return false; // Return false if the tab element is not found\n }\n\n const rect = tabElement.getBoundingClientRect(); /* 1 */\n const windowWidth = window.innerWidth || document.documentElement.clientWidth;\n return rect.left >= 0 && rect.right <= windowWidth; /* 2 */\n }\n\n /**\n * Set Tab Variant\n * 1. Loop through all the cre8-tab Components and set the size to 'sm' if the parent has size 'sm'.\n */\n setTabVariant() {\n if (this.size === 'sm') {\n this._Cre8TabItems.forEach((tab: Cre8Tab) => {\n tab.size = 'sm';\n });\n }\n }\n\n /**\n * Set the attributes on tab and tab panel\n * 1. Sets the index value on the tab items.\n * 2. Sets the `aria-labelledby` on the tab items.\n * 3. Set the index and id on the tab-panel to match the tab.\n */\n setTabAttributes() {\n this._Cre8TabItems.forEach((tab, index) => {\n /* 1 */\n tab.index = index;\n\n /* 2 */\n const ariaLabelledBy = tab.ariaLabelledBy;\n const id = ariaLabelledBy || nanoid();\n tab.ariaLabelledBy = id;\n\n\n /* 3 */\n const tabPanel = this._Cre8TabPanels[index];\n tabPanel.index = index;\n });\n }\n\n /**\n * Set Active Tab\n * 1. Sets the active state for the selected tab.\n * 2. Sets the active state for the tab panel with the same index value as the selected tab.\n */\n setActiveTab() {\n /* 1 */\n this.activeTab.isActive = true;\n\n /* 2 */\n const activeTabPanel = this._Cre8TabPanels.find((tabPanel) => tabPanel.index === this.activeTab.index);\n if (activeTabPanel) {\n activeTabPanel.isActive = true;\n }\n }\n\n /**\n * Set Active Tab Focus\n */\n setActiveTabFocus() {\n this.activeTab.shadowRoot?.querySelector<HTMLElement>('.cre8-c-tab').focus();\n }\n\n /**\n * Handle Tab Selected\n * 1. Only continue if event target is a tab\n * 2. If tab is active, make the previous selected tab inactive.\n * 3. Set the clicked tab active.\n * 4. Emit the custom event.\n * @fires tabSelected\n */\n handleTabSelected(event: MouseEvent) {\n const { target } = event;\n\n /* 1 */\n if (this._Cre8TabItems.includes(target as Cre8Tab)) {\n /* 2 */\n if (this.activeTab) {\n this.removePreviousActiveTab();\n }\n\n /* 3 */\n this.activeTab = target as Cre8Tab;\n const activeIndex = this._Cre8TabItems.findIndex((tab) => tab === this.activeTab);\n this.activeIndex = activeIndex;\n this.setActiveTab();\n\n /* 4 */\n this.emitEvent();\n }\n }\n\n /**\n * Handle Keydown\n * 1. If the active tab is not focused then handle the keydown events.\n * 2. On keydown of the right arrow, make the next tab active.\n * 3. On keydown of the left arrow, make the previous tab active.\n * 4. On keydown of the home key, make the first tab active.\n * 5. On keydown of the end key, make the last tab active.\n * 6. On keydown of the escape key, remove the focus.\n * @fires keydown\n */\n handleKeydown(event: KeyboardEvent) {\n /* 1 */\n const { target } = event;\n const focused = document.activeElement as Cre8Tab;\n if (!focused.matches('cre8-tab')) {\n return;\n }\n switch (event.key) {\n /* 2 */\n case 'ArrowRight':\n event.preventDefault();\n this.setSelectedToNextTab(target as Cre8Tab);\n break;\n /* 3 */\n case 'ArrowLeft':\n event.preventDefault();\n this.setSelectedToPreviousTab(target as Cre8Tab);\n break;\n /* 4 */\n case 'Home':\n event.preventDefault();\n this.setSelectedToNextTab(this._Cre8TabItems[this._Cre8TabItems.length - 1]);\n break;\n /* 5 */\n case 'End':\n event.preventDefault();\n this.setSelectedToPreviousTab(this._Cre8TabItems[0]);\n break;\n /* 6 */\n case 'Escape':\n this.activeTab.blur();\n break;\n default:\n // no default\n }\n }\n\n /**\n * Set Selected To Previous Tab\n * 1. Get current selected Tab index then deactivate previously selected tab.\n * 2. If current activeIndex is in first position then move the tab focus to last tab.\n * 3. Set the active tab and focus.\n * 4. Emit custom event.\n * @fires tabChange\n */\n setSelectedToPreviousTab(currentTab: Cre8Tab) {\n /* 1 */\n const activeIndex = currentTab.index;\n this.removePreviousActiveTab();\n\n /* 2 */\n const tabListLength = this._Cre8TabItems.length - 1;\n if (activeIndex === 0) {\n this.activeIndex = tabListLength;\n this.activeTab = this._Cre8TabItems[tabListLength];\n } else {\n const previousIndex = activeIndex - 1;\n this.activeIndex = previousIndex;\n this.activeTab = this._Cre8TabItems[previousIndex];\n }\n\n /* 3 */\n this.setActiveTab();\n this.setActiveTabFocus();\n\n /* 4 */\n this.emitEvent();\n }\n\n /**\n * Set Selected To Next Tab\n * 1. Get current selected Tab index then deactivate previously selected tab.\n * 2. If current activeIndex is in last position then move the tab focus to first tab.\n * 3. Set the active tab and focus.\n * 4. Emit custom event.\n * @fires tabChange\n */\n setSelectedToNextTab(currentTab: Cre8Tab) {\n /* 1 */\n const activeIndex = currentTab.index;\n this.removePreviousActiveTab();\n\n /* 2 */\n const tabListLength = this._Cre8TabItems.length - 1;\n if (activeIndex === tabListLength) {\n this.activeIndex = 0;\n this.activeTab = this._Cre8TabItems[0];\n } else {\n const nextIndex = activeIndex + 1;\n this.activeIndex = nextIndex;\n this.activeTab = this._Cre8TabItems[nextIndex];\n }\n\n /* 3 */\n this.setActiveTab();\n this.setActiveTabFocus();\n\n /* 4 */\n this.emitEvent();\n }\n\n /**\n * Remove Active from Previous Tab\n * 1. Get current selected Tab index then deactivate previously selected tab\n * 2. If current activeIndex is in first position then move the tab focus to last tab\n */\n removePreviousActiveTab() {\n /* 1 */\n this.activeTab.isActive = false;\n\n /* 2 */\n const activeTabPanel = this._Cre8TabPanels.find((tabPanel) => tabPanel.index === this.activeTab.index);\n if (activeTabPanel) {\n activeTabPanel.isActive = false;\n }\n }\n\n /**\n * Emit custom event\n */\n emitEvent() {\n const customEvent = new CustomEvent('tabChange', {\n detail: {\n value: this.activeTab,\n activeTabIndex: this.activeIndex,\n },\n bubbles: true,\n composed: true,\n });\n this.dispatchEvent(customEvent);\n }\n\n render() {\n const componentClassNames = this.componentClassNames('cre8-c-tabs', {\n 'cre8-is-start': this.isStart === true,\n 'cre8-is-end': this.isEnd === true,\n 'cre8-c-tabs--full-width': this.fullWidth,\n });\n\n return html`\n <div class=\"${componentClassNames}\">\n <div class=\"cre8-c-tabs__header\">\n <div\n class=\"cre8-c-tabs__list\"\n role=\"tablist\"\n tabindex=0\n @scroll=${this.handleScroll}\n @keydown=${this.handleKeydown}\n @click=${this.handleTabSelected}\n >\n <slot></slot>\n </div>\n </div>\n <div class=\"cre8-c-tabs__body\">\n <slot name=\"panel\"></slot>\n </div>\n </div>\n `;\n }\n}\n\nif (customElements.get('cre8-tabs') === undefined) {\n customElements.define('cre8-tabs', Cre8Tabs);\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'cre8-tabs': Cre8Tabs;\n }\n}\n\nexport default Cre8Tabs;\n"]}
|
|
1
|
+
{"version":3,"file":"tabs.js","sourceRoot":"","sources":["../../../components/tabs/tabs.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,GAAG,MAAM,KAAK,CAAC;AAC5B,OAAO,EACH,QAAQ,EAAE,KAAK,EAAE,qBAAqB,EAAE,KAAK,GAChD,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAkB,MAAM,yBAAyB,CAAC;AAG5E,OAAO,MAAM,MAAM,kBAAkB,CAAC;AAEtC,IAAI,KAAK,GAAG,CAAC,CAAC;AASd;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAGH,MAAM,OAAO,QAAS,SAAQ,WAAW;IAoFrC;;;;OAIG;IACH,IAAI,KAAK;QACL,OAAO,QAAQ,CAAC,GAAG,KAAK,KAAK,CAAC;IAClC,CAAC;IAED;;OAEG;IACH;QACI,KAAK,EAAE,CAAC;QAtEZ;;;WAGG;QAEH,gBAAW,GAAY,CAAC,CAAC;QAUzB;;;;;WAKG;QAEH,YAAO,GAAa,IAAI,CAAC;QAEzB;;;;;WAKG;Q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EAAE;yCACiB;AASzB;IADC,KAAK,EAAE;uCACgB;AAMxB;IADC,qBAAqB,EAAE;+CACM;AAM9B;IADC,qBAAqB,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;gDACL;AAMpC;IADC,KAAK,CAAC,sBAAsB,CAAC;iDACD;AAM7B;IADC,KAAK,CAAC,oBAAoB,CAAC;qDACK;AAoZ/B;IADH,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;uCACI;AAiDhC,IAAI,cAAc,CAAC,GAAG,CAAC,WAAW,CAAC,KAAK,SAAS,EAAE,CAAC;IAChD,cAAc,CAAC,MAAM,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;AACjD,CAAC;AAQD,eAAe,QAAQ,CAAC","sourcesContent":["import { html, } from 'lit';\nimport {\n property, query, queryAssignedElements, state,\n} from 'lit/decorators.js';\nimport { nanoid } from 'nanoid';\nimport { Cre8Element } from '../cre8-element';\nimport { syncLightChildren, type ChildSpec } from '../utils/light-children';\nimport { Cre8TabPanel } from '../tab-panel/tab-panel';\nimport { Cre8Tab } from '../tab/tab';\nimport styles from './tabs.styles.js';\n\nlet tabId = 1;\n\n/** One tab and its panel in a data-driven tab set. */\nexport interface Cre8TabItemData {\n label: string;\n /** Panel content. Omit to supply the panel yourself. */\n content?: string;\n}\n\n/**\n * Tabs are used to quickly navigate back and forth between views.\n * The Tab design and interaction varies depending on the requirements for your organization and project.\n * Standardizing on the best individual controls will improve usability and reduce development and QA time.\n *\n * Create a standard set of Tab controls:\n * Primary Tabs (for system navigation), Secondary Tabs (for sub navigation within a screen).\n *\n * ## Usability Guidelines\n * - The selected Tab should be visually differentiated from the other Tabs.\n * The deselected Tabs should still look enabled.\n * Dimming the other Tabs decreases the legibility of items that are actually active and clickable.\n * - There must be a minimum of 2 Tabs.\n * - Showing status in a Tab is non-standard (such as 0%, 10%).\n * - Tab labels and content should be parallel, with the exception of a Summary or Overview Tab\n * which can be a rollup of content across other Tabs.\n * - Keep the font size of the Tabs the same.\n * If the Tabs are a fixed width and one of the labels is too long,\n * don't resize the text to fit and consider wrapping text to a second line.\n * - If possible, don't truncate text because it makes it harder to understand what's in the Tab.\n * - Try not to use more than six Tabs to keep the UI uncluttered.\n * - Do not stack Tabs on top of each other, and do not nest Tabs within Tabs.\n * Find alternate ways of navigating page hierarchy.\n *\n * @slot default - Default, unnamed slot container for each `cre8-tab` button\n * @slot panel - Container for each `cre8-tab-panel` content item\n *\n * @fires tab-change - Fires when the active tab changes. `event.detail` is `{ value, activeTabIndex }`.\n */\n\n\nexport class Cre8Tabs extends Cre8Element {\n static styles = [styles];\n\n /**\n * Tab sizes\n * - **default** displays the cre8-tab text with cre8-typography-label-default\n * - **sm** displays the cre8-tab text with cre8-typography-label-small\n * @type {\"sm\"}\n * @attr\n */\n @property()\n size?: 'sm';\n\n /**\n * Displays a set of tabs with a spanning the width of the element\n * @attr {boolean}\n */\n @property({ type: Boolean, reflect: true })\n fullWidth?: boolean;\n\n /**\n * Auto Increment id to sync tab and tab panel\n *\n * _*This property is dynamically set_\n */\n tabId: string;\n\n /**\n * Sets the initial active tab (e.g. 0 sets the first tab, 1 sets the second tab, etc.)\n * @attr {number}\n */\n @property({ type: Number })\n activeIndex?: number = 0;\n\n /**\n * The active tab\n *\n * _*This property is dynamically set_\n */\n @state()\n activeTab?: Cre8Tab;\n\n /**\n * If position from left is greater than 0, set isStart to false. Otherwise set isStart to true.\n *\n * _*This property is dynamically set_\n * @attr {boolean}\n */\n @state()\n isStart?: boolean = true;\n\n /**\n * If last child is fully in the viewport, set isEnd to true. Otherwise, set isEnd to false.\n *\n * _*This property is dynamically set_\n * @attr {boolean}\n */\n @state()\n isEnd?: boolean = false;\n\n /**\n * Query all the tab items\n */\n @queryAssignedElements()\n _Cre8TabItems: Array<Cre8Tab>;\n\n /**\n * Query all the tab panels\n */\n @queryAssignedElements({ slot: 'panel' })\n _Cre8TabPanels: Array<Cre8TabPanel>;\n\n /**\n * Query the tabs header element\n */\n @query('.cre8-c-tabs__header')\n _Cre8TabsHeader: HTMLElement;\n\n /**\n * Query the tabs header list element\n */\n @query('.cre8-c-tabs__list')\n _Cre8TabsHeaderList: HTMLElement;\n\n /**\n * Query the document direction value\n *\n * _*This property is dynamically set_\n */\n get isRTL() {\n return document.dir === 'rtl';\n }\n\n /**\n * Initialize Functions\n */\n constructor() {\n super();\n this.handleScroll = this.handleScroll.bind(this);\n this.handleResize = this.handleResize.bind(this);\n this.setIsStart = this.setIsStart.bind(this);\n this.setIsEnd = this.setIsEnd.bind(this);\n this.emitEvent = this.emitEvent.bind(this);\n\n /**\n * Set the tab id.\n */\n this.tabId = `cre8-tabpanel-${tabId}`;\n tabId += 1;\n }\n\n /**\n * Connected Callback Lifecycle\n * 1. Fires each time a custom element is appended into a document-connected element.\n */\n connectedCallback() {\n super.connectedCallback();\n window.addEventListener('resize', this.handleResize);\n }\n\n /**\n * Disconnected Callback Lifecycle\n * 1. Removes the event listeners to ensure that any memory allocated by your component\n * will be cleaned up when your component is destroyed or disconnected from the page.\n */\n disconnectedCallback() {\n super.disconnectedCallback();\n window.removeEventListener('resize', this.handleResize);\n }\n\n /**\n * First Updated Lifecycle Hook\n * 1. Sets the `aria-labelledby` prop for accessible tabs if user doesn't define the `ariaLabelledBy` prop.\n * 2. Sets the active tab if activeIndex is defined. Otherwise, set the first tab as active by default.\n * 3. Initialize isStart and isEnd.\n * 4. Set the varaint on the cre8-tab according to the cre8-tabs variant.\n */\n async firstUpdated() {\n /* 1 */\n this.setTabAttributes();\n await this.updateComplete;\n\n /* 2 */\n this.activeTab = this._Cre8TabItems[this.activeIndex] || this._Cre8TabItems[0];\n this.setActiveTab();\n\n /* 3 */\n this.setIsStart();\n this.setIsEnd();\n\n /* 4 */\n this.setTabVariant();\n }\n\n /**\n * Updated Lifecycle Hook\n * 1. remove selected state from previously selected tab\n * 2. Checks to see if the old `activeIndex` property has been updated.\n * If the new value doesn't equal the old value, activate the proper tab\n */\n async updated(changedProperties: Map<string, unknown>) {\n // Generated tabs and panels must exist before the existing logic below\n // wires up indices and active state, so this runs first.\n if (changedProperties.has('items')) {\n syncLightChildren(this, this.buildComposition());\n }\n\n changedProperties.forEach(async (oldValue, propName) => {\n if (propName === 'activeIndex' && this.activeIndex !== oldValue) {\n await this.updateComplete;\n\n if (this.activeTab) {\n this.removePreviousActiveTab(); /* 1 */\n }\n\n this.activeTab = this._Cre8TabItems[this.activeIndex];\n this.setActiveTab(); /* 2 */\n }\n });\n }\n\n /**\n * Handle Resize\n * 1. On resize, if position from left is greater than 0, set isStart to false. Otherwise set isStart to true.\n * 2. On resize, If last child is fully in the viewport, set isEnd to true. Otherwise, set isEnd to false.\n * @fires resize\n */\n handleResize() {\n this.setIsStart(); /* 1 */\n this.setIsEnd(); /* 2 */\n }\n\n /**\n * Handle Scroll\n * 1. On scroll, if position from left is greater than 0, set isStart to false. Otherwise set isStart to true.\n * 2. On scroll, If last child is fully in the viewport, set isEnd to true. Otherwise, set isEnd to false.\n * @fires scroll\n */\n handleScroll() {\n this.setIsStart(); /* 1 */\n this.setIsEnd(); /* 2 */\n }\n\n /**\n * Set isStart State\n * 1. If position from left is greater than 0, set isStart to false. Otherwise set isStart to true.\n */\n setIsStart() {\n if (this.isRTL) {\n if (this._Cre8TabsHeaderList.scrollLeft > 0) {\n this.isStart = true;\n } else {\n this.isStart = false;\n }\n } else if (this._Cre8TabsHeaderList.scrollLeft > 0) {\n this.isStart = false;\n } else {\n this.isStart = true;\n }\n }\n\n /**\n * Set isEnd State\n * 1. If last child is fully in the viewport, set isEnd to true. Otherwise, set isEnd to false.\n */\n setIsEnd() {\n if (this.isInViewport() === true) {\n this.isEnd = true;\n } else {\n this.isEnd = false;\n }\n }\n\n /**\n * Check if last overflow list item is in the viewport\n * 1. Get children of the overflow list inner container and get bounding client rectangle of last child\n * 2. Return true if the left property is greater than or equal to 0 and if the right property is less\n * than or equal to the window inner width or document client width\n */\n isInViewport() {\n const lastChild = this._Cre8TabItems[this._Cre8TabItems.length - 1];\n const tabElement = lastChild.shadowRoot?.querySelector('.cre8-c-tab');\n if (!tabElement) {\n return false; // Return false if the tab element is not found\n }\n\n const rect = tabElement.getBoundingClientRect(); /* 1 */\n const windowWidth = window.innerWidth || document.documentElement.clientWidth;\n return rect.left >= 0 && rect.right <= windowWidth; /* 2 */\n }\n\n /**\n * Set Tab Variant\n * 1. Loop through all the cre8-tab Components and set the size to 'sm' if the parent has size 'sm'.\n */\n setTabVariant() {\n if (this.size === 'sm') {\n this._Cre8TabItems.forEach((tab: Cre8Tab) => {\n tab.size = 'sm';\n });\n }\n }\n\n /**\n * Set the attributes on tab and tab panel\n * 1. Sets the index value on the tab items.\n * 2. Sets the `aria-labelledby` on the tab items.\n * 3. Set the index and id on the tab-panel to match the tab.\n */\n setTabAttributes() {\n this._Cre8TabItems.forEach((tab, index) => {\n /* 1 */\n tab.index = index;\n\n /* 2 */\n const ariaLabelledBy = tab.ariaLabelledBy;\n const id = ariaLabelledBy || nanoid();\n tab.ariaLabelledBy = id;\n\n\n /* 3 */\n const tabPanel = this._Cre8TabPanels[index];\n tabPanel.index = index;\n });\n }\n\n /**\n * Set Active Tab\n * 1. Sets the active state for the selected tab.\n * 2. Sets the active state for the tab panel with the same index value as the selected tab.\n */\n setActiveTab() {\n /* 1 */\n this.activeTab.isActive = true;\n\n /* 2 */\n const activeTabPanel = this._Cre8TabPanels.find((tabPanel) => tabPanel.index === this.activeTab.index);\n if (activeTabPanel) {\n activeTabPanel.isActive = true;\n }\n }\n\n /**\n * Set Active Tab Focus\n */\n setActiveTabFocus() {\n this.activeTab.shadowRoot?.querySelector<HTMLElement>('.cre8-c-tab').focus();\n }\n\n /**\n * Handle Tab Selected\n * 1. Only continue if event target is a tab\n * 2. If tab is active, make the previous selected tab inactive.\n * 3. Set the clicked tab active.\n * 4. Emit the custom event.\n * @fires tab-select\n */\n handleTabSelected(event: MouseEvent) {\n const { target } = event;\n\n /* 1 */\n if (this._Cre8TabItems.includes(target as Cre8Tab)) {\n /* 2 */\n if (this.activeTab) {\n this.removePreviousActiveTab();\n }\n\n /* 3 */\n this.activeTab = target as Cre8Tab;\n const activeIndex = this._Cre8TabItems.findIndex((tab) => tab === this.activeTab);\n this.activeIndex = activeIndex;\n this.setActiveTab();\n\n /* 4 */\n this.emitEvent();\n }\n }\n\n /**\n * Handle Keydown\n * 1. If the active tab is not focused then handle the keydown events.\n * 2. On keydown of the right arrow, make the next tab active.\n * 3. On keydown of the left arrow, make the previous tab active.\n * 4. On keydown of the home key, make the first tab active.\n * 5. On keydown of the end key, make the last tab active.\n * 6. On keydown of the escape key, remove the focus.\n * @fires keydown\n */\n handleKeydown(event: KeyboardEvent) {\n /* 1 */\n const { target } = event;\n const focused = document.activeElement as Cre8Tab;\n if (!focused.matches('cre8-tab')) {\n return;\n }\n switch (event.key) {\n /* 2 */\n case 'ArrowRight':\n event.preventDefault();\n this.setSelectedToNextTab(target as Cre8Tab);\n break;\n /* 3 */\n case 'ArrowLeft':\n event.preventDefault();\n this.setSelectedToPreviousTab(target as Cre8Tab);\n break;\n /* 4 */\n case 'Home':\n event.preventDefault();\n this.setSelectedToNextTab(this._Cre8TabItems[this._Cre8TabItems.length - 1]);\n break;\n /* 5 */\n case 'End':\n event.preventDefault();\n this.setSelectedToPreviousTab(this._Cre8TabItems[0]);\n break;\n /* 6 */\n case 'Escape':\n this.activeTab.blur();\n break;\n default:\n // no default\n }\n }\n\n /**\n * Set Selected To Previous Tab\n * 1. Get current selected Tab index then deactivate previously selected tab.\n * 2. If current activeIndex is in first position then move the tab focus to last tab.\n * 3. Set the active tab and focus.\n * 4. Emit custom event.\n * @fires tab-change\n */\n setSelectedToPreviousTab(currentTab: Cre8Tab) {\n /* 1 */\n const activeIndex = currentTab.index;\n this.removePreviousActiveTab();\n\n /* 2 */\n const tabListLength = this._Cre8TabItems.length - 1;\n if (activeIndex === 0) {\n this.activeIndex = tabListLength;\n this.activeTab = this._Cre8TabItems[tabListLength];\n } else {\n const previousIndex = activeIndex - 1;\n this.activeIndex = previousIndex;\n this.activeTab = this._Cre8TabItems[previousIndex];\n }\n\n /* 3 */\n this.setActiveTab();\n this.setActiveTabFocus();\n\n /* 4 */\n this.emitEvent();\n }\n\n /**\n * Set Selected To Next Tab\n * 1. Get current selected Tab index then deactivate previously selected tab.\n * 2. If current activeIndex is in last position then move the tab focus to first tab.\n * 3. Set the active tab and focus.\n * 4. Emit custom event.\n * @fires tab-change\n */\n setSelectedToNextTab(currentTab: Cre8Tab) {\n /* 1 */\n const activeIndex = currentTab.index;\n this.removePreviousActiveTab();\n\n /* 2 */\n const tabListLength = this._Cre8TabItems.length - 1;\n if (activeIndex === tabListLength) {\n this.activeIndex = 0;\n this.activeTab = this._Cre8TabItems[0];\n } else {\n const nextIndex = activeIndex + 1;\n this.activeIndex = nextIndex;\n this.activeTab = this._Cre8TabItems[nextIndex];\n }\n\n /* 3 */\n this.setActiveTab();\n this.setActiveTabFocus();\n\n /* 4 */\n this.emitEvent();\n }\n\n /**\n * Remove Active from Previous Tab\n * 1. Get current selected Tab index then deactivate previously selected tab\n * 2. If current activeIndex is in first position then move the tab focus to last tab\n */\n removePreviousActiveTab() {\n /* 1 */\n this.activeTab.isActive = false;\n\n /* 2 */\n const activeTabPanel = this._Cre8TabPanels.find((tabPanel) => tabPanel.index === this.activeTab.index);\n if (activeTabPanel) {\n activeTabPanel.isActive = false;\n }\n }\n\n /**\n * Emit custom event\n */\n emitEvent() {\n const customEvent = new CustomEvent('tab-change', {\n detail: {\n value: this.activeTab,\n activeTabIndex: this.activeIndex,\n },\n bubbles: true,\n composed: true,\n });\n this.dispatchWithLegacyAlias(customEvent);\n }\n /**\n * Tabs for a data-driven tab set. Each entry becomes a `cre8-tab` in the\n * default slot *and* a `cre8-tab-panel` in the `panel` slot, with matching\n * indices — two slots kept in step, which is the part that goes wrong when\n * these are written by hand.\n */\n @property({ type: Array })\n items?: Cre8TabItemData[];\n\n /** The composition the data property stands for. */\n private buildComposition(): ChildSpec[] | null {\n if (!this.items) return null;\n const tabs: ChildSpec[] = this.items.map((item, index) => ({\n tag: 'cre8-tab',\n props: { index },\n text: item.label,\n }));\n const panels: ChildSpec[] = this.items.map((item, index) => ({\n tag: 'cre8-tab-panel',\n props: { index },\n slot: 'panel',\n text: item.content ?? '',\n }));\n return [...tabs, ...panels];\n }\n\n\n render() {\n const componentClassNames = this.componentClassNames('cre8-c-tabs', {\n 'cre8-is-start': this.isStart === true,\n 'cre8-is-end': this.isEnd === true,\n 'cre8-c-tabs--full-width': this.fullWidth,\n });\n\n return html`\n <div class=\"${componentClassNames}\">\n <div class=\"cre8-c-tabs__header\">\n <div\n class=\"cre8-c-tabs__list\"\n role=\"tablist\"\n tabindex=0\n @scroll=${this.handleScroll}\n @keydown=${this.handleKeydown}\n @click=${this.handleTabSelected}\n >\n <slot></slot>\n </div>\n </div>\n <div class=\"cre8-c-tabs__body\">\n <slot name=\"panel\"></slot>\n </div>\n </div>\n `;\n }\n}\n\nif (customElements.get('cre8-tabs') === undefined) {\n customElements.define('cre8-tabs', Cre8Tabs);\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'cre8-tabs': Cre8Tabs;\n }\n}\n\nexport default Cre8Tabs;\n"]}
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import { Cre8Element } from '../cre8-element';
|
|
2
|
+
/** One tag in a data-driven tag list. */
|
|
3
|
+
export interface Cre8TagData {
|
|
4
|
+
text: string;
|
|
5
|
+
variant?: 'neutral' | 'branded' | 'neutral-hybrid';
|
|
6
|
+
shape?: 'square' | 'round';
|
|
7
|
+
type?: 'checkbox' | 'radio';
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
}
|
|
2
10
|
/**
|
|
3
11
|
* Tag List must have children which are Tag components that are of type `checkbox` or `radio`.
|
|
4
12
|
* The Tags must use the `neutral` variant and the `round` shape when they are inside a Tag List.
|
|
@@ -19,6 +27,15 @@ export declare class Cre8TagList extends Cre8Element {
|
|
|
19
27
|
fieldId?: string;
|
|
20
28
|
firstUpdated(): void;
|
|
21
29
|
private _initializeAria;
|
|
30
|
+
/**
|
|
31
|
+
* Tags for a data-driven tag list. Set this and the list builds its own
|
|
32
|
+
* `cre8-tag` children in the light DOM. Leave it unset to compose them
|
|
33
|
+
* yourself.
|
|
34
|
+
*/
|
|
35
|
+
tags?: Cre8TagData[];
|
|
36
|
+
/** The composition the data property stands for. */
|
|
37
|
+
private buildComposition;
|
|
38
|
+
protected updated(changed: Map<string, unknown>): void;
|
|
22
39
|
render(): import("lit-html").TemplateResult<1>;
|
|
23
40
|
}
|
|
24
41
|
declare global {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tag-list.d.ts","sourceRoot":"","sources":["../../../components/tag-list/tag-list.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"tag-list.d.ts","sourceRoot":"","sources":["../../../components/tag-list/tag-list.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAI9C,yCAAyC;AACzC,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,gBAAgB,CAAC;IACnD,KAAK,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;IAC3B,IAAI,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;GAMG;AAEH,qBAAa,WAAY,SAAQ,WAAW;IACxC,MAAM,CAAC,MAAM,4BAAY;IAE3B;;OAEG;IAEC,KAAK,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IAEC,OAAO,CAAC,EAAE,MAAM,CAAC;IAErB,YAAY;IAIZ,OAAO,CAAC,eAAe;IAGvB;;;;OAIG;IAEC,IAAI,CAAC,EAAE,WAAW,EAAE,CAAC;IAEzB,oDAAoD;IACpD,OAAO,CAAC,gBAAgB;IAexB,SAAS,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAOtD,MAAM;CAYP;AAMD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,eAAe,EAAE,WAAW,CAAC;KAC9B;CACF;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -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,eAAe;QACnB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,MAAM,EAAE,CAAC;IAC5C,CAAC;IASD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C,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;QACL,OAAO,QAAQ,CAAC,GAAG,KAAK,KAAK,CAAC;IAClC,CAAC;IAED;;;;;SAKK;IACL,OAAO;QACL,WAAW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AAC,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,IAAI,CAAC,QAAQ,EAAE,CAAC;gBAChB,IAAI,CAAC,YAAY,EAAE,CAAC;YACxB,CAAC;QACL,CAAC,CAAC;I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AQnB;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
|