@devschile/chucao 2.7.1 → 2.9.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/chucao/chucao.esm.js +1 -1
- package/dist/chucao/{p-01b6c7bf.entry.js → p-03acf096.entry.js} +2 -2
- package/dist/chucao/{p-10f6801e.entry.js → p-0ce2b15d.entry.js} +2 -2
- package/dist/chucao/p-10e37157.entry.js +2 -0
- package/dist/chucao/p-10e37157.entry.js.map +1 -0
- package/dist/chucao/{p-f917d34f.entry.js → p-12043dc1.entry.js} +2 -2
- package/dist/chucao/p-1dca55d6.entry.js +2 -0
- package/dist/chucao/{p-deb2571b.entry.js.map → p-1dca55d6.entry.js.map} +1 -1
- package/dist/chucao/{p-0c7f6f8d.entry.js → p-244d8e96.entry.js} +2 -2
- package/dist/chucao/{p-a7c674b7.entry.js → p-29841714.entry.js} +2 -2
- package/dist/chucao/{p-ffecdf25.entry.js → p-302ec527.entry.js} +2 -2
- package/dist/chucao/{p-337d7f68.entry.js → p-51f6327c.entry.js} +2 -2
- package/dist/chucao/{p-1b70e3f1.entry.js → p-5a62951e.entry.js} +2 -2
- package/dist/chucao/{p-472ec451.entry.js → p-5d0ac17a.entry.js} +2 -2
- package/dist/chucao/{p-d8b71751.entry.js → p-5e0e1012.entry.js} +2 -2
- package/dist/chucao/{p-15d27bb7.entry.js → p-61a94a4e.entry.js} +2 -2
- package/dist/chucao/p-649c2cef.entry.js +2 -0
- package/dist/chucao/p-649c2cef.entry.js.map +1 -0
- package/dist/chucao/p-674c0f61.entry.js +2 -0
- package/dist/chucao/p-674c0f61.entry.js.map +1 -0
- package/dist/chucao/{p-c4b2bd1f.entry.js → p-67f0fc77.entry.js} +2 -2
- package/dist/chucao/{p-5240f5ac.entry.js → p-68e4a129.entry.js} +2 -2
- package/dist/chucao/{p-2e37c61b.entry.js → p-6e345b3f.entry.js} +2 -2
- package/dist/chucao/{p-f6ab0a11.entry.js → p-72d4dacf.entry.js} +2 -2
- package/dist/chucao/{p-8ae680a4.entry.js → p-74d9b7e5.entry.js} +2 -2
- package/dist/chucao/p-791ce537.entry.js +2 -0
- package/dist/chucao/p-791ce537.entry.js.map +1 -0
- package/dist/chucao/{p-c90da3c0.entry.js → p-79e8c10b.entry.js} +2 -2
- package/dist/chucao/{p-90284ebe.entry.js → p-7e13f725.entry.js} +2 -2
- package/dist/chucao/{p-9ebcc7be.entry.js → p-8b23d072.entry.js} +2 -2
- package/dist/chucao/{p-CIV5Gg1o.js → p-8l_6qAY9.js} +3 -3
- package/dist/chucao/p-8l_6qAY9.js.map +1 -0
- package/dist/chucao/{p-1e4cd3aa.entry.js → p-a5430e95.entry.js} +2 -2
- package/dist/chucao/{p-e77d35c3.entry.js → p-a7c66879.entry.js} +2 -2
- package/dist/chucao/p-b452d6cb.entry.js +2 -0
- package/dist/chucao/p-b7332faf.entry.js +2 -0
- package/dist/chucao/{p-60e1c1df.entry.js.map → p-b7332faf.entry.js.map} +1 -1
- package/dist/chucao/{p-42028c97.entry.js → p-f3d03388.entry.js} +2 -2
- package/dist/chucao/{p-7cdc71cc.entry.js → p-f925d45c.entry.js} +2 -2
- package/dist/cjs/ch-accordion.cjs.entry.js +2 -2
- package/dist/cjs/ch-alert_8.cjs.entry.js +8 -8
- package/dist/cjs/ch-checkbox.cjs.entry.js +2 -2
- package/dist/cjs/ch-cluster.cjs.entry.js +3 -3
- package/dist/cjs/ch-combobox.cjs.entry.js +304 -0
- package/dist/cjs/ch-combobox.cjs.entry.js.map +1 -0
- package/dist/cjs/ch-confirm-dialog.cjs.entry.js +138 -0
- package/dist/cjs/ch-confirm-dialog.cjs.entry.js.map +1 -0
- package/dist/cjs/ch-description-list.cjs.entry.js +2 -2
- package/dist/cjs/ch-divider.cjs.entry.js +2 -2
- package/dist/cjs/ch-drawer.cjs.entry.js +2 -2
- package/dist/cjs/ch-emoji.cjs.entry.js +2 -2
- package/dist/cjs/ch-empty-state.cjs.entry.js +2 -2
- package/dist/cjs/ch-grid.cjs.entry.js +2 -2
- package/dist/cjs/ch-icon-button.cjs.entry.js +2 -2
- package/dist/cjs/ch-icon.cjs.entry.js +2 -2
- package/dist/cjs/ch-link.cjs.entry.js +1 -1
- package/dist/cjs/ch-modal.cjs.entry.js +2 -2
- package/dist/cjs/ch-number-input.cjs.entry.js +3 -3
- package/dist/cjs/ch-otp-input.cjs.entry.js +196 -0
- package/dist/cjs/ch-otp-input.cjs.entry.js.map +1 -0
- package/dist/cjs/ch-page-header.cjs.entry.js +2 -2
- package/dist/cjs/ch-pagination.cjs.entry.js +67 -0
- package/dist/cjs/ch-pagination.cjs.entry.js.map +1 -0
- package/dist/cjs/ch-radio.cjs.entry.js +2 -2
- package/dist/cjs/ch-segmented-control.cjs.entry.js +2 -2
- package/dist/cjs/ch-skeleton.cjs.entry.js +2 -2
- package/dist/cjs/ch-stack.cjs.entry.js +2 -2
- package/dist/cjs/ch-stat.cjs.entry.js +3 -3
- package/dist/cjs/ch-table.cjs.entry.js +2 -2
- package/dist/cjs/ch-tabs.cjs.entry.js +2 -2
- package/dist/cjs/ch-textarea.cjs.entry.js +2 -2
- package/dist/cjs/ch-timeline.cjs.entry.js +2 -2
- package/dist/cjs/ch-tooltip.cjs.entry.js +3 -3
- package/dist/cjs/chucao.cjs.js +2 -2
- package/dist/cjs/{index-ByZY6aTj.js → index-C6khqyw3.js} +19 -2
- package/dist/cjs/index-C6khqyw3.js.map +1 -0
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/collection/collection-manifest.json +4 -0
- package/dist/collection/components/ch-accordion/ch-accordion.js +1 -1
- package/dist/collection/components/ch-alert/ch-alert.js +1 -1
- package/dist/collection/components/ch-badge/ch-badge.js +1 -1
- package/dist/collection/components/ch-card/ch-card.js +1 -1
- package/dist/collection/components/ch-checkbox/ch-checkbox.js +1 -1
- package/dist/collection/components/ch-cluster/ch-cluster.js +2 -2
- package/dist/collection/components/ch-combobox/ch-combobox.css +153 -0
- package/dist/collection/components/ch-combobox/ch-combobox.js +577 -0
- package/dist/collection/components/ch-combobox/ch-combobox.js.map +1 -0
- package/dist/collection/components/ch-confirm-dialog/ch-confirm-dialog.css +71 -0
- package/dist/collection/components/ch-confirm-dialog/ch-confirm-dialog.js +382 -0
- package/dist/collection/components/ch-confirm-dialog/ch-confirm-dialog.js.map +1 -0
- package/dist/collection/components/ch-description-list/ch-description-list.js +1 -1
- package/dist/collection/components/ch-divider/ch-divider.js +1 -1
- package/dist/collection/components/ch-drawer/ch-drawer.js +1 -1
- package/dist/collection/components/ch-emoji/ch-emoji.js +1 -1
- package/dist/collection/components/ch-empty-state/ch-empty-state.js +1 -1
- package/dist/collection/components/ch-grid/ch-grid.js +1 -1
- package/dist/collection/components/ch-icon/ch-icon.js +1 -1
- package/dist/collection/components/ch-icon-button/ch-icon-button.js +1 -1
- package/dist/collection/components/ch-input/ch-input.js +1 -1
- package/dist/collection/components/ch-modal/ch-modal.js +1 -1
- package/dist/collection/components/ch-number-input/ch-number-input.js +2 -2
- package/dist/collection/components/ch-otp-input/ch-otp-input.css +86 -0
- package/dist/collection/components/ch-otp-input/ch-otp-input.js +478 -0
- package/dist/collection/components/ch-otp-input/ch-otp-input.js.map +1 -0
- package/dist/collection/components/ch-page-header/ch-page-header.js +1 -1
- package/dist/collection/components/ch-pagination/ch-pagination.css +63 -0
- package/dist/collection/components/ch-pagination/ch-pagination.js +228 -0
- package/dist/collection/components/ch-pagination/ch-pagination.js.map +1 -0
- package/dist/collection/components/ch-radio/ch-radio.js +1 -1
- package/dist/collection/components/ch-segmented-control/ch-segmented-control.js +1 -1
- package/dist/collection/components/ch-select/ch-select.js +1 -1
- package/dist/collection/components/ch-skeleton/ch-skeleton.js +1 -1
- package/dist/collection/components/ch-spinner/ch-spinner.js +1 -1
- package/dist/collection/components/ch-stack/ch-stack.js +1 -1
- package/dist/collection/components/ch-stat/ch-stat.js +2 -2
- package/dist/collection/components/ch-switch/ch-switch.js +1 -1
- package/dist/collection/components/ch-table/ch-table.js +1 -1
- package/dist/collection/components/ch-tabs/ch-tabs.js +1 -1
- package/dist/collection/components/ch-textarea/ch-textarea.js +1 -1
- package/dist/collection/components/ch-timeline/ch-timeline.js +1 -1
- package/dist/collection/components/ch-tooltip/ch-tooltip.js +2 -2
- package/dist/components/ch-accordion.js +1 -1
- package/dist/components/ch-alert.js +1 -1
- package/dist/components/ch-badge.js +1 -1
- package/dist/components/ch-button.js +1 -1
- package/dist/components/ch-card.js +1 -1
- package/dist/components/ch-checkbox.js +1 -1
- package/dist/components/ch-cluster.js +1 -1
- package/dist/components/ch-combobox.d.ts +11 -0
- package/dist/components/ch-combobox.js +2 -0
- package/dist/components/ch-combobox.js.map +1 -0
- package/dist/components/ch-confirm-dialog.d.ts +11 -0
- package/dist/components/ch-confirm-dialog.js +2 -0
- package/dist/components/ch-confirm-dialog.js.map +1 -0
- package/dist/components/ch-description-list.js +1 -1
- package/dist/components/ch-divider.js +1 -1
- package/dist/components/ch-drawer.js +1 -1
- package/dist/components/ch-emoji.js +1 -1
- package/dist/components/ch-empty-state.js +1 -1
- package/dist/components/ch-grid.js +1 -1
- package/dist/components/ch-icon-button.js +1 -1
- package/dist/components/ch-icon.js +1 -1
- package/dist/components/ch-input.js +1 -1
- package/dist/components/ch-modal.js +1 -1
- package/dist/components/ch-modal.js.map +1 -1
- package/dist/components/ch-number-input.js +1 -1
- package/dist/components/ch-otp-input.d.ts +11 -0
- package/dist/components/ch-otp-input.js +2 -0
- package/dist/components/ch-otp-input.js.map +1 -0
- package/dist/components/ch-page-header.js +1 -1
- package/dist/components/ch-pagination.d.ts +11 -0
- package/dist/components/ch-pagination.js +2 -0
- package/dist/components/ch-pagination.js.map +1 -0
- package/dist/components/ch-radio.js +1 -1
- package/dist/components/ch-segmented-control.js +1 -1
- package/dist/components/ch-select.js +1 -1
- package/dist/components/ch-skeleton.js +1 -1
- package/dist/components/ch-spinner.js +1 -1
- package/dist/components/ch-stack.js +1 -1
- package/dist/components/ch-stat.js +1 -1
- package/dist/components/ch-switch.js +1 -1
- package/dist/components/ch-table.js +1 -1
- package/dist/components/ch-tabs.js +1 -1
- package/dist/components/ch-textarea.js +1 -1
- package/dist/components/ch-timeline.js +1 -1
- package/dist/components/ch-tooltip.js +1 -1
- package/dist/components/{p-DiUN1WGc.js → p-CuSstsTP.js} +2 -2
- package/dist/components/p-MBLhKofG.js +2 -0
- package/dist/components/p-MBLhKofG.js.map +1 -0
- package/dist/components/p-qP_9qshx.js.map +1 -1
- package/dist/esm/ch-accordion.entry.js +2 -2
- package/dist/esm/ch-alert_8.entry.js +8 -8
- package/dist/esm/ch-checkbox.entry.js +2 -2
- package/dist/esm/ch-cluster.entry.js +3 -3
- package/dist/esm/ch-combobox.entry.js +302 -0
- package/dist/esm/ch-combobox.entry.js.map +1 -0
- package/dist/esm/ch-confirm-dialog.entry.js +136 -0
- package/dist/esm/ch-confirm-dialog.entry.js.map +1 -0
- package/dist/esm/ch-description-list.entry.js +2 -2
- package/dist/esm/ch-divider.entry.js +2 -2
- package/dist/esm/ch-drawer.entry.js +2 -2
- package/dist/esm/ch-emoji.entry.js +2 -2
- package/dist/esm/ch-empty-state.entry.js +2 -2
- package/dist/esm/ch-grid.entry.js +2 -2
- package/dist/esm/ch-icon-button.entry.js +2 -2
- package/dist/esm/ch-icon.entry.js +2 -2
- package/dist/esm/ch-link.entry.js +1 -1
- package/dist/esm/ch-modal.entry.js +2 -2
- package/dist/esm/ch-number-input.entry.js +3 -3
- package/dist/esm/ch-otp-input.entry.js +194 -0
- package/dist/esm/ch-otp-input.entry.js.map +1 -0
- package/dist/esm/ch-page-header.entry.js +2 -2
- package/dist/esm/ch-pagination.entry.js +65 -0
- package/dist/esm/ch-pagination.entry.js.map +1 -0
- package/dist/esm/ch-radio.entry.js +2 -2
- package/dist/esm/ch-segmented-control.entry.js +2 -2
- package/dist/esm/ch-skeleton.entry.js +2 -2
- package/dist/esm/ch-stack.entry.js +2 -2
- package/dist/esm/ch-stat.entry.js +3 -3
- package/dist/esm/ch-table.entry.js +2 -2
- package/dist/esm/ch-tabs.entry.js +2 -2
- package/dist/esm/ch-textarea.entry.js +2 -2
- package/dist/esm/ch-timeline.entry.js +2 -2
- package/dist/esm/ch-tooltip.entry.js +3 -3
- package/dist/esm/chucao.js +3 -3
- package/dist/esm/{index-CIV5Gg1o.js → index-8l_6qAY9.js} +19 -2
- package/dist/esm/index-8l_6qAY9.js.map +1 -0
- package/dist/esm/loader.js +3 -3
- package/dist/types/components/ch-combobox/ch-combobox.d.ts +98 -0
- package/dist/types/components/ch-confirm-dialog/ch-confirm-dialog.d.ts +81 -0
- package/dist/types/components/ch-otp-input/ch-otp-input.d.ts +79 -0
- package/dist/types/components/ch-pagination/ch-pagination.d.ts +44 -0
- package/dist/types/components.d.ts +757 -0
- package/dist-react/components.d.ts +27 -1
- package/dist-react/components.js +45 -0
- package/dist-react/components.ts +67 -1
- package/dist-vue/index.d.ts +4 -0
- package/dist-vue/index.js +67 -0
- package/dist-vue/index.ts +75 -0
- package/hydrate/index.js +855 -35
- package/hydrate/index.mjs +855 -35
- package/package.json +17 -1
- package/dist/chucao/p-60e1c1df.entry.js +0 -2
- package/dist/chucao/p-9db118d9.entry.js +0 -2
- package/dist/chucao/p-CIV5Gg1o.js.map +0 -1
- package/dist/chucao/p-deb2571b.entry.js +0 -2
- package/dist/cjs/index-ByZY6aTj.js.map +0 -1
- package/dist/esm/index-CIV5Gg1o.js.map +0 -1
- /package/dist/chucao/{p-01b6c7bf.entry.js.map → p-03acf096.entry.js.map} +0 -0
- /package/dist/chucao/{p-10f6801e.entry.js.map → p-0ce2b15d.entry.js.map} +0 -0
- /package/dist/chucao/{p-f917d34f.entry.js.map → p-12043dc1.entry.js.map} +0 -0
- /package/dist/chucao/{p-0c7f6f8d.entry.js.map → p-244d8e96.entry.js.map} +0 -0
- /package/dist/chucao/{p-a7c674b7.entry.js.map → p-29841714.entry.js.map} +0 -0
- /package/dist/chucao/{p-ffecdf25.entry.js.map → p-302ec527.entry.js.map} +0 -0
- /package/dist/chucao/{p-337d7f68.entry.js.map → p-51f6327c.entry.js.map} +0 -0
- /package/dist/chucao/{p-1b70e3f1.entry.js.map → p-5a62951e.entry.js.map} +0 -0
- /package/dist/chucao/{p-472ec451.entry.js.map → p-5d0ac17a.entry.js.map} +0 -0
- /package/dist/chucao/{p-d8b71751.entry.js.map → p-5e0e1012.entry.js.map} +0 -0
- /package/dist/chucao/{p-15d27bb7.entry.js.map → p-61a94a4e.entry.js.map} +0 -0
- /package/dist/chucao/{p-c4b2bd1f.entry.js.map → p-67f0fc77.entry.js.map} +0 -0
- /package/dist/chucao/{p-5240f5ac.entry.js.map → p-68e4a129.entry.js.map} +0 -0
- /package/dist/chucao/{p-2e37c61b.entry.js.map → p-6e345b3f.entry.js.map} +0 -0
- /package/dist/chucao/{p-f6ab0a11.entry.js.map → p-72d4dacf.entry.js.map} +0 -0
- /package/dist/chucao/{p-8ae680a4.entry.js.map → p-74d9b7e5.entry.js.map} +0 -0
- /package/dist/chucao/{p-c90da3c0.entry.js.map → p-79e8c10b.entry.js.map} +0 -0
- /package/dist/chucao/{p-90284ebe.entry.js.map → p-7e13f725.entry.js.map} +0 -0
- /package/dist/chucao/{p-9ebcc7be.entry.js.map → p-8b23d072.entry.js.map} +0 -0
- /package/dist/chucao/{p-1e4cd3aa.entry.js.map → p-a5430e95.entry.js.map} +0 -0
- /package/dist/chucao/{p-e77d35c3.entry.js.map → p-a7c66879.entry.js.map} +0 -0
- /package/dist/chucao/{p-9db118d9.entry.js.map → p-b452d6cb.entry.js.map} +0 -0
- /package/dist/chucao/{p-42028c97.entry.js.map → p-f3d03388.entry.js.map} +0 -0
- /package/dist/chucao/{p-7cdc71cc.entry.js.map → p-f925d45c.entry.js.map} +0 -0
- /package/dist/components/{p-DiUN1WGc.js.map → p-CuSstsTP.js.map} +0 -0
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var index = require('./index-C6khqyw3.js');
|
|
4
|
+
var validationMessage = require('./validation-message-bbtJ2sa_.js');
|
|
5
|
+
|
|
6
|
+
const chComboboxCss = () => `:host{display:block;width:100%;font-family:var(--typography-body)}:host([hidden]){display:none}.label{display:block;margin-bottom:var(--spacing-sm);font-size:var(--typography-size-sm);font-weight:var(--typography-weight-semibold);color:var(--color-text-primary)}.chips{display:flex;flex-wrap:wrap;gap:var(--spacing-xs);margin:0 0 var(--spacing-sm);padding:0;list-style:none}.chip{display:inline-flex;align-items:center;gap:var(--spacing-xs);max-width:100%;padding:var(--spacing-2xs) var(--spacing-sm);border:var(--border-width) solid var(--color-border-default);border-radius:var(--radius-sm);background:var(--color-surface-hover);font-size:var(--typography-size-sm)}.chip__label{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.chip__remove{all:unset;cursor:pointer;padding:0 var(--spacing-2xs);border-radius:var(--radius-sm);color:var(--color-text-secondary);line-height:1}.chip__remove:focus-visible{outline:2px solid var(--color-accent-default);outline-offset:1px}.field{position:relative}.input{box-sizing:border-box;width:100%;padding:var(--spacing-xl) var(--spacing-3xl);border:var(--border-width) solid var(--color-border-default);border-radius:var(--radius-sm);background:var(--color-surface-default);color:var(--color-text-primary);font-family:inherit;font-size:var(--typography-size-md);transition:border-color var(--duration-normal) var(--easing-default)}.input::placeholder{color:var(--color-text-secondary)}.input:focus{border-color:var(--color-accent-default);outline:2px solid var(--color-accent-default);outline-offset:1px}.input:disabled{opacity:var(--opacity-disabled);cursor:not-allowed}.input--invalid{border-color:var(--color-status-warning)}.listbox{position:absolute;z-index:var(--z-index-dropdown);top:calc(100% + var(--spacing-2xs));left:0;right:0;max-height:16rem;margin:0;padding:var(--spacing-2xs);overflow-y:auto;list-style:none;border:var(--border-width) solid var(--color-border-default);border-radius:var(--radius-sm);background:var(--color-surface-default);box-shadow:var(--shadow-elevate)}.listbox[hidden]{display:none}.listbox__option{padding:var(--spacing-sm) var(--spacing-md);border-radius:var(--radius-sm);font-size:var(--typography-size-sm);cursor:pointer}.listbox__option--active{background:var(--color-surface-hover);font-weight:var(--typography-weight-semibold);box-shadow:inset 2px 0 0 var(--color-accent-default)}.listbox__option--disabled{opacity:var(--opacity-disabled);cursor:not-allowed}.listbox__empty{padding:var(--spacing-sm) var(--spacing-md);font-size:var(--typography-size-sm);color:var(--color-text-secondary)}.hint,.error{margin:var(--spacing-sm) 0 0;font-size:var(--typography-size-sm);color:var(--color-text-secondary)}.error{color:var(--color-status-warning)}`;
|
|
7
|
+
|
|
8
|
+
let comboboxIds = 0;
|
|
9
|
+
const ChCombobox = class {
|
|
10
|
+
constructor(hostRef) {
|
|
11
|
+
index.registerInstance(this, hostRef);
|
|
12
|
+
this.chChange = index.createEvent(this, "chChange");
|
|
13
|
+
this.chFilter = index.createEvent(this, "chFilter");
|
|
14
|
+
if (hostRef.$hostElement$["s-ei"]) {
|
|
15
|
+
this.internals = hostRef.$hostElement$["s-ei"];
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
this.internals = hostRef.$hostElement$.attachInternals();
|
|
19
|
+
hostRef.$hostElement$["s-ei"] = this.internals;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
inputId = `ch-combobox-${++comboboxIds}`;
|
|
23
|
+
listId = `${this.inputId}-list`;
|
|
24
|
+
hintId = `${this.inputId}-hint`;
|
|
25
|
+
errorId = `${this.inputId}-error`;
|
|
26
|
+
initialValue = [];
|
|
27
|
+
internals;
|
|
28
|
+
formDisabled = false;
|
|
29
|
+
get host() { return index.getElement(this); }
|
|
30
|
+
/** Visible label, associated with the input via `for`/`id`. */
|
|
31
|
+
label;
|
|
32
|
+
/** The options to filter and choose from. */
|
|
33
|
+
options = [];
|
|
34
|
+
/** The committed value. An array when `multiple`. */
|
|
35
|
+
value;
|
|
36
|
+
/** Whether the user can pick more than one option. */
|
|
37
|
+
multiple = false;
|
|
38
|
+
/** Placeholder shown while the field is empty. */
|
|
39
|
+
placeholder;
|
|
40
|
+
/** Name submitted with the form. Repeated once per value when `multiple`. */
|
|
41
|
+
name;
|
|
42
|
+
/** Whether the field is disabled. */
|
|
43
|
+
disabled = false;
|
|
44
|
+
/** Whether at least one value is required. */
|
|
45
|
+
required = false;
|
|
46
|
+
/** Helper text, replaced by `errorMessage` when invalid. */
|
|
47
|
+
hint;
|
|
48
|
+
/** Custom error message; wins over the built-in messages. */
|
|
49
|
+
errorMessage;
|
|
50
|
+
/** Whether the field is marked invalid by the consumer. */
|
|
51
|
+
invalid = false;
|
|
52
|
+
/** Text the user has typed to filter with. */
|
|
53
|
+
query = '';
|
|
54
|
+
/** Whether the list is rendered. */
|
|
55
|
+
expanded = false;
|
|
56
|
+
/** Index into `visibleOptions` of the option under the keyboard cursor. */
|
|
57
|
+
activeIndex = -1;
|
|
58
|
+
/** Emitted whenever the committed value changes. */
|
|
59
|
+
chChange;
|
|
60
|
+
/** Emitted as the user types, with the raw query, so a consumer can filter remotely. */
|
|
61
|
+
chFilter;
|
|
62
|
+
/** The committed values as an array, whatever the mode. */
|
|
63
|
+
get selected() {
|
|
64
|
+
if (Array.isArray(this.value)) {
|
|
65
|
+
return this.value;
|
|
66
|
+
}
|
|
67
|
+
return this.value === undefined || this.value === '' ? [] : [this.value];
|
|
68
|
+
}
|
|
69
|
+
/** Options that match the current query. */
|
|
70
|
+
get visibleOptions() {
|
|
71
|
+
const query = this.query.trim().toLowerCase();
|
|
72
|
+
if (query === '') {
|
|
73
|
+
return this.options;
|
|
74
|
+
}
|
|
75
|
+
return this.options.filter(option => option.label.toLowerCase().includes(query));
|
|
76
|
+
}
|
|
77
|
+
/** Options that are still choosable: already-picked ones drop out in multiple mode. */
|
|
78
|
+
get choosable() {
|
|
79
|
+
if (!this.multiple) {
|
|
80
|
+
return this.visibleOptions;
|
|
81
|
+
}
|
|
82
|
+
const chosen = new Set(this.selected);
|
|
83
|
+
return this.visibleOptions.filter(option => !chosen.has(option.value));
|
|
84
|
+
}
|
|
85
|
+
labelFor(value) {
|
|
86
|
+
return this.options.find(option => option.value === value)?.label ?? value;
|
|
87
|
+
}
|
|
88
|
+
componentDidLoad() {
|
|
89
|
+
this.initialValue = this.selected;
|
|
90
|
+
this.syncForm();
|
|
91
|
+
this.host.addEventListener('focusout', this.handleFocusOut);
|
|
92
|
+
this.host.addEventListener('invalid', this.markTouched);
|
|
93
|
+
}
|
|
94
|
+
disconnectedCallback() {
|
|
95
|
+
this.host.removeEventListener('focusout', this.handleFocusOut);
|
|
96
|
+
}
|
|
97
|
+
markTouched = () => {
|
|
98
|
+
this.host.setAttribute('data-touched', '');
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Closing on blur is deferred: clicking an option also blurs the input, and
|
|
102
|
+
* the click must be allowed to land first.
|
|
103
|
+
*/
|
|
104
|
+
handleFocusOut = () => {
|
|
105
|
+
this.markTouched();
|
|
106
|
+
window.setTimeout(() => {
|
|
107
|
+
if (!this.host.contains(document.activeElement) && this.host.shadowRoot?.activeElement == null) {
|
|
108
|
+
this.expanded = false;
|
|
109
|
+
this.syncForm();
|
|
110
|
+
}
|
|
111
|
+
}, 0);
|
|
112
|
+
};
|
|
113
|
+
syncForm() {
|
|
114
|
+
const internals = this.internals;
|
|
115
|
+
if (typeof internals?.setFormValue !== 'function') {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const values = this.selected;
|
|
119
|
+
// Multiple entries are submitted once per value, the way a multi-select does.
|
|
120
|
+
if (this.multiple) {
|
|
121
|
+
const data = new FormData();
|
|
122
|
+
for (const entry of values) {
|
|
123
|
+
data.append(this.name ?? '', entry);
|
|
124
|
+
}
|
|
125
|
+
internals.setFormValue(values.length === 0 ? null : data);
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
internals.setFormValue(values[0] ?? '');
|
|
129
|
+
}
|
|
130
|
+
const { flags, message } = validationMessage.resolveValidity({
|
|
131
|
+
required: this.required,
|
|
132
|
+
empty: values.length === 0,
|
|
133
|
+
invalid: this.invalid,
|
|
134
|
+
errorMessage: this.errorMessage,
|
|
135
|
+
});
|
|
136
|
+
internals.setValidity(flags, message);
|
|
137
|
+
}
|
|
138
|
+
formResetCallback() {
|
|
139
|
+
this.value = this.multiple ? [...this.initialValue] : (this.initialValue[0] ?? '');
|
|
140
|
+
this.query = '';
|
|
141
|
+
this.syncForm();
|
|
142
|
+
const input = this.host.shadowRoot?.querySelector('.input');
|
|
143
|
+
if (input) {
|
|
144
|
+
input.value = '';
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
formDisabledCallback(isDisabled) {
|
|
148
|
+
this.formDisabled = isDisabled;
|
|
149
|
+
}
|
|
150
|
+
commit(value) {
|
|
151
|
+
if (this.multiple) {
|
|
152
|
+
const next = this.selected.includes(value) ? this.selected : [...this.selected, value];
|
|
153
|
+
this.value = next;
|
|
154
|
+
this.query = '';
|
|
155
|
+
const input = this.host.shadowRoot?.querySelector('.input');
|
|
156
|
+
if (input) {
|
|
157
|
+
input.value = '';
|
|
158
|
+
}
|
|
159
|
+
// Keep the list open: choosing again is the common case here.
|
|
160
|
+
this.activeIndex = -1;
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
this.value = value;
|
|
164
|
+
this.query = this.labelFor(value);
|
|
165
|
+
this.expanded = false;
|
|
166
|
+
this.activeIndex = -1;
|
|
167
|
+
}
|
|
168
|
+
this.chChange.emit(this.value);
|
|
169
|
+
this.syncForm();
|
|
170
|
+
}
|
|
171
|
+
remove(value) {
|
|
172
|
+
const next = this.selected.filter(entry => entry !== value);
|
|
173
|
+
this.value = this.multiple ? next : '';
|
|
174
|
+
this.chChange.emit(this.value);
|
|
175
|
+
this.syncForm();
|
|
176
|
+
}
|
|
177
|
+
open() {
|
|
178
|
+
if (this.disabled || this.formDisabled) {
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
this.expanded = true;
|
|
182
|
+
}
|
|
183
|
+
moveActive(delta) {
|
|
184
|
+
const count = this.choosable.length;
|
|
185
|
+
if (count === 0) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
const next = this.activeIndex + delta;
|
|
189
|
+
this.activeIndex = next < 0 ? count - 1 : next >= count ? 0 : next;
|
|
190
|
+
}
|
|
191
|
+
handleInput = (event) => {
|
|
192
|
+
const input = event.target;
|
|
193
|
+
this.query = input.value;
|
|
194
|
+
this.expanded = true;
|
|
195
|
+
this.activeIndex = this.choosable.length > 0 ? 0 : -1;
|
|
196
|
+
// Single mode shows a typed-but-uncommitted value as no value at all.
|
|
197
|
+
if (!this.multiple && this.value !== undefined && this.value !== this.labelFor(this.selected[0] ?? '')) {
|
|
198
|
+
this.value = '';
|
|
199
|
+
}
|
|
200
|
+
this.chFilter.emit(this.query);
|
|
201
|
+
};
|
|
202
|
+
handleKeyDown = (event) => {
|
|
203
|
+
if (event.key === 'ArrowDown') {
|
|
204
|
+
event.preventDefault();
|
|
205
|
+
this.open();
|
|
206
|
+
this.moveActive(1);
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
if (event.key === 'ArrowUp') {
|
|
210
|
+
event.preventDefault();
|
|
211
|
+
this.open();
|
|
212
|
+
this.moveActive(-1);
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
if (event.key === 'Enter') {
|
|
216
|
+
const option = this.choosable[this.activeIndex];
|
|
217
|
+
if (this.expanded && option && !option.disabled) {
|
|
218
|
+
event.preventDefault();
|
|
219
|
+
this.commit(option.value);
|
|
220
|
+
}
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
if (event.key === 'Escape' && this.expanded) {
|
|
224
|
+
event.preventDefault();
|
|
225
|
+
this.expanded = false;
|
|
226
|
+
this.activeIndex = -1;
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
// Backspace in an empty multiple field removes the last chip.
|
|
230
|
+
if (event.key === 'Backspace' && this.multiple && this.query === '') {
|
|
231
|
+
const last = this.selected[this.selected.length - 1];
|
|
232
|
+
if (last !== undefined) {
|
|
233
|
+
event.preventDefault();
|
|
234
|
+
this.remove(last);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
handleFocus = () => {
|
|
239
|
+
this.open();
|
|
240
|
+
};
|
|
241
|
+
handleBlur = () => {
|
|
242
|
+
// A single-mode field shows the chosen label, not what was typed.
|
|
243
|
+
const input = this.host.shadowRoot?.querySelector('.input');
|
|
244
|
+
if (input && !this.multiple) {
|
|
245
|
+
this.query = '';
|
|
246
|
+
input.value = this.selected.length > 0 ? this.labelFor(this.selected[0]) : '';
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
get isInvalid() {
|
|
250
|
+
return this.invalid || (this.host.hasAttribute('data-touched') && this.selected.length === 0 && this.required);
|
|
251
|
+
}
|
|
252
|
+
get describedBy() {
|
|
253
|
+
if (this.isInvalid && this.errorMessage) {
|
|
254
|
+
return this.errorId;
|
|
255
|
+
}
|
|
256
|
+
return this.hint ? this.hintId : undefined;
|
|
257
|
+
}
|
|
258
|
+
/** The option id for `aria-activedescendant`. */
|
|
259
|
+
optionId(index) {
|
|
260
|
+
return `${this.inputId}-option-${index}`;
|
|
261
|
+
}
|
|
262
|
+
render() {
|
|
263
|
+
const options = this.choosable;
|
|
264
|
+
const active = this.activeIndex >= 0 && this.activeIndex < options.length ? options[this.activeIndex] : undefined;
|
|
265
|
+
const chosen = this.selected;
|
|
266
|
+
const showError = this.isInvalid && this.errorMessage;
|
|
267
|
+
return (index.h(index.Host, { key: '783df95d2970b0db5c6f839fb0acbaa7582301f0' }, this.label && (index.h("label", { key: '232933c04601d543b391d15603f1dcfafa2f6e73', class: "label", htmlFor: this.inputId }, this.label)), this.multiple && chosen.length > 0 && (index.h("ul", { key: 'e7e92805f42a9a97d0587463f0b68fa79368cc6b', class: "chips", "aria-label": "Selected values" }, chosen.map(entry => (index.h("li", { class: "chip", key: entry }, index.h("span", { class: "chip__label" }, this.labelFor(entry)), index.h("button", { type: "button", class: "chip__remove", "aria-label": `Remove ${this.labelFor(entry)}`, onClick: () => this.remove(entry) }, index.h("span", { "aria-hidden": "true" }, "\u00D7"))))))), index.h("div", { key: '076bd78c0c43327c298baf37e9411d68e6b03734', class: "field" }, index.h("input", { key: '0e2caa28567ea21d8b5a98a8b1ed949e07731e09', id: this.label && !this.multiple ? this.inputId : undefined, class: { 'input': true, 'input--invalid': this.isInvalid }, type: "text", role: "combobox", autocomplete: "off", "aria-expanded": this.expanded ? 'true' : 'false', "aria-controls": this.listId, "aria-autocomplete": "list", "aria-activedescendant": active ? this.optionId(this.activeIndex) : undefined, "aria-invalid": this.isInvalid ? 'true' : undefined, "aria-describedby": this.describedBy, name: this.name, disabled: this.disabled || this.formDisabled, required: this.required, placeholder: chosen.length === 0 ? this.placeholder : undefined, value: this.multiple ? this.query : this.query || (chosen[0] !== undefined ? this.labelFor(chosen[0]) : ''), onInput: this.handleInput, onKeyDown: this.handleKeyDown, onFocus: this.handleFocus, onBlur: this.handleBlur }), index.h("ul", { key: '5f843aef03c09ff9dd1e02c3da90f6e9dbcca858', class: "listbox", id: this.listId, role: "listbox", "aria-multiselectable": this.multiple ? 'true' : undefined, hidden: !this.expanded }, options.length === 0 && (index.h("li", { key: '1bb282438f1889da96af7d27b504e31ab19088e5', class: "listbox__empty", role: "presentation" }, "No results")), options.map((option, index$1) => (index.h("li", { class: {
|
|
268
|
+
'listbox__option': true,
|
|
269
|
+
'listbox__option--active': index$1 === this.activeIndex,
|
|
270
|
+
'listbox__option--disabled': option.disabled === true,
|
|
271
|
+
}, id: this.optionId(index$1), key: option.value, role: "option", "aria-selected": this.multiple ? 'false' : chosen[0] === option.value ? 'true' : 'false', "aria-disabled": option.disabled ? 'true' : undefined,
|
|
272
|
+
// Pointer-down commits before the input's blur closes the list.
|
|
273
|
+
onMouseDown: event => {
|
|
274
|
+
event.preventDefault();
|
|
275
|
+
if (!option.disabled) {
|
|
276
|
+
this.commit(option.value);
|
|
277
|
+
}
|
|
278
|
+
} }, option.label))))), this.hint && !showError && (index.h("p", { key: 'dc7f8a5d26e55d2d7836bf72a5359a6c0fbe0220', class: "hint", id: this.hintId }, this.hint)), showError && (index.h("p", { key: 'd3d9beaa0eb9d830b2c9f3082ea0bf0490efe3ee', class: "error", id: this.errorId, role: "alert" }, this.errorMessage))));
|
|
279
|
+
}
|
|
280
|
+
static get formAssociated() { return true; }
|
|
281
|
+
static get watchers() { return {
|
|
282
|
+
"value": [{
|
|
283
|
+
"syncForm": 0
|
|
284
|
+
}],
|
|
285
|
+
"required": [{
|
|
286
|
+
"syncForm": 0
|
|
287
|
+
}],
|
|
288
|
+
"invalid": [{
|
|
289
|
+
"syncForm": 0
|
|
290
|
+
}],
|
|
291
|
+
"errorMessage": [{
|
|
292
|
+
"syncForm": 0
|
|
293
|
+
}],
|
|
294
|
+
"multiple": [{
|
|
295
|
+
"syncForm": 0
|
|
296
|
+
}]
|
|
297
|
+
}; }
|
|
298
|
+
};
|
|
299
|
+
ChCombobox.style = chComboboxCss();
|
|
300
|
+
|
|
301
|
+
exports.ch_combobox = ChCombobox;
|
|
302
|
+
//# sourceMappingURL=ch-combobox.entry.cjs.js.map
|
|
303
|
+
|
|
304
|
+
//# sourceMappingURL=ch-combobox.cjs.entry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"ch-combobox.cjs.entry.js","mappings":";;;;;AAAA,MAAM,aAAa,GAAG,MAAM,CAAC,0qFAA0qF,CAAC;;ACYxsF,IAAI,WAAW,GAAG,CAAC;MAyBN,UAAU,GAAA,MAAA;;;;;;;;;;;;;AACJ,IAAA,OAAO,GAAG,CAAA,YAAA,EAAe,EAAE,WAAW,EAAE;AACxC,IAAA,MAAM,GAAG,CAAA,EAAG,IAAI,CAAC,OAAO,OAAO;AAC/B,IAAA,MAAM,GAAG,CAAA,EAAG,IAAI,CAAC,OAAO,OAAO;AAC/B,IAAA,OAAO,GAAG,CAAA,EAAG,IAAI,CAAC,OAAO,QAAQ;IAC1C,YAAY,GAAa,EAAE;AAEhB,IAAA,SAAS;IACnB,YAAY,GAAG,KAAK;;;AAIrB,IAAA,KAAK;;IAGL,OAAO,G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CAChB,CACL,CACI;;;;;;;;;;;;;;;;;;;;;;;;;","names":["resolveValidity","h","Host","index"],"sources":["src/components/ch-combobox/ch-combobox.css?tag=ch-combobox&encapsulation=shadow","src/components/ch-combobox/ch-combobox.tsx"],"sourcesContent":[":host {\n display: block;\n width: 100%;\n font-family: var(--typography-body);\n}\n\n:host([hidden]) {\n display: none;\n}\n\n.label {\n display: block;\n margin-bottom: var(--spacing-sm);\n font-size: var(--typography-size-sm);\n font-weight: var(--typography-weight-semibold);\n color: var(--color-text-primary);\n}\n\n.chips {\n display: flex;\n flex-wrap: wrap;\n gap: var(--spacing-xs);\n margin: 0 0 var(--spacing-sm);\n padding: 0;\n list-style: none;\n}\n\n.chip {\n display: inline-flex;\n align-items: center;\n gap: var(--spacing-xs);\n max-width: 100%;\n padding: var(--spacing-2xs) var(--spacing-sm);\n border: var(--border-width) solid var(--color-border-default);\n border-radius: var(--radius-sm);\n background: var(--color-surface-hover);\n font-size: var(--typography-size-sm);\n}\n\n.chip__label {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.chip__remove {\n all: unset;\n cursor: pointer;\n padding: 0 var(--spacing-2xs);\n border-radius: var(--radius-sm);\n color: var(--color-text-secondary);\n line-height: 1;\n}\n\n.chip__remove:focus-visible {\n outline: 2px solid var(--color-accent-default);\n outline-offset: 1px;\n}\n\n/* The list is positioned against the field, not the viewport: a dropdown that\n * is part of a form flow should move with it, unlike a tooltip. */\n.field {\n position: relative;\n}\n\n.input {\n box-sizing: border-box;\n width: 100%;\n padding: var(--spacing-xl) var(--spacing-3xl);\n border: var(--border-width) solid var(--color-border-default);\n border-radius: var(--radius-sm);\n background: var(--color-surface-default);\n color: var(--color-text-primary);\n font-family: inherit;\n font-size: var(--typography-size-md);\n transition: border-color var(--duration-normal) var(--easing-default);\n}\n\n.input::placeholder {\n color: var(--color-text-secondary);\n}\n\n.input:focus {\n border-color: var(--color-accent-default);\n outline: 2px solid var(--color-accent-default);\n outline-offset: 1px;\n}\n\n.input:disabled {\n opacity: var(--opacity-disabled);\n cursor: not-allowed;\n}\n\n.input--invalid {\n border-color: var(--color-status-warning);\n}\n\n.listbox {\n position: absolute;\n z-index: var(--z-index-dropdown);\n top: calc(100% + var(--spacing-2xs));\n left: 0;\n right: 0;\n max-height: 16rem;\n margin: 0;\n padding: var(--spacing-2xs);\n overflow-y: auto;\n list-style: none;\n border: var(--border-width) solid var(--color-border-default);\n border-radius: var(--radius-sm);\n background: var(--color-surface-default);\n box-shadow: var(--shadow-elevate);\n}\n\n.listbox[hidden] {\n display: none;\n}\n\n.listbox__option {\n padding: var(--spacing-sm) var(--spacing-md);\n border-radius: var(--radius-sm);\n font-size: var(--typography-size-sm);\n cursor: pointer;\n}\n\n/* The active option is marked by a rule and weight, not only a tint. */\n.listbox__option--active {\n background: var(--color-surface-hover);\n font-weight: var(--typography-weight-semibold);\n box-shadow: inset 2px 0 0 var(--color-accent-default);\n}\n\n.listbox__option--disabled {\n opacity: var(--opacity-disabled);\n cursor: not-allowed;\n}\n\n.listbox__empty {\n padding: var(--spacing-sm) var(--spacing-md);\n font-size: var(--typography-size-sm);\n color: var(--color-text-secondary);\n}\n\n.hint,\n.error {\n margin: var(--spacing-sm) 0 0;\n font-size: var(--typography-size-sm);\n color: var(--color-text-secondary);\n}\n\n.error {\n color: var(--color-status-warning);\n}\n","import { AttachInternals, Component, Element, Event, type EventEmitter, Host, Prop, State, Watch, h } from '@stencil/core';\n\nimport { resolveValidity } from '../../utils/validation-message';\n\nexport interface ChComboboxOption {\n label: string;\n value: string;\n disabled?: boolean;\n /** Optional grouping label; consecutive options with the same group are announced together. */\n group?: string;\n}\n\nlet comboboxIds = 0;\n\n/**\n * A text field that filters a list of options and commits a choice.\n *\n * The input is a native `<input>` rather than `ch-input`: the combobox role\n * and its `aria-*` state have to sit on the element that owns the interaction,\n * and ARIA does not forward through a wrapper component.\n *\n * Single and multiple are one component. `multiple` changes the value shape\n * (`string` vs `string[]`), renders the chosen values as removable chips, and\n * keeps the list open after a pick; single commits and closes. Everything else\n * — filtering, the active option, keyboard behaviour, validity — is shared, so\n * the two cannot drift apart.\n *\n * The consumer owns the options and, if it fetches them, their ordering: this\n * component never sorts, debounces or requests anything. It filters what it is\n * given, and reports what the user asked for.\n */\n@Component({\n tag: 'ch-combobox',\n styleUrl: 'ch-combobox.css',\n shadow: true,\n formAssociated: true,\n})\nexport class ChCombobox {\n private readonly inputId = `ch-combobox-${++comboboxIds}`;\n private readonly listId = `${this.inputId}-list`;\n private readonly hintId = `${this.inputId}-hint`;\n private readonly errorId = `${this.inputId}-error`;\n private initialValue: string[] = [];\n\n @AttachInternals() internals!: ElementInternals;\n @State() formDisabled = false;\n @Element() private host!: HTMLElement;\n\n /** Visible label, associated with the input via `for`/`id`. */\n @Prop() label?: string;\n\n /** The options to filter and choose from. */\n @Prop() options: ChComboboxOption[] = [];\n\n /** The committed value. An array when `multiple`. */\n @Prop({ mutable: true }) value?: string | string[];\n\n /** Whether the user can pick more than one option. */\n @Prop({ reflect: true }) multiple = false;\n\n /** Placeholder shown while the field is empty. */\n @Prop() placeholder?: string;\n\n /** Name submitted with the form. Repeated once per value when `multiple`. */\n @Prop({ reflect: true }) name?: string;\n\n /** Whether the field is disabled. */\n @Prop({ reflect: true }) disabled = false;\n\n /** Whether at least one value is required. */\n @Prop({ reflect: true }) required = false;\n\n /** Helper text, replaced by `errorMessage` when invalid. */\n @Prop() hint?: string;\n\n /** Custom error message; wins over the built-in messages. */\n @Prop() errorMessage?: string;\n\n /** Whether the field is marked invalid by the consumer. */\n @Prop() invalid = false;\n\n /** Text the user has typed to filter with. */\n @State() private query = '';\n\n /** Whether the list is rendered. */\n @State() private expanded = false;\n\n /** Index into `visibleOptions` of the option under the keyboard cursor. */\n @State() private activeIndex = -1;\n\n /** Emitted whenever the committed value changes. */\n @Event() chChange: EventEmitter<string | string[]>;\n\n /** Emitted as the user types, with the raw query, so a consumer can filter remotely. */\n @Event() chFilter: EventEmitter<string>;\n\n /** The committed values as an array, whatever the mode. */\n private get selected(): string[] {\n if (Array.isArray(this.value)) {\n return this.value;\n }\n return this.value === undefined || this.value === '' ? [] : [this.value];\n }\n\n /** Options that match the current query. */\n private get visibleOptions(): ChComboboxOption[] {\n const query = this.query.trim().toLowerCase();\n if (query === '') {\n return this.options;\n }\n return this.options.filter(option => option.label.toLowerCase().includes(query));\n }\n\n /** Options that are still choosable: already-picked ones drop out in multiple mode. */\n private get choosable(): ChComboboxOption[] {\n if (!this.multiple) {\n return this.visibleOptions;\n }\n const chosen = new Set(this.selected);\n return this.visibleOptions.filter(option => !chosen.has(option.value));\n }\n\n private labelFor(value: string): string {\n return this.options.find(option => option.value === value)?.label ?? value;\n }\n\n componentDidLoad() {\n this.initialValue = this.selected;\n this.syncForm();\n this.host.addEventListener('focusout', this.handleFocusOut);\n this.host.addEventListener('invalid', this.markTouched);\n }\n\n disconnectedCallback() {\n this.host.removeEventListener('focusout', this.handleFocusOut);\n }\n\n private markTouched = (): void => {\n this.host.setAttribute('data-touched', '');\n };\n\n /**\n * Closing on blur is deferred: clicking an option also blurs the input, and\n * the click must be allowed to land first.\n */\n private handleFocusOut = () => {\n this.markTouched();\n window.setTimeout(() => {\n if (!this.host.contains(document.activeElement) && this.host.shadowRoot?.activeElement == null) {\n this.expanded = false;\n this.syncForm();\n }\n }, 0);\n };\n\n @Watch('value')\n @Watch('required')\n @Watch('invalid')\n @Watch('errorMessage')\n @Watch('multiple')\n protected syncForm(): void {\n const internals = this.internals;\n if (typeof internals?.setFormValue !== 'function') {\n return;\n }\n const values = this.selected;\n // Multiple entries are submitted once per value, the way a multi-select does.\n if (this.multiple) {\n const data = new FormData();\n for (const entry of values) {\n data.append(this.name ?? '', entry);\n }\n internals.setFormValue(values.length === 0 ? null : data);\n } else {\n internals.setFormValue(values[0] ?? '');\n }\n\n const { flags, message } = resolveValidity({\n required: this.required,\n empty: values.length === 0,\n invalid: this.invalid,\n errorMessage: this.errorMessage,\n });\n internals.setValidity(flags, message);\n }\n\n formResetCallback(): void {\n this.value = this.multiple ? [...this.initialValue] : (this.initialValue[0] ?? '');\n this.query = '';\n this.syncForm();\n const input = this.host.shadowRoot?.querySelector('.input') as HTMLInputElement | null;\n if (input) {\n input.value = '';\n }\n }\n\n formDisabledCallback(isDisabled: boolean): void {\n this.formDisabled = isDisabled;\n }\n\n private commit(value: string) {\n if (this.multiple) {\n const next = this.selected.includes(value) ? this.selected : [...this.selected, value];\n this.value = next;\n this.query = '';\n const input = this.host.shadowRoot?.querySelector('.input') as HTMLInputElement | null;\n if (input) {\n input.value = '';\n }\n // Keep the list open: choosing again is the common case here.\n this.activeIndex = -1;\n } else {\n this.value = value;\n this.query = this.labelFor(value);\n this.expanded = false;\n this.activeIndex = -1;\n }\n this.chChange.emit(this.value as string | string[]);\n this.syncForm();\n }\n\n private remove(value: string) {\n const next = this.selected.filter(entry => entry !== value);\n this.value = this.multiple ? next : '';\n this.chChange.emit(this.value as string | string[]);\n this.syncForm();\n }\n\n private open() {\n if (this.disabled || this.formDisabled) {\n return;\n }\n this.expanded = true;\n }\n\n private moveActive(delta: number) {\n const count = this.choosable.length;\n if (count === 0) {\n return;\n }\n const next = this.activeIndex + delta;\n this.activeIndex = next < 0 ? count - 1 : next >= count ? 0 : next;\n }\n\n private handleInput = (event: InputEvent) => {\n const input = event.target as HTMLInputElement;\n this.query = input.value;\n this.expanded = true;\n this.activeIndex = this.choosable.length > 0 ? 0 : -1;\n // Single mode shows a typed-but-uncommitted value as no value at all.\n if (!this.multiple && this.value !== undefined && this.value !== this.labelFor(this.selected[0] ?? '')) {\n this.value = '';\n }\n this.chFilter.emit(this.query);\n };\n\n private handleKeyDown = (event: KeyboardEvent) => {\n if (event.key === 'ArrowDown') {\n event.preventDefault();\n this.open();\n this.moveActive(1);\n return;\n }\n if (event.key === 'ArrowUp') {\n event.preventDefault();\n this.open();\n this.moveActive(-1);\n return;\n }\n if (event.key === 'Enter') {\n const option = this.choosable[this.activeIndex];\n if (this.expanded && option && !option.disabled) {\n event.preventDefault();\n this.commit(option.value);\n }\n return;\n }\n if (event.key === 'Escape' && this.expanded) {\n event.preventDefault();\n this.expanded = false;\n this.activeIndex = -1;\n return;\n }\n // Backspace in an empty multiple field removes the last chip.\n if (event.key === 'Backspace' && this.multiple && this.query === '') {\n const last = this.selected[this.selected.length - 1];\n if (last !== undefined) {\n event.preventDefault();\n this.remove(last);\n }\n }\n };\n\n private handleFocus = () => {\n this.open();\n };\n\n private handleBlur = () => {\n // A single-mode field shows the chosen label, not what was typed.\n const input = this.host.shadowRoot?.querySelector('.input') as HTMLInputElement | null;\n if (input && !this.multiple) {\n this.query = '';\n input.value = this.selected.length > 0 ? this.labelFor(this.selected[0]) : '';\n }\n };\n\n private get isInvalid(): boolean {\n return this.invalid || (this.host.hasAttribute('data-touched') && this.selected.length === 0 && this.required);\n }\n\n private get describedBy(): string | undefined {\n if (this.isInvalid && this.errorMessage) {\n return this.errorId;\n }\n return this.hint ? this.hintId : undefined;\n }\n\n /** The option id for `aria-activedescendant`. */\n private optionId(index: number): string {\n return `${this.inputId}-option-${index}`;\n }\n\n render() {\n const options = this.choosable;\n const active = this.activeIndex >= 0 && this.activeIndex < options.length ? options[this.activeIndex] : undefined;\n const chosen = this.selected;\n const showError = this.isInvalid && this.errorMessage;\n\n return (\n <Host>\n {this.label && (\n <label class=\"label\" htmlFor={this.inputId}>\n {this.label}\n </label>\n )}\n {this.multiple && chosen.length > 0 && (\n <ul class=\"chips\" aria-label=\"Selected values\">\n {chosen.map(entry => (\n <li class=\"chip\" key={entry}>\n <span class=\"chip__label\">{this.labelFor(entry)}</span>\n <button type=\"button\" class=\"chip__remove\" aria-label={`Remove ${this.labelFor(entry)}`} onClick={() => this.remove(entry)}>\n <span aria-hidden=\"true\">×</span>\n </button>\n </li>\n ))}\n </ul>\n )}\n <div class=\"field\">\n <input\n id={this.label && !this.multiple ? this.inputId : undefined}\n class={{ 'input': true, 'input--invalid': this.isInvalid }}\n type=\"text\"\n role=\"combobox\"\n autocomplete=\"off\"\n aria-expanded={this.expanded ? 'true' : 'false'}\n aria-controls={this.listId}\n aria-autocomplete=\"list\"\n aria-activedescendant={active ? this.optionId(this.activeIndex) : undefined}\n aria-invalid={this.isInvalid ? 'true' : undefined}\n aria-describedby={this.describedBy}\n name={this.name}\n disabled={this.disabled || this.formDisabled}\n required={this.required}\n placeholder={chosen.length === 0 ? this.placeholder : undefined}\n value={this.multiple ? this.query : this.query || (chosen[0] !== undefined ? this.labelFor(chosen[0]) : '')}\n onInput={this.handleInput}\n onKeyDown={this.handleKeyDown}\n onFocus={this.handleFocus}\n onBlur={this.handleBlur}\n />\n <ul class=\"listbox\" id={this.listId} role=\"listbox\" aria-multiselectable={this.multiple ? 'true' : undefined} hidden={!this.expanded}>\n {options.length === 0 && (\n <li class=\"listbox__empty\" role=\"presentation\">\n No results\n </li>\n )}\n {options.map((option, index) => (\n <li\n class={{\n 'listbox__option': true,\n 'listbox__option--active': index === this.activeIndex,\n 'listbox__option--disabled': option.disabled === true,\n }}\n id={this.optionId(index)}\n key={option.value}\n role=\"option\"\n aria-selected={this.multiple ? 'false' : chosen[0] === option.value ? 'true' : 'false'}\n aria-disabled={option.disabled ? 'true' : undefined}\n // Pointer-down commits before the input's blur closes the list.\n onMouseDown={event => {\n event.preventDefault();\n if (!option.disabled) {\n this.commit(option.value);\n }\n }}\n >\n {option.label}\n </li>\n ))}\n </ul>\n </div>\n {this.hint && !showError && (\n <p class=\"hint\" id={this.hintId}>\n {this.hint}\n </p>\n )}\n {showError && (\n <p class=\"error\" id={this.errorId} role=\"alert\">\n {this.errorMessage}\n </p>\n )}\n </Host>\n );\n }\n}\n"],"version":3}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var index = require('./index-C6khqyw3.js');
|
|
4
|
+
|
|
5
|
+
const chConfirmDialogCss = () => `:host{display:contents;font-family:var(--typography-body)}.confirm__heading{margin:0;font-family:var(--typography-heading);font-size:var(--typography-size-lg);font-weight:var(--typography-weight-semibold);color:var(--color-text-primary)}.confirm__message{margin:0;font-size:var(--typography-size-sm);color:var(--color-text-secondary);overflow-wrap:break-word}.confirm__actions{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:var(--spacing-md);margin-top:var(--spacing-2xl)}.confirm__button{display:inline-flex;align-items:center;justify-content:center;min-height:2.25rem;padding:0 var(--spacing-lg);border:var(--border-width) solid var(--color-border-default);border-radius:var(--radius-sm);background:var(--color-surface-default);color:var(--color-text-primary);font-family:var(--typography-body);font-size:var(--typography-size-sm);font-weight:var(--typography-weight-semibold);cursor:pointer}.confirm__button:focus-visible{outline:2px solid var(--color-accent-default);outline-offset:2px}.confirm__button:disabled{opacity:var(--opacity-disabled);cursor:not-allowed}.confirm__button--confirm{border-color:var(--color-accent-default);background:var(--color-accent-default);color:var(--color-accent-text)}.confirm__button--danger{border-color:var(--color-status-warning);background:var(--color-status-warning);color:var(--color-text-primary)}.confirm__button--danger::before{content:'⚠';margin-right:var(--spacing-xs)}`;
|
|
6
|
+
|
|
7
|
+
const ChConfirmDialog = class {
|
|
8
|
+
constructor(hostRef) {
|
|
9
|
+
index.registerInstance(this, hostRef);
|
|
10
|
+
this.chConfirm = index.createEvent(this, "chConfirm");
|
|
11
|
+
this.chCancel = index.createEvent(this, "chCancel");
|
|
12
|
+
}
|
|
13
|
+
get el() { return index.getElement(this); }
|
|
14
|
+
/** Whether the dialog is open. Kept in sync when it is dismissed. */
|
|
15
|
+
open = false;
|
|
16
|
+
/**
|
|
17
|
+
* The question, set as the dialog's accessible name. Required: a dialog
|
|
18
|
+
* without a name is announced as an unlabelled group.
|
|
19
|
+
*/
|
|
20
|
+
heading;
|
|
21
|
+
/** Supporting text, rendered under the heading. */
|
|
22
|
+
message;
|
|
23
|
+
/** Label of the confirming action. */
|
|
24
|
+
confirmLabel = 'Confirm';
|
|
25
|
+
/** Label of the dismissing action. */
|
|
26
|
+
cancelLabel = 'Cancel';
|
|
27
|
+
/**
|
|
28
|
+
* `danger` styles the confirm action as destructive and moves the initial
|
|
29
|
+
* focus to Cancel, so the safe choice is the default one.
|
|
30
|
+
*/
|
|
31
|
+
tone = 'default';
|
|
32
|
+
/** Whether the confirm action is in flight; both buttons are then disabled. */
|
|
33
|
+
pending = false;
|
|
34
|
+
/**
|
|
35
|
+
* Whether Escape and the backdrop dismiss the dialog. When false, the only
|
|
36
|
+
* way out is one of the two buttons — use it only for a decision that must
|
|
37
|
+
* be answered rather than abandoned.
|
|
38
|
+
*/
|
|
39
|
+
dismissible = true;
|
|
40
|
+
/** Emitted once when the user confirms. */
|
|
41
|
+
chConfirm;
|
|
42
|
+
/** Emitted once when the dialog is dismissed without confirming. */
|
|
43
|
+
chCancel;
|
|
44
|
+
/** `true` once an outcome has been emitted for the current opening. */
|
|
45
|
+
settled = false;
|
|
46
|
+
cancelButton;
|
|
47
|
+
confirmButton;
|
|
48
|
+
componentDidLoad() {
|
|
49
|
+
if (this.open) {
|
|
50
|
+
this.onOpening();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
handleOpenChange(open) {
|
|
54
|
+
if (open) {
|
|
55
|
+
this.onOpening();
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
this.settled = false;
|
|
59
|
+
}
|
|
60
|
+
onOpening() {
|
|
61
|
+
this.settled = false;
|
|
62
|
+
// Focus is moved once the dialog is actually shown; the modal handles
|
|
63
|
+
// moving focus into itself, and this refines where it lands.
|
|
64
|
+
requestAnimationFrame(() => {
|
|
65
|
+
const target = this.tone === 'danger' ? this.cancelButton : this.confirmButton;
|
|
66
|
+
target?.focus();
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
settle(outcome) {
|
|
70
|
+
if (this.settled) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
this.settled = true;
|
|
74
|
+
if (outcome === 'confirm') {
|
|
75
|
+
this.chConfirm.emit();
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
this.chCancel.emit();
|
|
79
|
+
}
|
|
80
|
+
handleConfirm = () => {
|
|
81
|
+
if (this.pending) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
this.settle('confirm');
|
|
85
|
+
};
|
|
86
|
+
handleCancel = () => {
|
|
87
|
+
if (this.pending) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
this.open = false;
|
|
91
|
+
this.settle('cancel');
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* `ch-modal` reports every close that was not requested by the consumer —
|
|
95
|
+
* Escape and the backdrop. A close while `pending` is the consumer's own
|
|
96
|
+
* doing and is not a cancellation.
|
|
97
|
+
*/
|
|
98
|
+
handleModalClose = () => {
|
|
99
|
+
this.open = false;
|
|
100
|
+
if (this.pending) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
this.settle('cancel');
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* Escape is a platform close request on the inner `<dialog>`, so a
|
|
107
|
+
* non-dismissible dialog cancels it before it takes effect. The backdrop is
|
|
108
|
+
* handled by `ch-modal` and is suppressed the same way.
|
|
109
|
+
*/
|
|
110
|
+
handleKeyDown = (event) => {
|
|
111
|
+
if (this.dismissible || event.key !== 'Escape') {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
event.preventDefault();
|
|
115
|
+
event.stopPropagation();
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Focus the safe action. Exposed so a consumer can return focus deliberately
|
|
119
|
+
* after a request settles.
|
|
120
|
+
*/
|
|
121
|
+
async focusCancel() {
|
|
122
|
+
this.cancelButton?.focus();
|
|
123
|
+
}
|
|
124
|
+
render() {
|
|
125
|
+
return (index.h(index.Host, { key: 'b51a806f4cca331fc3a95421d3342608c6e0df4c', onKeyDown: this.handleKeyDown }, index.h("ch-modal", { key: '453db02cd724bc9bf2ed7c4b61bcf04c77b8d449', open: this.open, label: this.heading, size: "sm", onChClose: this.handleModalClose, onChOpen: () => this.onOpening() }, index.h("h2", { key: '1dee8f11ee68679792c394506ab2e8a7f98b852b', slot: "heading", class: "confirm__heading" }, this.heading), this.message && index.h("p", { key: 'f2a8a473acfcdfee51600a0dc7bc47b85f4a0889', class: "confirm__message" }, this.message), index.h("div", { key: '7ecfa78e4df217e38519f115fdcb4761ed88937d', class: "confirm__actions" }, index.h("button", { key: '0c4a117caee9ef316932e2eea9c0aa3734f0bbee', class: { 'confirm__button': true, 'confirm__button--cancel': true }, type: "button", ref: el => (this.cancelButton = el), disabled: this.pending, onClick: this.handleCancel }, this.cancelLabel), index.h("button", { key: 'd33fd5f6f218bfcd39f179e29d757f7f9bdcae30', class: { 'confirm__button': true, 'confirm__button--confirm': true, 'confirm__button--danger': this.tone === 'danger' }, type: "button", ref: el => (this.confirmButton = el), disabled: this.pending, "aria-busy": this.pending ? 'true' : undefined, onClick: this.handleConfirm }, this.confirmLabel)))));
|
|
126
|
+
}
|
|
127
|
+
static get watchers() { return {
|
|
128
|
+
"open": [{
|
|
129
|
+
"handleOpenChange": 0
|
|
130
|
+
}]
|
|
131
|
+
}; }
|
|
132
|
+
};
|
|
133
|
+
ChConfirmDialog.style = chConfirmDialogCss();
|
|
134
|
+
|
|
135
|
+
exports.ch_confirm_dialog = ChConfirmDialog;
|
|
136
|
+
//# sourceMappingURL=ch-confirm-dialog.entry.cjs.js.map
|
|
137
|
+
|
|
138
|
+
//# sourceMappingURL=ch-confirm-dialog.cjs.entry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"ch-confirm-dialog.cjs.entry.js","mappings":";;;;AAAA,MAAM,kBAAkB,GAAG,MAAM,CAAC,m5CAAm5C,CAAC;;MC2Bz6C,eAAe,GAAA,MAAA;;;;;;;;IAID,IAAI,GAAG,KAAK;AAErC;;;AAGG;AACK,IAAA,OAAO;;AAGP,IAAA,OAAO;;IAGP,YAAY,GAAG,SAAS;;IAGxB,WAAW,GAAG,QAAQ;AAE9B;;;AAGG;IACK,IAAI,GAAwB,S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K,KAAK,EAAC,kBAAkB,EAAA,EAC3BA,OAAA,CAAA,QAAA,EAAA,EAAA,GAAA,EAAA,0CAAA,EACE,KAAK,EAAE,EAAE,iBAAiB,EAAE,IAAI,EAAE,yBAAyB,EAAE,IAAI,EAAE,EACnE,IAAI,EAAC,QAAQ,EACb,GAAG,EAAE,EAAE,KAAK,IAAI,CAAC,YAAY,GAAG,EAAuB,CAAC,EACxD,QAAQ,EAAE,IAAI,CAAC,OAAO,EACtB,OAAO,EAAE,IAAI,CAAC,YAAY,EAAA,EAEzB,IAAI,CAAC,WAAW,CACV,EACTA,OAAA,CAAA,QAAA,EAAA,EAAA,GAAA,EAAA,0CAAA,EACE,KAAK,EAAE,EAAE,iBAAiB,EAAE,IAAI,EAAE,0BAA0B,EAAE,IAAI,EAAE,yBAAyB,EAAE,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE,EACvH,IAAI,EAAC,QAAQ,EACb,GAAG,EAAE,EAAE,KAAK,IAAI,CAAC,aAAa,GAAG,EAAuB,CAAC,EACzD,QAAQ,EAAE,IAAI,CAAC,OAAO,EAAA,WAAA,EACX,IAAI,CAAC,OAAO,GAAG,MAAM,GAAG,SAAS,EAC5C,OAAO,EAAE,IAAI,CAAC,aAAa,EAAA,EAE1B,IAAI,CAAC,YAAY,CACX,CACL,CACG,CACN;;;;;;;;;;;;","names":["h","Host"],"sources":["src/components/ch-confirm-dialog/ch-confirm-dialog.css?tag=ch-confirm-dialog&encapsulation=shadow","src/components/ch-confirm-dialog/ch-confirm-dialog.tsx"],"sourcesContent":[":host {\n display: contents;\n font-family: var(--typography-body);\n}\n\n.confirm__heading {\n margin: 0;\n font-family: var(--typography-heading);\n font-size: var(--typography-size-lg);\n font-weight: var(--typography-weight-semibold);\n color: var(--color-text-primary);\n}\n\n.confirm__message {\n margin: 0;\n font-size: var(--typography-size-sm);\n color: var(--color-text-secondary);\n overflow-wrap: break-word;\n}\n\n.confirm__actions {\n display: flex;\n flex-wrap: wrap;\n justify-content: flex-end;\n gap: var(--spacing-md);\n margin-top: var(--spacing-2xl);\n}\n\n.confirm__button {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n min-height: 2.25rem;\n padding: 0 var(--spacing-lg);\n border: var(--border-width) solid var(--color-border-default);\n border-radius: var(--radius-sm);\n background: var(--color-surface-default);\n color: var(--color-text-primary);\n font-family: var(--typography-body);\n font-size: var(--typography-size-sm);\n font-weight: var(--typography-weight-semibold);\n cursor: pointer;\n}\n\n.confirm__button:focus-visible {\n outline: 2px solid var(--color-accent-default);\n outline-offset: 2px;\n}\n\n.confirm__button:disabled {\n opacity: var(--opacity-disabled);\n cursor: not-allowed;\n}\n\n.confirm__button--confirm {\n border-color: var(--color-accent-default);\n background: var(--color-accent-default);\n color: var(--color-accent-text);\n}\n\n/* Destructive intent is carried by weight and iconography as well as colour. */\n.confirm__button--danger {\n border-color: var(--color-status-warning);\n background: var(--color-status-warning);\n color: var(--color-text-primary);\n}\n\n.confirm__button--danger::before {\n content: '⚠';\n margin-right: var(--spacing-xs);\n}\n","import { Component, Element, Event, type EventEmitter, Host, Method, Prop, State, Watch, h } from '@stencil/core';\n\nexport type ChConfirmDialogTone = 'default' | 'danger';\n\n/**\n * A confirmation dialog over `ch-modal`.\n *\n * Declarative only: the consumer opens it with `open` and handles the outcome.\n * The imperative `confirm()` helper is a separate concern and a separate issue,\n * because a promise-returning helper has to own mounting, focus and unhandled\n * rejection, none of which a component should decide for its consumer.\n *\n * The guarantees this adds over a plain `ch-modal` are the ones that make a\n * confirmation safe:\n *\n * - exactly one outcome per interaction — a double click on Confirm emits once;\n * - every dismissal path (Cancel, Escape, backdrop, confirm) is reported, so a\n * consumer awaiting an answer cannot hang;\n * - focus lands on Cancel for a destructive action, so the absent-minded Enter\n * does not destroy anything;\n * - `pending` is not a cancellation: a slow request keeps the dialog open.\n */\n@Component({\n tag: 'ch-confirm-dialog',\n styleUrl: 'ch-confirm-dialog.css',\n shadow: true,\n})\nexport class ChConfirmDialog {\n @Element() el: HTMLElement;\n\n /** Whether the dialog is open. Kept in sync when it is dismissed. */\n @Prop({ mutable: true }) open = false;\n\n /**\n * The question, set as the dialog's accessible name. Required: a dialog\n * without a name is announced as an unlabelled group.\n */\n @Prop() heading!: string;\n\n /** Supporting text, rendered under the heading. */\n @Prop() message?: string;\n\n /** Label of the confirming action. */\n @Prop() confirmLabel = 'Confirm';\n\n /** Label of the dismissing action. */\n @Prop() cancelLabel = 'Cancel';\n\n /**\n * `danger` styles the confirm action as destructive and moves the initial\n * focus to Cancel, so the safe choice is the default one.\n */\n @Prop() tone: ChConfirmDialogTone = 'default';\n\n /** Whether the confirm action is in flight; both buttons are then disabled. */\n @Prop() pending = false;\n\n /**\n * Whether Escape and the backdrop dismiss the dialog. When false, the only\n * way out is one of the two buttons — use it only for a decision that must\n * be answered rather than abandoned.\n */\n @Prop() dismissible = true;\n\n /** Emitted once when the user confirms. */\n @Event() chConfirm: EventEmitter<void>;\n\n /** Emitted once when the dialog is dismissed without confirming. */\n @Event() chCancel: EventEmitter<void>;\n\n /** `true` once an outcome has been emitted for the current opening. */\n @State() private settled = false;\n\n private cancelButton?: HTMLButtonElement;\n private confirmButton?: HTMLButtonElement;\n\n componentDidLoad() {\n if (this.open) {\n this.onOpening();\n }\n }\n\n @Watch('open')\n handleOpenChange(open: boolean) {\n if (open) {\n this.onOpening();\n return;\n }\n this.settled = false;\n }\n\n private onOpening() {\n this.settled = false;\n // Focus is moved once the dialog is actually shown; the modal handles\n // moving focus into itself, and this refines where it lands.\n requestAnimationFrame(() => {\n const target = this.tone === 'danger' ? this.cancelButton : this.confirmButton;\n target?.focus();\n });\n }\n\n private settle(outcome: 'confirm' | 'cancel') {\n if (this.settled) {\n return;\n }\n this.settled = true;\n if (outcome === 'confirm') {\n this.chConfirm.emit();\n return;\n }\n this.chCancel.emit();\n }\n\n private handleConfirm = () => {\n if (this.pending) {\n return;\n }\n this.settle('confirm');\n };\n\n private handleCancel = () => {\n if (this.pending) {\n return;\n }\n this.open = false;\n this.settle('cancel');\n };\n\n /**\n * `ch-modal` reports every close that was not requested by the consumer —\n * Escape and the backdrop. A close while `pending` is the consumer's own\n * doing and is not a cancellation.\n */\n private handleModalClose = () => {\n this.open = false;\n if (this.pending) {\n return;\n }\n this.settle('cancel');\n };\n\n /**\n * Escape is a platform close request on the inner `<dialog>`, so a\n * non-dismissible dialog cancels it before it takes effect. The backdrop is\n * handled by `ch-modal` and is suppressed the same way.\n */\n private handleKeyDown = (event: KeyboardEvent) => {\n if (this.dismissible || event.key !== 'Escape') {\n return;\n }\n event.preventDefault();\n event.stopPropagation();\n };\n\n /**\n * Focus the safe action. Exposed so a consumer can return focus deliberately\n * after a request settles.\n */\n @Method()\n async focusCancel(): Promise<void> {\n this.cancelButton?.focus();\n }\n\n render() {\n return (\n <Host onKeyDown={this.handleKeyDown}>\n <ch-modal open={this.open} label={this.heading} size=\"sm\" onChClose={this.handleModalClose} onChOpen={() => this.onOpening()}>\n <h2 slot=\"heading\" class=\"confirm__heading\">\n {this.heading}\n </h2>\n {this.message && <p class=\"confirm__message\">{this.message}</p>}\n <div class=\"confirm__actions\">\n <button\n class={{ 'confirm__button': true, 'confirm__button--cancel': true }}\n type=\"button\"\n ref={el => (this.cancelButton = el as HTMLButtonElement)}\n disabled={this.pending}\n onClick={this.handleCancel}\n >\n {this.cancelLabel}\n </button>\n <button\n class={{ 'confirm__button': true, 'confirm__button--confirm': true, 'confirm__button--danger': this.tone === 'danger' }}\n type=\"button\"\n ref={el => (this.confirmButton = el as HTMLButtonElement)}\n disabled={this.pending}\n aria-busy={this.pending ? 'true' : undefined}\n onClick={this.handleConfirm}\n >\n {this.confirmLabel}\n </button>\n </div>\n </ch-modal>\n </Host>\n );\n }\n}\n"],"version":3}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index-
|
|
3
|
+
var index = require('./index-C6khqyw3.js');
|
|
4
4
|
|
|
5
5
|
const chDescriptionListCss = () => `:host{display:block;font-family:var(--typography-body);color:var(--color-text-secondary)}:host([hidden]){display:none}.list{margin:0;display:grid;grid-template-columns:repeat(1, minmax(0, 1fr));gap:var(--spacing-sm) var(--spacing-2xl)}.list--columns-2,.list--columns-3{grid-template-columns:repeat(2, minmax(0, 1fr))}.list--columns-3{grid-template-columns:repeat(3, minmax(0, 1fr))}@media (max-width: 48rem){.list--columns-2,.list--columns-3{grid-template-columns:minmax(0, 1fr)}}::slotted(div){display:grid;grid-template-columns:fit-content(min(12rem, 40%)) minmax(0, 1fr);gap:var(--spacing-sm);align-items:baseline}::slotted(dt){font-family:var(--typography-heading);font-weight:var(--typography-weight-semibold);font-size:var(--typography-size-sm);color:var(--color-text-primary)}::slotted(dd){margin:0;font-size:var(--typography-size-sm);min-width:0;overflow-wrap:break-word}`;
|
|
6
6
|
|
|
@@ -18,7 +18,7 @@ const ChDescriptionList = class {
|
|
|
18
18
|
return COLUMNS.has(this.columns) ? this.columns : '1';
|
|
19
19
|
}
|
|
20
20
|
render() {
|
|
21
|
-
return (index.h(index.Host, { key: '
|
|
21
|
+
return (index.h(index.Host, { key: '1fd1228705a78196b618efc4b9665de038663ae5' }, index.h("dl", { key: '0b724aa3c5dec011106347d9d29d0420f723012f', class: `list list--columns-${this.columnCount}` }, index.h("slot", { key: '4da2c6965568cf7d2f93ee98e131a7bede26d5dc' }))));
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
24
|
ChDescriptionList.style = chDescriptionListCss();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index-
|
|
3
|
+
var index = require('./index-C6khqyw3.js');
|
|
4
4
|
|
|
5
5
|
const chDividerCss = () => `:host{display:block}:host(.divider--vertical){display:inline-block;height:100%;align-self:stretch}.divider{margin:0;border:none;background:var(--border)}.divider--horizontal{width:100%;height:var(--border-width)}.divider--vertical{width:var(--border-width);height:100%}`;
|
|
6
6
|
|
|
@@ -13,7 +13,7 @@ const ChDivider = class {
|
|
|
13
13
|
*/
|
|
14
14
|
orientation = 'horizontal';
|
|
15
15
|
render() {
|
|
16
|
-
return (index.h(index.Host, { key: '
|
|
16
|
+
return (index.h(index.Host, { key: 'cc193b7e7229de8ff96eb056bd345cc8d666004b', class: { 'divider--vertical': this.orientation === 'vertical' } }, index.h("hr", { key: '659320c0372d208aab9b13d471427e479499a72c', class: { divider: true, [`divider--${this.orientation}`]: true }, "aria-orientation": this.orientation })));
|
|
17
17
|
}
|
|
18
18
|
};
|
|
19
19
|
ChDivider.style = chDividerCss();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index-
|
|
3
|
+
var index = require('./index-C6khqyw3.js');
|
|
4
4
|
var scrollLock = require('./scroll-lock-DIRqLP4K.js');
|
|
5
5
|
|
|
6
6
|
const chDrawerCss = () => `.drawer{position:fixed;inset:0;margin:0;box-sizing:border-box;flex-direction:column;gap:var(--spacing-2xl);width:min(24rem, 100vw);height:100vh;height:100dvh;max-width:100vw;max-height:100dvh;padding:var(--spacing-5xl);border:var(--border-width) solid var(--border);border-radius:0;background:var(--color-background-base);color:var(--text);font-family:var(--font-body);font-size:var(--typography-size-md);overflow:hidden}.drawer[open]{display:flex}.drawer--start{inset:0 auto 0 0;border-inline-start:none;animation:drawer-in-start var(--duration-normal) var(--easing-default)}.drawer--end{inset:0 0 0 auto;border-inline-end:none;animation:drawer-in-end var(--duration-normal) var(--easing-default)}.drawer--top{inset:0 0 auto 0;width:100vw;height:auto;max-height:80dvh;border-block-start:none;animation:drawer-in-top var(--duration-normal) var(--easing-default)}.drawer--bottom{inset:auto 0 0 0;width:100vw;height:auto;max-height:80dvh;border-block-end:none;animation:drawer-in-bottom var(--duration-normal) var(--easing-default)}.drawer::backdrop{background:var(--color-scrim-default);backdrop-filter:blur(var(--effect-blur))}.drawer-head{display:flex;align-items:flex-start;justify-content:space-between;gap:var(--spacing-2xl);flex:none}.drawer-body{flex:1;min-height:0;overflow-y:auto}::slotted([slot='footer']){display:flex;align-items:center;justify-content:flex-end;gap:var(--spacing-md);flex:none;padding-top:var(--spacing-2xl);border-top:var(--border-width) solid var(--border)}.drawer-close{display:inline-flex;align-items:center;justify-content:center;flex:none;padding:var(--spacing-2xs) var(--spacing-md);border:0;border-radius:var(--radius);background:none;color:var(--text-muted);cursor:pointer;font-family:var(--font-heading);font-size:var(--typography-size-lg);line-height:1;transition:background-color var(--duration-normal) var(--easing-default)}.drawer-close:hover{background:var(--surface-hover);color:var(--text)}.drawer-close:focus-visible{outline:var(--focus-outline-width) solid var(--accent);outline-offset:var(--focus-outline-offset)}@keyframes drawer-in-start{from{transform:translateX(-100%)}}@keyframes drawer-in-end{from{transform:translateX(100%)}}@keyframes drawer-in-top{from{transform:translateY(-100%)}}@keyframes drawer-in-bottom{from{transform:translateY(100%)}}@media (pointer: coarse){.drawer-close{min-width:44px;min-height:44px}}@media (prefers-reduced-motion: reduce){.drawer{animation:none}.drawer-close{transition:none}}`;
|
|
@@ -138,7 +138,7 @@ const ChDrawer = class {
|
|
|
138
138
|
this.chClose.emit();
|
|
139
139
|
};
|
|
140
140
|
render() {
|
|
141
|
-
return (index.h(index.Host, { key: '
|
|
141
|
+
return (index.h(index.Host, { key: '1a51b3f19b956fe860fe4def9f2ac23eac7f86ac' }, index.h("dialog", { key: 'ad7366eb2e6274962faa2a1564a06ecc3268329c', class: { drawer: true, [`drawer--${this.side}`]: true }, "aria-label": this.label, ref: el => (this.dialog = el) }, index.h("div", { key: 'ce532be71c35234f1713051e5669f1cf9316031e', class: "drawer-head" }, index.h("slot", { key: 'b522a8f26dddefd2aaf146134ac24e026a5eb72a', name: "header" }), this.closeLabel && (index.h("button", { key: 'b51fb4e20797cd82661c72c9250b0875338180f0', class: "drawer-close", type: "button", "aria-label": this.closeLabel, onClick: this.handleCloseClick }, index.h("span", { key: 'dd21e30fcb74f08c80b1c2ba79696e1d54bf4c26', "aria-hidden": "true" }, "\u00D7")))), index.h("div", { key: 'eacafa24e5af7c107e09a7cbfdfc93ae6f373dc5', class: "drawer-body" }, index.h("slot", { key: 'ddf9370c27956bc2954a3af29064394d37ec5e67' })), index.h("slot", { key: '0065c8f5bafb14791e63d15bbec0ec2ba533c222', name: "footer" }))));
|
|
142
142
|
}
|
|
143
143
|
static get watchers() { return {
|
|
144
144
|
"open": [{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index-
|
|
3
|
+
var index = require('./index-C6khqyw3.js');
|
|
4
4
|
|
|
5
5
|
const aaaa = "aaaa";
|
|
6
6
|
const ameno = "ameno";
|
|
@@ -84,7 +84,7 @@ const ChEmoji = class {
|
|
|
84
84
|
this.loaded = true;
|
|
85
85
|
};
|
|
86
86
|
render() {
|
|
87
|
-
return (index.h(index.Host, { key: '
|
|
87
|
+
return (index.h(index.Host, { key: 'd6e224a01b95fdebb4525b30b326585ee96e1050' }, index.h("img", { key: '6bc232d8f25e0099c9e2794f15b8e47f6c2dbb22', class: {
|
|
88
88
|
'emoji': true,
|
|
89
89
|
[`emoji--${this.size}`]: true,
|
|
90
90
|
'emoji--hidden': !this.loaded,
|