@threadlabs/looma 0.1.23 → 0.1.25
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/chunk-HNFCGIBP.js +8 -0
- package/dist/chunk-NB6DBRXQ.js +323 -0
- package/dist/{chunk-GDMQKT5F.js → chunk-UY423IKN.js} +33 -30
- package/dist/cjs/controlled-state-BFya8rAX.js +9 -0
- package/dist/cjs/icons-BAdjrnhS.js +680 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/looma.cjs.js +1 -1
- package/dist/cjs/ui-affordance-scope.cjs.entry.js +1 -1
- package/dist/cjs/ui-avatar-group.cjs.entry.js +9 -17
- package/dist/cjs/ui-avatar.cjs.entry.js +2 -2
- package/dist/cjs/ui-badge.cjs.entry.js +2 -2
- package/dist/cjs/ui-button.cjs.entry.js +1 -1
- package/dist/cjs/ui-callout.cjs.entry.js +27 -0
- package/dist/cjs/ui-checkbox.cjs.entry.js +13 -7
- package/dist/cjs/{ui-combobox.cjs.entry.js → ui-chip_2.cjs.entry.js} +29 -4
- package/dist/cjs/ui-context-menu.cjs.entry.js +1 -1
- package/dist/cjs/ui-dialog.cjs.entry.js +44 -8
- package/dist/cjs/ui-disclosure.cjs.entry.js +9 -6
- package/dist/cjs/ui-editable.cjs.entry.js +100 -0
- package/dist/cjs/ui-floating-action-button.cjs.entry.js +1 -1
- package/dist/cjs/ui-form-field.cjs.entry.js +59 -4
- package/dist/cjs/ui-icon-button.cjs.entry.js +1 -1
- package/dist/cjs/ui-input.cjs.entry.js +1 -1
- package/dist/cjs/ui-menu-item.cjs.entry.js +2 -2
- package/dist/cjs/ui-menu.cjs.entry.js +14 -9
- package/dist/cjs/ui-multi-combobox.cjs.entry.js +158 -0
- package/dist/cjs/ui-popover.cjs.entry.js +10 -7
- package/dist/cjs/ui-radio-group.cjs.entry.js +1 -1
- package/dist/cjs/ui-radio.cjs.entry.js +16 -7
- package/dist/cjs/ui-search-result-row.cjs.entry.js +1 -1
- package/dist/cjs/ui-search-shell.cjs.entry.js +1 -1
- package/dist/cjs/ui-select.cjs.entry.js +1 -1
- package/dist/cjs/ui-switch.cjs.entry.js +19 -10
- package/dist/cjs/ui-tabs.cjs.entry.js +10 -9
- package/dist/cjs/ui-textarea.cjs.entry.js +1 -1
- package/dist/cjs/ui-toast-region.cjs.entry.js +30 -19
- package/dist/cjs/ui-tooltip.cjs.entry.js +12 -8
- package/dist/cjs/ui-top-bar.cjs.entry.js +1 -1
- package/dist/cjs/ui-tree-item.cjs.entry.js +54 -617
- package/dist/cjs/ui-tree.cjs.entry.js +123 -11
- package/dist/collection/collection-manifest.json +4 -0
- package/dist/collection/components/ui-affordance-scope/ui-affordance-scope.js +1 -1
- package/dist/collection/components/ui-avatar/ui-avatar.css +4 -4
- package/dist/collection/components/ui-avatar/ui-avatar.js +1 -1
- package/dist/collection/components/ui-avatar-group/ui-avatar-group.css +2 -2
- package/dist/collection/components/ui-avatar-group/ui-avatar-group.js +8 -16
- package/dist/collection/components/ui-badge/ui-badge.css +64 -48
- package/dist/collection/components/ui-badge/ui-badge.js +1 -1
- package/dist/collection/components/ui-button/ui-button.js +1 -1
- package/dist/collection/components/ui-callout/ui-callout.css +74 -0
- package/dist/collection/components/ui-callout/ui-callout.js +59 -0
- package/dist/collection/components/ui-checkbox/ui-checkbox.js +16 -11
- package/dist/collection/components/ui-chip/ui-chip.css +47 -0
- package/dist/collection/components/ui-chip/ui-chip.js +67 -0
- package/dist/collection/components/ui-combobox/ui-combobox.js +49 -4
- package/dist/collection/components/ui-context-menu/ui-context-menu.js +1 -1
- package/dist/collection/components/ui-dialog/ui-dialog.js +49 -13
- package/dist/collection/components/ui-disclosure/ui-disclosure.js +12 -10
- package/dist/collection/components/ui-editable/ui-editable.css +2 -0
- package/dist/collection/components/ui-editable/ui-editable.js +196 -0
- package/dist/collection/components/ui-floating-action-button/ui-floating-action-button.js +1 -1
- package/dist/collection/components/ui-form-field/ui-form-field.js +59 -4
- package/dist/collection/components/ui-icon-button/ui-icon-button.js +1 -1
- package/dist/collection/components/ui-input/ui-input.js +1 -1
- package/dist/collection/components/ui-menu/ui-menu.css +12 -23
- package/dist/collection/components/ui-menu/ui-menu.js +16 -12
- package/dist/collection/components/ui-menu-item/ui-menu-item.css +9 -3
- package/dist/collection/components/ui-menu-item/ui-menu-item.js +1 -1
- package/dist/collection/components/ui-multi-combobox/ui-multi-combobox.css +29 -0
- package/dist/collection/components/ui-multi-combobox/ui-multi-combobox.js +503 -0
- package/dist/collection/components/ui-popover/ui-popover.css +14 -5
- package/dist/collection/components/ui-popover/ui-popover.js +12 -10
- package/dist/collection/components/ui-radio/ui-radio.js +24 -11
- package/dist/collection/components/ui-radio-group/ui-radio-group.js +1 -1
- package/dist/collection/components/ui-search-result-row/ui-search-result-row.js +1 -1
- package/dist/collection/components/ui-search-shell/ui-search-shell.js +1 -1
- package/dist/collection/components/ui-select/ui-select.js +1 -1
- package/dist/collection/components/ui-switch/ui-switch.js +22 -14
- package/dist/collection/components/ui-tabs/ui-tabs.js +13 -13
- package/dist/collection/components/ui-textarea/ui-textarea.js +1 -1
- package/dist/collection/components/ui-toast-region/ui-toast-region.js +30 -19
- package/dist/collection/components/ui-tooltip/ui-tooltip.css +16 -7
- package/dist/collection/components/ui-tooltip/ui-tooltip.js +14 -11
- package/dist/collection/components/ui-top-bar/ui-top-bar.js +1 -1
- package/dist/collection/components/ui-tree/ui-tree.css +2 -1
- package/dist/collection/components/ui-tree/ui-tree.js +122 -10
- package/dist/collection/components/ui-tree-item/ui-tree-item.js +61 -44
- package/dist/collection/field/editable.js +1 -0
- package/dist/collection/field/multi-combobox.js +1 -0
- package/dist/collection/icons.js +6 -1
- package/dist/collection/utils/controlled-state.js +4 -0
- package/dist/components/index.d.ts +8 -0
- package/dist/components/index.js +1 -1
- package/dist/components/p-B9CzOHvE.js +1 -0
- package/dist/components/p-BMgIcOh-.js +1 -0
- package/dist/components/p-BVteuP_d.js +1 -0
- package/dist/components/p-BnGhGgTH.js +1 -0
- package/dist/components/p-C6p-ygxq.js +1 -0
- package/dist/components/p-CoFximGM.js +13 -0
- package/dist/components/ui-affordance-scope.js +1 -1
- package/dist/components/ui-avatar-group.js +1 -1
- package/dist/components/ui-avatar.js +1 -1
- package/dist/components/ui-badge.js +1 -1
- package/dist/components/ui-button.js +1 -1
- package/dist/components/ui-callout.d.ts +11 -0
- package/dist/components/ui-callout.js +1 -0
- package/dist/components/ui-checkbox.js +1 -1
- package/dist/components/ui-chip.d.ts +11 -0
- package/dist/components/ui-chip.js +1 -0
- package/dist/components/ui-combobox.js +1 -1
- package/dist/components/ui-context-menu.js +1 -1
- package/dist/components/ui-dialog.js +1 -1
- package/dist/components/ui-disclosure.js +1 -1
- package/dist/components/ui-editable.d.ts +11 -0
- package/dist/components/ui-editable.js +1 -0
- package/dist/components/ui-floating-action-button.js +1 -1
- package/dist/components/ui-form-field.js +1 -1
- package/dist/components/ui-icon-button.js +1 -1
- package/dist/components/ui-input.js +1 -1
- package/dist/components/ui-menu-item.js +1 -1
- package/dist/components/ui-menu.js +1 -1
- package/dist/components/ui-multi-combobox.d.ts +11 -0
- package/dist/components/ui-multi-combobox.js +1 -0
- package/dist/components/ui-popover.js +1 -1
- package/dist/components/ui-radio-group.js +1 -1
- package/dist/components/ui-radio.js +1 -1
- package/dist/components/ui-search-result-row.js +1 -1
- package/dist/components/ui-search-shell.js +1 -1
- package/dist/components/ui-select.js +1 -1
- package/dist/components/ui-switch.js +1 -1
- package/dist/components/ui-tabs.js +1 -1
- package/dist/components/ui-textarea.js +1 -1
- package/dist/components/ui-toast-region.js +1 -1
- package/dist/components/ui-tooltip.js +1 -1
- package/dist/components/ui-top-bar.js +1 -1
- package/dist/components/ui-tree-item.js +1 -13
- package/dist/components/ui-tree.js +1 -1
- package/dist/esm/controlled-state-BnGhGgTH.js +6 -0
- package/dist/esm/icons-CoFximGM.js +678 -0
- package/dist/esm/loader.js +1 -1
- package/dist/esm/looma.js +1 -1
- package/dist/esm/ui-affordance-scope.entry.js +1 -1
- package/dist/esm/ui-avatar-group.entry.js +9 -17
- package/dist/esm/ui-avatar.entry.js +2 -2
- package/dist/esm/ui-badge.entry.js +2 -2
- package/dist/esm/ui-button.entry.js +1 -1
- package/dist/esm/ui-callout.entry.js +25 -0
- package/dist/esm/ui-checkbox.entry.js +13 -7
- package/dist/esm/{ui-combobox.entry.js → ui-chip_2.entry.js} +30 -6
- package/dist/esm/ui-context-menu.entry.js +1 -1
- package/dist/esm/ui-dialog.entry.js +44 -8
- package/dist/esm/ui-disclosure.entry.js +9 -6
- package/dist/esm/ui-editable.entry.js +98 -0
- package/dist/esm/ui-floating-action-button.entry.js +1 -1
- package/dist/esm/ui-form-field.entry.js +59 -4
- package/dist/esm/ui-icon-button.entry.js +1 -1
- package/dist/esm/ui-input.entry.js +1 -1
- package/dist/esm/ui-menu-item.entry.js +2 -2
- package/dist/esm/ui-menu.entry.js +14 -9
- package/dist/esm/ui-multi-combobox.entry.js +156 -0
- package/dist/esm/ui-popover.entry.js +10 -7
- package/dist/esm/ui-radio-group.entry.js +1 -1
- package/dist/esm/ui-radio.entry.js +16 -7
- package/dist/esm/ui-search-result-row.entry.js +1 -1
- package/dist/esm/ui-search-shell.entry.js +1 -1
- package/dist/esm/ui-select.entry.js +1 -1
- package/dist/esm/ui-switch.entry.js +19 -10
- package/dist/esm/ui-tabs.entry.js +10 -9
- package/dist/esm/ui-textarea.entry.js +1 -1
- package/dist/esm/ui-toast-region.entry.js +30 -19
- package/dist/esm/ui-tooltip.entry.js +12 -8
- package/dist/esm/ui-top-bar.entry.js +1 -1
- package/dist/esm/ui-tree-item.entry.js +54 -617
- package/dist/esm/ui-tree.entry.js +123 -11
- package/dist/index.cjs +1552 -894
- package/dist/index.d.cts +23 -1
- package/dist/index.d.ts +23 -1
- package/dist/index.js +12 -2
- package/dist/looma/looma.esm.js +1 -1
- package/dist/looma/p-08f80207.entry.js +1 -0
- package/dist/looma/{p-ed368426.entry.js → p-0e1741cb.entry.js} +1 -1
- package/dist/looma/p-0ef4bf13.entry.js +1 -0
- package/dist/looma/{p-7e0bb7f6.entry.js → p-166f8593.entry.js} +1 -1
- package/dist/looma/p-262a542c.entry.js +1 -0
- package/dist/looma/{p-13347631.entry.js → p-26d357ae.entry.js} +1 -1
- package/dist/looma/p-30f01909.entry.js +1 -0
- package/dist/looma/p-393e3e02.entry.js +1 -0
- package/dist/looma/p-3a44b9f9.entry.js +1 -0
- package/dist/looma/p-558d4f5b.entry.js +1 -0
- package/dist/looma/{p-5a87b59d.entry.js → p-5780cefa.entry.js} +1 -1
- package/dist/looma/p-5a7261e1.entry.js +1 -0
- package/dist/looma/p-5fdcee1d.entry.js +1 -0
- package/dist/looma/{p-add36e74.entry.js → p-72338f53.entry.js} +1 -1
- package/dist/looma/p-7319c147.entry.js +1 -0
- package/dist/looma/p-78b7e466.entry.js +1 -0
- package/dist/looma/{p-a90d2821.entry.js → p-7ab661ec.entry.js} +1 -1
- package/dist/looma/p-7eb04f09.entry.js +1 -0
- package/dist/looma/{p-69a5557b.entry.js → p-81c533f5.entry.js} +1 -1
- package/dist/looma/p-87f501cf.entry.js +1 -0
- package/dist/looma/p-89e71bbb.entry.js +1 -0
- package/dist/looma/{p-8b8840b8.entry.js → p-92cd1841.entry.js} +1 -1
- package/dist/looma/{p-f0487ff3.entry.js → p-95eb3b58.entry.js} +1 -1
- package/dist/looma/p-96ec4d7a.entry.js +1 -0
- package/dist/looma/p-9d2662ca.entry.js +1 -0
- package/dist/looma/p-BnGhGgTH.js +1 -0
- package/dist/looma/p-CoFximGM.js +13 -0
- package/dist/looma/p-add67e4c.entry.js +1 -0
- package/dist/looma/p-b6c776fb.entry.js +1 -0
- package/dist/looma/p-bcb1b47b.entry.js +1 -0
- package/dist/looma/p-d56571a2.entry.js +1 -0
- package/dist/looma/{p-582973b5.entry.js → p-d62da01d.entry.js} +1 -1
- package/dist/looma/{p-f74e5546.entry.js → p-dbcb479c.entry.js} +1 -1
- package/dist/looma/p-e14024bf.entry.js +1 -0
- package/dist/looma/{p-5da09f47.entry.js → p-fc180770.entry.js} +1 -1
- package/dist/types/components/ui-avatar-group/ui-avatar-group.d.ts +1 -2
- package/dist/types/components/ui-callout/ui-callout.d.ts +6 -0
- package/dist/types/components/ui-checkbox/ui-checkbox.d.ts +2 -1
- package/dist/types/components/ui-chip/ui-chip.d.ts +8 -0
- package/dist/types/components/ui-combobox/ui-combobox.d.ts +4 -0
- package/dist/types/components/ui-dialog/ui-dialog.d.ts +7 -1
- package/dist/types/components/ui-disclosure/ui-disclosure.d.ts +2 -1
- package/dist/types/components/ui-editable/ui-editable.d.ts +24 -0
- package/dist/types/components/ui-form-field/ui-form-field.d.ts +8 -0
- package/dist/types/components/ui-menu/ui-menu.d.ts +2 -1
- package/dist/types/components/ui-multi-combobox/ui-multi-combobox.d.ts +47 -0
- package/dist/types/components/ui-popover/ui-popover.d.ts +2 -1
- package/dist/types/components/ui-radio/ui-radio.d.ts +4 -1
- package/dist/types/components/ui-switch/ui-switch.d.ts +2 -1
- package/dist/types/components/ui-tabs/ui-tabs.d.ts +2 -1
- package/dist/types/components/ui-toast-region/ui-toast-region.d.ts +3 -1
- package/dist/types/components/ui-tooltip/ui-tooltip.d.ts +2 -1
- package/dist/types/components/ui-tree/ui-tree.d.ts +12 -0
- package/dist/types/components/ui-tree-item/ui-tree-item.d.ts +11 -7
- package/dist/types/components.d.ts +343 -46
- package/dist/types/field/editable.d.ts +5 -0
- package/dist/types/field/multi-combobox.d.ts +11 -0
- package/dist/types/icons.d.ts +5 -0
- package/dist/types/utils/controlled-state.d.ts +4 -0
- package/dist/{ui-affordance-scope.entry-VO4C2MZX.js → ui-affordance-scope.entry-VSSP52ZP.js} +2 -2
- package/dist/ui-avatar-group.entry-JMCLL6FW.js +51 -0
- package/dist/{ui-avatar.entry-T6FU6ZYM.js → ui-avatar.entry-X2YQ3QPG.js} +3 -3
- package/dist/ui-badge.entry-OJ6FJJKL.js +22 -0
- package/dist/{ui-button.entry-7UXMUGHN.js → ui-button.entry-ZN6JLND7.js} +2 -2
- package/dist/ui-callout.entry-7K6NXQ7U.js +32 -0
- package/dist/{ui-checkbox.entry-DMZJB3RE.js → ui-checkbox.entry-GUYRVU6O.js} +17 -8
- package/dist/{ui-combobox.entry-ZCTPXEES.js → ui-chip_2.entry-M2DOTIGY.js} +32 -7
- package/dist/{ui-context-menu.entry-2WMCBGCP.js → ui-context-menu.entry-BM7FHOUJ.js} +5 -5
- package/dist/{ui-dialog.entry-WO23XOSW.js → ui-dialog.entry-AZAD37CG.js} +50 -12
- package/dist/{ui-disclosure.entry-USX7OUEW.js → ui-disclosure.entry-XDPGKMBK.js} +13 -7
- package/dist/ui-editable.entry-S3TE6KFT.js +110 -0
- package/dist/{ui-floating-action-button.entry-MXDIN7MV.js → ui-floating-action-button.entry-U7HGA3CS.js} +2 -2
- package/dist/ui-form-field.entry-C2ZSP3TM.js +120 -0
- package/dist/{ui-icon-button.entry-MJUNXHBU.js → ui-icon-button.entry-P6H2LY7D.js} +2 -2
- package/dist/{ui-input.entry-AWG63YIG.js → ui-input.entry-GTNQJCQ2.js} +2 -2
- package/dist/ui-menu-item.entry-2HWOGUO5.js +22 -0
- package/dist/{ui-menu.entry-IT3GW5TL.js → ui-menu.entry-NZ7ER54K.js} +22 -14
- package/dist/ui-multi-combobox.entry-DZ5LLSVQ.js +167 -0
- package/dist/{ui-popover.entry-ZQQB4N6E.js → ui-popover.entry-ZOEQMUWG.js} +17 -11
- package/dist/{ui-radio-group.entry-V7PCTS7I.js → ui-radio-group.entry-QCQ46EK5.js} +2 -2
- package/dist/{ui-radio.entry-JYH6TQBI.js → ui-radio.entry-QAATWUYT.js} +20 -8
- package/dist/{ui-search-result-row.entry-JBNYXXUN.js → ui-search-result-row.entry-2I3DH2OT.js} +2 -2
- package/dist/{ui-search-shell.entry-TEAWE76O.js → ui-search-shell.entry-7RS55ORF.js} +2 -2
- package/dist/{ui-select.entry-F3A6TE2U.js → ui-select.entry-6O4KD4G7.js} +2 -2
- package/dist/{ui-switch.entry-MJIICMP2.js → ui-switch.entry-DY5PSHCQ.js} +23 -11
- package/dist/{ui-tabs.entry-6REFIUHV.js → ui-tabs.entry-6X56UOUE.js} +14 -10
- package/dist/{ui-textarea.entry-OJTXCED7.js → ui-textarea.entry-RDYP6O77.js} +2 -2
- package/dist/{ui-toast-region.entry-NOFXLKPS.js → ui-toast-region.entry-EBY42KS5.js} +32 -23
- package/dist/{ui-tooltip.entry-COWTWVHX.js → ui-tooltip.entry-PLXMPOKV.js} +19 -12
- package/dist/{ui-top-bar.entry-PIAWXJNV.js → ui-top-bar.entry-QKE2DLVD.js} +2 -2
- package/dist/ui-tree-item.entry-TC6YWIC6.js +145 -0
- package/dist/{ui-tree.entry-XYI3ZFAZ.js → ui-tree.entry-UL6UHCUT.js} +114 -12
- package/editor/{chunk-QCOYOVQL.js → chunk-B5WVJOPV.js} +113 -97
- package/editor/extensions/index.d.ts +14 -6
- package/editor/extensions/index.js +1 -1
- package/editor/index.js +1 -1
- package/editor.css +37 -20
- package/package.json +1 -1
- package/styles.css +10 -0
- package/tokens.css +3 -0
- package/vue/{chunk-JLW23USW.js → chunk-GXQY27K2.js} +112 -17
- package/vue/editor/index.d.ts +5 -15
- package/vue/editor/index.js +1 -1
- package/vue/index.d.ts +442 -116
- package/vue/index.js +9 -1
- package/dist/components/p-CaietZcq.js +0 -1
- package/dist/components/p-DHd18bK7.js +0 -1
- package/dist/looma/p-14c081cf.entry.js +0 -1
- package/dist/looma/p-25366205.entry.js +0 -1
- package/dist/looma/p-2e3aa869.entry.js +0 -1
- package/dist/looma/p-40fe7fee.entry.js +0 -1
- package/dist/looma/p-446cda76.entry.js +0 -1
- package/dist/looma/p-4fc1b005.entry.js +0 -13
- package/dist/looma/p-6a8a4736.entry.js +0 -1
- package/dist/looma/p-6bf4038b.entry.js +0 -1
- package/dist/looma/p-8204fee6.entry.js +0 -1
- package/dist/looma/p-8238e0dc.entry.js +0 -1
- package/dist/looma/p-99d88efb.entry.js +0 -1
- package/dist/looma/p-a27669b1.entry.js +0 -1
- package/dist/looma/p-a6ee76b7.entry.js +0 -1
- package/dist/looma/p-b6398a6b.entry.js +0 -1
- package/dist/looma/p-d50faaff.entry.js +0 -1
- package/dist/looma/p-d77278ce.entry.js +0 -1
- package/dist/looma/p-d9ec13b7.entry.js +0 -1
- package/dist/looma/p-ecf8005f.entry.js +0 -1
- package/dist/ui-avatar-group.entry-TAXJRIIU.js +0 -59
- package/dist/ui-badge.entry-MZFYNBMJ.js +0 -22
- package/dist/ui-form-field.entry-7ZCMEHPY.js +0 -67
- package/dist/ui-menu-item.entry-HFTWG62N.js +0 -22
- package/dist/ui-tree-item.entry-BSEWNL2O.js +0 -389
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { Host, h } from "@stencil/core";
|
|
2
2
|
import { eventToTrigger, dispatchDetail } from "../../utils/events";
|
|
3
|
+
import { controlledOrDefault, isControlled } from "../../utils/controlled-state";
|
|
3
4
|
export class UICheckbox {
|
|
4
5
|
host;
|
|
5
|
-
checked
|
|
6
|
+
/** Controlled checked state. Omit it to use defaultChecked and local interaction state. */
|
|
7
|
+
checked;
|
|
6
8
|
defaultChecked = false;
|
|
7
9
|
disabled = false;
|
|
8
10
|
indeterminate = false;
|
|
@@ -11,7 +13,8 @@ export class UICheckbox {
|
|
|
11
13
|
internalChecked = false;
|
|
12
14
|
slotRef;
|
|
13
15
|
syncFromProp() {
|
|
14
|
-
|
|
16
|
+
if (isControlled(this.checked))
|
|
17
|
+
this.internalChecked = this.checked;
|
|
15
18
|
}
|
|
16
19
|
syncToInput() {
|
|
17
20
|
const input = this.getInput();
|
|
@@ -26,8 +29,7 @@ export class UICheckbox {
|
|
|
26
29
|
input.value = this.value;
|
|
27
30
|
}
|
|
28
31
|
componentDidLoad() {
|
|
29
|
-
this.
|
|
30
|
-
this.internalChecked = this.internalChecked || this.defaultChecked;
|
|
32
|
+
this.internalChecked = controlledOrDefault(this.checked, this.defaultChecked);
|
|
31
33
|
this.slotRef?.addEventListener('slotchange', () => this.syncToInput());
|
|
32
34
|
this.syncToInput();
|
|
33
35
|
const input = this.getInput();
|
|
@@ -49,16 +51,20 @@ export class UICheckbox {
|
|
|
49
51
|
const input = e.target;
|
|
50
52
|
if (!input)
|
|
51
53
|
return;
|
|
52
|
-
|
|
54
|
+
const checked = input.checked;
|
|
55
|
+
if (!isControlled(this.checked))
|
|
56
|
+
this.internalChecked = checked;
|
|
57
|
+
else
|
|
58
|
+
this.syncToInput();
|
|
53
59
|
this.indeterminate = input.indeterminate;
|
|
54
60
|
dispatchDetail(this.host, 'change', {
|
|
55
|
-
checked
|
|
61
|
+
checked,
|
|
56
62
|
value: this.value,
|
|
57
63
|
trigger: eventToTrigger(e),
|
|
58
64
|
});
|
|
59
65
|
};
|
|
60
66
|
render() {
|
|
61
|
-
return (h(Host, { key: '
|
|
67
|
+
return (h(Host, { key: 'eb46eb41a5ab871058960bd2aa1163a03144bc0f', role: "checkbox", "aria-checked": this.indeterminate ? 'mixed' : String(this.internalChecked), "aria-disabled": String(this.disabled), "data-disabled": this.disabled ? '' : undefined }, h("slot", { key: 'ce18b1f1b63efebf048cd67b87064641cf4d915c', ref: (el) => (this.slotRef = el) })));
|
|
62
68
|
}
|
|
63
69
|
static get is() { return "ui-checkbox"; }
|
|
64
70
|
static get encapsulation() { return "shadow"; }
|
|
@@ -83,16 +89,15 @@ export class UICheckbox {
|
|
|
83
89
|
"references": {}
|
|
84
90
|
},
|
|
85
91
|
"required": false,
|
|
86
|
-
"optional":
|
|
92
|
+
"optional": true,
|
|
87
93
|
"docs": {
|
|
88
94
|
"tags": [],
|
|
89
|
-
"text": ""
|
|
95
|
+
"text": "Controlled checked state. Omit it to use defaultChecked and local interaction state."
|
|
90
96
|
},
|
|
91
97
|
"getter": false,
|
|
92
98
|
"setter": false,
|
|
93
99
|
"reflect": false,
|
|
94
|
-
"attribute": "checked"
|
|
95
|
-
"defaultValue": "false"
|
|
100
|
+
"attribute": "checked"
|
|
96
101
|
},
|
|
97
102
|
"defaultChecked": {
|
|
98
103
|
"type": "boolean",
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
--ui-chip-surface: var(--ui-surface-subtle);
|
|
3
|
+
--ui-chip-text: var(--ui-text-secondary);
|
|
4
|
+
--ui-chip-border: var(--ui-border-default);
|
|
5
|
+
--ui-chip-font-size: var(--ui-font-size-xs);
|
|
6
|
+
--ui-chip-font-weight: var(--ui-font-normal);
|
|
7
|
+
--ui-chip-line-height: var(--ui-line-height-tight);
|
|
8
|
+
--ui-chip-padding-block: var(--ui-space-0-5);
|
|
9
|
+
--ui-chip-padding-inline: var(--ui-space-2);
|
|
10
|
+
--ui-chip-notch: var(--ui-space-1);
|
|
11
|
+
|
|
12
|
+
display: inline-flex;
|
|
13
|
+
max-width: 100%;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
:host([data-size='sm']) {
|
|
17
|
+
--ui-chip-font-size: var(--ui-font-size-sm);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.chip__surface {
|
|
21
|
+
display: inline-flex;
|
|
22
|
+
align-items: center;
|
|
23
|
+
max-width: 100%;
|
|
24
|
+
padding: var(--ui-chip-padding-block) var(--ui-chip-padding-inline);
|
|
25
|
+
border: 1px solid var(--ui-chip-border);
|
|
26
|
+
background: var(--ui-chip-surface);
|
|
27
|
+
/* The shared light-DOM reset establishes a baseline host color; the chip's
|
|
28
|
+
semantic text hook must remain authoritative for consumer color systems. */
|
|
29
|
+
color: var(--ui-chip-text) !important;
|
|
30
|
+
/* The shared light-DOM reset establishes inherited defaults; this compact
|
|
31
|
+
metadata primitive owns its own typography contract. */
|
|
32
|
+
font-family: var(--ui-font-family-sans) !important;
|
|
33
|
+
font-size: var(--ui-chip-font-size) !important;
|
|
34
|
+
font-weight: var(--ui-chip-font-weight) !important;
|
|
35
|
+
line-height: var(--ui-chip-line-height) !important;
|
|
36
|
+
white-space: nowrap;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
:host([data-appearance='pill']) .chip__surface {
|
|
40
|
+
border-radius: var(--ui-radius-round);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
:host([data-appearance='tag']) .chip__surface {
|
|
44
|
+
border: 0;
|
|
45
|
+
padding-inline-end: calc(var(--ui-chip-padding-inline) + var(--ui-chip-notch));
|
|
46
|
+
clip-path: polygon(0 0, calc(100% - var(--ui-chip-notch)) 0, 100% 50%, calc(100% - var(--ui-chip-notch)) 100%, 0 100%);
|
|
47
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { Host, h } from "@stencil/core";
|
|
2
|
+
/** A compact, non-interactive metadata label. */
|
|
3
|
+
export class UIChip {
|
|
4
|
+
/** `tag` has a square leading edge and an angled trailing edge; `pill` is fully rounded. */
|
|
5
|
+
appearance = 'tag';
|
|
6
|
+
/** Compact typography size. */
|
|
7
|
+
size = 'xs';
|
|
8
|
+
render() {
|
|
9
|
+
return (h(Host, { key: '970cb48cf8d70c47feaab90fe428c09f0d052a03', "data-appearance": this.appearance, "data-size": this.size }, h("span", { key: '6d8c6104d2869520097a2a61bd2a887b363b4912', class: "chip__surface" }, h("slot", { key: 'b61c50a8060d8a2684aed6f87dc859b1c9e99858' }))));
|
|
10
|
+
}
|
|
11
|
+
static get is() { return "ui-chip"; }
|
|
12
|
+
static get encapsulation() { return "shadow"; }
|
|
13
|
+
static get originalStyleUrls() {
|
|
14
|
+
return {
|
|
15
|
+
"$": ["ui-chip.css"]
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
static get styleUrls() {
|
|
19
|
+
return {
|
|
20
|
+
"$": ["ui-chip.css"]
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
static get properties() {
|
|
24
|
+
return {
|
|
25
|
+
"appearance": {
|
|
26
|
+
"type": "string",
|
|
27
|
+
"mutable": false,
|
|
28
|
+
"complexType": {
|
|
29
|
+
"original": "'tag' | 'pill'",
|
|
30
|
+
"resolved": "\"pill\" | \"tag\"",
|
|
31
|
+
"references": {}
|
|
32
|
+
},
|
|
33
|
+
"required": false,
|
|
34
|
+
"optional": false,
|
|
35
|
+
"docs": {
|
|
36
|
+
"tags": [],
|
|
37
|
+
"text": "`tag` has a square leading edge and an angled trailing edge; `pill` is fully rounded."
|
|
38
|
+
},
|
|
39
|
+
"getter": false,
|
|
40
|
+
"setter": false,
|
|
41
|
+
"reflect": false,
|
|
42
|
+
"attribute": "appearance",
|
|
43
|
+
"defaultValue": "'tag'"
|
|
44
|
+
},
|
|
45
|
+
"size": {
|
|
46
|
+
"type": "string",
|
|
47
|
+
"mutable": false,
|
|
48
|
+
"complexType": {
|
|
49
|
+
"original": "'xs' | 'sm'",
|
|
50
|
+
"resolved": "\"sm\" | \"xs\"",
|
|
51
|
+
"references": {}
|
|
52
|
+
},
|
|
53
|
+
"required": false,
|
|
54
|
+
"optional": false,
|
|
55
|
+
"docs": {
|
|
56
|
+
"tags": [],
|
|
57
|
+
"text": "Compact typography size."
|
|
58
|
+
},
|
|
59
|
+
"getter": false,
|
|
60
|
+
"setter": false,
|
|
61
|
+
"reflect": false,
|
|
62
|
+
"attribute": "size",
|
|
63
|
+
"defaultValue": "'xs'"
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -21,6 +21,8 @@ export class UICombobox {
|
|
|
21
21
|
readOnly = false;
|
|
22
22
|
required = false;
|
|
23
23
|
size = 'md';
|
|
24
|
+
/** Keep the native label accessible while allowing compact composed controls. */
|
|
25
|
+
labelVisibility = 'visible';
|
|
24
26
|
disclosure = false;
|
|
25
27
|
clearable = false;
|
|
26
28
|
/** Optional description shown by the connected question-mark button. */
|
|
@@ -242,8 +244,9 @@ export class UICombobox {
|
|
|
242
244
|
}, reason === 'disclosure' ? 0 : Math.max(0, config.debounce ?? 200));
|
|
243
245
|
}
|
|
244
246
|
get canCreate() {
|
|
247
|
+
const candidates = this.config.options ? [...this.config.options, ...this.rows] : this.rows;
|
|
245
248
|
return Boolean(this.config.allowCreate && this.raw.trim() && !this.loading && !this.lookupError
|
|
246
|
-
&& !
|
|
249
|
+
&& !candidates.some(row => row.label.toLocaleLowerCase() === this.raw.toLocaleLowerCase()));
|
|
247
250
|
}
|
|
248
251
|
format(timing) {
|
|
249
252
|
if ((this.config.formatOn ?? 'blur') !== timing || !this.input)
|
|
@@ -428,19 +431,24 @@ export class UICombobox {
|
|
|
428
431
|
catch { /* Aborted work never becomes current field state. */ }
|
|
429
432
|
return this.validation;
|
|
430
433
|
}
|
|
434
|
+
/** Focus the native editing input from a composed control. */
|
|
435
|
+
async focusInput() { this.input?.focus(); }
|
|
431
436
|
render() {
|
|
432
437
|
const description = [this.helpOpen ? 'help-text' : '', this.validation.issues.length ? 'validation' : ''].filter(Boolean).join(' ') || undefined;
|
|
433
438
|
const status = this.loading ? 'Loading suggestions…' : this.lookupError || (this.expanded ? `${this.rows.length} suggestions available.` : '');
|
|
434
439
|
const groups = [...new Set(this.rows.map(row => row.group ?? ''))];
|
|
435
|
-
return h(Host, { key: '
|
|
440
|
+
return h(Host, { key: 'a33890c2824f29dfea5e22edddca4480a6d1d032', "data-size": this.size, "data-validation": this.validation.status, onFocusout: this.onFocusOut }, h("label", { key: 'c936530cf696c1d14245fd83895e9c58c908df12', htmlFor: "input", part: "label", class: this.labelVisibility === 'sr-only' ? 'sr-only' : undefined }, this.label, this.required ? ' *' : ''), h("div", { key: '0fe0ed9b15a3e256867e071ca7e4fa3abc66f27c', class: "field", part: "field", ref: element => this.field = element, onClick: event => {
|
|
441
|
+
if (!event.composedPath().some(node => node instanceof HTMLButtonElement))
|
|
442
|
+
this.input?.focus();
|
|
443
|
+
} }, h("slot", { key: '9cc4c22eb7776e415792fbdf3c17c962c7107f70', name: "start" }), h("input", { key: '0898e8ec5af57c7ba8ad227164f7955ef4011729', id: "input", ref: element => this.input = element, role: "combobox", "aria-autocomplete": "list", "aria-expanded": String(this.expanded), "aria-controls": "listbox", "aria-activedescendant": this.expanded && this.active >= 0 ? `option-${this.active}` : undefined, "aria-describedby": description, "aria-invalid": String(this.validation.status === 'error'), "aria-busy": String(this.validation.status === 'pending'), value: this.display, placeholder: this.placeholder, name: this.name || undefined, disabled: this.disabled, readOnly: this.readOnly, required: this.required, autoComplete: "off", part: "input", onInput: this.onInput, onKeyDown: this.onKeydown, onCompositionstart: () => this.composing = true, onCompositionend: () => { this.composing = false; this.onInput(new InputEvent('input')); } }), this.clearable && h("button", { key: 'f9a49484ae9bcc4ace72a46d0c59202040ff39d8', type: "button", part: "affordance", "aria-label": `Clear ${this.label}`, disabled: this.disabled || this.readOnly, onClick: () => { this.commit(null, '', null, 'clear', 'pointer'); this.close(); this.input?.focus(); } }, "\u00D7"), this.help && h("button", { key: '597106eda4dcc68aa9fb2eaa99c1edad0d68a892', id: "help", type: "button", part: "affordance", "aria-label": `Help for ${this.label}`, disabled: this.disabled }, h("span", { key: 'd26085a52b16d65e26dc20ef8afacb5defec5f7b', "aria-hidden": "true" }, "?")), this.disclosure && h("button", { key: '391d1c987eb8e868b2846eafd0627cfc78ab7478', type: "button", part: "affordance", "aria-label": `Suggestions for ${this.label}`, "aria-controls": "listbox", "aria-expanded": String(this.expanded), disabled: this.disabled || this.readOnly, onClick: () => {
|
|
436
444
|
if (this.expanded)
|
|
437
445
|
this.close();
|
|
438
446
|
else
|
|
439
447
|
this.open('disclosure');
|
|
440
448
|
this.input?.focus();
|
|
441
|
-
} }, h("span", { key: '
|
|
449
|
+
} }, h("span", { key: '45678ce468fd7944306d4542e3c6af0fe211af14', "aria-hidden": "true" }, "\u2304"))), this.help && h("ui-tooltip", { key: 'a8dc037639a60aff5a12b4651ffa10fc5ccd33eb', id: "help-text", for: "help", toggleOnClick: true, onOpen: () => this.helpOpen = true, onClose: () => this.helpOpen = false }, this.help), h("div", { key: 'f13fc7a11c3d22995035b6701ea24637a048a5b8', class: "popup", part: "popup", hidden: !this.expanded, ref: element => this.popup = element }, h("div", { key: '9d2bdfcc558f8e7de87f2915ea5607a8f32c1762', id: "listbox", role: "listbox", "aria-label": `${this.label} suggestions`, "aria-busy": String(this.loading) }, groups.map(group => h("div", { role: group ? 'group' : 'presentation', "aria-label": group || undefined }, group && h("div", { class: "group", part: "group" }, group), this.rows.map((row, index) => (row.group ?? '') !== group ? null : h("div", { id: `option-${index}`, role: "option", "aria-selected": String(this.selected === row.value), "aria-disabled": String(Boolean(row.disabled)), "data-active": this.active === index ? '' : undefined, part: "option", class: "option", onPointerDown: event => event.preventDefault(), onClick: () => this.choose(index, 'pointer') }, h("slot", { name: `option-${row.id}` }, h("span", { class: "primary", part: "option-primary" }, row.label), row.description && h("span", { class: "secondary", part: "option-secondary" }, row.description)))))), this.canCreate && h("div", { key: '9495fd43a721c84621b8083cb8eac776f843ab59', id: `option-${this.rows.length}`, role: "option", "aria-selected": "false", class: "option", part: "option", "data-active": this.active === this.rows.length ? '' : undefined, onPointerDown: event => event.preventDefault(), onClick: () => this.choose(this.rows.length, 'pointer') }, h("slot", { key: 'f0407c5622dcf3b325985c136657f8b9ac8a4ab5', name: "create" }, "Create \u201C", this.raw, "\u201D"))), this.loading ? h("div", { class: "message" }, h("slot", { name: "loading" }, "Loading suggestions\u2026"))
|
|
442
450
|
: this.lookupError ? h("div", { class: "message" }, h("slot", { name: "error" }, this.lookupError))
|
|
443
|
-
: !this.rows.length && !this.canCreate ? h("div", { class: "message" }, h("slot", { name: "empty" }, "No suggestions.")) : null), h("div", { key: '
|
|
451
|
+
: !this.rows.length && !this.canCreate ? h("div", { class: "message" }, h("slot", { name: "empty" }, "No suggestions.")) : null, h("slot", { key: 'efcaee3efb029a9e0bb4e033ab61b251331c1c93', name: "footer" })), h("div", { key: 'b44ccb319f94ebc9e6ac3204a8c1771d49485a58', id: "validation", class: "message", part: "validation", hidden: !this.validation.issues.length }, this.validation.issues.map(issue => h("div", null, issue.message))), h("div", { key: 'c3cb51dd4603734af4c7a02d8fe0bb42ac69083a', class: "sr-only", role: "status", "aria-live": "polite", "aria-atomic": "true" }, status, " ", this.validation.status === 'pending' ? 'Checking value…' : this.validation.issues.map(issue => issue.message).join(' ')));
|
|
444
452
|
}
|
|
445
453
|
static get is() { return "ui-combobox"; }
|
|
446
454
|
static get encapsulation() { return "shadow"; }
|
|
@@ -698,6 +706,26 @@ export class UICombobox {
|
|
|
698
706
|
"attribute": "size",
|
|
699
707
|
"defaultValue": "'md'"
|
|
700
708
|
},
|
|
709
|
+
"labelVisibility": {
|
|
710
|
+
"type": "string",
|
|
711
|
+
"mutable": false,
|
|
712
|
+
"complexType": {
|
|
713
|
+
"original": "'visible' | 'sr-only'",
|
|
714
|
+
"resolved": "\"sr-only\" | \"visible\"",
|
|
715
|
+
"references": {}
|
|
716
|
+
},
|
|
717
|
+
"required": false,
|
|
718
|
+
"optional": false,
|
|
719
|
+
"docs": {
|
|
720
|
+
"tags": [],
|
|
721
|
+
"text": "Keep the native label accessible while allowing compact composed controls."
|
|
722
|
+
},
|
|
723
|
+
"getter": false,
|
|
724
|
+
"setter": false,
|
|
725
|
+
"reflect": false,
|
|
726
|
+
"attribute": "label-visibility",
|
|
727
|
+
"defaultValue": "'visible'"
|
|
728
|
+
},
|
|
701
729
|
"disclosure": {
|
|
702
730
|
"type": "boolean",
|
|
703
731
|
"mutable": false,
|
|
@@ -948,6 +976,23 @@ export class UICombobox {
|
|
|
948
976
|
"text": "Validate for submission. Caller submits only non-pending, non-error output.",
|
|
949
977
|
"tags": []
|
|
950
978
|
}
|
|
979
|
+
},
|
|
980
|
+
"focusInput": {
|
|
981
|
+
"complexType": {
|
|
982
|
+
"signature": "() => Promise<void>",
|
|
983
|
+
"parameters": [],
|
|
984
|
+
"references": {
|
|
985
|
+
"Promise": {
|
|
986
|
+
"location": "global",
|
|
987
|
+
"id": "global::Promise"
|
|
988
|
+
}
|
|
989
|
+
},
|
|
990
|
+
"return": "Promise<void>"
|
|
991
|
+
},
|
|
992
|
+
"docs": {
|
|
993
|
+
"text": "Focus the native editing input from a composed control.",
|
|
994
|
+
"tags": []
|
|
995
|
+
}
|
|
951
996
|
}
|
|
952
997
|
};
|
|
953
998
|
}
|
|
@@ -212,7 +212,7 @@ export class UIContextMenu {
|
|
|
212
212
|
this.closeMenu('action', 'pointer');
|
|
213
213
|
};
|
|
214
214
|
render() {
|
|
215
|
-
return (h(Host, { key: '
|
|
215
|
+
return (h(Host, { key: '171e647667bab4a9f905f2b531aa2db182fc426f', "data-open": this.internalOpen ? '' : undefined, "data-focus-trigger": this.internalOpen ? this.focusTrigger : undefined, onKeyDown: this.onKeydown, onClick: this.onItemClick }, h("slot", { key: 'f1a15e54ab3b14515553e05b4b3cf60ed7a99f8b', name: "trigger" }), h("div", { key: '450aaacf3f75a71ecce86300c0d824452ceec4a0', class: "menu", "data-open": this.internalOpen ? '' : undefined }, h("ui-menu", { key: '667003b7c6ab3ccbaa888b25cb87d921036ab827', open: this.internalOpen }, h("slot", { key: 'c0731115bc3dbd02c4125ef8208269dd97e124bf' })))));
|
|
216
216
|
}
|
|
217
217
|
static get is() { return "ui-context-menu"; }
|
|
218
218
|
static get encapsulation() { return "shadow"; }
|
|
@@ -1,19 +1,30 @@
|
|
|
1
1
|
import { Host, h } from "@stencil/core";
|
|
2
2
|
import { openOverlay, closeOverlay, requestTopOverlayClose } from "../../overlay/manager";
|
|
3
3
|
import { dispatchDetail } from "../../utils/events";
|
|
4
|
+
import { controlledOrDefault, isControlled } from "../../utils/controlled-state";
|
|
4
5
|
export class UIDialog {
|
|
5
6
|
host;
|
|
6
|
-
open
|
|
7
|
+
/** Controlled open state. Omit it to use defaultOpen and local interaction state. */
|
|
8
|
+
open;
|
|
7
9
|
defaultOpen = false;
|
|
8
10
|
modal = true;
|
|
9
11
|
dismissible = true;
|
|
10
12
|
/** Accessible name forwarded to the native dialog surface. */
|
|
11
13
|
label;
|
|
12
14
|
internalOpen = false;
|
|
15
|
+
accessibleLabel = 'Dialog';
|
|
13
16
|
overlayId = `ui-dialog-${Math.random().toString(36).slice(2, 11)}`;
|
|
14
17
|
dialogRef;
|
|
18
|
+
contentObserver = null;
|
|
15
19
|
syncFromProp() {
|
|
16
|
-
|
|
20
|
+
if (isControlled(this.open))
|
|
21
|
+
this.internalOpen = this.open;
|
|
22
|
+
}
|
|
23
|
+
syncLabelFromProp() {
|
|
24
|
+
this.syncAccessibleLabel();
|
|
25
|
+
}
|
|
26
|
+
componentWillLoad() {
|
|
27
|
+
this.syncAccessibleLabel();
|
|
17
28
|
}
|
|
18
29
|
syncOpen() {
|
|
19
30
|
if (this.dialogRef) {
|
|
@@ -34,20 +45,29 @@ export class UIDialog {
|
|
|
34
45
|
}
|
|
35
46
|
}
|
|
36
47
|
componentDidLoad() {
|
|
37
|
-
this.
|
|
38
|
-
this.
|
|
48
|
+
this.contentObserver = new MutationObserver(this.syncAccessibleLabel);
|
|
49
|
+
this.contentObserver.observe(this.host, {
|
|
50
|
+
childList: true,
|
|
51
|
+
subtree: true,
|
|
52
|
+
characterData: true,
|
|
53
|
+
});
|
|
54
|
+
this.internalOpen = controlledOrDefault(this.open, this.defaultOpen);
|
|
39
55
|
this.dialogRef?.addEventListener('close', this.onDialogClose);
|
|
56
|
+
this.syncAccessibleLabel();
|
|
40
57
|
this.syncOpen();
|
|
41
58
|
}
|
|
42
59
|
disconnectedCallback() {
|
|
43
60
|
this.dialogRef?.removeEventListener('close', this.onDialogClose);
|
|
61
|
+
this.contentObserver?.disconnect();
|
|
62
|
+
this.contentObserver = null;
|
|
44
63
|
closeOverlay(this.overlayId);
|
|
45
64
|
}
|
|
46
65
|
componentDidUpdate() {
|
|
47
66
|
this.syncOpen();
|
|
48
67
|
}
|
|
49
68
|
handleRequestClose(reason, trigger) {
|
|
50
|
-
this.
|
|
69
|
+
if (!isControlled(this.open))
|
|
70
|
+
this.internalOpen = false;
|
|
51
71
|
dispatchDetail(this.host, 'close', {
|
|
52
72
|
open: false,
|
|
53
73
|
reason: reason,
|
|
@@ -56,8 +76,13 @@ export class UIDialog {
|
|
|
56
76
|
}
|
|
57
77
|
onDialogClose = () => {
|
|
58
78
|
if (this.internalOpen) {
|
|
59
|
-
this.
|
|
60
|
-
|
|
79
|
+
if (!isControlled(this.open)) {
|
|
80
|
+
this.internalOpen = false;
|
|
81
|
+
closeOverlay(this.overlayId);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
requestAnimationFrame(() => this.syncOpen());
|
|
85
|
+
}
|
|
61
86
|
dispatchDetail(this.host, 'close', {
|
|
62
87
|
open: false,
|
|
63
88
|
reason: 'programmatic',
|
|
@@ -70,8 +95,16 @@ export class UIDialog {
|
|
|
70
95
|
requestTopOverlayClose('escape', 'keyboard');
|
|
71
96
|
}
|
|
72
97
|
};
|
|
98
|
+
syncAccessibleLabel = () => {
|
|
99
|
+
const explicitLabel = this.label?.trim();
|
|
100
|
+
const heading = this.host.querySelector('[slot="heading"], [data-ui-dialog-title], h1, h2, h3, h4, h5, h6');
|
|
101
|
+
const headingLabel = heading?.textContent?.trim();
|
|
102
|
+
const nextLabel = explicitLabel || headingLabel || 'Dialog';
|
|
103
|
+
if (this.accessibleLabel !== nextLabel)
|
|
104
|
+
this.accessibleLabel = nextLabel;
|
|
105
|
+
};
|
|
73
106
|
render() {
|
|
74
|
-
return (h(Host, { key: '
|
|
107
|
+
return (h(Host, { key: '6e12a287866c76305c791c0ae538dcde63da3044', "data-open": this.internalOpen ? '' : undefined, onKeyDown: this.onKeydown }, h("dialog", { key: '99ba3815e8a8c70ce50ff08d9a8b162aa9c1011f', ref: (el) => (this.dialogRef = el), open: this.internalOpen, "aria-label": this.accessibleLabel }, h("slot", { key: 'e72b001877d2dfad1bcee9af87167c66d77fc952' }))));
|
|
75
108
|
}
|
|
76
109
|
static get is() { return "ui-dialog"; }
|
|
77
110
|
static get encapsulation() { return "shadow"; }
|
|
@@ -96,16 +129,15 @@ export class UIDialog {
|
|
|
96
129
|
"references": {}
|
|
97
130
|
},
|
|
98
131
|
"required": false,
|
|
99
|
-
"optional":
|
|
132
|
+
"optional": true,
|
|
100
133
|
"docs": {
|
|
101
134
|
"tags": [],
|
|
102
|
-
"text": ""
|
|
135
|
+
"text": "Controlled open state. Omit it to use defaultOpen and local interaction state."
|
|
103
136
|
},
|
|
104
137
|
"getter": false,
|
|
105
138
|
"setter": false,
|
|
106
139
|
"reflect": false,
|
|
107
|
-
"attribute": "open"
|
|
108
|
-
"defaultValue": "false"
|
|
140
|
+
"attribute": "open"
|
|
109
141
|
},
|
|
110
142
|
"defaultOpen": {
|
|
111
143
|
"type": "boolean",
|
|
@@ -190,7 +222,8 @@ export class UIDialog {
|
|
|
190
222
|
}
|
|
191
223
|
static get states() {
|
|
192
224
|
return {
|
|
193
|
-
"internalOpen": {}
|
|
225
|
+
"internalOpen": {},
|
|
226
|
+
"accessibleLabel": {}
|
|
194
227
|
};
|
|
195
228
|
}
|
|
196
229
|
static get elementRef() { return "host"; }
|
|
@@ -198,6 +231,9 @@ export class UIDialog {
|
|
|
198
231
|
return [{
|
|
199
232
|
"propName": "open",
|
|
200
233
|
"methodName": "syncFromProp"
|
|
234
|
+
}, {
|
|
235
|
+
"propName": "label",
|
|
236
|
+
"methodName": "syncLabelFromProp"
|
|
201
237
|
}, {
|
|
202
238
|
"propName": "internalOpen",
|
|
203
239
|
"methodName": "syncOpen"
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { Host, h } from "@stencil/core";
|
|
2
2
|
import { createId } from "../../utils/id";
|
|
3
3
|
import { eventToTrigger, isActivationKey, dispatchDetail } from "../../utils/events";
|
|
4
|
+
import { controlledOrDefault, isControlled } from "../../utils/controlled-state";
|
|
4
5
|
export class UIDisclosure {
|
|
5
6
|
host;
|
|
6
|
-
open
|
|
7
|
+
/** Controlled open state. Omit it to use defaultOpen and local interaction state. */
|
|
8
|
+
open;
|
|
7
9
|
defaultOpen = false;
|
|
8
10
|
disabled = false;
|
|
9
11
|
internalOpen = false;
|
|
@@ -11,7 +13,8 @@ export class UIDisclosure {
|
|
|
11
13
|
trigger = null;
|
|
12
14
|
content = null;
|
|
13
15
|
syncFromProp() {
|
|
14
|
-
|
|
16
|
+
if (isControlled(this.open))
|
|
17
|
+
this.internalOpen = this.open;
|
|
15
18
|
}
|
|
16
19
|
syncState() {
|
|
17
20
|
if (this.trigger) {
|
|
@@ -23,8 +26,7 @@ export class UIDisclosure {
|
|
|
23
26
|
}
|
|
24
27
|
componentDidLoad() {
|
|
25
28
|
this.resolveParts();
|
|
26
|
-
this.
|
|
27
|
-
this.internalOpen = this.internalOpen || this.defaultOpen;
|
|
29
|
+
this.internalOpen = controlledOrDefault(this.open, this.defaultOpen);
|
|
28
30
|
this.syncState();
|
|
29
31
|
this.trigger?.addEventListener('click', this.onTriggerClick);
|
|
30
32
|
this.trigger?.addEventListener('keydown', this.onTriggerKeydown);
|
|
@@ -64,7 +66,8 @@ export class UIDisclosure {
|
|
|
64
66
|
setOpen(next, action) {
|
|
65
67
|
if (this.internalOpen === next)
|
|
66
68
|
return;
|
|
67
|
-
this.
|
|
69
|
+
if (!isControlled(this.open))
|
|
70
|
+
this.internalOpen = next;
|
|
68
71
|
dispatchDetail(this.host, next ? 'open' : 'close', {
|
|
69
72
|
open: next,
|
|
70
73
|
reason: action.reason,
|
|
@@ -85,7 +88,7 @@ export class UIDisclosure {
|
|
|
85
88
|
this.setOpen(!this.internalOpen, { reason: 'action', trigger: 'keyboard' });
|
|
86
89
|
};
|
|
87
90
|
render() {
|
|
88
|
-
return (h(Host, { key: '
|
|
91
|
+
return (h(Host, { key: '55f998f8e47ebe01fd5832d6c3dac310dda34b8d' }, h("slot", { key: '0d88728151901e1e412d7f5a3ae78b06aa7548fb' })));
|
|
89
92
|
}
|
|
90
93
|
static get is() { return "ui-disclosure"; }
|
|
91
94
|
static get encapsulation() { return "shadow"; }
|
|
@@ -110,16 +113,15 @@ export class UIDisclosure {
|
|
|
110
113
|
"references": {}
|
|
111
114
|
},
|
|
112
115
|
"required": false,
|
|
113
|
-
"optional":
|
|
116
|
+
"optional": true,
|
|
114
117
|
"docs": {
|
|
115
118
|
"tags": [],
|
|
116
|
-
"text": ""
|
|
119
|
+
"text": "Controlled open state. Omit it to use defaultOpen and local interaction state."
|
|
117
120
|
},
|
|
118
121
|
"getter": false,
|
|
119
122
|
"setter": false,
|
|
120
123
|
"reflect": false,
|
|
121
|
-
"attribute": "open"
|
|
122
|
-
"defaultValue": "false"
|
|
124
|
+
"attribute": "open"
|
|
123
125
|
},
|
|
124
126
|
"defaultOpen": {
|
|
125
127
|
"type": "boolean",
|