@redvars/peacock 4.0.0 → 4.1.0
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/dist/{BaseField-CAog9TIc.js → BaseField-BMumJpkW.js} +6 -3
- package/dist/BaseField-BMumJpkW.js.map +1 -0
- package/dist/{BaseInput-CcMfg1Y2.js → BaseInput-mWdyYv27.js} +6 -3
- package/dist/BaseInput-mWdyYv27.js.map +1 -0
- package/dist/accordion.js.map +1 -1
- package/dist/ai-badge.js +2 -2
- package/dist/ai-summary.js +2 -2
- package/dist/alert.js +2 -2
- package/dist/anchor-nav.js +2 -2
- package/dist/app-shell.js +2 -2
- package/dist/assistant-panel.js +2 -2
- package/dist/assistant-step.js +2 -2
- package/dist/assistant-steps.js +2 -2
- package/dist/avatar-group.js +2 -2
- package/dist/banner.js +2 -2
- package/dist/{base-button-Do2TUy8M.js → base-button-BJMGMcMv.js} +3 -1
- package/dist/base-button-BJMGMcMv.js.map +1 -0
- package/dist/{base-progress-BiLlZVHJ.js → base-progress-CvLVSjuy.js} +4 -2
- package/dist/base-progress-CvLVSjuy.js.map +1 -0
- package/dist/bottom-sheet.js +2 -2
- package/dist/breadcrumb.js +2 -2
- package/dist/button-group.js +4 -4
- package/dist/button.js +3 -3
- package/dist/calendar.js +2 -2
- package/dist/canvas-base-BTQMEVn_.js +788 -0
- package/dist/canvas-base-BTQMEVn_.js.map +1 -0
- package/dist/canvas-link-CtgsALq4.js +54 -0
- package/dist/canvas-link-CtgsALq4.js.map +1 -0
- package/dist/{cartesian-chart-C-f1frt0.js → cartesian-chart-DM1FC_XT.js} +3 -2
- package/dist/cartesian-chart-DM1FC_XT.js.map +1 -0
- package/dist/{cb-group-base-DeuCVx3a.js → cb-group-base-B6fa4Lll.js} +2 -2
- package/dist/{cb-group-base-DeuCVx3a.js.map → cb-group-base-B6fa4Lll.js.map} +1 -1
- package/dist/cb-group.js +3 -3
- package/dist/cb-rule.js +3 -3
- package/dist/chart-area.js +5 -4
- package/dist/chart-area.js.map +1 -1
- package/dist/chart-bar.js +5 -4
- package/dist/chart-bar.js.map +1 -1
- package/dist/chart-base-Dhxuw_Mw.js +833 -0
- package/dist/chart-base-Dhxuw_Mw.js.map +1 -0
- package/dist/chart-doughnut.js +4 -3
- package/dist/chart-doughnut.js.map +1 -1
- package/dist/chart-line.js +5 -4
- package/dist/chart-line.js.map +1 -1
- package/dist/chart-pie.js +4 -3
- package/dist/chart-pie.js.map +1 -1
- package/dist/chat-message.js +2 -2
- package/dist/chat-thread.js +2 -2
- package/dist/checkbox-group.js +4 -4
- package/dist/checkbox.js +4 -4
- package/dist/chip-set.js +3 -3
- package/dist/chip.js +4 -4
- package/dist/circular-progress.js +3 -3
- package/dist/citation.js +2 -2
- package/dist/code-editor.js +5 -4
- package/dist/code-editor.js.map +1 -1
- package/dist/code-highlighter.js +2 -2
- package/dist/color-field.js +5 -5
- package/dist/color-picker.js +2 -2
- package/dist/command-palette.js +2 -2
- package/dist/comment-composer.js +5 -5
- package/dist/condition-builder.js +3 -3
- package/dist/confirm-dialog.js +2 -2
- package/dist/copy-button.js +2 -2
- package/dist/currency-field.js +5 -5
- package/dist/custom-elements-jsdocs.json +2115 -336
- package/dist/custom-elements.json +19483 -615
- package/dist/date-field.js +6 -6
- package/dist/date-picker.js +4 -2
- package/dist/date-picker.js.map +1 -1
- package/dist/date-range-field.js +6 -6
- package/dist/datetime-field.js +6 -6
- package/dist/dependency-map-layout-5KUueabk.js +1390 -0
- package/dist/dependency-map-layout-5KUueabk.js.map +1 -0
- package/dist/dependency-map.js +1605 -0
- package/dist/dependency-map.js.map +1 -0
- package/dist/description-item.js +2 -2
- package/dist/description-list.js +2 -2
- package/dist/diagram-2r11KySs.js +2029 -0
- package/dist/diagram-2r11KySs.js.map +1 -0
- package/dist/diagram-controls.js +345 -0
- package/dist/diagram-controls.js.map +1 -0
- package/dist/diagram-minimap.js +216 -0
- package/dist/diagram-minimap.js.map +1 -0
- package/dist/diagram.js +20 -0
- package/dist/diagram.js.map +1 -0
- package/dist/diff-viewer.js +2 -2
- package/dist/discussion-activity.js +2 -2
- package/dist/discussion-comment.js +2 -2
- package/dist/discussion.js +5 -5
- package/dist/{document-editor-BO7QPbO5.js → document-editor-BnEugM3E.js} +2 -2
- package/dist/{document-editor-BO7QPbO5.js.map → document-editor-BnEugM3E.js.map} +1 -1
- package/dist/document-editor.js +3 -3
- package/dist/draft-card.js +2 -2
- package/dist/erd.js +2021 -0
- package/dist/erd.js.map +1 -0
- package/dist/fab.js +4 -4
- package/dist/field.js +257 -43
- package/dist/field.js.map +1 -1
- package/dist/file-upload.js +37 -15
- package/dist/file-upload.js.map +1 -1
- package/dist/filter-bar.js +2 -2
- package/dist/flow.js +27 -970
- package/dist/flow.js.map +1 -1
- package/dist/focus-ring.js +2 -0
- package/dist/focus-ring.js.map +1 -1
- package/dist/{form-associated-D3Tn33s_.js → form-associated-BHbg72PG.js} +3 -1
- package/dist/{form-associated-D3Tn33s_.js.map → form-associated-BHbg72PG.js.map} +1 -1
- package/dist/{form-submitter-DWwv6K9-.js → form-submitter-beG1CXAn.js} +7 -1
- package/dist/{form-submitter-DWwv6K9-.js.map → form-submitter-beG1CXAn.js.map} +1 -1
- package/dist/form.js +2 -2
- package/dist/{generative-view-DmtpDobn.js → generative-view-BgOcLRXr.js} +13 -13
- package/dist/generative-view-BgOcLRXr.js.map +1 -0
- package/dist/generative-view.js +3 -3
- package/dist/geometry-INg82Lxq.js +305 -0
- package/dist/geometry-INg82Lxq.js.map +1 -0
- package/dist/history-YbTSQZHj.js +45 -0
- package/dist/history-YbTSQZHj.js.map +1 -0
- package/dist/host-CZK7xhzh.js +40 -0
- package/dist/host-CZK7xhzh.js.map +1 -0
- package/dist/html-editor.js +5 -5
- package/dist/{hyperlink-DhE9RlVS.js → hyperlink-DycWPKwU.js} +10 -1
- package/dist/hyperlink-DycWPKwU.js.map +1 -0
- package/dist/{i18n-controller-urcQKYGe.js → i18n-controller-Cp43HjJl.js} +2 -2
- package/dist/{i18n-controller-urcQKYGe.js.map → i18n-controller-Cp43HjJl.js.map} +1 -1
- package/dist/icon-button.js +4 -4
- package/dist/image.js +2 -2
- package/dist/index.js +37 -18
- package/dist/index.js.map +1 -1
- package/dist/inline-edit.js +2 -2
- package/dist/input.js +4 -4
- package/dist/json-viewer.js +2 -2
- package/dist/kanban.js +2 -2
- package/dist/kbd.js +2 -2
- package/dist/linear-progress.js +3 -3
- package/dist/link-button.js +2 -2
- package/dist/list-item.js +2 -2
- package/dist/list.js +2 -2
- package/dist/listbox.js +3 -3
- package/dist/loader-full.js +13 -13
- package/dist/loader.js +44 -15
- package/dist/loader.js.map +1 -1
- package/dist/markdown-editor.js +5 -5
- package/dist/markers-BFmh1OCz.js +46 -0
- package/dist/markers-BFmh1OCz.js.map +1 -0
- package/dist/measure-controller-Dmc5hZKg.js +89 -0
- package/dist/measure-controller-Dmc5hZKg.js.map +1 -0
- package/dist/mention-input.js +6 -5
- package/dist/mention-input.js.map +1 -1
- package/dist/menu-item.js +3 -2
- package/dist/menu-item.js.map +1 -1
- package/dist/menu.js +2 -2
- package/dist/modal.js +2 -2
- package/dist/navigation-bar.js +2 -2
- package/dist/navigation-drawer.js +2 -2
- package/dist/navigation-rail.js +2 -2
- package/dist/notification-center.js +2 -2
- package/dist/number-field.js +6 -5
- package/dist/number-field.js.map +1 -1
- package/dist/option.js +2 -2
- package/dist/page-header.js +2 -2
- package/dist/pagination.js +2 -2
- package/dist/password-field.js +5 -5
- package/dist/password-rules.js +2 -2
- package/dist/phone-field.js +5 -5
- package/dist/{picker-field-B4DtcJfL.js → picker-field-dTlIMAQn.js} +3 -3
- package/dist/{picker-field-B4DtcJfL.js.map → picker-field-dTlIMAQn.js.map} +1 -1
- package/dist/pin-input.js +5 -5
- package/dist/presence-indicator.js +2 -2
- package/dist/prompt-input.js +5 -5
- package/dist/radio-group.js +1 -0
- package/dist/radio-group.js.map +1 -1
- package/dist/radio.js +5 -5
- package/dist/radio.js.map +1 -1
- package/dist/rating.js +5 -4
- package/dist/rating.js.map +1 -1
- package/dist/redvars-loader.js +2 -2
- package/dist/relative-time.js +2 -2
- package/dist/resizable-panels.js +2 -2
- package/dist/{rich-text-input-DLICqof1.js → rich-text-input-DM_BOzgk.js} +3 -3
- package/dist/{rich-text-input-DLICqof1.js.map → rich-text-input-DM_BOzgk.js.map} +1 -1
- package/dist/ripple.js +2 -0
- package/dist/ripple.js.map +1 -1
- package/dist/{schema-hMt-NRLk.js → schema-B8g30A_n.js} +2 -2
- package/dist/{schema-hMt-NRLk.js.map → schema-B8g30A_n.js.map} +1 -1
- package/dist/search.js +4 -4
- package/dist/segmented-button-group.js +1 -1
- package/dist/select.js +7 -7
- package/dist/side-sheet.js +2 -2
- package/dist/signature-pad.js +5 -4
- package/dist/signature-pad.js.map +1 -1
- package/dist/slider.js +5 -4
- package/dist/slider.js.map +1 -1
- package/dist/snackbar.js +2 -2
- package/dist/sparkline.js +2 -2
- package/dist/split-button.js +2 -2
- package/dist/src/__internal/diagram/canvas-base.d.ts +105 -0
- package/dist/src/__internal/diagram/canvas-link.d.ts +21 -0
- package/dist/src/__internal/diagram/geometry.d.ts +49 -0
- package/dist/src/__internal/diagram/history.d.ts +17 -0
- package/dist/src/__internal/diagram/host.d.ts +45 -0
- package/dist/src/__internal/diagram/markers.d.ts +16 -0
- package/dist/src/__internal/diagram/measure-controller.d.ts +32 -0
- package/dist/src/__internal/diagram/motion.d.ts +22 -0
- package/dist/src/__internal/diagram/selection.d.ts +20 -0
- package/dist/src/__internal/diagram/types.d.ts +39 -0
- package/dist/src/__internal/diagram/viewport-controller.d.ts +89 -0
- package/dist/src/__internal/i18n/strings.d.ts +149 -0
- package/dist/src/__internal/toggle-base.d.ts +8 -0
- package/dist/src/__internal/utils/deprecate.d.ts +3 -3
- package/dist/src/accordion/accordion.d.ts +1 -0
- package/dist/src/code-editor/code-editor.d.ts +1 -0
- package/dist/src/date-picker/date-picker.d.ts +2 -0
- package/dist/src/dependency-map/dependency-map-layout.d.ts +48 -0
- package/dist/src/dependency-map/dependency-map.d.ts +241 -0
- package/dist/src/dependency-map/index.d.ts +2 -0
- package/dist/src/diagram/diagram.d.ts +300 -0
- package/dist/src/diagram/flow.d.ts +53 -0
- package/dist/src/diagram/index.d.ts +4 -0
- package/dist/src/diagram-controls/diagram-controls.d.ts +46 -0
- package/dist/src/diagram-controls/index.d.ts +1 -0
- package/dist/src/diagram-minimap/diagram-minimap.d.ts +39 -0
- package/dist/src/diagram-minimap/index.d.ts +1 -0
- package/dist/src/erd/erd-layout.d.ts +27 -0
- package/dist/src/erd/erd.d.ts +266 -0
- package/dist/src/erd/index.d.ts +2 -0
- package/dist/src/field/field.d.ts +38 -1
- package/dist/src/file-upload/file-upload.d.ts +3 -1
- package/dist/src/focus-ring/focus-ring.d.ts +2 -0
- package/dist/src/index.d.ts +15 -2
- package/dist/src/input/BaseField.d.ts +3 -0
- package/dist/src/input/BaseInput.d.ts +3 -0
- package/dist/src/menu/menu-item/menu-item.d.ts +1 -0
- package/dist/src/number-field/number-field.d.ts +4 -0
- package/dist/src/progress/base-progress.d.ts +3 -0
- package/dist/src/radio/radio-group.d.ts +1 -0
- package/dist/src/rating/rating.d.ts +1 -0
- package/dist/src/ripple/ripple.d.ts +2 -0
- package/dist/src/signature-pad/signature-pad.d.ts +1 -0
- package/dist/src/slider/slider.d.ts +1 -0
- package/dist/src/switch/switch.d.ts +1 -0
- package/dist/src/tabs/tab.d.ts +2 -0
- package/dist/src/tabs/tabs.d.ts +1 -0
- package/dist/src/textarea/textarea.d.ts +1 -0
- package/dist/src/time-picker/time-picker.d.ts +2 -0
- package/dist/src/transfer-list/transfer-list.d.ts +1 -0
- package/dist/src/tree-chart/index.d.ts +2 -0
- package/dist/src/tree-chart/tree-chart-layout.d.ts +49 -0
- package/dist/src/tree-chart/tree-chart.d.ts +221 -0
- package/dist/src/workflow/index.d.ts +2 -0
- package/dist/src/workflow/workflow-format.d.ts +5 -0
- package/dist/src/workflow/workflow-model.d.ts +194 -0
- package/dist/src/workflow/workflow.d.ts +313 -0
- package/dist/src/workflow-timeline/index.d.ts +1 -0
- package/dist/src/workflow-timeline/workflow-timeline.d.ts +41 -0
- package/dist/stat.js +2 -2
- package/dist/status-indicator.js +2 -2
- package/dist/step.js +2 -2
- package/dist/stepper.js +2 -2
- package/dist/{strings-DmbqMTfs.js → strings-BJPuhKJk.js} +163 -1
- package/dist/{strings-DmbqMTfs.js.map → strings-BJPuhKJk.js.map} +1 -1
- package/dist/sub-menu.js +2 -2
- package/dist/svg.js +2 -2
- package/dist/switch.js +5 -4
- package/dist/switch.js.map +1 -1
- package/dist/tab.js +1 -0
- package/dist/tab.js.map +1 -1
- package/dist/table.js +2 -2
- package/dist/tabs.js +1 -0
- package/dist/tabs.js.map +1 -1
- package/dist/test/diagram-controls.test.d.ts +1 -0
- package/dist/test/diagram-geometry.test.d.ts +1 -0
- package/dist/test/diagram.test.d.ts +1 -0
- package/dist/test/erd.test.d.ts +1 -0
- package/dist/test/toggle-label.test.d.ts +1 -0
- package/dist/test/tree-chart.test.d.ts +1 -0
- package/dist/test/workflow-debug.test.d.ts +1 -0
- package/dist/test/workflow.test.d.ts +1 -0
- package/dist/textarea.js +7 -5
- package/dist/textarea.js.map +1 -1
- package/dist/time-field.js +6 -6
- package/dist/time-picker.js +4 -2
- package/dist/time-picker.js.map +1 -1
- package/dist/timeline-item.js +2 -2
- package/dist/timeline.js +2 -2
- package/dist/{toggle-base-BQO5pjrU.js → toggle-base-BlaHalfS.js} +19 -3
- package/dist/toggle-base-BlaHalfS.js.map +1 -0
- package/dist/tour.js +2 -2
- package/dist/transfer-list.js +5 -4
- package/dist/transfer-list.js.map +1 -1
- package/dist/{chart-base-B-gOg2Di.js → transform-CxeQFXXB.js} +9 -839
- package/dist/transform-CxeQFXXB.js.map +1 -0
- package/dist/tree-chart.js +1986 -0
- package/dist/tree-chart.js.map +1 -0
- package/dist/tree-item.js +2 -2
- package/dist/tree.js +2 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/typing-indicator.js +2 -2
- package/dist/url-field.js +5 -5
- package/dist/user-menu.js +2 -2
- package/dist/virtual-list.js +2 -2
- package/dist/workflow-format-BsyveyeC.js +34 -0
- package/dist/workflow-format-BsyveyeC.js.map +1 -0
- package/dist/workflow-model-CauduOG2.js +330 -0
- package/dist/workflow-model-CauduOG2.js.map +1 -0
- package/dist/workflow-timeline.js +354 -0
- package/dist/workflow-timeline.js.map +1 -0
- package/dist/workflow.js +3337 -0
- package/dist/workflow.js.map +1 -0
- package/dist/workspace-switcher.js +2 -2
- package/package.json +1 -1
- package/readme.md +44 -2
- package/src/LoaderUtils.ts +9 -2
- package/src/__internal/diagram/canvas-base.ts +410 -0
- package/src/__internal/diagram/canvas-link.ts +66 -0
- package/src/__internal/diagram/geometry.ts +372 -0
- package/src/__internal/diagram/history.ts +49 -0
- package/src/__internal/diagram/host.ts +76 -0
- package/src/__internal/diagram/markers.ts +56 -0
- package/src/__internal/diagram/measure-controller.ts +104 -0
- package/src/__internal/diagram/motion.ts +89 -0
- package/src/__internal/diagram/selection.ts +69 -0
- package/src/__internal/diagram/types.ts +56 -0
- package/src/__internal/diagram/viewport-controller.ts +494 -0
- package/src/__internal/i18n/strings.ts +201 -0
- package/src/__internal/mixins/field.ts +3 -0
- package/src/__internal/mixins/form-associated.ts +2 -0
- package/src/__internal/mixins/form-submitter.ts +6 -0
- package/src/__internal/mixins/hyperlink.ts +10 -0
- package/src/__internal/toggle-base.ts +16 -0
- package/src/__internal/utils/deprecate.ts +5 -4
- package/src/accordion/accordion.ts +1 -0
- package/src/button/base-button/base-button.ts +2 -0
- package/src/code-editor/code-editor.ts +1 -0
- package/src/date-picker/date-picker.ts +2 -0
- package/src/dependency-map/dependency-map-layout.ts +505 -0
- package/src/dependency-map/dependency-map.scss +626 -0
- package/src/dependency-map/dependency-map.ts +1280 -0
- package/src/dependency-map/index.ts +16 -0
- package/src/diagram/diagram.scss +513 -0
- package/src/diagram/diagram.ts +1852 -0
- package/src/diagram/flow.ts +81 -0
- package/src/diagram/index.ts +44 -0
- package/src/diagram-controls/diagram-controls.scss +68 -0
- package/src/diagram-controls/diagram-controls.ts +255 -0
- package/src/diagram-controls/index.ts +1 -0
- package/src/diagram-minimap/diagram-minimap.scss +41 -0
- package/src/diagram-minimap/diagram-minimap.ts +149 -0
- package/src/diagram-minimap/index.ts +1 -0
- package/src/erd/erd-layout.ts +92 -0
- package/src/erd/erd.scss +636 -0
- package/src/erd/erd.ts +1728 -0
- package/src/erd/index.ts +17 -0
- package/src/field/field.scss +197 -23
- package/src/field/field.ts +109 -16
- package/src/file-upload/file-upload.scss +37 -10
- package/src/file-upload/file-upload.ts +3 -1
- package/src/focus-ring/focus-ring.ts +2 -0
- package/src/generative-view/catalog.generated.ts +12 -11
- package/src/index.ts +121 -2
- package/src/input/BaseField.ts +3 -0
- package/src/input/BaseInput.ts +3 -0
- package/src/loader.ts +25 -0
- package/src/mention-input/mention-input.scss +2 -0
- package/src/menu/menu-item/menu-item.ts +1 -0
- package/src/number-field/number-field.ts +4 -0
- package/src/progress/base-progress.ts +3 -0
- package/src/radio/radio-group.ts +1 -0
- package/src/radio/radio.ts +1 -1
- package/src/rating/rating.ts +1 -0
- package/src/ripple/ripple.ts +2 -0
- package/src/signature-pad/signature-pad.ts +1 -0
- package/src/slider/slider.ts +1 -0
- package/src/switch/switch.ts +1 -0
- package/src/tabs/tab.ts +2 -0
- package/src/tabs/tabs.ts +1 -0
- package/src/textarea/textarea.scss +2 -0
- package/src/textarea/textarea.ts +1 -0
- package/src/time-picker/time-picker.ts +2 -0
- package/src/transfer-list/transfer-list.ts +1 -0
- package/src/tree-chart/index.ts +13 -0
- package/src/tree-chart/tree-chart-layout.ts +185 -0
- package/src/tree-chart/tree-chart.scss +377 -0
- package/src/tree-chart/tree-chart.ts +1170 -0
- package/src/workflow/index.ts +35 -0
- package/src/workflow/workflow-format.ts +29 -0
- package/src/workflow/workflow-model.ts +583 -0
- package/src/workflow/workflow.scss +1164 -0
- package/src/workflow/workflow.ts +2674 -0
- package/src/workflow-timeline/index.ts +1 -0
- package/src/workflow-timeline/workflow-timeline.scss +128 -0
- package/src/workflow-timeline/workflow-timeline.ts +238 -0
- package/dist/BaseField-CAog9TIc.js.map +0 -1
- package/dist/BaseInput-CcMfg1Y2.js.map +0 -1
- package/dist/base-button-Do2TUy8M.js.map +0 -1
- package/dist/base-progress-BiLlZVHJ.js.map +0 -1
- package/dist/cartesian-chart-C-f1frt0.js.map +0 -1
- package/dist/chart-base-B-gOg2Di.js.map +0 -1
- package/dist/generative-view-DmtpDobn.js.map +0 -1
- package/dist/hyperlink-DhE9RlVS.js.map +0 -1
- package/dist/src/flow/flow.d.ts +0 -178
- package/dist/src/flow/index.d.ts +0 -2
- package/dist/toggle-base-BQO5pjrU.js.map +0 -1
- package/src/button/button-group/readme.md +0 -23
- package/src/flow/flow.scss +0 -215
- package/src/flow/flow.ts +0 -958
- package/src/flow/index.ts +0 -10
- /package/dist/test/{flow.test.d.ts → dependency-map.test.d.ts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { WorkflowTimeline } from './workflow-timeline.js';
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
@use '../../scss/mixin';
|
|
2
|
+
|
|
3
|
+
@include mixin.base-styles;
|
|
4
|
+
|
|
5
|
+
:host {
|
|
6
|
+
display: block;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.timeline {
|
|
10
|
+
padding: 12px 16px;
|
|
11
|
+
background: var(--color-surface-container-lowest);
|
|
12
|
+
border: 1px solid var(--color-outline-variant);
|
|
13
|
+
border-radius: var(--shape-corner-large);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.head {
|
|
17
|
+
display: flex;
|
|
18
|
+
align-items: baseline;
|
|
19
|
+
justify-content: space-between;
|
|
20
|
+
margin-block-end: 8px;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.title {
|
|
24
|
+
font-size: 14px;
|
|
25
|
+
font-weight: 500;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.total {
|
|
29
|
+
font-size: 12px;
|
|
30
|
+
color: var(--color-on-surface-variant);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.rows {
|
|
34
|
+
display: flex;
|
|
35
|
+
flex-direction: column;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.row {
|
|
39
|
+
@include mixin.reset-button-styles;
|
|
40
|
+
|
|
41
|
+
display: grid;
|
|
42
|
+
grid-template-columns: minmax(120px, 30%) 1fr 72px;
|
|
43
|
+
align-items: center;
|
|
44
|
+
gap: 12px;
|
|
45
|
+
inline-size: 100%;
|
|
46
|
+
min-block-size: 30px;
|
|
47
|
+
padding: 0 8px;
|
|
48
|
+
font-size: 13px;
|
|
49
|
+
text-align: start;
|
|
50
|
+
border-radius: var(--shape-corner-small);
|
|
51
|
+
cursor: pointer;
|
|
52
|
+
|
|
53
|
+
&:hover {
|
|
54
|
+
background: color-mix(in srgb, var(--color-on-surface) 6%, transparent);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
&:focus-visible {
|
|
58
|
+
outline: 2px solid var(--color-primary);
|
|
59
|
+
outline-offset: -2px;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
&.is-selected {
|
|
63
|
+
background: color-mix(in srgb, var(--color-primary) 10%, transparent);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.name {
|
|
68
|
+
display: flex;
|
|
69
|
+
align-items: center;
|
|
70
|
+
gap: 6px;
|
|
71
|
+
min-inline-size: 0;
|
|
72
|
+
--icon-size: 1rem;
|
|
73
|
+
--icon-color: var(--color-on-surface-variant);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.label {
|
|
77
|
+
overflow: hidden;
|
|
78
|
+
text-overflow: ellipsis;
|
|
79
|
+
white-space: nowrap;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.track {
|
|
83
|
+
position: relative;
|
|
84
|
+
block-size: 10px;
|
|
85
|
+
border-radius: var(--shape-corner-full);
|
|
86
|
+
background: var(--color-surface-container);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/* Bars are placed along the time axis, which does not mirror. */
|
|
90
|
+
/* stylelint-disable property-disallowed-list */
|
|
91
|
+
.bar {
|
|
92
|
+
position: absolute;
|
|
93
|
+
top: 0;
|
|
94
|
+
block-size: 100%;
|
|
95
|
+
border-radius: var(--shape-corner-full);
|
|
96
|
+
background: var(--color-outline);
|
|
97
|
+
|
|
98
|
+
.st-success & {
|
|
99
|
+
background: var(--color-success);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.st-failed & {
|
|
103
|
+
background: var(--color-error);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.st-running &,
|
|
107
|
+
.st-waiting &,
|
|
108
|
+
.st-paused & {
|
|
109
|
+
background: var(--color-primary);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.st-skipped &,
|
|
113
|
+
.st-canceled & {
|
|
114
|
+
background: var(--color-outline-variant);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/* stylelint-enable property-disallowed-list */
|
|
118
|
+
|
|
119
|
+
.duration {
|
|
120
|
+
font-size: 12px;
|
|
121
|
+
text-align: end;
|
|
122
|
+
font-variant-numeric: tabular-nums;
|
|
123
|
+
color: var(--color-on-surface-variant);
|
|
124
|
+
|
|
125
|
+
.st-failed & {
|
|
126
|
+
color: var(--color-error);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { html, LitElement, nothing } from 'lit';
|
|
2
|
+
import { property } from 'lit/decorators.js';
|
|
3
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
4
|
+
import IndividualComponent from '@/IndividualComponent.js';
|
|
5
|
+
import { I18nController } from '@/__internal/i18n/i18n-controller.js';
|
|
6
|
+
import { DiagramCanvasLink } from '@/__internal/diagram/canvas-link.js';
|
|
7
|
+
import {
|
|
8
|
+
walk,
|
|
9
|
+
type WorkflowRun,
|
|
10
|
+
type WorkflowRunStep,
|
|
11
|
+
type WorkflowRunStepStatus,
|
|
12
|
+
type WorkflowStep,
|
|
13
|
+
type WorkflowValue,
|
|
14
|
+
} from '@/workflow/workflow-model.js';
|
|
15
|
+
import { formatDuration } from '@/workflow/workflow-format.js';
|
|
16
|
+
import styles from './workflow-timeline.scss';
|
|
17
|
+
|
|
18
|
+
/** The parts of `wc-workflow` the timeline reads, without importing the component. */
|
|
19
|
+
interface WorkflowSource {
|
|
20
|
+
value: WorkflowValue;
|
|
21
|
+
run?: WorkflowRun;
|
|
22
|
+
selected: string;
|
|
23
|
+
selectStep(id: string): void;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface Row {
|
|
27
|
+
id: string;
|
|
28
|
+
label: string;
|
|
29
|
+
icon?: string;
|
|
30
|
+
depth: number;
|
|
31
|
+
run: WorkflowRunStep;
|
|
32
|
+
start: number;
|
|
33
|
+
end: number;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const STATUS_KEYS: Record<WorkflowRunStepStatus, string> = {
|
|
37
|
+
queued: 'workflowStatusQueued',
|
|
38
|
+
running: 'workflowStatusRunning',
|
|
39
|
+
waiting: 'workflowStatusWaiting',
|
|
40
|
+
paused: 'workflowStatusPaused',
|
|
41
|
+
success: 'workflowStatusSuccess',
|
|
42
|
+
failed: 'workflowStatusFailed',
|
|
43
|
+
skipped: 'workflowStatusSkipped',
|
|
44
|
+
canceled: 'workflowStatusCanceled',
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
function isWorkflow(el: unknown): el is WorkflowSource {
|
|
48
|
+
return (
|
|
49
|
+
!!el &&
|
|
50
|
+
typeof (el as WorkflowSource).selectStep === 'function' &&
|
|
51
|
+
'value' in (el as object)
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* @label Workflow timeline
|
|
57
|
+
* @tag wc-workflow-timeline
|
|
58
|
+
* @rawTag workflow-timeline
|
|
59
|
+
* @summary The steps of a workflow run as bars on a shared time scale, in step with a `wc-workflow`.
|
|
60
|
+
*
|
|
61
|
+
* @overview
|
|
62
|
+
* <p>Set <code>for</code> to the id of a <code>wc-workflow</code> in debug or history mode: the timeline
|
|
63
|
+
* shows its <code>run</code>, follows its selection, and selects a step in the workflow when a row is
|
|
64
|
+
* clicked. Without a workflow, set <code>value</code> and <code>run</code> yourself.</p>
|
|
65
|
+
* <p>Each step that ran is a row with its name, a bar from when it started to when it finished
|
|
66
|
+
* (running steps grow to now), coloured by status, and its duration. Steps without a
|
|
67
|
+
* <code>startedAt</code> are laid end to end in reading order.</p>
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```html
|
|
71
|
+
* <wc-workflow id="rule" mode="history"></wc-workflow>
|
|
72
|
+
* <wc-workflow-timeline for="rule"></wc-workflow-timeline>
|
|
73
|
+
* ```
|
|
74
|
+
* @tags data
|
|
75
|
+
*/
|
|
76
|
+
@IndividualComponent
|
|
77
|
+
export class WorkflowTimeline extends LitElement {
|
|
78
|
+
// ── Static
|
|
79
|
+
|
|
80
|
+
static styles = [styles];
|
|
81
|
+
|
|
82
|
+
// ── Properties
|
|
83
|
+
|
|
84
|
+
/** Id of the `wc-workflow` to show. */
|
|
85
|
+
@property({ type: String })
|
|
86
|
+
for = '';
|
|
87
|
+
|
|
88
|
+
/** The workflow, when the timeline is not linked to a `wc-workflow`. */
|
|
89
|
+
@property({ attribute: false })
|
|
90
|
+
value?: WorkflowValue;
|
|
91
|
+
|
|
92
|
+
/** The run, when the timeline is not linked to a `wc-workflow`. */
|
|
93
|
+
@property({ attribute: false })
|
|
94
|
+
run?: WorkflowRun;
|
|
95
|
+
|
|
96
|
+
/** The accessible name and heading. Defaults to "Run timeline". */
|
|
97
|
+
@property({ type: String })
|
|
98
|
+
label = '';
|
|
99
|
+
|
|
100
|
+
// ── Private fields
|
|
101
|
+
|
|
102
|
+
private readonly i18n = new I18nController(this);
|
|
103
|
+
|
|
104
|
+
private readonly link = new DiagramCanvasLink(this, {
|
|
105
|
+
forId: () => this.for,
|
|
106
|
+
onSync: () => this.requestUpdate(),
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
// ── Lifecycle
|
|
110
|
+
|
|
111
|
+
protected updated(changed: Map<string, unknown>) {
|
|
112
|
+
if (changed.has('for') && changed.get('for') !== undefined)
|
|
113
|
+
this.link.attach();
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// ── Private methods
|
|
117
|
+
|
|
118
|
+
private get source(): {
|
|
119
|
+
value?: WorkflowValue;
|
|
120
|
+
run?: WorkflowRun;
|
|
121
|
+
selected: string;
|
|
122
|
+
} {
|
|
123
|
+
const linked = this.link.canvas;
|
|
124
|
+
if (isWorkflow(linked)) {
|
|
125
|
+
return {
|
|
126
|
+
value: linked.value,
|
|
127
|
+
run: linked.run,
|
|
128
|
+
selected: linked.selected,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
return { value: this.value, run: this.run, selected: '' };
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
private rows(): Row[] {
|
|
135
|
+
const { value, run } = this.source;
|
|
136
|
+
if (!value || !run) return [];
|
|
137
|
+
const steps: { step: WorkflowStep; depth: number }[] = [];
|
|
138
|
+
if (value.trigger) steps.push({ step: value.trigger, depth: 1 });
|
|
139
|
+
walk(value, ({ step, depth }) => steps.push({ step, depth }));
|
|
140
|
+
const now = Date.now();
|
|
141
|
+
let cursor = 0;
|
|
142
|
+
const rows: Row[] = [];
|
|
143
|
+
for (const { step, depth } of steps) {
|
|
144
|
+
const r = run.steps[step.id];
|
|
145
|
+
if (r && r.status !== 'queued') {
|
|
146
|
+
const live =
|
|
147
|
+
r.status === 'running' ||
|
|
148
|
+
r.status === 'waiting' ||
|
|
149
|
+
r.status === 'paused';
|
|
150
|
+
const start = r.startedAt ?? cursor;
|
|
151
|
+
let duration = r.durationMs ?? 0;
|
|
152
|
+
if (live && r.startedAt !== undefined && r.startedAt > 1e11) {
|
|
153
|
+
duration = Math.max(duration, now - r.startedAt);
|
|
154
|
+
}
|
|
155
|
+
rows.push({
|
|
156
|
+
id: step.id,
|
|
157
|
+
label:
|
|
158
|
+
step.headline ??
|
|
159
|
+
(step.type === 'end' ? this.i18n.t('workflowEnd') : step.id),
|
|
160
|
+
icon: step.icon,
|
|
161
|
+
depth,
|
|
162
|
+
run: r,
|
|
163
|
+
start,
|
|
164
|
+
end: start + duration,
|
|
165
|
+
});
|
|
166
|
+
cursor = Math.max(cursor, start + duration);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return rows;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
private select(id: string) {
|
|
173
|
+
const linked = this.link.canvas;
|
|
174
|
+
if (isWorkflow(linked)) linked.selectStep(id);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// ── Render
|
|
178
|
+
|
|
179
|
+
protected render() {
|
|
180
|
+
const rows = this.rows();
|
|
181
|
+
const { run, selected } = this.source;
|
|
182
|
+
const t0 = Math.min(...rows.map(r => r.start));
|
|
183
|
+
const t1 = Math.max(...rows.map(r => r.end));
|
|
184
|
+
const span = Math.max(t1 - t0, 1);
|
|
185
|
+
const heading = this.label || this.i18n.t('workflowRunTimeline');
|
|
186
|
+
return html`<section class="timeline" aria-label=${heading}>
|
|
187
|
+
<header class="head">
|
|
188
|
+
<span class="title">${heading}</span>
|
|
189
|
+
${run?.durationMs !== undefined
|
|
190
|
+
? html`<span class="total"
|
|
191
|
+
>${formatDuration(run.durationMs, this.i18n.locale)}</span
|
|
192
|
+
>`
|
|
193
|
+
: nothing}
|
|
194
|
+
</header>
|
|
195
|
+
<div class="rows" role="list">
|
|
196
|
+
${rows.map(row => {
|
|
197
|
+
const left = ((row.start - t0) / span) * 100;
|
|
198
|
+
const width = Math.max(((row.end - row.start) / span) * 100, 0.6);
|
|
199
|
+
const status = this.i18n.t(
|
|
200
|
+
STATUS_KEYS[row.run.status] as 'workflowStatusQueued',
|
|
201
|
+
);
|
|
202
|
+
const duration = formatDuration(row.run.durationMs, this.i18n.locale);
|
|
203
|
+
return html`<div role="listitem">
|
|
204
|
+
<button
|
|
205
|
+
type="button"
|
|
206
|
+
class=${classMap({
|
|
207
|
+
row: true,
|
|
208
|
+
[`st-${row.run.status}`]: true,
|
|
209
|
+
'is-selected': selected === row.id,
|
|
210
|
+
})}
|
|
211
|
+
aria-label=${[row.label, status, duration]
|
|
212
|
+
.filter(Boolean)
|
|
213
|
+
.join(', ')}
|
|
214
|
+
aria-current=${selected === row.id ? 'true' : 'false'}
|
|
215
|
+
@click=${() => this.select(row.id)}
|
|
216
|
+
>
|
|
217
|
+
<span
|
|
218
|
+
class="name"
|
|
219
|
+
style="padding-inline-start: ${(row.depth - 1) * 12}px"
|
|
220
|
+
>
|
|
221
|
+
${row.icon
|
|
222
|
+
? html`<wc-icon name=${row.icon}></wc-icon>`
|
|
223
|
+
: nothing}<span class="label">${row.label}</span>
|
|
224
|
+
</span>
|
|
225
|
+
<span class="track"
|
|
226
|
+
><span
|
|
227
|
+
class="bar"
|
|
228
|
+
style="left: ${left}%; width: ${width}%"
|
|
229
|
+
></span
|
|
230
|
+
></span>
|
|
231
|
+
<span class="duration">${duration || status}</span>
|
|
232
|
+
</button>
|
|
233
|
+
</div>`;
|
|
234
|
+
})}
|
|
235
|
+
</div>
|
|
236
|
+
</section>`;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BaseField-CAog9TIc.js","sources":["../../src/input/BaseField.ts"],"sourcesContent":["import { html, nothing, type TemplateResult } from 'lit';\nimport { property, state } from 'lit/decorators.js';\n\nimport { peacockString } from '@/__internal/i18n/strings.js';\nimport type { Size } from '@/__internal/utils/size.js';\nimport BaseInput from './BaseInput.js';\n\n/** What a field component passes to `renderField()`. */\nexport interface FieldRenderOptions {\n /** Whether the field has a value; outlined fields float their label when it does. */\n populated: boolean;\n /** Overrides the field's own focus state, for fields whose popup keeps them active. */\n focused?: boolean;\n /** An error the control found itself, such as text that does not parse. */\n controlError?: string;\n /** Extra content before the control (after the `start` slot). */\n start?: unknown;\n /** Extra content after the control (after the `end` slot), such as a picker button. */\n end?: unknown;\n /** Character counter shown in the footer, such as `12/100`; empty or unset for none. */\n textCount?: string;\n}\n\nlet fieldCount = 0;\n\n/**\n * Base class for Peacock's text-like fields (input, textarea, number, URL, select, date/time,\n * color). It adds the props every field shares (label, helper/error/warning text, variant, size,\n * clearable, `start`/`end` slots) and renders the `wc-field` frame.\n *\n * It also makes the inner control accessible across the shadow boundary: `fieldAria()` gives it\n * an accessible name from `label`, `aria-invalid` while an error shows, and `aria-describedby`\n * pointing at a hidden copy of the helper or error text in the same shadow root.\n *\n * Subclasses call `renderField(control, options)` in `render()`, spread `fieldAria()` onto the\n * native control, call `emitValue('input' | 'change')` instead of re-dispatching native events\n * (the field event contract: `CustomEvent<{ value }>`, bubbling and composed), and override\n * `clearValue()` if clearing means more than `value = ''`.\n */\nexport default abstract class BaseField extends BaseInput {\n // ── Properties ───────────────────────────────────────────────────────────\n\n /** Label shown above the field; also the control's accessible name. */\n @property({ type: String }) label = '';\n\n @property({ type: String }) placeholder = '';\n\n /** Help text shown below the field. */\n @property({ type: String, attribute: 'helper-text' }) helperText = '';\n\n /** Shows the field in its error state with `error-text`. */\n @property({ type: Boolean }) error = false;\n\n @property({ type: String, attribute: 'error-text' }) errorText = '';\n\n /** Shows the field in its warning state with `warning-text`. */\n @property({ type: Boolean }) warning = false;\n\n @property({ type: String, attribute: 'warning-text' }) warningText = '';\n\n /** Visual variant of the field. */\n @property({ type: String }) variant: 'default' | 'filled' | 'outlined' =\n 'default';\n\n /** Height of the field: `sm` (2.5rem, default), `md` (3.5rem) or `lg` (4rem). */\n @property({ type: String, reflect: true }) size: Size = 'sm';\n\n /** Shows a button that clears the value while the field has one. */\n @property({ type: Boolean }) clearable = false;\n\n /** ARIA attributes moved from the host onto the inner control. */\n @property({ type: Object }) configAria: Record<string, string> = {};\n\n // ── State ────────────────────────────────────────────────────────────────\n\n @state() protected focused = false;\n\n // ── Private fields ───────────────────────────────────────────────────────\n\n /** Id of the hidden description the inner control points at. */\n protected readonly fieldDescriptionId = `wc-field-description-${(fieldCount += 1)}`;\n\n /** A `tabindex` set on the host, moved to the inner control. */\n protected controlTabIndex?: string;\n\n // ── Lifecycle ────────────────────────────────────────────────────────────\n\n override connectedCallback() {\n super.connectedCallback();\n // `aria-*` and `tabindex` set on the host belong to the inner control; move them there.\n for (const attr of Array.from(this.attributes)) {\n if (attr.name.startsWith('aria-')) {\n this.configAria = { ...this.configAria, [attr.name]: attr.value };\n this.removeAttribute(attr.name);\n }\n }\n if (this.hasAttribute('tabindex')) {\n this.controlTabIndex = this.getAttribute('tabindex') ?? undefined;\n this.removeAttribute('tabindex');\n }\n }\n\n // ── Protected ────────────────────────────────────────────────────────────\n\n /**\n * The error text the field shows: the consumer's `error-text` while `error` is set, else an\n * error the control found itself, else the validation message once it should show.\n */\n protected fieldErrorText(controlError = ''): string {\n if (this.error) return this.errorText;\n return controlError || this.validationText;\n }\n\n /**\n * Attributes for the native control: accessible name, invalid state, description and the\n * host's `tabindex`, plus `configAria`. Spread them onto it with `spread(this.fieldAria())`.\n */\n protected fieldAria(controlError = ''): Record<string, string | undefined> {\n const invalid = this.error || !!this.fieldErrorText(controlError);\n return {\n tabindex: this.controlTabIndex,\n 'aria-label': this.label || undefined,\n 'aria-invalid': invalid ? 'true' : undefined,\n 'aria-describedby': this.fieldDescription(controlError)\n ? this.fieldDescriptionId\n : undefined,\n ...this.configAria,\n };\n }\n\n /** Renders the `wc-field` frame around `control`, plus the hidden description. */\n protected renderField(\n control: unknown,\n options: FieldRenderOptions,\n ): TemplateResult {\n const errorText = this.fieldErrorText(options.controlError);\n const description = this.fieldDescription(options.controlError);\n // While a suggestion shows, its reason takes the helper text's place.\n const helperText = this.suggestionReason || this.helperText;\n return html`\n <wc-field\n label=${this.label}\n size=${this.size}\n variant=${this.variant}\n helper-text=${helperText}\n ?required=${this.required}\n ?disabled=${this.disabled}\n ?readonly=${this.readonly}\n ?skeleton=${this.skeleton}\n ?error=${this.error || !!errorText}\n error-text=${errorText}\n ?warning=${this.warning}\n warning-text=${this.warningText}\n text-count=${options.textCount ?? ''}\n ?populated=${options.populated}\n ?focused=${options.focused ?? this.focused}\n .host=${this}\n class=\"field\"\n >\n <slot name=\"start\" slot=\"field-start\"></slot>\n ${options.start ?? nothing} ${control}\n <slot name=\"end\" slot=\"field-end\"></slot>\n ${this.suggestionBadge({ slot: 'field-end' })}\n ${this.renderClearButton(options.populated)} ${options.end ?? nothing}\n </wc-field>\n ${description\n ? html`<span id=${this.fieldDescriptionId} hidden>${description}</span>`\n : nothing}\n `;\n }\n\n /** Dispatches `input` or `change` with the current value: the field event contract. */\n protected emitValue(type: 'input' | 'change') {\n this.dispatchEvent(\n new CustomEvent(type, {\n detail: { value: this.value },\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n protected override emitSuggestionValue() {\n this.emitValue('input');\n this.emitValue('change');\n }\n\n /** Clears the value for the clear button. Fields with another empty value override it. */\n protected clearValue() {\n this.value = '';\n this.emitValue('input');\n this.emitValue('change');\n }\n\n /** The counter text for a field with a `maxlength`: `12/100`, or '' when there is no limit. */\n protected characterCount(maxLength: number | null | undefined): string {\n if (typeof maxLength !== 'number' || !Number.isFinite(maxLength)) return '';\n if (maxLength < 0) return '';\n const count = String(this.value ?? '').length;\n return peacockString('characterCount')(count, maxLength);\n }\n\n /** Tracks focus of the inner control; bind it to the control's `focus` and `blur`. */\n protected handleFieldFocus = (event: FocusEvent) => {\n this.focused = event.type === 'focus';\n };\n\n // ── Private ──────────────────────────────────────────────────────────────\n\n /** The text the description carries: the error, else the warning, else the help. */\n private fieldDescription(controlError = ''): string {\n const errorText = this.fieldErrorText(controlError);\n if (errorText) return errorText;\n if (this.warning && this.warningText) return this.warningText;\n if (this.suggestionVisible) {\n return peacockString('aiSuggestedDescription')(this.suggestionReason);\n }\n return this.helperText;\n }\n\n private renderClearButton(populated: boolean) {\n if (!this.clearable || !populated || this.disabled || this.readonly) {\n return nothing;\n }\n return html`<wc-icon-button\n slot=\"field-end\"\n class=\"clear-button\"\n shape=\"round\"\n variant=\"text\"\n size=\"sm\"\n aria-label=${peacockString('clear')}\n @click=${() => {\n this.clearValue();\n this.focus();\n }}\n >\n <wc-icon name=\"close\"></wc-icon>\n </wc-icon-button>`;\n }\n}\n"],"names":["html","nothing","property","state"],"mappings":";;;;;;AAuBA,IAAI,UAAU,GAAG,CAAC;AAElB;;;;;;;;;;;;;AAaG;AACW,MAAgB,SAAU,SAAQ,SAAS,CAAA;AAAzD,IAAA,WAAA,GAAA;;;;QAI8B,IAAA,CAAA,KAAK,GAAG,EAAE;QAEV,IAAA,CAAA,WAAW,GAAG,EAAE;;QAGU,IAAA,CAAA,UAAU,GAAG,EAAE;;QAGxC,IAAA,CAAA,KAAK,GAAG,KAAK;QAEW,IAAA,CAAA,SAAS,GAAG,EAAE;;QAGtC,IAAA,CAAA,OAAO,GAAG,KAAK;QAEW,IAAA,CAAA,WAAW,GAAG,EAAE;;QAG3C,IAAA,CAAA,OAAO,GACjC,SAAS;;QAGgC,IAAA,CAAA,IAAI,GAAS,IAAI;;QAG/B,IAAA,CAAA,SAAS,GAAG,KAAK;;QAGlB,IAAA,CAAA,UAAU,GAA2B,EAAE;;QAIhD,IAAA,CAAA,OAAO,GAAG,KAAK;;;QAKf,IAAA,CAAA,kBAAkB,GAAG,yBAAyB,UAAU,IAAI,CAAC,GAAG;;AA2HzE,QAAA,IAAA,CAAA,gBAAgB,GAAG,CAAC,KAAiB,KAAI;YACjD,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,IAAI,KAAK,OAAO;AACvC,QAAA,CAAC;IAkCH;;IAxJW,iBAAiB,GAAA;QACxB,KAAK,CAAC,iBAAiB,EAAE;;AAEzB,QAAA,KAAK,MAA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O,EAAE;AAAkB,CAAA,EAAA,SAAA,CAAA,SAAA,EAAA,SAAA,EAAA,MAAA,CAAA;AAEU,UAAA,CAAA;IAAtDA,CAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc,EAAE;AAAmB,CAAA,EAAA,SAAA,CAAA,SAAA,EAAA,aAAA,EAAA,MAAA,CAAA;AAG5C,UAAA,CAAA;AAA3B,IAAAA,CAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE;AACd,CAAA,EAAA,SAAA,CAAA,SAAA,EAAA,SAAA,EAAA,MAAA,CAAA;AAG+B,UAAA,CAAA;IAA1CA,CAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE;AAAoB,CAAA,EAAA,SAAA,CAAA,SAAA,EAAA,MAAA,EAAA,MAAA,CAAA;AAGhC,UAAA,CAAA;AAA5B,IAAAA,CAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE;AAAoB,CAAA,EAAA,SAAA,CAAA,SAAA,EAAA,WAAA,EAAA,MAAA,CAAA;AAGnB,UAAA,CAAA;AAA3B,IAAAA,CAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE;AAA0C,CAAA,EAAA,SAAA,CAAA,SAAA,EAAA,YAAA,EAAA,MAAA,CAAA;AAIjD,UAAA,CAAA;AAAlB,IAAAC,CAAK;AAA6B,CAAA,EAAA,SAAA,CAAA,SAAA,EAAA,SAAA,EAAA,MAAA,CAAA;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BaseInput-CcMfg1Y2.js","sources":["../../src/input/BaseInput.ts"],"sourcesContent":["import { html, LitElement, type PropertyValues } from 'lit';\nimport { property, state } from 'lit/decorators.js';\n\nimport {\n internals,\n mixinElementInternals,\n} from '@/__internal/mixins/element-internals.js';\nimport {\n type FormRestoreState,\n type FormValue,\n getFormValue,\n mixinFormAssociated,\n} from '@/__internal/mixins/form-associated.js';\nimport { peacockString } from '@/__internal/i18n/strings.js';\nimport {\n SuggestionController,\n type SuggestionAcceptCause,\n} from '@/__internal/ai/suggestion-controller.js';\nimport type { AiSuggestion } from '@/__internal/ai/types.js';\n\nconst VALIDITY_KEYS = [\n 'valueMissing',\n 'typeMismatch',\n 'patternMismatch',\n 'tooLong',\n 'tooShort',\n 'rangeUnderflow',\n 'rangeOverflow',\n 'stepMismatch',\n 'badInput',\n] as const;\n\n/** The flags `ElementInternals.setValidity()` takes, as the DOM's `ValidityStateFlags`. */\nexport type ValidityFlags = {\n [Key in (typeof VALIDITY_KEYS)[number] | 'customError']?: boolean;\n};\n\n/** What a control reports to `ElementInternals.setValidity()`. */\nexport interface ControlValidity {\n flags: ValidityFlags;\n message: string;\n /** Element the browser points at when it reports the problem; defaults to the host. */\n anchor?: HTMLElement;\n}\n\n/** The validity of a native control, for controls that wrap one. */\nexport function nativeValidity(\n control: HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement,\n): ControlValidity {\n const flags: ValidityFlags = {};\n for (const key of VALIDITY_KEYS) {\n if (control.validity[key]) flags[key] = true;\n }\n return { flags, message: control.validationMessage, anchor: control };\n}\n\n/** Set while one `invalid` event per form submission moves focus, so only the first one does. */\nlet focusClaimed = false;\n\n/**\n * Base class for Peacock's form controls.\n *\n * It is form-associated: `value` is submitted with the surrounding `<form>`, `form.reset()`\n * restores the value the control started with, and a disabled `<fieldset>` disables it.\n * `name` and `disabled` come from `mixinFormAssociated`; they are backed by attributes, so\n * subclasses must not redeclare them.\n *\n * It takes part in constraint validation like a native control: `required` and the control's own\n * rules (from `computeValidity()`) block form submission, `checkValidity()`, `reportValidity()`,\n * `setCustomValidity()`, `validity` and `validationMessage` work as on `<input>`, and `:invalid`\n * matches. A control shows its message (`validationText`) once the person has committed a value\n * or the form was submitted.\n *\n * It can hold a value the assistant suggested (ADR-030002): `suggestion` fills the control and\n * marks it until the person accepts or clears it. `sensitive` keeps the control out of AI\n * altogether. Subclasses show the marker with `suggestionBadge()` and `suggestionReason`, and\n * override `readSuggestionValue()`, `writeSuggestionValue()` and `emitSuggestionValue()` when\n * their value is not `value` with `input`/`change` events.\n *\n * @fires {CustomEvent<SuggestionAcceptDetail>} accept - Fired when a suggested value is accepted: the person edited it (`cause: 'edit'`), the form was submitted (`'submit'`) or `acceptSuggestion()` was called (`'action'`).\n * @fires {CustomEvent<SuggestionDismissDetail>} dismiss - Fired when the person clears a suggestion, before `input` and `change` with the restored value.\n */\nexport default abstract class BaseInput extends mixinFormAssociated(\n mixinElementInternals(LitElement),\n) {\n // ── Properties ───────────────────────────────────────────────────────────\n\n /** Each control declares its own `value` (a property, or an accessor such as Switch's). */\n abstract value?: any;\n\n @property({ type: Boolean, reflect: true })\n readonly: boolean = false;\n\n @property({ type: Boolean, reflect: true })\n required: boolean = false;\n\n @property({ type: Boolean, reflect: true })\n skeleton = false;\n\n /**\n * Holds data that must never reach a model, such as a salary or a bank account: the control\n * takes no suggestions and offers no AI features.\n */\n @property({ type: Boolean, reflect: true })\n sensitive = false;\n\n /**\n * A value the assistant suggests, with why. The control takes the value and shows a Suggested\n * badge and the reason until the person edits it, the form is submitted, or the badge clears it,\n * which puts the previous value back. `null` drops the marker and keeps the value. Ignored while\n * AI is off and on `sensitive` controls.\n */\n @property({ attribute: false })\n get suggestion(): AiSuggestion | null {\n return this.__suggestions.suggestion;\n }\n\n set suggestion(suggestion: AiSuggestion | null) {\n const old = this.__suggestions.suggestion;\n this.__suggestions.set(suggestion);\n this.requestUpdate('suggestion', old);\n }\n\n // ── State ────────────────────────────────────────────────────────────────\n\n /** Whether to show the validation message: after a commit, or after a failed submit. */\n @state() protected showValidity = false;\n\n // ── Private fields ───────────────────────────────────────────────────────\n\n /** The value the control had when it was first connected; `form.reset()` returns to it. */\n private __defaultValue: unknown = undefined;\n\n private __defaultValueCaptured = false;\n\n private __customValidity = '';\n\n private readonly __suggestions = new SuggestionController(this, {\n read: () => this.readSuggestionValue(),\n write: value => this.writeSuggestionValue(value),\n emit: () => this.emitSuggestionValue(),\n });\n\n // ── Lifecycle ────────────────────────────────────────────────────────────\n\n constructor() {\n super();\n this.addEventListener('invalid', this.__handleInvalid);\n // Every control fires `change` when the person commits a value; from then on, show problems.\n this.addEventListener('change', this.__handleCommit);\n }\n\n override connectedCallback() {\n super.connectedCallback();\n if (!this.__defaultValueCaptured) {\n this.__defaultValue = this.value;\n this.__defaultValueCaptured = true;\n }\n }\n\n protected override updated(changed: PropertyValues) {\n super.updated(changed);\n // After render, so a control's inner native input reflects the new value and attributes.\n this.updateValidity();\n }\n\n // ── Public: constraint validation ────────────────────────────────────────\n\n get validity(): ValidityState {\n this.updateValidity();\n return this[internals].validity;\n }\n\n get validationMessage(): string {\n this.updateValidity();\n return this[internals].validationMessage;\n }\n\n get willValidate(): boolean {\n return this[internals].willValidate;\n }\n\n checkValidity(): boolean {\n this.updateValidity();\n return this[internals].checkValidity();\n }\n\n reportValidity(): boolean {\n this.updateValidity();\n return this[internals].reportValidity();\n }\n\n /** Sets a custom error message, as on `<input>`; an empty string clears it. */\n setCustomValidity(message: string): void {\n this.__customValidity = message;\n this.updateValidity();\n this.requestUpdate();\n }\n\n // ── Public: suggestions ──────────────────────────────────────────────────\n\n /** Whether the control holds a suggestion the person hasn't accepted or cleared. */\n get suggested(): boolean {\n return !!this.__suggestions.suggestion;\n }\n\n /** Accepts the suggestion: the value stays and the marker goes. Fires `accept`. */\n acceptSuggestion(cause: SuggestionAcceptCause = 'action'): void {\n this.__suggestions.accept(cause);\n }\n\n /** Clears the suggestion and puts the previous value back. Fires `dismiss`, `input` and `change`. */\n dismissSuggestion(): void {\n this.__suggestions.dismiss();\n }\n\n // ── Protected ────────────────────────────────────────────────────────────\n\n /**\n * The Suggested badge with its clear button, while a suggestion shows; else nothing. Controls\n * without helper text pass `withReason` so the badge's tooltip carries the reason.\n */\n protected suggestionBadge(\n options: { slot?: string; withReason?: boolean } = {},\n ) {\n return this.__suggestions.badge(options);\n }\n\n /**\n * A group's label with the Suggested badge beside it while a suggestion shows. The badge stays\n * outside the label element, so it is not part of the group's accessible name. Style\n * `.label-row` as a row.\n */\n protected labelWithSuggestion(label: unknown) {\n if (!this.suggestionVisible) return label;\n return html`<div class=\"label-row\">${label}${this.suggestionBadge()}</div>`;\n }\n\n /** Why the value was suggested, while the suggestion shows; else `''`. */\n protected get suggestionReason(): string {\n return this.__suggestions.reason;\n }\n\n /** Whether a suggestion shows as one now (AI on, not sensitive). */\n protected get suggestionVisible(): boolean {\n return this.__suggestions.visible;\n }\n\n /** The value a suggestion replaces and a dismissed one restores. */\n protected readSuggestionValue(): unknown {\n return this.value;\n }\n\n /** Puts a suggested or restored value into the control. */\n protected writeSuggestionValue(value: unknown): void {\n this.value = value;\n }\n\n /** Fires `input` and `change` after the person cleared a suggestion. */\n protected emitSuggestionValue(): void {\n for (const type of ['input', 'change']) {\n this.dispatchEvent(\n new CustomEvent(type, {\n detail: { value: this.value },\n bubbles: true,\n composed: true,\n }),\n );\n }\n }\n\n /**\n * The control's own validity. The default checks `required` against an empty `value`;\n * controls that wrap a native input return `nativeValidity(input)`, others add their rules.\n */\n protected computeValidity(): ControlValidity {\n const empty =\n this.value === undefined || this.value === null || this.value === '';\n if (this.required && empty && !this.disabled) {\n return {\n flags: { valueMissing: true },\n message: this.valueMissingText(),\n };\n }\n return { flags: {}, message: '' };\n }\n\n /** The message for a missing required value. */\n protected valueMissingText(): string {\n return peacockString('valueMissing');\n }\n\n /** Pushes the current validity to `ElementInternals`. */\n protected updateValidity(): void {\n if (this.__customValidity) {\n this[internals].setValidity(\n { customError: true },\n this.__customValidity,\n this.validityAnchor(),\n );\n return;\n }\n const { flags, message, anchor } = this.computeValidity();\n const invalid = Object.values(flags).some(Boolean);\n if (invalid) {\n this[internals].setValidity(\n flags,\n message || ' ',\n anchor ?? this.validityAnchor(),\n );\n } else {\n this[internals].setValidity({});\n }\n }\n\n /** The element the browser points at when it reports a problem. */\n protected validityAnchor(): HTMLElement | undefined {\n return undefined;\n }\n\n /** The message to show under the control, or '' while there is nothing to show. */\n protected get validationText(): string {\n if (!this.showValidity) return '';\n this.updateValidity();\n return this[internals].validity.valid\n ? ''\n : this[internals].validationMessage;\n }\n\n // ── Form association ─────────────────────────────────────────────────────\n\n override [getFormValue](): FormValue | null {\n if (this.value === undefined || this.value === null) return null;\n return String(this.value);\n }\n\n formResetCallback() {\n this.__suggestions.set(null);\n this.value = this.__defaultValue;\n this.showValidity = false;\n }\n\n formStateRestoreCallback(restored: FormRestoreState | null) {\n this.value =\n restored === null\n ? this.__defaultValue\n : this.parseRestoreState(restored);\n }\n\n /** Turns saved form state back into a value. Strings by default. */\n protected parseRestoreState(restored: FormRestoreState): unknown {\n return typeof restored === 'string' ? restored : this.__defaultValue;\n }\n\n // ── Private ──────────────────────────────────────────────────────────────\n\n private __handleInvalid = (event: Event) => {\n // Show the message under the control instead of the browser bubble, and move focus to the\n // first invalid control of the submission.\n event.preventDefault();\n this.showValidity = true;\n if (!focusClaimed) {\n focusClaimed = true;\n this.focus();\n queueMicrotask(() => {\n focusClaimed = false;\n });\n }\n };\n\n private __handleCommit = (event: Event) => {\n if (event.target === this) this.showValidity = true;\n };\n}\n"],"names":["LitElement","html","property","state"],"mappings":";;;;;;;;AAoBA,MAAM,aAAa,GAAG;IACpB,cAAc;IACd,cAAc;IACd,iBAAiB;IACjB,SAAS;IACT,UAAU;IACV,gBAAgB;IAChB,eAAe;IACf,cAAc;IACd,UAAU;CACF;AAeV;AACM,SAAU,cAAc,CAC5B,OAAmE,EAAA;IAEnE,MAAM,KAAK,GAAkB,EAAE;AAC/B,IAAA,KAAK,MAAM,GAAG,IAAI,aAAa,EAAE;AAC/B,QAAA,IAAI,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC;AAAE,YAAA,KAAK,CAAC,GAAG,CAAC,GAAG,IAAI;IAC9C;AACA,IAAA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,iBAAiB,EAAE,MAAM,EAAE,OAAO,EAAE;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,QAAQ,KAAK,QAAQ,GAAG,QAAQ,GAAG,IAAI,CAAC,cAAc;IACtE;AAqBD;AA1RC,UAAA,CAAA;IADCC,CAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE;AAChB,CAAA,EAAA,SAAA,CAAA,SAAA,EAAA,UAAA,EAAA,MAAA,CAAA;AAG1B,UAAA,CAAA;IADCA,CAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE;AAChB,CAAA,EAAA,SAAA,CAAA,SAAA,EAAA,UAAA,EAAA,MAAA,CAAA;AAG1B,UAAA,CAAA;IADCA,CAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE;AACzB,CAAA,EAAA,SAAA,CAAA,SAAA,EAAA,UAAA,EAAA,MAAA,CAAA;AAOjB,UAAA,CAAA;IADCA,CAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE;AACxB,CAAA,EAAA,SAAA,CAAA,SAAA,EAAA,WAAA,EAAA,MAAA,CAAA;AASlB,UAAA,CAAA;AADC,IAAAA,CAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE;AAG7B,CAAA,EAAA,SAAA,CAAA,SAAA,EAAA,YAAA,EAAA,IAAA,CAAA;AAWkB,UAAA,CAAA;AAAlB,IAAAC,CAAK;AAAkC,CAAA,EAAA,SAAA,CAAA,SAAA,EAAA,cAAA,EAAA,MAAA,CAAA;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base-button-Do2TUy8M.js","sources":["../../src/button/base-button/base-button.ts"],"sourcesContent":["import { LitElement, PropertyValues } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { WithElementInternals } from '@/__internal/mixins/element-internals.js';\nimport { throttle } from '@/__internal/utils/throttle.js';\nimport { warnOnce } from '@/__internal/utils/warn-once.js';\nimport { MixinBase, MixinReturn } from '@/__internal/mixins/mixin.js';\nimport type {\n ButtonColor,\n ButtonLevel,\n ButtonVariant,\n} from '@/button/ButtonTypes.js';\n\n/**\n * 1. Define an interface for the members the mixin adds.\n * This makes the type annotation much cleaner.\n */\nexport interface BaseButton {\n variant: string;\n\n color: string;\n\n disabled: boolean;\n\n softDisabled: boolean;\n\n disabledReason: string;\n\n throttleDelay?: number;\n\n __dispatchClickWithThrottle: (event: MouseEvent | KeyboardEvent) => void;\n\n __dispatchClick: (event: MouseEvent | KeyboardEvent) => void;\n}\n\nexport function mixinBaseButton<\n T extends MixinBase<LitElement & WithElementInternals>,\n>(base: T): MixinReturn<T, BaseButton> {\n abstract class BaseButtonElement extends base implements BaseButton {\n @property({ type: String, reflect: true })\n variant: string = '';\n\n @property({ type: String, reflect: true })\n color: string = '';\n\n /**\n * When `true`, the button is disabled and cannot be interacted with. Reflects to the `disabled` attribute. Defaults to `false`.\n */\n @property({ type: Boolean, reflect: true })\n disabled: boolean = false;\n\n /**\n * When `true`, the button is visually styled as disabled and cannot be interacted with, but remains focusable.\n * Use this in combination with `disabledReason` to communicate why the button is unavailable.\n * Reflects to the `soft-disabled` attribute. Defaults to `false`.\n */\n @property({ type: Boolean, reflect: true, attribute: 'soft-disabled' })\n softDisabled: boolean = false;\n\n /**\n * A human-readable explanation of why the button is disabled or soft-disabled.\n * Rendered as a visually hidden tooltip and linked via `aria-describedby` for accessibility.\n * Maps to the `disabled-reason` attribute.\n */\n @property({ attribute: 'disabled-reason' })\n disabledReason: string = '';\n\n /**\n * Sets the delay for throttle in milliseconds. When undefined (default), no throttle is applied.\n */\n @property({ type: Number, attribute: 'throttle-delay' })\n throttleDelay?: number;\n\n __dispatchClickWithThrottle: (event: MouseEvent | KeyboardEvent) => void =\n event => {\n this.__dispatchClick(event);\n };\n\n abstract __dispatchClick: (event: MouseEvent | KeyboardEvent) => void;\n\n override firstUpdated(changedProperties: PropertyValues) {\n super.firstUpdated(changedProperties);\n if (typeof this.throttleDelay === 'number') {\n this.__dispatchClickWithThrottle = throttle(\n this.__dispatchClick,\n this.throttleDelay,\n );\n }\n }\n }\n\n return BaseButtonElement;\n}\n\n// ── Level ────────────────────────────────────────────────────────────────────\n\n/**\n * What each `level` preset resolves to, shared by `wc-button`, `wc-icon-button` and\n * `wc-link-button`. A `color` or `variant` the consumer sets wins over the preset, one property at\n * a time, so `level=\"danger\" variant=\"outlined\"` is an outlined danger button.\n */\nexport const BUTTON_LEVEL_APPEARANCE: Readonly<\n Record<\n ButtonLevel,\n { readonly color: ButtonColor; readonly variant: ButtonVariant }\n >\n> = {\n primary: { color: 'primary', variant: 'filled' },\n secondary: { color: 'surface', variant: 'tonal' },\n tertiary: { color: 'primary', variant: 'text' },\n danger: { color: 'danger', variant: 'filled' },\n};\n\n/** Variant and color used when neither the consumer nor a `level` sets one. */\nexport const BUTTON_DEFAULT_APPEARANCE = {\n color: 'primary',\n variant: 'filled',\n} as const satisfies { color: ButtonColor; variant: ButtonVariant };\n\n/** The preset for `level`, or `undefined` for no level or an unknown one. */\nexport function levelAppearance(\n level: string | undefined | null,\n):\n | { readonly color: ButtonColor; readonly variant: ButtonVariant }\n | undefined {\n if (\n !level ||\n !Object.prototype.hasOwnProperty.call(BUTTON_LEVEL_APPEARANCE, level)\n )\n return undefined;\n return BUTTON_LEVEL_APPEARANCE[level as ButtonLevel];\n}\n\n/** The members `mixinButtonLevel` adds. */\nexport interface ButtonLevelAppearance {\n /**\n * Preset of `color` and `variant`: `primary` (primary, filled), `secondary` (surface, tonal),\n * `tertiary` (primary, text), `danger` (danger, filled). A `color` or `variant` set on the\n * element wins over the preset.\n */\n level?: ButtonLevel;\n\n /** The visual style. Reads back the resolved value: the one set, else the level's, else `filled`. */\n variant: ButtonVariant;\n\n /** The color role. Reads back the resolved value: the one set, else the level's, else `primary`. */\n color: ButtonColor;\n}\n\n/**\n * Adds `level` and resolves `variant` and `color` from it at render time. The `variant` and\n * `color` attributes reflect the resolved values (the styles key on them), but the level never\n * writes the consumer's own values, so a later change to `level` takes effect and an explicit\n * `color`/`variant` always wins.\n */\nexport function mixinButtonLevel<T extends MixinBase<LitElement & BaseButton>>(\n base: T,\n): MixinReturn<T, ButtonLevelAppearance> {\n abstract class ButtonLevelElement\n extends base\n implements ButtonLevelAppearance\n {\n /**\n * Preset of `color` and `variant`: `primary` (primary, filled), `secondary` (surface, tonal),\n * `tertiary` (primary, text), `danger` (danger, filled). A `color` or `variant` set on the\n * element wins over the preset.\n */\n @property({ type: String }) level?: ButtonLevel;\n\n /**\n * The visual style of the button: `\"filled\"`, `\"tonal\"`, `\"outlined\"`, `\"text\"`,\n * `\"elevated\"` or `\"neo\"`. Unset, it comes from `level`, else `\"filled\"`.\n */\n @property({ type: String, reflect: true })\n get variant(): ButtonVariant {\n return (\n this.__explicitVariant ||\n levelAppearance(this.level)?.variant ||\n BUTTON_DEFAULT_APPEARANCE.variant\n );\n }\n\n set variant(value: ButtonVariant) {\n this.__explicitVariant = value || undefined;\n }\n\n /**\n * The color role of the button. Unset, it comes from `level`, else `\"primary\"`.\n */\n @property({ type: String, reflect: true })\n get color(): ButtonColor {\n return (\n this.__explicitColor ||\n levelAppearance(this.level)?.color ||\n BUTTON_DEFAULT_APPEARANCE.color\n );\n }\n\n set color(value: ButtonColor) {\n this.__explicitColor = value || undefined;\n }\n\n __explicitVariant?: ButtonVariant;\n\n __explicitColor?: ButtonColor;\n\n override willUpdate(changedProperties: PropertyValues) {\n super.willUpdate(changedProperties);\n // The level changes the resolved values without going through their setters, so ask Lit\n // to reflect them (also on the first update, when nothing has set them yet).\n if (!this.hasUpdated || changedProperties.has('level')) {\n this.requestUpdate('variant', undefined);\n this.requestUpdate('color', undefined);\n }\n }\n }\n\n return ButtonLevelElement;\n}\n\n// ── Toggle ───────────────────────────────────────────────────────────────────\n\n/** A button that can act as a toggle: `toggle` turns it on, `selected` is its pressed state. */\nexport interface ToggleableButton extends HTMLElement {\n toggle: boolean;\n selected: boolean;\n disabled: boolean;\n}\n\n/**\n * Flips `selected` on a toggle button and fires `change` with the new state. Does nothing unless\n * `toggle` is set or while the button is disabled; callers block soft-disabled and loading first.\n */\nexport function toggleButtonSelected(host: ToggleableButton): void {\n if (!host.toggle || host.disabled) return;\n host.selected = !host.selected;\n host.dispatchEvent(\n new CustomEvent<{ selected: boolean }>('change', {\n detail: { selected: host.selected },\n bubbles: true,\n composed: true,\n }),\n );\n}\n\n// ── Accessible name ──────────────────────────────────────────────────────────\n\n/**\n * The name an icon-only button falls back to: its `aria-label`, else its tooltip text.\n */\nexport function iconButtonLabel(\n ariaLabel: string | null | undefined,\n tooltip: string | undefined,\n): string | undefined {\n return ariaLabel || tooltip || undefined;\n}\n\n/**\n * Warns once per tag when an icon-only button has nothing to be announced by: no `aria-label`,\n * no `aria-labelledby`, no `tooltip` and no slotted text.\n */\nexport function warnIfUnnamed(\n host: HTMLElement,\n ariaLabel: string | null | undefined,\n ...otherNames: (string | null | undefined)[]\n): void {\n if (ariaLabel || otherNames.some(name => !!name)) return;\n if (host.hasAttribute('aria-labelledby')) return;\n if (host.hasAttribute('data-aria-labelledby')) return;\n if (host.textContent?.trim()) return;\n const tag = host.localName;\n warnOnce(\n `${tag}:accessible-name`,\n `[peacock] ${tag} has no accessible name, so screen readers announce it as just \"button\". Give it an aria-label or a tooltip.`,\n );\n}\n"],"names":["property"],"mappings":";;;;;AAkCM,SAAU,eAAe,CAE7B,IAAO,EAAA;IACP,MAAe,iBAAkB,SAAQ,IAAI,CAAA;AAA7C,QAAA,WAAA,GAAA;;YAEE,IAAA,CAAA,OAAO,GAAW,EAAE;YAGpB,IAAA,CAAA,KAAK,GAAW,EAAE;AAElB;;AAEG;YAEH,IAAA,CAAA,QAAQ,GAAY,KAAK;AAEzB;;;;AAIG;YAEH,IAAA,CAAA,YAAY,GAAY,KAAK;AAE7B;;;;AAIG;YAEH,IAAA,CAAA,cAAc,GAAW,EAAE;YAQ3B,IAAA,CAAA,2BAA2B,GACzB,KAAK,IAAG;AACN,gBAAA,IAA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AG,CAAC,IAAI,CAAC,QAAQ;AAC9B,IAAA,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAwB,QAAQ,EAAE;AAC/C,QAAA,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE;AACnC,QAAA,OAAO,EAAE,IAAI;AACb,QAAA,QAAQ,EAAE,IAAI;AACf,KAAA,CAAC,CACH;AACH;AAEA;AAEA;;AAEG;AACG,SAAU,eAAe,CAC7B,SAAoC,EACpC,OAA2B,EAAA;AAE3B,IAAA,OAAO,SAAS,IAAI,OAAO,IAAI,SAAS;AAC1C;AAEA;;;AAGG;AACG,SAAU,aAAa,CAC3B,IAAiB,EACjB,SAAoC,EACpC,GAAG,UAAyC,EAAA;AAE5C,IAAA,IAAI,SAAS,IAAI,UAAU,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC;QAAE;AAClD,IAAA,IAAI,IAAI,CAAC,YAAY,CAAC,iBAAiB,CAAC;QAAE;AAC1C,IAAA,IAAI,IAAI,CAAC,YAAY,CAAC,sBAAsB,CAAC;QAAE;AAC/C,IAAA,IAAI,IAAI,CAAC,WAAW,EAAE,IAAI,EAAE;QAAE;AAC9B,IAAA,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS;IAC1B,QAAQ,CACN,GAAG,GAAG,CAAA,gBAAA,CAAkB,EACxB,CAAA,UAAA,EAAa,GAAG,CAAA,4GAAA,CAA8G,CAC/H;AACH;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base-progress-BiLlZVHJ.js","sources":["../../src/progress/base-progress.ts"],"sourcesContent":["import { LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { I18nController } from '@/__internal/i18n/i18n-controller.js';\nimport { mixinDelegatesAria } from '@/__internal/aria/delegate.js';\nimport type { ARIAMixinStrict } from '@/__internal/aria/aria.js';\n\n/**\n * `aria-label` on the host names the progress bar without a visible label (it moves to the inner\n * `role=\"progressbar\"` element, as on buttons).\n */\nexport class BaseProgress extends mixinDelegatesAria(LitElement) {\n /** The current value, clamped into `0`–`max`. */\n @property({ type: Number }) value?: number;\n\n /** The value at which the task is complete. Defaults to `100`. */\n @property({ type: Number }) max = 100;\n\n @property({ type: Boolean }) indeterminate = false;\n\n /**\n * A visible label describing the progress, which also names the progress bar\n * (`aria-labelledby`). Without one the bar is named \"Loading\" (string `loading`).\n */\n @property({ type: String }) label?: string;\n\n @property({ type: String, attribute: 'helper-text' }) helperText?: string;\n\n @property({ type: Boolean }) inline = false;\n\n /** Peacock's strings, for the fallback accessible name. */\n protected readonly i18n = new I18nController(this);\n\n /** The bar's name without a visible `label`: the host's `aria-label`, else \"Loading\". */\n protected get __fallbackLabel(): string {\n return (this as ARIAMixinStrict).ariaLabel || this.i18n.t('loading');\n }\n\n /** `max`, or 100 when it is not a positive number. */\n protected get __max(): number {\n return Number.isFinite(this.max) && this.max > 0 ? this.max : 100;\n }\n\n /** `value` clamped into `0`–`max`; 0 when unset. */\n protected get __clampedValue(): number {\n const value = Number(this.value);\n if (!Number.isFinite(value)) return 0;\n return Math.min(this.__max, Math.max(0, value));\n }\n\n /** The clamped value as a percentage of `max`. */\n __getPercentageValue(): number {\n return (this.__clampedValue / this.__max) * 100;\n }\n}\n"],"names":["LitElement","property"],"mappings":";;;;;AAMA;;;AAGG;MACU,YAAa,SAAQ,kBAAkB,CAACA,CAAU,CAAC,CAAA;AAAhE,IAAA,WAAA,GAAA;;;QAK8B,IAAA,CAAA,GAAG,GAAG,GAAG;QAER,IAAA,CAAA,aAAa,GAAG,KAAK;QAUrB,IAAA,CAAA,MAAM,GAAG,KAAK;;AAGxB,QAAA,IAAA,CAAA,IAAI,GAAG,IAAI,cAAc,CAAC,IAAI,CAAC;IAuBpD;;AApBE,IAAA,IAAc,eAAe,GAAA;AAC3B,QAAA,OAAQ,IAAwB,CAAC,SAAS,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;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