@astryx-vue/core 0.33.3 → 0.34.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/AlertDialog/index.js +1 -1
- package/dist/{AlertDialog-BwH9WU-t.js → AlertDialog-CdrF01J0.js} +5 -5
- package/dist/AppShell/index.js +1 -1
- package/dist/{AppShell-BwzRYOky.js → AppShell-4hWTPKSD.js} +5 -5
- package/dist/AvatarGroup/index.d.ts +1 -1
- package/dist/AvatarGroup/index.js +1 -1
- package/dist/{AvatarGroup-C0V--ipx.js → AvatarGroup-CACtdvXz.js} +1 -1
- package/dist/Banner/index.d.ts +1 -1
- package/dist/Banner/index.js +1 -1
- package/dist/{Banner-Ds5KIeES.js → Banner-CAyN5-NO.js} +1 -1
- package/dist/Breadcrumbs/index.js +2 -2
- package/dist/{Breadcrumbs-DWAYp-JJ.js → Breadcrumbs-BQnrbWXt.js} +1 -1
- package/dist/Button/index.js +1 -1
- package/dist/{Button-X-Q_ghg8.js → Button-CrZtv_4j.js} +2 -2
- package/dist/ButtonGroup/index.d.ts +1 -1
- package/dist/ButtonGroup/index.js +1 -1
- package/dist/{ButtonGroup-DsYdUmF1.js → ButtonGroup-Jgx-IWPz.js} +2 -2
- package/dist/Calendar/index.d.ts +1 -1
- package/dist/Carousel/index.d.ts +1 -1
- package/dist/Carousel/index.js +1 -1
- package/dist/{Carousel-D8uVV1J_.js → Carousel-BdhtUtf-.js} +1 -1
- package/dist/Chat/index.d.ts +1 -1
- package/dist/Chat/index.js +1 -1
- package/dist/{Chat-Dy-icS2C.js → Chat-DT712Yft.js} +1 -1
- package/dist/CheckboxInput/index.d.ts +1 -1
- package/dist/CheckboxInput/index.js +1 -1
- package/dist/{CheckboxInput-CiUtutIS.js → CheckboxInput-D8N6yvK5.js} +79 -74
- package/dist/CheckboxList/index.d.ts +1 -1
- package/dist/CheckboxList/index.js +1 -1
- package/dist/{CheckboxListItem-B6sV7-Og.js → CheckboxListItem--iUp9-KO.js} +4 -4
- package/dist/ClickableCard/index.d.ts +1 -1
- package/dist/ClickableCard/index.js +1 -1
- package/dist/{ClickableCard-DDk_RtHd.js → ClickableCard-B_upAn7L.js} +1 -1
- package/dist/Code/index.d.ts +3 -2
- package/dist/Code/index.js +3 -2
- package/dist/Code/languages/dockerfile/index.d.ts +5 -0
- package/dist/Code/languages/dockerfile/index.js +47 -0
- package/dist/Code/languages/graphql/index.d.ts +5 -0
- package/dist/Code/languages/graphql/index.js +24 -0
- package/dist/Code/languages/java/index.d.ts +5 -0
- package/dist/Code/languages/java/index.js +17 -0
- package/dist/Code/languages/lua/index.d.ts +5 -0
- package/dist/Code/languages/lua/index.js +14 -0
- package/dist/Code/languages/objective-c/index.d.ts +5 -0
- package/dist/Code/languages/objective-c/index.js +29 -0
- package/dist/Code/languages/powershell/index.d.ts +5 -0
- package/dist/Code/languages/powershell/index.js +36 -0
- package/dist/Code/languages/ruby/index.d.ts +5 -0
- package/dist/Code/languages/ruby/index.js +21 -0
- package/dist/Code/languages/thrift/index.d.ts +5 -0
- package/dist/Code/languages/thrift/index.js +15 -0
- package/dist/Code/languages/toml/index.d.ts +5 -0
- package/dist/Code/languages/toml/index.js +55 -0
- package/dist/{CodeBlock-r2-MlpBB.js → CodeBlock-BkqcfoZ1.js} +309 -96
- package/dist/Collapsible/index.js +1 -1
- package/dist/{Collapsible-0XI3tKgj.js → Collapsible-BKt7UCeF.js} +3 -3
- package/dist/CommandPalette/index.js +1 -1
- package/dist/{CommandPalette-BYR0Lxxd.js → CommandPalette-CvOeE6i-.js} +2 -2
- package/dist/ComplexSelector/index.d.ts +1 -1
- package/dist/ComplexSelector/index.js +1 -1
- package/dist/{ComplexSelector-CIXrqCoX.js → ComplexSelector-CVEfoN0k.js} +2 -2
- package/dist/ContextMenu/index.d.ts +1 -1
- package/dist/ContextMenu/index.js +2 -2
- package/dist/{ContextMenu-CfVyaP5v.js → ContextMenu-ZqWtb5Si.js} +3 -3
- package/dist/DateInput/index.d.ts +1 -1
- package/dist/DateInput/index.js +1 -1
- package/dist/{DateInput-DRzZ8dY7.js → DateInput-7FFzOvcu.js} +2 -2
- package/dist/DateRangeInput/index.d.ts +1 -1
- package/dist/DateRangeInput/index.js +1 -1
- package/dist/{DateRangeInput-DL2aOQXJ.js → DateRangeInput-C0ICAvm7.js} +3 -3
- package/dist/DateTimeInput/index.d.ts +1 -1
- package/dist/DateTimeInput/index.js +1 -1
- package/dist/{DateTimeInput-KWkpamG4.js → DateTimeInput-CaX09wfm.js} +4 -4
- package/dist/Dialog/index.js +3 -3
- package/dist/{Dialog-BM5VEE8z.js → Dialog-B1xC9xMC.js} +1 -1
- package/dist/{Dialog-CJzq1gms.js → Dialog-BmdNX3NC.js} +1 -1
- package/dist/{DialogHeader-Do4EOX2f.js → DialogHeader-DLaiYrvF.js} +2 -2
- package/dist/Drawer/index.d.ts +1 -1
- package/dist/Drawer/index.js +1 -1
- package/dist/{Drawer-DuQ620WO.js → Drawer-BpuER-VT.js} +2 -2
- package/dist/DropdownMenu/index.js +2 -2
- package/dist/{DropdownMenu-CbENfJOq.js → DropdownMenu-K8JPIcSk.js} +6 -6
- package/dist/Field/index.js +3 -3
- package/dist/{Field-B1fsgAqp.js → Field-CjC4qc2q.js} +1 -1
- package/dist/{FieldInfoTip-CntJCcnM.js → FieldInfoTip-Cu4LNidQ.js} +1 -1
- package/dist/{FieldLabel-D56uJrRE.js → FieldLabel-BFBAGrFY.js} +1 -1
- package/dist/FileInput/index.js +1 -1
- package/dist/{FileInput-EjlruVVX.js → FileInput-DFsbOoe-.js} +3 -3
- package/dist/IconButton/index.js +1 -1
- package/dist/{IconButton-CXg9qTRM.js → IconButton-BPjZPGRy.js} +1 -1
- package/dist/InfoTip/index.d.ts +1 -1
- package/dist/InfoTip/index.js +1 -1
- package/dist/{InfoTip-jFet-iAx.js → InfoTip-DqDgJRtp.js} +1 -1
- package/dist/{InputClearButton-DBTrsrSH.js → InputClearButton-BZzOtoH7.js} +1 -1
- package/dist/InputGroup/index.js +1 -1
- package/dist/{InputGroup-D7UBxktR.js → InputGroup-BN6v-b9L.js} +1 -1
- package/dist/InternationalizationProvider/index.d.ts +1 -1
- package/dist/InternationalizationProvider/index.js +1 -1
- package/dist/{InternationalizationProvider-BGtwZDY0.js → InternationalizationProvider-DzNfleAX.js} +1 -1
- package/dist/{Item-DbalBZXc.js → Item-BzjepDWA.js} +2 -2
- package/dist/Layout/index.js +2 -2
- package/dist/{Layout-BEJwZon4.js → Layout-SJoCw8NC.js} +1 -1
- package/dist/{LayoutPanel-BgJdL0KV.js → LayoutPanel-DZN4RxX6.js} +1 -1
- package/dist/Lightbox/index.js +1 -1
- package/dist/{Lightbox-DJXB22k0.js → Lightbox-K2cAUZRG.js} +1 -1
- package/dist/Link/index.d.ts +1 -1
- package/dist/Link/index.js +1 -1
- package/dist/{Link-eXwB0Hjg.js → Link-v-K2lhCh.js} +1 -1
- package/dist/List/index.d.ts +1 -1
- package/dist/List/index.js +2 -2
- package/dist/{ListItem-C5B8uYyn.js → ListItem-BTcwwpFb.js} +3 -3
- package/dist/Markdown/index.d.ts +1 -1
- package/dist/Markdown/index.js +2 -2
- package/dist/Markdown/parser/index.js +1 -1
- package/dist/{Markdown-COub2yng.js → Markdown-B4WsMYzN.js} +80 -5
- package/dist/MetadataList/index.d.ts +1 -1
- package/dist/MobileNav/index.js +1 -1
- package/dist/{MobileNavToggle-DI5yDKfp.js → MobileNavToggle-AgT6hzTg.js} +1 -1
- package/dist/MoreMenu/index.d.ts +1 -1
- package/dist/MoreMenu/index.js +1 -1
- package/dist/{MoreMenu-C7gie2PE.js → MoreMenu-BF9qhsxq.js} +5 -5
- package/dist/MultiSelector/index.d.ts +1 -1
- package/dist/MultiSelector/index.js +1 -1
- package/dist/{MultiSelector-CnGUU8P3.js → MultiSelector-CDMoxGKV.js} +4 -4
- package/dist/NavItem/index.d.ts +1 -1
- package/dist/NavItem/index.js +1 -1
- package/dist/{NavItem-Cciu9aok.js → NavItem-DUnSwKRl.js} +1 -1
- package/dist/NavMenu/index.js +2 -2
- package/dist/{NavMenu--iyy_m84.js → NavMenu-DAnQr1S5.js} +1 -1
- package/dist/{NavMenuItem-BmAm-Cv8.js → NavMenuItem-CrTUxgBP.js} +2 -2
- package/dist/NumberInput/index.d.ts +1 -1
- package/dist/NumberInput/index.js +1 -1
- package/dist/{NumberInput-CD9sHbON.js → NumberInput-DQ7FMUTd.js} +3 -3
- package/dist/Outline/index.js +1 -1
- package/dist/{Outline-vieAJS2J.js → Outline-CSHJqtg4.js} +2 -2
- package/dist/OverflowList/index.d.ts +1 -1
- package/dist/OverflowList/index.js +1 -1
- package/dist/{OverflowList-YLVHypB3.js → OverflowList-CK6sgmY3.js} +1 -1
- package/dist/Overlay/index.d.ts +1 -1
- package/dist/Pagination/index.d.ts +1 -1
- package/dist/Pagination/index.js +1 -1
- package/dist/{Pagination-Bnkp4oAA.js → Pagination-B-337WLy.js} +2 -2
- package/dist/{PanGestureRecognizer-CzIWpazn.js → PanGestureRecognizer-yYMpXB93.js} +1 -1
- package/dist/Popover/index.js +1 -1
- package/dist/{Popover-CYJ1z_7L.js → Popover-DVrWAYg2.js} +4 -4
- package/dist/PowerSearch/index.d.ts +1 -1
- package/dist/PowerSearch/index.js +1 -1
- package/dist/{PowerSearch-DEpXEmgs.js → PowerSearch-sWyeh9Az.js} +19 -19
- package/dist/{PressTracker-L5-Ark_9.js → PressTracker-CjfG1d8n.js} +2 -2
- package/dist/ProgressBar/index.d.ts +1 -1
- package/dist/Radio/index.d.ts +1 -1
- package/dist/Radio/index.js +1 -1
- package/dist/{RadioGroup-BdO-xZv0.js → RadioGroup-BloTgj7H.js} +8 -5
- package/dist/RadioList/index.d.ts +1 -1
- package/dist/RadioList/index.js +1 -1
- package/dist/{RadioListItem-DzGPuWTt.js → RadioListItem-BERujpW8.js} +1 -1
- package/dist/Resizable/index.js +1 -1
- package/dist/{ResizeHandle-Dcel1HkU.js → ResizeHandle-J9-dAMuo.js} +1 -1
- package/dist/ScrollableArea/index.d.ts +1 -1
- package/dist/SegmentedControl/index.js +1 -1
- package/dist/SegmentedControl-BzvLJL8T.js +1465 -0
- package/dist/SelectableCard/index.d.ts +1 -1
- package/dist/SelectableCard/index.js +1 -1
- package/dist/{SelectableCard-BZTF6qw-.js → SelectableCard-IAv2X4dq.js} +1 -1
- package/dist/Selector/index.d.ts +1 -1
- package/dist/Selector/index.js +1 -1
- package/dist/{Selector-SkwSbf4j.js → Selector-CsEWOfWV.js} +2 -2
- package/dist/SideNav/index.d.ts +1 -1
- package/dist/SideNav/index.js +2 -2
- package/dist/{SideNav-BxJfJU95.js → SideNav-CVAi462m.js} +6 -6
- package/dist/Slider/index.js +1 -1
- package/dist/{Slider-ORmi7QJ7.js → Slider-D0omHlRI.js} +6 -5
- package/dist/Stepper/index.d.ts +1 -1
- package/dist/Stepper/index.js +1 -1
- package/dist/{Stepper-C4-wtxn4.js → Stepper-CetoMTog.js} +1 -1
- package/dist/Switch/index.d.ts +1 -1
- package/dist/Switch/index.js +1 -1
- package/dist/{Switch-Cw1UKVjQ.js → Switch-DTwurKmh.js} +11 -82
- package/dist/TabList/index.js +1 -1
- package/dist/{TabList-DNDe2ipJ.js → TabList-BJTT4nm6.js} +2 -2
- package/dist/Table/index.d.ts +1 -1
- package/dist/Table/index.js +1 -1
- package/dist/{Table-CqppyRk8.js → Table-CUqi9BXT.js} +13 -13
- package/dist/TextArea/index.d.ts +1 -1
- package/dist/TextArea/index.js +1 -1
- package/dist/{TextArea-I3ghDb9r.js → TextArea-BKwmXPGQ.js} +4 -4
- package/dist/TextInput/index.d.ts +1 -1
- package/dist/TextInput/index.js +1 -1
- package/dist/{TextInput-Xz_ibpOl.js → TextInput-CRXs8cDs.js} +4 -4
- package/dist/Thumbnail/index.js +1 -1
- package/dist/{Thumbnail-bS62Tr_f.js → Thumbnail-GUwgnwZb.js} +2 -2
- package/dist/{TimeField-Bsb8n22d.js → TimeField-Bn_ziTCi.js} +1 -1
- package/dist/TimeInput/index.d.ts +1 -1
- package/dist/TimeInput/index.js +1 -1
- package/dist/{TimeInput-D40_6GrX.js → TimeInput-BKkwmN1V.js} +2 -2
- package/dist/Timestamp/index.d.ts +1 -1
- package/dist/Timestamp/index.js +1 -1
- package/dist/{Timestamp-Bt9ZR975.js → Timestamp-Dlz2SvSe.js} +1 -1
- package/dist/Toast/index.js +1 -1
- package/dist/{Toast-BQxfIeVU.js → Toast-BSnsRCyB.js} +3 -3
- package/dist/ToggleButton/index.d.ts +1 -1
- package/dist/ToggleButton/index.js +1 -1
- package/dist/{ToggleButton-IFhFMpQh.js → ToggleButton-DE79lIQq.js} +3 -3
- package/dist/Token/index.js +1 -1
- package/dist/{Token-CpmqfG4i.js → Token-BdClMOG9.js} +1 -1
- package/dist/Tokenizer/index.d.ts +1 -1
- package/dist/Tokenizer/index.js +1 -1
- package/dist/{Tokenizer-Dvr7ICpS.js → Tokenizer-BitI30VU.js} +7 -7
- package/dist/Toolbar/index.d.ts +1 -1
- package/dist/TopNav/index.d.ts +1 -1
- package/dist/TopNav/index.js +1 -1
- package/dist/{TopNav-Cw_dcKpf.js → TopNav-BUjEldSq.js} +3 -3
- package/dist/TreeList/index.d.ts +1 -1
- package/dist/TreeList/index.js +1 -1
- package/dist/{TreeList-CBfKKbUQ.js → TreeList-BVJ3V-xI.js} +4 -4
- package/dist/Typeahead/index.js +1 -1
- package/dist/{Typeahead-D9-WjsCU.js → Typeahead-C54ao2ye.js} +3 -3
- package/dist/{accessibleName-Cw9s1690.js → accessibleName-19W3jhkD.js} +2 -2
- package/dist/{assertOptions-V_jJxpn9.js → assertOptions-Byu4Yqfg.js} +1 -1
- package/dist/boxHold-0ChMpiin.js +170 -0
- package/dist/browserClickWait-DIj9tkLa.js +77 -0
- package/dist/{coarsePointer-DGnAPIcU.js → coarsePointer-BWNSUIY8.js} +2 -32
- package/dist/code-block-DCVrTLMZ.js +19 -0
- package/dist/composables/index.js +6 -6
- package/dist/{composables-BJoAw6XA.js → composables-CF2weN-L.js} +3 -2
- package/dist/{context-WDet15_N.js → context-C1MPE6J5.js} +1 -1
- package/dist/{geometry-CoQRz-F1.js → geometry-BnZ6uDX_.js} +6 -131
- package/dist/grammar-4Pn2745Q.d.ts +58 -0
- package/dist/grammar-Dz71GleT.js +144 -0
- package/dist/{holdEntranceInput-BsusS3bM.js → holdEntranceInput-C8B_DYYs.js} +1 -1
- package/dist/{index-CQi9WGWE.d.ts → index-AgTJRqUY.d.ts} +2 -2
- package/dist/{index-BuubzuE8.d.ts → index-BDZCJ9ri.d.ts} +2 -2
- package/dist/{index-CTv55aOa.d.ts → index-BRr_eg_u.d.ts} +1 -1
- package/dist/{index-ChqMaV6N.d.ts → index-BZDl_iLU.d.ts} +61 -13
- package/dist/{index-ZKBj_1nu.d.ts → index-BfFpUr1B.d.ts} +1 -1
- package/dist/{index-CKnr0JlT.d.ts → index-C4S65SAW.d.ts} +1 -1
- package/dist/{index-CY0KtUSC.d.ts → index-CArlEl1O.d.ts} +515 -119
- package/dist/{index-COgrQZIL.d.ts → index-CdvmnNMH.d.ts} +1 -1
- package/dist/{index-DuxRUPMc.d.ts → index-D1C2Nt3F.d.ts} +3 -3
- package/dist/{index-BVx-HFp8.d.ts → index-D9t_l8pJ.d.ts} +1 -1
- package/dist/{index-D1JOMiI5.d.ts → index-DHsYyqMP.d.ts} +4 -4
- package/dist/{index-utZGF4GR.d.ts → index-NOXYEdOI.d.ts} +1 -1
- package/dist/{index-BqQlY3fL.d.ts → index-QC9FDUDA.d.ts} +2 -2
- package/dist/{index-BI1QLuYB.d.ts → index-ZXrvTM3A.d.ts} +3 -3
- package/dist/{index-Pad9p8CU.d.ts → index-a6o69uPN.d.ts} +1 -1
- package/dist/{index-GyRgg1-v.d.ts → index-uLDBzCDo.d.ts} +5 -5
- package/dist/index.d.ts +19 -19
- package/dist/index.js +90 -88
- package/dist/{landing-Qk_FHR-s.js → landing-BW6qLvC8.js} +1 -1
- package/dist/{loadCatalog-BODWYaNy.d.ts → loadCatalog-C_Cy_8WN.d.ts} +2 -0
- package/dist/{loadCatalog-DMOOMWtw.js → loadCatalog-VlWGFIMU.js} +6 -17
- package/dist/locale/index.d.ts +2 -2
- package/dist/locale/index.js +3 -2
- package/dist/{locale-C8X7gJlc.js → locale-U0KLmREA.js} +1 -1
- package/dist/{presentationHold-CZsVmjlY.js → presentationHold-ZKixVLcz.js} +1 -1
- package/dist/pressClaim-DvdlIn4w.js +24 -0
- package/dist/{pressFeedback-9ogipvI4.js → pressFeedback-B3cqaMGl.js} +45 -5
- package/dist/{publicParser-C8RBKNLA.js → publicParser-Dbu2LRTf.js} +2 -2
- package/dist/{reportChange-BUTgduu-.js → reportChange-DwOfucSf.js} +1 -1
- package/dist/{resizableChannel-_j_AW2B6.js → resizableChannel-BnwrR5tr.js} +2 -2
- package/dist/selectionLock-BrUpRS0E.js +130 -0
- package/dist/{themeTiming-ClYaZxGf.js → themeTiming-BJziEh4O.js} +1 -1
- package/dist/touchQueries-xy5IeZfe.js +32 -0
- package/dist/{useActionGroupTracking-ByLJoM-8.js → useActionGroupTracking-D0IwimcQ.js} +2 -2
- package/dist/{useAnimatedLayout-IcX0UfS4.js → useAnimatedLayout-CRAuCwTZ.js} +1 -1
- package/dist/{useHeldPresentation-DJEthuMT.js → useHeldPresentation-CaIKTwUh.js} +1 -1
- package/dist/{useInputStatusIcon-D0q4S1Ye.js → useInputStatusIcon-C2AkJiAT.js} +1 -1
- package/dist/{useMenuEntranceHold-B7f9ShX2.js → useMenuEntranceHold-C-kHicUN.js} +1 -1
- package/dist/{useMenuPress-cBIQyTsN.js → useMenuPress-B5h9PBx_.js} +3 -1
- package/dist/{usePressFeedback-Dx-a3i82.js → usePressFeedback-iyoKakPX.js} +1 -1
- package/dist/{useResizable-JvgYydox.js → useResizable-I0APFcMz.js} +1 -1
- package/dist/{useTouchHitArea-BGkvMAyp.js → useTouchHitArea-MvzPCmJg.js} +1 -1
- package/package.json +37 -1
- package/reset.css +14 -0
- package/styles/code.css +85 -8
- package/styles/markdown.css +6 -5
- package/styles/progress-bar.css +25 -26
- package/styles/segmented-control.css +20 -11
- package/dist/SegmentedControl-BURyE9XU.js +0 -416
- package/dist/index-C9ZssPUV.d.ts +0 -380
|
@@ -0,0 +1,1465 @@
|
|
|
1
|
+
import { t as hasSlotContent } from "./slotContent-CNWOrGOr.js";
|
|
2
|
+
import { i as pressFadeMs, t as PRESSED_ATTRIBUTE } from "./pressFeedback-B3cqaMGl.js";
|
|
3
|
+
import { t as armClickGuard } from "./clickGuard-CxqcfBCJ.js";
|
|
4
|
+
import { n as useTouchHitArea } from "./useTouchHitArea-MvzPCmJg.js";
|
|
5
|
+
import { a as registerMotionTable } from "./roles-DWH31Bn3.js";
|
|
6
|
+
import { t as usePressFeedback } from "./usePressFeedback-iyoKakPX.js";
|
|
7
|
+
import { n as readLayerScoped, t as defineLayerScopedKey } from "./scopedProvide-C-Df7c15.js";
|
|
8
|
+
import { i as useSize } from "./SizeContext-BbaF-SEx.js";
|
|
9
|
+
import { t as _sfc_main$2 } from "./ButtonTooltip-ZpQP-aQg.js";
|
|
10
|
+
import { t as invokeNativeEventHandler } from "./eventHandlers-DUXzBWZy.js";
|
|
11
|
+
import { t as useCoarsePointer } from "./useCoarsePointer-GItEMrjX.js";
|
|
12
|
+
import { n as createMotionEngine } from "./animator-ozeBZ_zC.js";
|
|
13
|
+
import { a as registerSpringsTable, o as springs } from "./springs-DjAn_oV5.js";
|
|
14
|
+
import { i as getGestureHost } from "./geometry-BnZ6uDX_.js";
|
|
15
|
+
import { t as PanGestureRecognizer } from "./PanGestureRecognizer-yYMpXB93.js";
|
|
16
|
+
import { n as lockSelection } from "./selectionLock-BrUpRS0E.js";
|
|
17
|
+
import { n as readThemeTiming, t as easedProgress } from "./themeTiming-BJziEh4O.js";
|
|
18
|
+
import { n as observeResize } from "./sharedResizeObserver-BekhnB3E.js";
|
|
19
|
+
import { n as mapRange, t as mapProgress } from "./progress-FQfSgLZC.js";
|
|
20
|
+
import { n as clickForLift, t as awaitBrowserClick } from "./browserClickWait-DIj9tkLa.js";
|
|
21
|
+
import { n as createPressTracker } from "./PressTracker-CjfG1d8n.js";
|
|
22
|
+
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, defineComponent, mergeModels, mergeProps, onBeforeUnmount, onMounted, onScopeDispose, onUpdated, openBlock, provide, renderSlot, shallowRef, toDisplayString, unref, useAttrs, useId, useModel, useTemplateRef, watch } from "vue";
|
|
23
|
+
import "../styles/segmented-control.css";
|
|
24
|
+
//#region src/SegmentedControl/context.ts
|
|
25
|
+
const segmentedControlContextKey = defineLayerScopedKey("astryx-segmented-control", null);
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region src/SegmentedControl/segmentedGeometry.ts
|
|
28
|
+
/**
|
|
29
|
+
* @file segmentedGeometry.ts
|
|
30
|
+
* @input A SegmentedControl's radiogroup and its segments
|
|
31
|
+
* @output The segments' boxes in the track's coordinates, the pointer's x
|
|
32
|
+
* there, and the segment a lift commits
|
|
33
|
+
* @position Pure geometry of SegmentedControl's selection motion
|
|
34
|
+
* (segmentedSelectionMotion.ts) and press tracking (segmentedTracking.ts)
|
|
35
|
+
*/
|
|
36
|
+
/** The segments, in DOM order. */
|
|
37
|
+
const SEGMENT_SELECTOR = "[role=\"radio\"][data-value]";
|
|
38
|
+
function segmentsOf(track) {
|
|
39
|
+
return Array.from(track.querySelectorAll(SEGMENT_SELECTOR));
|
|
40
|
+
}
|
|
41
|
+
/** The selected segment, as the DOM shows it now. */
|
|
42
|
+
function selectedIn(track) {
|
|
43
|
+
return segmentsOf(track).find((segment) => segment.getAttribute("aria-checked") === "true") ?? null;
|
|
44
|
+
}
|
|
45
|
+
/** The segment that commits `value`. */
|
|
46
|
+
function segmentFor(track, value) {
|
|
47
|
+
return value == null ? null : segmentsOf(track).find((segment) => segment.dataset.value === value) ?? null;
|
|
48
|
+
}
|
|
49
|
+
function isEnabledSegment(segment) {
|
|
50
|
+
return !segment.hasAttribute("disabled") && segment.getAttribute("aria-disabled") !== "true";
|
|
51
|
+
}
|
|
52
|
+
function isLaidOut(box) {
|
|
53
|
+
return box.width > 0 && box.height > 0;
|
|
54
|
+
}
|
|
55
|
+
function center(box) {
|
|
56
|
+
return box.x + box.width / 2;
|
|
57
|
+
}
|
|
58
|
+
/** Whether two boxes are the same to a quarter of a pixel. */
|
|
59
|
+
function isSameBox(a, b) {
|
|
60
|
+
return Math.abs(a.x - b.x) < .25 && Math.abs(a.y - b.y) < .25 && Math.abs(a.width - b.width) < .25 && Math.abs(a.height - b.height) < .25;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The scale an ancestor transform applies to the track's client rects. The
|
|
64
|
+
* lens lays out untransformed. `offsetWidth` rounds to whole pixels, so only
|
|
65
|
+
* a difference past that rounding counts as a transform.
|
|
66
|
+
*/
|
|
67
|
+
function scaleOf(track, rect) {
|
|
68
|
+
if (track.offsetWidth <= 0 || rect.width <= 0) return 1;
|
|
69
|
+
return Math.abs(rect.width - track.offsetWidth) <= 1 ? 1 : rect.width / track.offsetWidth;
|
|
70
|
+
}
|
|
71
|
+
/** Boxes relative to the track's padding box, where the lens lays out. */
|
|
72
|
+
function boxesIn(track) {
|
|
73
|
+
const trackRect = track.getBoundingClientRect();
|
|
74
|
+
const scale = scaleOf(track, trackRect);
|
|
75
|
+
return (element) => {
|
|
76
|
+
const rect = element.getBoundingClientRect();
|
|
77
|
+
return {
|
|
78
|
+
x: (rect.left - trackRect.left) / scale - track.clientLeft,
|
|
79
|
+
y: (rect.top - trackRect.top) / scale - track.clientTop,
|
|
80
|
+
width: rect.width / scale,
|
|
81
|
+
height: rect.height / scale
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/** Maps a client x to the track's padding-box x, read once per press. */
|
|
86
|
+
function trackXIn(track) {
|
|
87
|
+
const rect = track.getBoundingClientRect();
|
|
88
|
+
const scale = scaleOf(track, rect);
|
|
89
|
+
return (clientX) => (clientX - rect.left) / scale - track.clientLeft;
|
|
90
|
+
}
|
|
91
|
+
/** Every segment of `track`, disabled ones included, measured once. */
|
|
92
|
+
function measureSegments(track) {
|
|
93
|
+
return segmentsOf(track).map((element) => {
|
|
94
|
+
const { left, right, top, bottom } = element.getBoundingClientRect();
|
|
95
|
+
return {
|
|
96
|
+
element,
|
|
97
|
+
left,
|
|
98
|
+
right,
|
|
99
|
+
top,
|
|
100
|
+
bottom
|
|
101
|
+
};
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
/** No segment has a width: the control has no layout, as in a unit test's DOM. */
|
|
105
|
+
function hasNoLayout(segments) {
|
|
106
|
+
return segments.every(({ left, right }) => right - left <= 0);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* The segment a pointer at viewport `x` counts for: the one under it, else
|
|
110
|
+
* the nearest. A gap between two segments splits at its middle, as UIKit's
|
|
111
|
+
* segments share an edge, and past the ends the end segment counts. Null
|
|
112
|
+
* when that segment is disabled.
|
|
113
|
+
*/
|
|
114
|
+
function segmentTargetAt(x, segments) {
|
|
115
|
+
let best = null;
|
|
116
|
+
let distance = Infinity;
|
|
117
|
+
for (const segment of segments) {
|
|
118
|
+
const d = Math.max(segment.left - x, 0, x - segment.right);
|
|
119
|
+
if (d < distance) {
|
|
120
|
+
distance = d;
|
|
121
|
+
best = segment;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return best != null && isEnabledSegment(best.element) ? best.element : null;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* The segment a lift at viewport (`x`, `y`) commits. The press counts along
|
|
128
|
+
* the control's axis: a pointer that drifted off the control above or below
|
|
129
|
+
* keeps choosing by its horizontal position, and one past an end chooses that
|
|
130
|
+
* end. A pointer inside a segment's own box picks that segment, so a tap on a
|
|
131
|
+
* segment wrapped onto a second row keeps it.
|
|
132
|
+
*/
|
|
133
|
+
function liftTargetAt(x, y, segments) {
|
|
134
|
+
const under = segments.find(({ left, right, top, bottom }) => x >= left && x <= right && y >= top && y <= bottom);
|
|
135
|
+
if (under != null) return isEnabledSegment(under.element) ? under.element : null;
|
|
136
|
+
return segmentTargetAt(x, segments);
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* The selected face moves to another segment only once the lens's center is
|
|
140
|
+
* this far past the boundary: a quarter of that segment's width, at least
|
|
141
|
+
* 8 px, so a pointer resting on a boundary does not flip it.
|
|
142
|
+
*/
|
|
143
|
+
const FACE_HYSTERESIS_RATIO = .25;
|
|
144
|
+
const FACE_HYSTERESIS_MIN_PX = 8;
|
|
145
|
+
/**
|
|
146
|
+
* The segment whose title wears the selected face while the lens's center
|
|
147
|
+
* is at `lensCenter`, given the one wearing it now (`current`). `spans` are
|
|
148
|
+
* the enabled segments' boxes in the track's coordinates.
|
|
149
|
+
*/
|
|
150
|
+
function facedSegmentAt(lensCenter, spans, current) {
|
|
151
|
+
const sorted = [...spans].sort((a, b) => a[1].x - b[1].x);
|
|
152
|
+
const at = sorted.findIndex(([segment]) => segment === current);
|
|
153
|
+
if (at < 0) return current;
|
|
154
|
+
const edge = (i) => (sorted[i][1].x + sorted[i][1].width + sorted[i + 1][1].x) / 2;
|
|
155
|
+
let next = at;
|
|
156
|
+
while (next + 1 < sorted.length && lensCenter > edge(next)) next += 1;
|
|
157
|
+
while (next > 0 && lensCenter < edge(next - 1)) next -= 1;
|
|
158
|
+
if (next === at) return current;
|
|
159
|
+
const boundary = next > at ? edge(at) : edge(at - 1);
|
|
160
|
+
const hysteresis = Math.max(FACE_HYSTERESIS_MIN_PX, FACE_HYSTERESIS_RATIO * sorted[next][1].width);
|
|
161
|
+
return Math.abs(lensCenter - boundary) >= hysteresis ? sorted[next][0] : current;
|
|
162
|
+
}
|
|
163
|
+
//#endregion
|
|
164
|
+
//#region src/motion/uikit/segmented.ts
|
|
165
|
+
/**
|
|
166
|
+
* @file segmented.ts
|
|
167
|
+
* @input Nothing; data only
|
|
168
|
+
* @output Exports `segmentedControl`, UISegmentedControl's selection slide
|
|
169
|
+
* spring, its drag overshoot and its lift; and `registerSegmentedTable`,
|
|
170
|
+
* which registers the two springs as internal motion roles
|
|
171
|
+
* @position The segmented-control domain of the UIKit constants table
|
|
172
|
+
* (motion/uikit); read by SegmentedControl's touch presentation
|
|
173
|
+
*/
|
|
174
|
+
/**
|
|
175
|
+
* UIKit's own UISegmentedControl, measured with three text segments in a
|
|
176
|
+
* 300 × 31 pt control. A tap and a programmatic change follow the same
|
|
177
|
+
* spring. Every leaf carries a `@source`, and uikit.test.ts checks it.
|
|
178
|
+
*
|
|
179
|
+
* Some UIKit motion is left out on purpose. UIKit cross-fades the two titles
|
|
180
|
+
* that change, over 0.2 s. Astryx switches them at once, because a
|
|
181
|
+
* cross-fade needs a second copy of each title. Under Reduce Motion, UIKit's
|
|
182
|
+
* lens fades in at the new segment and scales from 0.88. Astryx allows no
|
|
183
|
+
* scaling there, so the animator's Reduce Motion cross-fade replaces it.
|
|
184
|
+
* UIKit's lens also stretches along a slide; that stretch is not modeled.
|
|
185
|
+
* The lens chases a dragging finger on the shared `springs.fingerTracking`
|
|
186
|
+
* role, which matches the values UIKit reports for this control. A flick
|
|
187
|
+
* carries the selection no further than a slow drag: UIKit projects no
|
|
188
|
+
* flick, so the release position alone decides.
|
|
189
|
+
*/
|
|
190
|
+
const segmentedControl = {
|
|
191
|
+
/**
|
|
192
|
+
* The selection indicator's slide from the old segment to the new one,
|
|
193
|
+
* after a tap or a programmatic change. Its response is 0.40 s and its
|
|
194
|
+
* damping ratio 0.85. That gives about 1.25 pt of overshoot on a 200 pt
|
|
195
|
+
* move, settled by about 0.6 s. The width follows the same spring when the
|
|
196
|
+
* segments differ in width.
|
|
197
|
+
* @source measured: UIKit lab (injected host app), iOS 26.2 simulator,
|
|
198
|
+
* iPhone 17 Pro, UIViewSpringAnimationBehavior read on the lens position
|
|
199
|
+
* for a tap and a programmatic set (dampingRatio 0.85, response 0.40,
|
|
200
|
+
* tracking off), Oct 23 2026
|
|
201
|
+
* @source measured: UIKit lab (injected host app), iOS 26.2 simulator,
|
|
202
|
+
* iPhone 17 Pro, per-frame log of the lens's presentation position and
|
|
203
|
+
* velocity (method C) for a tap, a programmatic set and an animated set,
|
|
204
|
+
* least-squares spring fit (response 0.395 / 0.405 / 0.400 s, damping
|
|
205
|
+
* ratio 0.855 / 0.845 / 0.850, rms at most 0.65 pt over 200 pt),
|
|
206
|
+
* Oct 23 2026
|
|
207
|
+
*/
|
|
208
|
+
selectionSpring: {
|
|
209
|
+
response: .4,
|
|
210
|
+
dampingRatio: .85
|
|
211
|
+
},
|
|
212
|
+
/**
|
|
213
|
+
* How far past the first or last segment's center the lens follows a
|
|
214
|
+
* dragging finger, in pt. Beyond that, the lens stays put while the finger
|
|
215
|
+
* goes on.
|
|
216
|
+
* @source measured: UIKit lab (injected host app), iOS 26.2 simulator,
|
|
217
|
+
* iPhone 17 Pro, a drag 60 pt past the last segment: the lens stops about
|
|
218
|
+
* 11 pt past its center (312 vs 301), Oct 23 2026
|
|
219
|
+
*/
|
|
220
|
+
dragOvershoot: 11,
|
|
221
|
+
/**
|
|
222
|
+
* How much a finger's press on the selected segment grows the lens, in pt
|
|
223
|
+
* (width, height). The growth is the same at every control size.
|
|
224
|
+
* @source measured: UIKit lab (injected host app), iOS 26.2 simulator,
|
|
225
|
+
* iPhone 17 Pro, per-frame lens bounds of a held selected segment:
|
|
226
|
+
* 96 × 27 to 120 × 43 (three segments), 71 × 27 to 95 × 43 (four
|
|
227
|
+
* segments), 126 × 40 to 150 × 56 (a 390 × 44 control), Oct 23 2026
|
|
228
|
+
*/
|
|
229
|
+
liftGrowth: [24, 16],
|
|
230
|
+
/**
|
|
231
|
+
* The lens growing by `liftGrowth` under a finger that presses the
|
|
232
|
+
* selected segment, and shrinking back after the release. It is critically
|
|
233
|
+
* damped and reaches 99 % in about 0.27 s.
|
|
234
|
+
* @source measured: UIKit lab (injected host app), iOS 26.2 simulator,
|
|
235
|
+
* iPhone 17 Pro, UIViewSpringAnimationBehaviorSettings read on the lens
|
|
236
|
+
* while it lifts and settles (dampingRatio 1.0, response 0.25),
|
|
237
|
+
* Oct 23 2026
|
|
238
|
+
* @source measured: UIKit lab (injected host app), iOS 26.2 simulator,
|
|
239
|
+
* iPhone 17 Pro, per-frame lens bounds of a 600 ms hold of the selected
|
|
240
|
+
* segment, spring fit with (1.0, 0.25): lift rms 0.16 pt (width) and
|
|
241
|
+
* 0.13 pt (height), settle rms 0.05 pt and 0.03 pt, each starting about
|
|
242
|
+
* 16 ms after the touch event, Nov 2 2026
|
|
243
|
+
*/
|
|
244
|
+
lift: {
|
|
245
|
+
response: .25,
|
|
246
|
+
dampingRatio: 1
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
/**
|
|
250
|
+
* Registers this table with the motion registry (motion/roles.ts). The
|
|
251
|
+
* slide's and the lift's springs become internal motion roles. The drag
|
|
252
|
+
* overshoot and the lift's growth are not motion, so they stay internal
|
|
253
|
+
* constants. Nothing registers on import, and a second call does nothing.
|
|
254
|
+
*/
|
|
255
|
+
function registerSegmentedTable() {
|
|
256
|
+
registerMotionTable("segmented", segmentedControl, { roles: ["selectionSpring", "lift"] });
|
|
257
|
+
}
|
|
258
|
+
//#endregion
|
|
259
|
+
//#region src/SegmentedControl/segmentedLens.ts
|
|
260
|
+
/** The lifted lens wears the theme's low elevation (see segmented-control.css). */
|
|
261
|
+
const LIFTED_ATTRIBUTE = "data-lifted";
|
|
262
|
+
/** A theme that gives the segments no transition: the lens lands at once. */
|
|
263
|
+
const INSTANT = easedProgress(.001, (progress) => progress);
|
|
264
|
+
const SPRINGS = {
|
|
265
|
+
selection: segmentedControl.selectionSpring,
|
|
266
|
+
lift: segmentedControl.lift,
|
|
267
|
+
tracking: springs.fingerTracking
|
|
268
|
+
};
|
|
269
|
+
var SegmentedLens = class {
|
|
270
|
+
options;
|
|
271
|
+
/** The box the lens lays out on; null while it shows nothing. */
|
|
272
|
+
box = null;
|
|
273
|
+
lens = null;
|
|
274
|
+
leaving = null;
|
|
275
|
+
animator = null;
|
|
276
|
+
leavingAnimator = null;
|
|
277
|
+
/** Velocities captured by the last `carry`, in the new box's units. */
|
|
278
|
+
velocity = {};
|
|
279
|
+
/** Bumped by every leaving fade: a finished fade hides only its own. */
|
|
280
|
+
leavingRun = 0;
|
|
281
|
+
constructor(options) {
|
|
282
|
+
this.options = options;
|
|
283
|
+
}
|
|
284
|
+
attach(lens, leaving) {
|
|
285
|
+
this.detach();
|
|
286
|
+
this.lens = lens;
|
|
287
|
+
this.leaving = leaving;
|
|
288
|
+
this.animator = createMotionEngine(lens);
|
|
289
|
+
this.leavingAnimator = createMotionEngine(leaving, { initial: { opacity: 0 } });
|
|
290
|
+
}
|
|
291
|
+
detach() {
|
|
292
|
+
for (const animator of [this.animator, this.leavingAnimator]) {
|
|
293
|
+
const element = animator?.element;
|
|
294
|
+
animator?.dispose();
|
|
295
|
+
for (const property of [
|
|
296
|
+
"translate",
|
|
297
|
+
"scale",
|
|
298
|
+
"opacity"
|
|
299
|
+
]) element?.style.removeProperty(property);
|
|
300
|
+
}
|
|
301
|
+
this.animator = this.leavingAnimator = null;
|
|
302
|
+
this.lens = this.leaving = null;
|
|
303
|
+
this.box = null;
|
|
304
|
+
this.velocity = {};
|
|
305
|
+
}
|
|
306
|
+
get isAttached() {
|
|
307
|
+
return this.animator != null;
|
|
308
|
+
}
|
|
309
|
+
/** What Reduce Motion makes of a lens motion now (see Animator.reducedMotion). */
|
|
310
|
+
reducedMotion(touchRelease = false) {
|
|
311
|
+
return this.animator?.reducedMotion({ touchRelease }) ?? "off";
|
|
312
|
+
}
|
|
313
|
+
/** The lens's presented center and size, from the animator. */
|
|
314
|
+
presented(at = this.options.now()) {
|
|
315
|
+
const box = this.box;
|
|
316
|
+
const animator = this.animator;
|
|
317
|
+
if (box == null || animator == null) return null;
|
|
318
|
+
return {
|
|
319
|
+
center: center(box) + animator.get("x", at),
|
|
320
|
+
width: box.width * animator.get("scaleX", at),
|
|
321
|
+
height: box.height * animator.get("scaleY", at)
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
/** Lays the lens out on `box` at rest, or hides it (null). Ends every motion. */
|
|
325
|
+
rest(box) {
|
|
326
|
+
this.endLeaving();
|
|
327
|
+
this.velocity = {};
|
|
328
|
+
this.animator?.stop();
|
|
329
|
+
this.box = box;
|
|
330
|
+
this.setLifted(false);
|
|
331
|
+
if (this.lens != null && box != null) place(this.lens, box);
|
|
332
|
+
this.animator?.set({
|
|
333
|
+
x: 0,
|
|
334
|
+
scaleX: 1,
|
|
335
|
+
scaleY: 1,
|
|
336
|
+
opacity: 1
|
|
337
|
+
}, { promote: false });
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Binds the lens to `box` and keeps what is on screen: the presented
|
|
341
|
+
* geometry re-based onto the new box, with its velocities kept for the
|
|
342
|
+
* next spring. Returns when that motion continues (now), so the next call
|
|
343
|
+
* starts on the same instant.
|
|
344
|
+
*/
|
|
345
|
+
carry(box) {
|
|
346
|
+
const animator = this.animator;
|
|
347
|
+
const lens = this.lens;
|
|
348
|
+
if (animator == null || lens == null) return void 0;
|
|
349
|
+
const previous = this.box;
|
|
350
|
+
const at = this.options.now();
|
|
351
|
+
this.velocity = {};
|
|
352
|
+
let start = {
|
|
353
|
+
x: 0,
|
|
354
|
+
scaleX: 1,
|
|
355
|
+
scaleY: 1
|
|
356
|
+
};
|
|
357
|
+
if (previous != null) {
|
|
358
|
+
const presented = this.presented(at);
|
|
359
|
+
start = {
|
|
360
|
+
x: presented.center - center(box),
|
|
361
|
+
scaleX: presented.width / box.width,
|
|
362
|
+
scaleY: presented.height / box.height
|
|
363
|
+
};
|
|
364
|
+
this.velocity = {
|
|
365
|
+
x: animator.getVelocity("x", at),
|
|
366
|
+
scaleX: animator.getVelocity("scaleX", at) * previous.width / box.width,
|
|
367
|
+
scaleY: animator.getVelocity("scaleY", at) * previous.height / box.height
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
this.box = box;
|
|
371
|
+
place(lens, box);
|
|
372
|
+
animator.set({
|
|
373
|
+
...start,
|
|
374
|
+
opacity: 1
|
|
375
|
+
});
|
|
376
|
+
return at;
|
|
377
|
+
}
|
|
378
|
+
/** Puts the lens's center at `x` in the track's coordinates (direct manipulation). */
|
|
379
|
+
follow(x) {
|
|
380
|
+
if (this.box != null) this.animator?.set({ x: x - center(this.box) });
|
|
381
|
+
}
|
|
382
|
+
/** Springs the lens toward `values`, keeping the velocities `carry` captured. */
|
|
383
|
+
spring(values, kind, options) {
|
|
384
|
+
const animator = this.animator;
|
|
385
|
+
if (animator == null) return;
|
|
386
|
+
this.track(animator.animate(values, this.springFrom(values, kind), options));
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* The lens lands at rest on its box on `segment`'s own transition: the
|
|
390
|
+
* theme's duration and easing, which a mouse's change plays.
|
|
391
|
+
*/
|
|
392
|
+
playThemed(segment, options) {
|
|
393
|
+
const animator = this.animator;
|
|
394
|
+
if (animator == null) return;
|
|
395
|
+
this.velocity = {};
|
|
396
|
+
const progress = readThemeTiming(segment) ?? INSTANT;
|
|
397
|
+
const at = options.at;
|
|
398
|
+
const toward = (from, to) => mapProgress(progress, mapRange([0, 1], [from, to], { clamp: false }));
|
|
399
|
+
this.track(animator.play({
|
|
400
|
+
x: toward(animator.get("x", at), 0),
|
|
401
|
+
scaleX: toward(animator.get("scaleX", at), 1),
|
|
402
|
+
scaleY: toward(animator.get("scaleY", at), 1)
|
|
403
|
+
}, options));
|
|
404
|
+
}
|
|
405
|
+
/** The lens grows to `scaleX` × `scaleY` on the lift spring and wears its elevation. */
|
|
406
|
+
lift(scaleX, scaleY) {
|
|
407
|
+
this.spring({ x: 0 }, "selection");
|
|
408
|
+
this.spring({
|
|
409
|
+
scaleX,
|
|
410
|
+
scaleY
|
|
411
|
+
}, "lift");
|
|
412
|
+
this.setLifted(true);
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* Under Reduce Motion the lens lands on `box` and fades in there, while
|
|
416
|
+
* the surface on screen fades out in place on the same clock. On a fine
|
|
417
|
+
* pointer both change at once, unless a finger released the change.
|
|
418
|
+
*/
|
|
419
|
+
crossFadeTo(box, touchRelease) {
|
|
420
|
+
const animator = this.animator;
|
|
421
|
+
if (animator == null) return;
|
|
422
|
+
const now = this.options.now();
|
|
423
|
+
const shown = this.presented(now);
|
|
424
|
+
const from = shown == null || this.box == null ? null : {
|
|
425
|
+
x: shown.center - shown.width / 2,
|
|
426
|
+
y: box.y,
|
|
427
|
+
width: shown.width,
|
|
428
|
+
height: box.height
|
|
429
|
+
};
|
|
430
|
+
const opacity = animator.get("opacity", now);
|
|
431
|
+
this.endLeaving();
|
|
432
|
+
const fades = from != null && opacity > 0 && this.reducedMotion(touchRelease) === "crossfade";
|
|
433
|
+
if (fades && this.leaving != null) {
|
|
434
|
+
place(this.leaving, from);
|
|
435
|
+
this.leaving.toggleAttribute(LIFTED_ATTRIBUTE, this.lens?.hasAttribute(LIFTED_ATTRIBUTE) === true);
|
|
436
|
+
this.leavingAnimator?.set({
|
|
437
|
+
x: 0,
|
|
438
|
+
scaleX: 1,
|
|
439
|
+
scaleY: 1,
|
|
440
|
+
opacity
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
const at = this.carry(box);
|
|
444
|
+
this.velocity = {};
|
|
445
|
+
this.setLifted(false);
|
|
446
|
+
this.track(animator.animate({
|
|
447
|
+
x: 0,
|
|
448
|
+
scaleX: 1,
|
|
449
|
+
scaleY: 1
|
|
450
|
+
}, { spring: segmentedControl.selectionSpring }, {
|
|
451
|
+
at,
|
|
452
|
+
crossfadeAs: "entrance",
|
|
453
|
+
touchRelease
|
|
454
|
+
}));
|
|
455
|
+
if (fades) this.fadeLeaving(center(box) - center(from), at, touchRelease);
|
|
456
|
+
}
|
|
457
|
+
/** Stops every motion where it is shown. */
|
|
458
|
+
stop() {
|
|
459
|
+
this.animator?.stop();
|
|
460
|
+
this.endLeaving();
|
|
461
|
+
}
|
|
462
|
+
/** The leaving surface fades out in place; as a travel, it lands only once invisible. */
|
|
463
|
+
fadeLeaving(dx, at, touchRelease) {
|
|
464
|
+
const run = ++this.leavingRun;
|
|
465
|
+
const handle = this.leavingAnimator?.animate({
|
|
466
|
+
x: dx,
|
|
467
|
+
opacity: 0
|
|
468
|
+
}, { spring: segmentedControl.selectionSpring }, {
|
|
469
|
+
at,
|
|
470
|
+
touchRelease
|
|
471
|
+
});
|
|
472
|
+
this.leaving?.setAttribute("data-shown", "");
|
|
473
|
+
handle?.finished.then(() => {
|
|
474
|
+
if (this.leavingRun === run) this.endLeaving();
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
endLeaving() {
|
|
478
|
+
this.leavingRun++;
|
|
479
|
+
if (this.leaving?.hasAttribute("data-shown") !== true) return;
|
|
480
|
+
this.leaving.removeAttribute("data-shown");
|
|
481
|
+
this.leavingAnimator?.stop();
|
|
482
|
+
this.leavingAnimator?.set({
|
|
483
|
+
x: 0,
|
|
484
|
+
opacity: 0
|
|
485
|
+
}, { promote: false });
|
|
486
|
+
}
|
|
487
|
+
setLifted(isLifted) {
|
|
488
|
+
this.lens?.toggleAttribute(LIFTED_ATTRIBUTE, isLifted);
|
|
489
|
+
}
|
|
490
|
+
/** A spring transition that keeps the captured velocities of `values`; each is spent once. */
|
|
491
|
+
springFrom(values, kind) {
|
|
492
|
+
const spring = SPRINGS[kind];
|
|
493
|
+
const velocity = {};
|
|
494
|
+
for (const key of Object.keys(values)) {
|
|
495
|
+
const v = this.velocity[key];
|
|
496
|
+
if (v != null && v !== 0) velocity[key] = v;
|
|
497
|
+
delete this.velocity[key];
|
|
498
|
+
}
|
|
499
|
+
return Object.keys(velocity).length > 0 ? {
|
|
500
|
+
spring,
|
|
501
|
+
velocity
|
|
502
|
+
} : { spring };
|
|
503
|
+
}
|
|
504
|
+
track(handle) {
|
|
505
|
+
this.options.onMotion(handle);
|
|
506
|
+
}
|
|
507
|
+
};
|
|
508
|
+
/** Lays `element` out on `box`. */
|
|
509
|
+
function place(element, box) {
|
|
510
|
+
element.style.left = `${box.x}px`;
|
|
511
|
+
element.style.top = `${box.y}px`;
|
|
512
|
+
element.style.width = `${box.width}px`;
|
|
513
|
+
element.style.height = `${box.height}px`;
|
|
514
|
+
}
|
|
515
|
+
//#endregion
|
|
516
|
+
//#region src/SegmentedControl/segmentedSelectionMotion.ts
|
|
517
|
+
const TITLE_SELECTOR = ".astryx-segmented-control-item__label";
|
|
518
|
+
function now() {
|
|
519
|
+
return typeof performance === "undefined" ? Date.now() : performance.now();
|
|
520
|
+
}
|
|
521
|
+
function titleOf(segment) {
|
|
522
|
+
return segment.querySelector(TITLE_SELECTOR);
|
|
523
|
+
}
|
|
524
|
+
function faceOf(title) {
|
|
525
|
+
return { color: getComputedStyle(title).color };
|
|
526
|
+
}
|
|
527
|
+
var SegmentedSelectionMotion = class {
|
|
528
|
+
clock;
|
|
529
|
+
track = null;
|
|
530
|
+
lens;
|
|
531
|
+
running = /* @__PURE__ */ new Set();
|
|
532
|
+
press = null;
|
|
533
|
+
/** The lens is bound to the pressed segment: a drag moves it. */
|
|
534
|
+
isHeld = false;
|
|
535
|
+
/** The held lens grew by `liftGrowth`; its settle shrinks it back. */
|
|
536
|
+
isLifted = false;
|
|
537
|
+
/** The touch presentation applies: changes slide on UIKit's springs. */
|
|
538
|
+
isPresenting = false;
|
|
539
|
+
/** The value a release already sent the lens to; its change re-aims it. */
|
|
540
|
+
committed = null;
|
|
541
|
+
/** The commit's click ran unvetoed: the lens waits for the value. */
|
|
542
|
+
isAwaitingValue = false;
|
|
543
|
+
/** The last release was a finger's. */
|
|
544
|
+
releasedByFinger = true;
|
|
545
|
+
/** The track's layout size when the lens's motion began. */
|
|
546
|
+
trackSize = {
|
|
547
|
+
width: 0,
|
|
548
|
+
height: 0
|
|
549
|
+
};
|
|
550
|
+
/** The segment showing the selected face under a dragging pointer. */
|
|
551
|
+
facedSegment = null;
|
|
552
|
+
faceOverrides = /* @__PURE__ */ new Set();
|
|
553
|
+
lensFrame = null;
|
|
554
|
+
declineTimer = null;
|
|
555
|
+
constructor(clock = now) {
|
|
556
|
+
this.clock = clock;
|
|
557
|
+
registerSpringsTable();
|
|
558
|
+
registerSegmentedTable();
|
|
559
|
+
this.lens = new SegmentedLens({
|
|
560
|
+
now: clock,
|
|
561
|
+
onMotion: (handle) => this.trackHandle(handle)
|
|
562
|
+
});
|
|
563
|
+
}
|
|
564
|
+
/** Attaches the radiogroup and its two layers, and lays the lens on the selection. */
|
|
565
|
+
attach(track, lens, leaving) {
|
|
566
|
+
this.track = track;
|
|
567
|
+
this.lens.attach(lens, leaving);
|
|
568
|
+
this.settle();
|
|
569
|
+
}
|
|
570
|
+
detach() {
|
|
571
|
+
this.stop();
|
|
572
|
+
this.lens.detach();
|
|
573
|
+
this.track?.removeAttribute("data-selection");
|
|
574
|
+
this.track = null;
|
|
575
|
+
}
|
|
576
|
+
/** A press of any pointer is down on the control. */
|
|
577
|
+
get isPressed() {
|
|
578
|
+
return this.press != null;
|
|
579
|
+
}
|
|
580
|
+
/** Whether the touch presentation applies; a change of it lands anything in flight. */
|
|
581
|
+
present(isPresenting) {
|
|
582
|
+
if (this.isPresenting === isPresenting) return;
|
|
583
|
+
this.isPresenting = isPresenting;
|
|
584
|
+
this.settle();
|
|
585
|
+
}
|
|
586
|
+
/** The selection moved from `from` to `to`; the DOM already shows `to`. */
|
|
587
|
+
select(from, to) {
|
|
588
|
+
const track = this.track;
|
|
589
|
+
if (track == null) return;
|
|
590
|
+
const destination = segmentFor(track, to);
|
|
591
|
+
const isReleaseCommit = this.committed === to;
|
|
592
|
+
this.clearFaces();
|
|
593
|
+
this.committed = null;
|
|
594
|
+
this.isAwaitingValue = false;
|
|
595
|
+
if (isReleaseCommit) {
|
|
596
|
+
if (destination != null) this.reaim(destination);
|
|
597
|
+
return;
|
|
598
|
+
}
|
|
599
|
+
const box = destination == null ? null : boxesIn(track)(destination);
|
|
600
|
+
if (destination == null || box == null || !isLaidOut(box) || this.lens.box == null || from === to) {
|
|
601
|
+
this.settle();
|
|
602
|
+
return;
|
|
603
|
+
}
|
|
604
|
+
if (!this.isPresenting && this.lens.reducedMotion() !== "off") {
|
|
605
|
+
this.settle();
|
|
606
|
+
return;
|
|
607
|
+
}
|
|
608
|
+
this.moveLensTo(destination, box, false);
|
|
609
|
+
}
|
|
610
|
+
/** A press landed on `origin` (null: none). It reads the geometry and title faces once. */
|
|
611
|
+
begin(origin, isFinger) {
|
|
612
|
+
const track = this.track;
|
|
613
|
+
if (track == null) return;
|
|
614
|
+
const segments = segmentsOf(track);
|
|
615
|
+
const boxOf = boxesIn(track);
|
|
616
|
+
const selected = selectedIn(track);
|
|
617
|
+
const other = segments.find((segment) => segment !== selected && isEnabledSegment(segment));
|
|
618
|
+
const selectedTitle = selected == null ? null : titleOf(selected);
|
|
619
|
+
const otherTitle = other == null ? null : titleOf(other);
|
|
620
|
+
this.press = {
|
|
621
|
+
toTrackX: trackXIn(track),
|
|
622
|
+
boxes: new Map(segments.map((segment) => [segment, boxOf(segment)])),
|
|
623
|
+
origin,
|
|
624
|
+
carriesLens: origin != null && origin === selected,
|
|
625
|
+
isFinger,
|
|
626
|
+
faces: selectedTitle != null && otherTitle != null ? {
|
|
627
|
+
selected: faceOf(selectedTitle),
|
|
628
|
+
unselected: faceOf(otherTitle)
|
|
629
|
+
} : null
|
|
630
|
+
};
|
|
631
|
+
}
|
|
632
|
+
/** The press tracker highlighted the press: a press on the selected segment lifts the lens. */
|
|
633
|
+
highlighted() {
|
|
634
|
+
if (this.press?.carriesLens === true) this.lift();
|
|
635
|
+
}
|
|
636
|
+
/** The pointer moved to `clientX`. A drag from the selected segment carries the lens. */
|
|
637
|
+
drag(clientX) {
|
|
638
|
+
const press = this.press;
|
|
639
|
+
if (press == null || !press.carriesLens) return;
|
|
640
|
+
this.lift();
|
|
641
|
+
this.hold();
|
|
642
|
+
if (!this.isHeld || this.lens.box == null) return;
|
|
643
|
+
const centers = [...press.boxes.values()].map(center);
|
|
644
|
+
const reach = segmentedControl.dragOvershoot;
|
|
645
|
+
const target = Math.min(Math.max(press.toTrackX(clientX), Math.min(...centers) - reach), Math.max(...centers) + reach);
|
|
646
|
+
if (!this.isPresenting || this.lens.reducedMotion() !== "off") this.lens.follow(target);
|
|
647
|
+
else this.lens.spring({ x: target - center(this.lens.box) }, "tracking", { at: this.clock() });
|
|
648
|
+
this.followLens();
|
|
649
|
+
}
|
|
650
|
+
/**
|
|
651
|
+
* The pointer let go on `target` (null: none, or disabled). Moves the lens
|
|
652
|
+
* there and returns its value when it is not the selected one (the
|
|
653
|
+
* caller's click commits it), else null.
|
|
654
|
+
*/
|
|
655
|
+
release(target) {
|
|
656
|
+
const press = this.press;
|
|
657
|
+
this.press = null;
|
|
658
|
+
if (press == null) return null;
|
|
659
|
+
const selected = [...press.boxes.keys()].find((segment) => segment.getAttribute("aria-checked") === "true") ?? null;
|
|
660
|
+
const destination = (target != null && isEnabledSegment(target) ? target : null) ?? selected;
|
|
661
|
+
const isHeld = press.carriesLens && this.isHeld;
|
|
662
|
+
this.releasedByFinger = press.isFinger;
|
|
663
|
+
if (destination == null) {
|
|
664
|
+
this.clearFaces();
|
|
665
|
+
if (isHeld) this.settle();
|
|
666
|
+
return null;
|
|
667
|
+
}
|
|
668
|
+
const value = destination !== selected ? destination.dataset.value ?? null : null;
|
|
669
|
+
if (value == null) this.clearFaces();
|
|
670
|
+
this.committed = value;
|
|
671
|
+
this.isAwaitingValue = false;
|
|
672
|
+
const box = press.boxes.get(destination);
|
|
673
|
+
if (isHeld || value != null && (this.isPresenting || this.lens.reducedMotion(press.isFinger) !== "instant")) this.moveLensTo(destination, box, press.isFinger);
|
|
674
|
+
return value;
|
|
675
|
+
}
|
|
676
|
+
/** The commit's click for `value` ran; a cancelled click sends the lens back. */
|
|
677
|
+
clicked(value, isCancelled) {
|
|
678
|
+
if (this.committed !== value) return;
|
|
679
|
+
if (isCancelled) {
|
|
680
|
+
this.decline(value);
|
|
681
|
+
return;
|
|
682
|
+
}
|
|
683
|
+
this.isAwaitingValue = true;
|
|
684
|
+
if (this.declineTimer != null) clearTimeout(this.declineTimer);
|
|
685
|
+
this.declineTimer = setTimeout(() => {
|
|
686
|
+
this.declineTimer = null;
|
|
687
|
+
if (this.committed === value && this.running.size === 0) this.decline(value);
|
|
688
|
+
}, 0);
|
|
689
|
+
}
|
|
690
|
+
/** The press was taken back (Escape, or the browser took the pointer): the lens goes back. */
|
|
691
|
+
cancel() {
|
|
692
|
+
const press = this.press;
|
|
693
|
+
this.press = null;
|
|
694
|
+
this.clearFaces();
|
|
695
|
+
if (press?.origin == null || !press.carriesLens || !this.isHeld) return;
|
|
696
|
+
this.moveLensTo(press.origin, press.boxes.get(press.origin), press.isFinger);
|
|
697
|
+
}
|
|
698
|
+
/** The control resized: a lens in motion aims at stale boxes, so it lands at once. */
|
|
699
|
+
resized() {
|
|
700
|
+
const track = this.track;
|
|
701
|
+
if (track == null || this.press != null) return;
|
|
702
|
+
if (this.running.size > 0 && Math.abs(track.offsetWidth - this.trackSize.width) < .5 && Math.abs(track.offsetHeight - this.trackSize.height) < .5) return;
|
|
703
|
+
this.settle();
|
|
704
|
+
}
|
|
705
|
+
/** Lands the lens at rest on the selected segment now, or hides it when there is none. */
|
|
706
|
+
settle() {
|
|
707
|
+
this.isHeld = false;
|
|
708
|
+
this.isLifted = false;
|
|
709
|
+
this.running.clear();
|
|
710
|
+
const track = this.track;
|
|
711
|
+
if (track == null) return;
|
|
712
|
+
const selected = selectedIn(track);
|
|
713
|
+
const box = selected == null ? null : boxesIn(track)(selected);
|
|
714
|
+
const shows = box != null && isLaidOut(box);
|
|
715
|
+
this.lens.rest(shows ? box : null);
|
|
716
|
+
track.toggleAttribute("data-selection", shows);
|
|
717
|
+
}
|
|
718
|
+
/** Ends everything in flight (unmount). */
|
|
719
|
+
stop() {
|
|
720
|
+
this.press = null;
|
|
721
|
+
this.committed = null;
|
|
722
|
+
this.isAwaitingValue = false;
|
|
723
|
+
this.cancelFrame();
|
|
724
|
+
if (this.declineTimer != null) {
|
|
725
|
+
clearTimeout(this.declineTimer);
|
|
726
|
+
this.declineTimer = null;
|
|
727
|
+
}
|
|
728
|
+
this.clearFaces();
|
|
729
|
+
this.lens.stop();
|
|
730
|
+
this.settle();
|
|
731
|
+
}
|
|
732
|
+
/** The value a release sent the lens to was not adopted: it goes back to the selection. */
|
|
733
|
+
decline(value) {
|
|
734
|
+
if (this.committed !== value) return;
|
|
735
|
+
this.committed = null;
|
|
736
|
+
this.isAwaitingValue = false;
|
|
737
|
+
this.clearFaces();
|
|
738
|
+
const track = this.track;
|
|
739
|
+
const selected = track == null ? null : selectedIn(track);
|
|
740
|
+
const box = selected == null ? null : boxesIn(track)(selected);
|
|
741
|
+
if (selected == null || box == null || !isLaidOut(box)) {
|
|
742
|
+
this.settle();
|
|
743
|
+
return;
|
|
744
|
+
}
|
|
745
|
+
this.moveLensTo(selected, box, this.releasedByFinger);
|
|
746
|
+
}
|
|
747
|
+
/** Aims the lens at `destination`'s box as it is now. */
|
|
748
|
+
reaim(destination) {
|
|
749
|
+
const track = this.track;
|
|
750
|
+
const current = this.lens.box;
|
|
751
|
+
if (track == null || current == null) return;
|
|
752
|
+
const box = boxesIn(track)(destination);
|
|
753
|
+
if (isLaidOut(box) && !isSameBox(box, current)) this.moveLensTo(destination, box, this.releasedByFinger);
|
|
754
|
+
}
|
|
755
|
+
/** A press on the selected segment binds the lens there, so a drag moves it. */
|
|
756
|
+
hold() {
|
|
757
|
+
const press = this.press;
|
|
758
|
+
if (press?.origin == null || this.isHeld) return;
|
|
759
|
+
const box = press.boxes.get(press.origin);
|
|
760
|
+
if (box == null || !isLaidOut(box)) return;
|
|
761
|
+
this.beginMotion();
|
|
762
|
+
this.lens.carry(box);
|
|
763
|
+
this.isHeld = true;
|
|
764
|
+
}
|
|
765
|
+
/** Under the touch presentation the held lens grows by `liftGrowth`. */
|
|
766
|
+
lift() {
|
|
767
|
+
if (this.isLifted || !this.isPresenting || this.lens.reducedMotion() !== "off") return;
|
|
768
|
+
this.hold();
|
|
769
|
+
const box = this.lens.box;
|
|
770
|
+
if (!this.isHeld || box == null) return;
|
|
771
|
+
const [width, height] = segmentedControl.liftGrowth;
|
|
772
|
+
this.isLifted = true;
|
|
773
|
+
this.lens.lift((box.width + width) / box.width, (box.height + height) / box.height);
|
|
774
|
+
}
|
|
775
|
+
/**
|
|
776
|
+
* The lens lands at rest on `segment`'s `box`. Under the touch
|
|
777
|
+
* presentation it springs on the slide spring (a lifted lens shrinks back
|
|
778
|
+
* on the lift's); under a fine pointer it plays the theme's timing. Under
|
|
779
|
+
* Reduce Motion it cross-fades, or lands at once.
|
|
780
|
+
*/
|
|
781
|
+
moveLensTo(segment, box, touchRelease) {
|
|
782
|
+
this.isHeld = false;
|
|
783
|
+
if (!isLaidOut(box)) {
|
|
784
|
+
this.settle();
|
|
785
|
+
return;
|
|
786
|
+
}
|
|
787
|
+
this.beginMotion();
|
|
788
|
+
const reduced = this.lens.reducedMotion(touchRelease);
|
|
789
|
+
if (reduced !== "off") {
|
|
790
|
+
this.isLifted = false;
|
|
791
|
+
if (reduced === "crossfade") this.lens.crossFadeTo(box, touchRelease);
|
|
792
|
+
else this.lens.rest(box);
|
|
793
|
+
return;
|
|
794
|
+
}
|
|
795
|
+
const at = this.lens.carry(box);
|
|
796
|
+
if (this.isPresenting && this.isLifted) {
|
|
797
|
+
this.isLifted = false;
|
|
798
|
+
this.lens.spring({ x: 0 }, "selection", { at });
|
|
799
|
+
this.lens.spring({
|
|
800
|
+
scaleX: 1,
|
|
801
|
+
scaleY: 1
|
|
802
|
+
}, "lift", { at });
|
|
803
|
+
} else if (this.isPresenting) this.lens.spring({
|
|
804
|
+
x: 0,
|
|
805
|
+
scaleX: 1,
|
|
806
|
+
scaleY: 1
|
|
807
|
+
}, "selection", { at });
|
|
808
|
+
else this.lens.playThemed(segment, { at });
|
|
809
|
+
}
|
|
810
|
+
beginMotion() {
|
|
811
|
+
const track = this.track;
|
|
812
|
+
if (track != null) this.trackSize = {
|
|
813
|
+
width: track.offsetWidth,
|
|
814
|
+
height: track.offsetHeight
|
|
815
|
+
};
|
|
816
|
+
}
|
|
817
|
+
/** Waits for `handle`: once nothing is left, the lens lands, or an unanswered commit goes back. */
|
|
818
|
+
trackHandle(handle) {
|
|
819
|
+
this.running.add(handle);
|
|
820
|
+
handle.finished.then(() => {
|
|
821
|
+
if (!this.running.delete(handle) || this.running.size > 0 || this.isHeld || this.press != null) return;
|
|
822
|
+
if (this.isAwaitingValue && this.committed != null) this.decline(this.committed);
|
|
823
|
+
else if (this.committed == null) this.settle();
|
|
824
|
+
});
|
|
825
|
+
}
|
|
826
|
+
/**
|
|
827
|
+
* The selected face follows the held lens's presented center, every frame
|
|
828
|
+
* while it is held, so the face keeps up as the lens settles under a
|
|
829
|
+
* still pointer.
|
|
830
|
+
*/
|
|
831
|
+
followLens() {
|
|
832
|
+
const press = this.press;
|
|
833
|
+
const shown = this.lens.presented();
|
|
834
|
+
if (press?.origin == null || !press.carriesLens || !this.isHeld || shown == null) {
|
|
835
|
+
this.cancelFrame();
|
|
836
|
+
return;
|
|
837
|
+
}
|
|
838
|
+
const spans = [...press.boxes.entries()].filter(([segment]) => isEnabledSegment(segment));
|
|
839
|
+
const faced = facedSegmentAt(shown.center, spans, this.facedSegment ?? press.origin);
|
|
840
|
+
this.showFaceAt(faced === press.origin ? null : faced);
|
|
841
|
+
const view = this.track?.ownerDocument.defaultView;
|
|
842
|
+
if (this.lensFrame == null && view != null) this.lensFrame = view.requestAnimationFrame(() => {
|
|
843
|
+
this.lensFrame = null;
|
|
844
|
+
this.followLens();
|
|
845
|
+
});
|
|
846
|
+
}
|
|
847
|
+
cancelFrame() {
|
|
848
|
+
if (this.lensFrame != null) {
|
|
849
|
+
this.track?.ownerDocument.defaultView?.cancelAnimationFrame(this.lensFrame);
|
|
850
|
+
this.lensFrame = null;
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
/**
|
|
854
|
+
* `segment`'s title wears the selected face and the selected segment's
|
|
855
|
+
* title an unselected one (none for null). Only the color moves: a weight
|
|
856
|
+
* swap would resize the titles under the pointer.
|
|
857
|
+
*/
|
|
858
|
+
showFaceAt(segment) {
|
|
859
|
+
const press = this.press;
|
|
860
|
+
if (segment === this.facedSegment) return;
|
|
861
|
+
this.clearFaces();
|
|
862
|
+
const selectedTitle = press?.origin == null ? null : titleOf(press.origin);
|
|
863
|
+
const title = segment == null ? null : titleOf(segment);
|
|
864
|
+
if (press?.faces == null || title == null || selectedTitle == null) return;
|
|
865
|
+
this.wearFace(title, press.faces.selected);
|
|
866
|
+
this.wearFace(selectedTitle, press.faces.unselected);
|
|
867
|
+
this.facedSegment = segment;
|
|
868
|
+
}
|
|
869
|
+
wearFace(title, face) {
|
|
870
|
+
title.style.color = face.color;
|
|
871
|
+
this.faceOverrides.add(title);
|
|
872
|
+
}
|
|
873
|
+
clearFaces() {
|
|
874
|
+
for (const title of this.faceOverrides) title.style.removeProperty("color");
|
|
875
|
+
this.faceOverrides.clear();
|
|
876
|
+
this.facedSegment = null;
|
|
877
|
+
}
|
|
878
|
+
};
|
|
879
|
+
//#endregion
|
|
880
|
+
//#region src/SegmentedControl/segmentedTracking.ts
|
|
881
|
+
/** The enabled segment a press landed on, from the element under it. */
|
|
882
|
+
function segmentUnder(track, target) {
|
|
883
|
+
const segment = target instanceof Element ? target.closest(SEGMENT_SELECTOR) : null;
|
|
884
|
+
return segment != null && track.contains(segment) && isEnabledSegment(segment) ? segment : null;
|
|
885
|
+
}
|
|
886
|
+
function attachSegmentedTracking(track, motion, isEnabled) {
|
|
887
|
+
const doc = track.ownerDocument;
|
|
888
|
+
const host = getGestureHost(doc);
|
|
889
|
+
let segments = [];
|
|
890
|
+
let beganOn = null;
|
|
891
|
+
/** The horizontal pan began: a drag, not a tap. */
|
|
892
|
+
let isDragging = false;
|
|
893
|
+
/** The press began on the selected segment, so the lens shows it. */
|
|
894
|
+
let isLensPress = false;
|
|
895
|
+
/** Escape or the browser took this press back: the rest changes nothing. */
|
|
896
|
+
let isCancelled = false;
|
|
897
|
+
let isTracking = false;
|
|
898
|
+
/** A tap lifted and its click has not run yet. */
|
|
899
|
+
let isClickToCome = false;
|
|
900
|
+
let endClickWait = null;
|
|
901
|
+
/** The segment painted as the one a drag would commit. */
|
|
902
|
+
let painted = null;
|
|
903
|
+
const fades = /* @__PURE__ */ new Map();
|
|
904
|
+
function endWait() {
|
|
905
|
+
isClickToCome = false;
|
|
906
|
+
endClickWait?.();
|
|
907
|
+
endClickWait = null;
|
|
908
|
+
}
|
|
909
|
+
function paint(next) {
|
|
910
|
+
if (next === painted) return;
|
|
911
|
+
painted?.removeAttribute(PRESSED_ATTRIBUTE);
|
|
912
|
+
painted = next;
|
|
913
|
+
if (next != null) {
|
|
914
|
+
clearTimeout(fades.get(next));
|
|
915
|
+
fades.delete(next);
|
|
916
|
+
next.setAttribute(PRESSED_ATTRIBUTE, "on");
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
/** The painted segment fades out with the shared press fade. */
|
|
920
|
+
function fadePaint() {
|
|
921
|
+
const element = painted;
|
|
922
|
+
painted = null;
|
|
923
|
+
if (element == null) return;
|
|
924
|
+
element.setAttribute(PRESSED_ATTRIBUTE, "fading");
|
|
925
|
+
fades.set(element, setTimeout(() => {
|
|
926
|
+
fades.delete(element);
|
|
927
|
+
if (element.getAttribute("data-astryx-press") === "fading") element.removeAttribute(PRESSED_ATTRIBUTE);
|
|
928
|
+
}, pressFadeMs(element)));
|
|
929
|
+
}
|
|
930
|
+
function stopTracking() {
|
|
931
|
+
isTracking = false;
|
|
932
|
+
doc.removeEventListener("keydown", onKeydown, true);
|
|
933
|
+
}
|
|
934
|
+
/** Escape or the browser took the press back: the highlight returns at once. */
|
|
935
|
+
function cancelPress() {
|
|
936
|
+
isCancelled = true;
|
|
937
|
+
endWait();
|
|
938
|
+
paint(null);
|
|
939
|
+
for (const { element } of segments) if (element.getAttribute("data-astryx-press") === "on") element.removeAttribute(PRESSED_ATTRIBUTE);
|
|
940
|
+
motion.cancel();
|
|
941
|
+
}
|
|
942
|
+
function onKeydown(event) {
|
|
943
|
+
if (event.key === "Escape" && isTracking && !isCancelled) cancelPress();
|
|
944
|
+
}
|
|
945
|
+
function commit(lifted, value, isTap) {
|
|
946
|
+
if (!isTap) {
|
|
947
|
+
motion.clicked(value, clickForLift(lifted));
|
|
948
|
+
return;
|
|
949
|
+
}
|
|
950
|
+
isClickToCome = true;
|
|
951
|
+
endClickWait = awaitBrowserClick(lifted, {
|
|
952
|
+
onClicked: (cancelled) => {
|
|
953
|
+
endClickWait = null;
|
|
954
|
+
isClickToCome = false;
|
|
955
|
+
motion.clicked(value, cancelled);
|
|
956
|
+
},
|
|
957
|
+
onNoClick: () => {
|
|
958
|
+
endClickWait = null;
|
|
959
|
+
isClickToCome = false;
|
|
960
|
+
motion.clicked(value, clickForLift(lifted));
|
|
961
|
+
}
|
|
962
|
+
});
|
|
963
|
+
}
|
|
964
|
+
function lift(event, touch) {
|
|
965
|
+
stopTracking();
|
|
966
|
+
if (isCancelled) {
|
|
967
|
+
armClickGuard(doc);
|
|
968
|
+
return;
|
|
969
|
+
}
|
|
970
|
+
if (hasNoLayout(segments)) {
|
|
971
|
+
paint(null);
|
|
972
|
+
motion.cancel();
|
|
973
|
+
return;
|
|
974
|
+
}
|
|
975
|
+
const lifted = liftTargetAt(touch.x, touch.y, segments);
|
|
976
|
+
if (isDragging && !isLensPress) paint(lifted != null && lifted.getAttribute("aria-checked") !== "true" ? lifted : null);
|
|
977
|
+
fadePaint();
|
|
978
|
+
const isTap = event === "touchUpInside" && !isDragging && lifted != null && lifted === beganOn;
|
|
979
|
+
const value = motion.release(lifted);
|
|
980
|
+
if (value != null && lifted != null) commit(lifted, value, isTap);
|
|
981
|
+
}
|
|
982
|
+
function land(touch) {
|
|
983
|
+
endWait();
|
|
984
|
+
isDragging = false;
|
|
985
|
+
isCancelled = false;
|
|
986
|
+
isTracking = true;
|
|
987
|
+
segments = measureSegments(track);
|
|
988
|
+
beganOn = segmentUnder(track, touch.target);
|
|
989
|
+
isLensPress = beganOn?.getAttribute("aria-checked") === "true";
|
|
990
|
+
motion.begin(beganOn, touch.pointerType === "touch");
|
|
991
|
+
doc.addEventListener("keydown", onKeydown, true);
|
|
992
|
+
}
|
|
993
|
+
/** The press from landing to lift; the horizontal pan follows the drag in between. */
|
|
994
|
+
function onControlEvent(event, touch) {
|
|
995
|
+
if (event === "touchDown") land(touch);
|
|
996
|
+
else if (event === "touchUpInside" || event === "touchUpOutside") lift(event, touch);
|
|
997
|
+
else if (event === "touchCancel") {
|
|
998
|
+
stopTracking();
|
|
999
|
+
if (!isCancelled) cancelPress();
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
const tracker = createPressTracker({
|
|
1003
|
+
view: track,
|
|
1004
|
+
getBounds: () => track.getBoundingClientRect(),
|
|
1005
|
+
isEnabled,
|
|
1006
|
+
onControlEvent,
|
|
1007
|
+
onHighlightChange: (isHighlighted) => {
|
|
1008
|
+
if (isHighlighted && !isCancelled) motion.highlighted();
|
|
1009
|
+
}
|
|
1010
|
+
});
|
|
1011
|
+
const pan = new PanGestureRecognizer({
|
|
1012
|
+
name: "segmented-control-drag",
|
|
1013
|
+
direction: "horizontal",
|
|
1014
|
+
cancelsTouchesInView: false,
|
|
1015
|
+
selectionLock: lockSelection
|
|
1016
|
+
});
|
|
1017
|
+
const detachers = [
|
|
1018
|
+
host.attachConsumer(track, tracker),
|
|
1019
|
+
host.attach(track, pan),
|
|
1020
|
+
pan.addListener((current) => {
|
|
1021
|
+
if (isCancelled || !isTracking || current.state !== "began" && current.state !== "changed") return;
|
|
1022
|
+
isDragging = true;
|
|
1023
|
+
const { x, y } = current.location();
|
|
1024
|
+
motion.drag(x);
|
|
1025
|
+
if (!isLensPress && !hasNoLayout(segments)) {
|
|
1026
|
+
const target = liftTargetAt(x, y, segments);
|
|
1027
|
+
paint(target != null && target.getAttribute("aria-checked") !== "true" ? target : null);
|
|
1028
|
+
}
|
|
1029
|
+
}),
|
|
1030
|
+
() => tracker.dispose()
|
|
1031
|
+
];
|
|
1032
|
+
return {
|
|
1033
|
+
isPressing: () => isTracking || isClickToCome,
|
|
1034
|
+
keyPressed: endWait,
|
|
1035
|
+
detach: () => {
|
|
1036
|
+
stopTracking();
|
|
1037
|
+
endWait();
|
|
1038
|
+
paint(null);
|
|
1039
|
+
for (const [element, timer] of fades) {
|
|
1040
|
+
clearTimeout(timer);
|
|
1041
|
+
if (element.getAttribute("data-astryx-press") === "fading") element.removeAttribute(PRESSED_ATTRIBUTE);
|
|
1042
|
+
}
|
|
1043
|
+
fades.clear();
|
|
1044
|
+
for (const detach of detachers) detach();
|
|
1045
|
+
}
|
|
1046
|
+
};
|
|
1047
|
+
}
|
|
1048
|
+
//#endregion
|
|
1049
|
+
//#region src/SegmentedControl/useSegmentedSelection.ts
|
|
1050
|
+
/**
|
|
1051
|
+
* Lays the lens on the selected segment once there is layout (before that,
|
|
1052
|
+
* and on the server, the selected segment paints its own surface), moves it
|
|
1053
|
+
* on every change, and tracks presses of every pointer.
|
|
1054
|
+
*/
|
|
1055
|
+
function useSegmentedSelection(parts, options) {
|
|
1056
|
+
const isTouch = useCoarsePointer();
|
|
1057
|
+
const motion = new SegmentedSelectionMotion();
|
|
1058
|
+
let tracking = null;
|
|
1059
|
+
const observed = /* @__PURE__ */ new Map();
|
|
1060
|
+
function onResize() {
|
|
1061
|
+
motion.resized();
|
|
1062
|
+
}
|
|
1063
|
+
/** Every segment and the track: a segment that grows, wraps or loads a font moves the lens's box. */
|
|
1064
|
+
function syncObserved() {
|
|
1065
|
+
const track = parts.track.value;
|
|
1066
|
+
const elements = new Set(track == null ? [] : [track, ...track.querySelectorAll(SEGMENT_SELECTOR)]);
|
|
1067
|
+
for (const [element, unobserve] of observed) if (!elements.has(element)) {
|
|
1068
|
+
unobserve();
|
|
1069
|
+
observed.delete(element);
|
|
1070
|
+
}
|
|
1071
|
+
for (const element of elements) if (!observed.has(element)) observed.set(element, observeResize(element, onResize));
|
|
1072
|
+
}
|
|
1073
|
+
watch(options.value, (to, from) => motion.select(from ?? "", to ?? ""), { flush: "post" });
|
|
1074
|
+
watch(isTouch, (touch) => motion.present(touch), { flush: "post" });
|
|
1075
|
+
onMounted(() => {
|
|
1076
|
+
const track = parts.track.value;
|
|
1077
|
+
const lens = parts.lens.value;
|
|
1078
|
+
const leaving = parts.leaving.value;
|
|
1079
|
+
if (track == null || lens == null || leaving == null) return;
|
|
1080
|
+
motion.present(isTouch.value);
|
|
1081
|
+
motion.attach(track, lens, leaving);
|
|
1082
|
+
tracking = attachSegmentedTracking(track, motion, options.isEnabled);
|
|
1083
|
+
syncObserved();
|
|
1084
|
+
});
|
|
1085
|
+
onUpdated(syncObserved);
|
|
1086
|
+
onBeforeUnmount(() => {
|
|
1087
|
+
for (const unobserve of observed.values()) unobserve();
|
|
1088
|
+
observed.clear();
|
|
1089
|
+
tracking?.detach();
|
|
1090
|
+
tracking = null;
|
|
1091
|
+
motion.detach();
|
|
1092
|
+
});
|
|
1093
|
+
return {
|
|
1094
|
+
isTouch,
|
|
1095
|
+
isPressing: () => tracking?.isPressing() ?? false,
|
|
1096
|
+
keyPressed: () => tracking?.keyPressed()
|
|
1097
|
+
};
|
|
1098
|
+
}
|
|
1099
|
+
//#endregion
|
|
1100
|
+
//#region src/SegmentedControl/SegmentedControl.vue
|
|
1101
|
+
const _hoisted_1$1 = [
|
|
1102
|
+
"aria-describedby",
|
|
1103
|
+
"aria-disabled",
|
|
1104
|
+
"aria-label",
|
|
1105
|
+
"data-disabled",
|
|
1106
|
+
"data-disabled-message",
|
|
1107
|
+
"data-layout",
|
|
1108
|
+
"data-size",
|
|
1109
|
+
"data-touch"
|
|
1110
|
+
];
|
|
1111
|
+
const ITEM_SELECTOR = "[role=\"radio\"]";
|
|
1112
|
+
const TOOLTIP_SHOW_DELAY = 200;
|
|
1113
|
+
const TOOLTIP_HIDE_DELAY = 100;
|
|
1114
|
+
const _sfc_main$1 = /*@__PURE__*/ defineComponent({
|
|
1115
|
+
name: "AstryxSegmentedControl",
|
|
1116
|
+
inheritAttrs: false,
|
|
1117
|
+
__name: "SegmentedControl",
|
|
1118
|
+
props: /*@__PURE__*/ mergeModels({
|
|
1119
|
+
label: {},
|
|
1120
|
+
size: {},
|
|
1121
|
+
layout: { default: "hug" },
|
|
1122
|
+
isDisabled: {
|
|
1123
|
+
type: Boolean,
|
|
1124
|
+
default: false
|
|
1125
|
+
},
|
|
1126
|
+
disabledMessage: {}
|
|
1127
|
+
}, {
|
|
1128
|
+
"modelValue": { required: true },
|
|
1129
|
+
"modelModifiers": {}
|
|
1130
|
+
}),
|
|
1131
|
+
emits: /*@__PURE__*/ mergeModels(["update:modelValue", "change"], ["update:modelValue"]),
|
|
1132
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
1133
|
+
const props = __props;
|
|
1134
|
+
const emit = __emit;
|
|
1135
|
+
const size = useSize(() => props.size, "md");
|
|
1136
|
+
const model = useModel(__props, "modelValue");
|
|
1137
|
+
const attrs = useAttrs();
|
|
1138
|
+
const root = useTemplateRef("root");
|
|
1139
|
+
const tooltipId = `astryx-segmented-control-${useId()}-tooltip`;
|
|
1140
|
+
const element = computed(() => root.value ?? null);
|
|
1141
|
+
const lens = useTemplateRef("lens");
|
|
1142
|
+
const leaving = useTemplateRef("leaving");
|
|
1143
|
+
const selection = useSegmentedSelection({
|
|
1144
|
+
track: root,
|
|
1145
|
+
lens,
|
|
1146
|
+
leaving
|
|
1147
|
+
}, {
|
|
1148
|
+
value: () => model.value,
|
|
1149
|
+
isEnabled: () => !props.isDisabled
|
|
1150
|
+
});
|
|
1151
|
+
__expose({ element });
|
|
1152
|
+
const showsDisabledMessage = computed(() => props.isDisabled && !!props.disabledMessage?.trim());
|
|
1153
|
+
function select(value) {
|
|
1154
|
+
if (props.isDisabled || value === model.value) return;
|
|
1155
|
+
model.value = value;
|
|
1156
|
+
emit("change", value);
|
|
1157
|
+
}
|
|
1158
|
+
provide(segmentedControlContextKey, {
|
|
1159
|
+
value: computed(() => model.value),
|
|
1160
|
+
size,
|
|
1161
|
+
layout: computed(() => props.layout),
|
|
1162
|
+
isDisabled: computed(() => props.isDisabled),
|
|
1163
|
+
hasDisabledMessage: showsDisabledMessage,
|
|
1164
|
+
disabledReasonId: computed(() => showsDisabledMessage.value ? tooltipId : void 0),
|
|
1165
|
+
select
|
|
1166
|
+
});
|
|
1167
|
+
function getItems() {
|
|
1168
|
+
const element = root.value;
|
|
1169
|
+
return element == null ? [] : Array.from(element.querySelectorAll(ITEM_SELECTOR));
|
|
1170
|
+
}
|
|
1171
|
+
function isItemDisabled(item) {
|
|
1172
|
+
return item.getAttribute("aria-disabled") === "true" || item.disabled === true || item.hasAttribute("disabled");
|
|
1173
|
+
}
|
|
1174
|
+
function setTabIndex(item, value) {
|
|
1175
|
+
if (item.getAttribute("tabindex") !== String(value)) item.setAttribute("tabindex", String(value));
|
|
1176
|
+
}
|
|
1177
|
+
/** 分段自己被禁用(不是整个控件被禁用)。 */
|
|
1178
|
+
function isDisabledOnItsOwn(item) {
|
|
1179
|
+
return item.hasAttribute("data-own-disabled");
|
|
1180
|
+
}
|
|
1181
|
+
/**
|
|
1182
|
+
* 控件始终有且只有一个 Tab 落脚点:选中的分段,不管它是否被禁用、整个控件是否被禁用;
|
|
1183
|
+
* 没有选中的分段时,取第一个没有被自己禁用的分段,再不行取第一个。
|
|
1184
|
+
*/
|
|
1185
|
+
function syncTabStops() {
|
|
1186
|
+
const items = getItems();
|
|
1187
|
+
if (items.length === 0) return;
|
|
1188
|
+
const stop = items.find((item) => item.getAttribute("aria-checked") === "true") ?? items.find((item) => !isDisabledOnItsOwn(item)) ?? items[0];
|
|
1189
|
+
for (const item of items) setTabIndex(item, item === stop ? 0 : -1);
|
|
1190
|
+
}
|
|
1191
|
+
onMounted(syncTabStops);
|
|
1192
|
+
onUpdated(syncTabStops);
|
|
1193
|
+
function isRtl() {
|
|
1194
|
+
const element = root.value;
|
|
1195
|
+
return element != null && typeof window !== "undefined" && window.getComputedStyle(element).direction === "rtl";
|
|
1196
|
+
}
|
|
1197
|
+
function findEnabledIndex(items, start, step, wrap) {
|
|
1198
|
+
let index = start;
|
|
1199
|
+
for (let visited = 0; visited < items.length; visited += 1) {
|
|
1200
|
+
if (index < 0 || index >= items.length) {
|
|
1201
|
+
if (!wrap) return -1;
|
|
1202
|
+
index = (index + items.length) % items.length;
|
|
1203
|
+
}
|
|
1204
|
+
const item = items[index];
|
|
1205
|
+
if (item != null && !isItemDisabled(item)) return index;
|
|
1206
|
+
index += step;
|
|
1207
|
+
}
|
|
1208
|
+
return -1;
|
|
1209
|
+
}
|
|
1210
|
+
function focusIndex(items, index) {
|
|
1211
|
+
const target = items[index];
|
|
1212
|
+
if (target == null) return;
|
|
1213
|
+
for (const item of items) setTabIndex(item, item === target ? 0 : -1);
|
|
1214
|
+
target.focus();
|
|
1215
|
+
}
|
|
1216
|
+
function handleKeydown(event) {
|
|
1217
|
+
selection.keyPressed();
|
|
1218
|
+
invokeNativeEventHandler(attrs.onKeydown ?? attrs.onKeyDown, event);
|
|
1219
|
+
if (event.defaultPrevented || event.ctrlKey || event.metaKey || event.altKey) return;
|
|
1220
|
+
const items = getItems();
|
|
1221
|
+
if (items.length === 0) return;
|
|
1222
|
+
const rtl = (event.key === "ArrowRight" || event.key === "ArrowLeft") && isRtl();
|
|
1223
|
+
const nextKey = rtl ? "ArrowLeft" : "ArrowRight";
|
|
1224
|
+
const previousKey = rtl ? "ArrowRight" : "ArrowLeft";
|
|
1225
|
+
const active = typeof document === "undefined" ? null : document.activeElement;
|
|
1226
|
+
const currentIndex = items.findIndex((item) => item === active || item.contains(active));
|
|
1227
|
+
let targetIndex = -1;
|
|
1228
|
+
if (event.key === nextKey) targetIndex = findEnabledIndex(items, currentIndex === -1 ? 0 : currentIndex + 1, 1, true);
|
|
1229
|
+
else if (event.key === previousKey) targetIndex = findEnabledIndex(items, currentIndex === -1 ? items.length - 1 : currentIndex - 1, -1, true);
|
|
1230
|
+
else if (event.key === "Home") targetIndex = findEnabledIndex(items, 0, 1, false);
|
|
1231
|
+
else if (event.key === "End") targetIndex = findEnabledIndex(items, items.length - 1, -1, false);
|
|
1232
|
+
else return;
|
|
1233
|
+
event.preventDefault();
|
|
1234
|
+
if (targetIndex !== -1 && targetIndex !== currentIndex) focusIndex(items, targetIndex);
|
|
1235
|
+
}
|
|
1236
|
+
onMounted(() => root.value?.addEventListener("keydown", handleKeydown));
|
|
1237
|
+
onBeforeUnmount(() => root.value?.removeEventListener("keydown", handleKeydown));
|
|
1238
|
+
function matchesFocusVisible(element) {
|
|
1239
|
+
try {
|
|
1240
|
+
return element.matches(":focus-visible");
|
|
1241
|
+
} catch {
|
|
1242
|
+
return false;
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
function handleFocusIn(event) {
|
|
1246
|
+
invokeNativeEventHandler(attrs.onFocusin ?? attrs.onFocusIn, event);
|
|
1247
|
+
if (event.defaultPrevented) return;
|
|
1248
|
+
syncTabStops();
|
|
1249
|
+
if (showsDisabledMessage.value) {
|
|
1250
|
+
const target = event.target;
|
|
1251
|
+
if (target instanceof HTMLElement && matchesFocusVisible(target)) showTooltip();
|
|
1252
|
+
}
|
|
1253
|
+
if (props.isDisabled || selection.isPressing()) return;
|
|
1254
|
+
if (!event.currentTarget?.contains(event.relatedTarget)) return;
|
|
1255
|
+
const focused = event.target?.closest("[role=\"radio\"][data-value]");
|
|
1256
|
+
if (focused == null || focused.getAttribute("aria-disabled") === "true") return;
|
|
1257
|
+
const next = focused.dataset.value;
|
|
1258
|
+
if (next != null) select(next);
|
|
1259
|
+
}
|
|
1260
|
+
const isTooltipOpen = shallowRef(false);
|
|
1261
|
+
let showTimer;
|
|
1262
|
+
let hideTimer;
|
|
1263
|
+
function clearTimers() {
|
|
1264
|
+
clearTimeout(showTimer);
|
|
1265
|
+
clearTimeout(hideTimer);
|
|
1266
|
+
showTimer = void 0;
|
|
1267
|
+
hideTimer = void 0;
|
|
1268
|
+
}
|
|
1269
|
+
function showTooltip() {
|
|
1270
|
+
if (!showsDisabledMessage.value) return;
|
|
1271
|
+
clearTimers();
|
|
1272
|
+
isTooltipOpen.value = true;
|
|
1273
|
+
}
|
|
1274
|
+
function hideTooltip() {
|
|
1275
|
+
clearTimers();
|
|
1276
|
+
isTooltipOpen.value = false;
|
|
1277
|
+
}
|
|
1278
|
+
function scheduleShowTooltip() {
|
|
1279
|
+
if (!showsDisabledMessage.value) return;
|
|
1280
|
+
clearTimers();
|
|
1281
|
+
showTimer = setTimeout(showTooltip, TOOLTIP_SHOW_DELAY);
|
|
1282
|
+
}
|
|
1283
|
+
function scheduleHideTooltip() {
|
|
1284
|
+
if (!showsDisabledMessage.value) return;
|
|
1285
|
+
clearTimers();
|
|
1286
|
+
hideTimer = setTimeout(hideTooltip, TOOLTIP_HIDE_DELAY);
|
|
1287
|
+
}
|
|
1288
|
+
onScopeDispose(clearTimers);
|
|
1289
|
+
const controlledAttrs = /* @__PURE__ */ new Set([
|
|
1290
|
+
"aria-describedby",
|
|
1291
|
+
"aria-disabled",
|
|
1292
|
+
"aria-label",
|
|
1293
|
+
"class",
|
|
1294
|
+
"onFocusIn",
|
|
1295
|
+
"onFocusin",
|
|
1296
|
+
"onKeyDown",
|
|
1297
|
+
"onKeydown",
|
|
1298
|
+
"role",
|
|
1299
|
+
"style"
|
|
1300
|
+
]);
|
|
1301
|
+
const forwardedAttrs = computed(() => Object.fromEntries(Object.entries(attrs).filter(([key]) => !controlledAttrs.has(key))));
|
|
1302
|
+
const rootClass = computed(() => ["astryx-segmented-control", attrs.class]);
|
|
1303
|
+
const rootStyle = computed(() => attrs.style);
|
|
1304
|
+
const describedBy = computed(() => [attrs["aria-describedby"], showsDisabledMessage.value ? tooltipId : void 0].filter(Boolean).join(" ") || void 0);
|
|
1305
|
+
return (_ctx, _cache) => {
|
|
1306
|
+
return openBlock(), createElementBlock(Fragment, null, [createElementVNode("div", mergeProps({
|
|
1307
|
+
ref_key: "root",
|
|
1308
|
+
ref: root
|
|
1309
|
+
}, forwardedAttrs.value, {
|
|
1310
|
+
"aria-describedby": describedBy.value,
|
|
1311
|
+
"aria-disabled": __props.isDisabled || void 0,
|
|
1312
|
+
"aria-label": __props.label,
|
|
1313
|
+
class: rootClass.value,
|
|
1314
|
+
"data-disabled": __props.isDisabled || void 0,
|
|
1315
|
+
"data-disabled-message": showsDisabledMessage.value || void 0,
|
|
1316
|
+
"data-layout": __props.layout,
|
|
1317
|
+
"data-size": unref(size),
|
|
1318
|
+
"data-touch": unref(selection).isTouch.value || void 0,
|
|
1319
|
+
style: rootStyle.value,
|
|
1320
|
+
role: "radiogroup",
|
|
1321
|
+
onFocusin: handleFocusIn,
|
|
1322
|
+
onFocusout: scheduleHideTooltip,
|
|
1323
|
+
onPointerenter: scheduleShowTooltip,
|
|
1324
|
+
onPointerleave: scheduleHideTooltip
|
|
1325
|
+
}), [
|
|
1326
|
+
createElementVNode("span", {
|
|
1327
|
+
ref_key: "lens",
|
|
1328
|
+
ref: lens,
|
|
1329
|
+
class: "astryx-segmented-control__selection",
|
|
1330
|
+
"aria-hidden": "true"
|
|
1331
|
+
}, null, 512),
|
|
1332
|
+
createElementVNode("span", {
|
|
1333
|
+
ref_key: "leaving",
|
|
1334
|
+
ref: leaving,
|
|
1335
|
+
class: "astryx-segmented-control__selection astryx-segmented-control__selection--leaving",
|
|
1336
|
+
"aria-hidden": "true"
|
|
1337
|
+
}, null, 512),
|
|
1338
|
+
renderSlot(_ctx.$slots, "default")
|
|
1339
|
+
], 16, _hoisted_1$1), showsDisabledMessage.value ? (openBlock(), createBlock(_sfc_main$2, {
|
|
1340
|
+
key: 0,
|
|
1341
|
+
id: tooltipId,
|
|
1342
|
+
anchor: root.value,
|
|
1343
|
+
open: isTooltipOpen.value,
|
|
1344
|
+
text: __props.disabledMessage ?? "",
|
|
1345
|
+
onPointerEnter: clearTimers,
|
|
1346
|
+
onPointerLeave: scheduleHideTooltip
|
|
1347
|
+
}, null, 8, [
|
|
1348
|
+
"anchor",
|
|
1349
|
+
"open",
|
|
1350
|
+
"text"
|
|
1351
|
+
])) : createCommentVNode("v-if", true)], 64);
|
|
1352
|
+
};
|
|
1353
|
+
}
|
|
1354
|
+
});
|
|
1355
|
+
//#endregion
|
|
1356
|
+
//#region src/SegmentedControl/SegmentedControlItem.vue
|
|
1357
|
+
const _hoisted_1 = [
|
|
1358
|
+
"aria-checked",
|
|
1359
|
+
"aria-describedby",
|
|
1360
|
+
"aria-disabled",
|
|
1361
|
+
"aria-label",
|
|
1362
|
+
"data-own-disabled",
|
|
1363
|
+
"data-icon-only",
|
|
1364
|
+
"data-selected",
|
|
1365
|
+
"data-size",
|
|
1366
|
+
"data-value",
|
|
1367
|
+
"tabindex"
|
|
1368
|
+
];
|
|
1369
|
+
const _hoisted_2 = {
|
|
1370
|
+
key: 0,
|
|
1371
|
+
class: "astryx-segmented-control-item__icon",
|
|
1372
|
+
"aria-hidden": "true"
|
|
1373
|
+
};
|
|
1374
|
+
const _hoisted_3 = {
|
|
1375
|
+
key: 1,
|
|
1376
|
+
class: "astryx-segmented-control-item__label"
|
|
1377
|
+
};
|
|
1378
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
1379
|
+
name: "AstryxSegmentedControlItem",
|
|
1380
|
+
inheritAttrs: false,
|
|
1381
|
+
__name: "SegmentedControlItem",
|
|
1382
|
+
props: {
|
|
1383
|
+
value: {},
|
|
1384
|
+
label: {},
|
|
1385
|
+
isLabelHidden: {
|
|
1386
|
+
type: Boolean,
|
|
1387
|
+
default: false
|
|
1388
|
+
},
|
|
1389
|
+
isDisabled: {
|
|
1390
|
+
type: Boolean,
|
|
1391
|
+
default: false
|
|
1392
|
+
}
|
|
1393
|
+
},
|
|
1394
|
+
setup(__props, { expose: __expose }) {
|
|
1395
|
+
const props = __props;
|
|
1396
|
+
const attrs = useAttrs();
|
|
1397
|
+
const press = usePressFeedback({ hasOverlay: false });
|
|
1398
|
+
const context = readLayerScoped(segmentedControlContextKey);
|
|
1399
|
+
const root = useTemplateRef("root");
|
|
1400
|
+
const element = computed(() => root.value ?? null);
|
|
1401
|
+
__expose({ element });
|
|
1402
|
+
const size = computed(() => context?.size.value ?? "md");
|
|
1403
|
+
const isSelected = computed(() => context != null && context.value.value === props.value);
|
|
1404
|
+
const isDisabled = computed(() => props.isDisabled || (context?.isDisabled.value ?? false));
|
|
1405
|
+
const iconOnly = computed(() => props.isLabelHidden);
|
|
1406
|
+
const tabIndex = computed(() => {
|
|
1407
|
+
if (context == null) return props.isDisabled ? -1 : 0;
|
|
1408
|
+
return isSelected.value ? 0 : -1;
|
|
1409
|
+
});
|
|
1410
|
+
const describedBy = computed(() => [attrs["aria-describedby"], context?.disabledReasonId.value].filter(Boolean).join(" ") || void 0);
|
|
1411
|
+
function handleClick(event) {
|
|
1412
|
+
if (isDisabled.value) return;
|
|
1413
|
+
invokeNativeEventHandler(attrs.onClick, event);
|
|
1414
|
+
if (event.defaultPrevented) return;
|
|
1415
|
+
context?.select(props.value);
|
|
1416
|
+
}
|
|
1417
|
+
const controlledAttrs = /* @__PURE__ */ new Set([
|
|
1418
|
+
"aria-checked",
|
|
1419
|
+
"aria-describedby",
|
|
1420
|
+
"aria-disabled",
|
|
1421
|
+
"aria-label",
|
|
1422
|
+
"class",
|
|
1423
|
+
"data-value",
|
|
1424
|
+
"onClick",
|
|
1425
|
+
"role",
|
|
1426
|
+
"style",
|
|
1427
|
+
"tabindex",
|
|
1428
|
+
"type"
|
|
1429
|
+
]);
|
|
1430
|
+
const forwardedAttrs = computed(() => Object.fromEntries(Object.entries(attrs).filter(([key]) => !controlledAttrs.has(key))));
|
|
1431
|
+
useTouchHitArea(element, () => !isDisabled.value);
|
|
1432
|
+
const rootClass = computed(() => [
|
|
1433
|
+
"astryx-segmented-control-item",
|
|
1434
|
+
{ "astryx-touch-hit-area": !isDisabled.value },
|
|
1435
|
+
attrs.class
|
|
1436
|
+
]);
|
|
1437
|
+
return (_ctx, _cache) => {
|
|
1438
|
+
return openBlock(), createElementBlock("button", mergeProps({
|
|
1439
|
+
ref_key: "root",
|
|
1440
|
+
ref: root
|
|
1441
|
+
}, {
|
|
1442
|
+
...forwardedAttrs.value,
|
|
1443
|
+
...isDisabled.value ? {} : unref(press).pressableProps
|
|
1444
|
+
}, {
|
|
1445
|
+
"aria-checked": isSelected.value,
|
|
1446
|
+
"aria-describedby": describedBy.value,
|
|
1447
|
+
"aria-disabled": isDisabled.value || void 0,
|
|
1448
|
+
"aria-label": __props.isLabelHidden ? __props.label : void 0,
|
|
1449
|
+
class: rootClass.value,
|
|
1450
|
+
"data-own-disabled": props.isDisabled || void 0,
|
|
1451
|
+
"data-icon-only": iconOnly.value || void 0,
|
|
1452
|
+
"data-selected": isSelected.value || void 0,
|
|
1453
|
+
"data-size": size.value,
|
|
1454
|
+
"data-value": __props.value,
|
|
1455
|
+
style: unref(attrs).style,
|
|
1456
|
+
tabindex: tabIndex.value,
|
|
1457
|
+
role: "radio",
|
|
1458
|
+
type: "button",
|
|
1459
|
+
onClick: handleClick
|
|
1460
|
+
}), [unref(hasSlotContent)(_ctx.$slots.icon) ? (openBlock(), createElementBlock("span", _hoisted_2, [renderSlot(_ctx.$slots, "icon")])) : createCommentVNode("v-if", true), !__props.isLabelHidden ? (openBlock(), createElementBlock("span", _hoisted_3, toDisplayString(__props.label), 1)) : createCommentVNode("v-if", true)], 16, _hoisted_1);
|
|
1461
|
+
};
|
|
1462
|
+
}
|
|
1463
|
+
});
|
|
1464
|
+
//#endregion
|
|
1465
|
+
export { _sfc_main$1 as n, _sfc_main as t };
|