@astryx-vue/core 0.2.3 → 0.2.5
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/README.md +28 -26
- package/THIRD_PARTY_NOTICES.md +2 -0
- package/dist/AlertDialog/index.js +1 -1
- package/dist/{AlertDialog-ovx4cBjM.js → AlertDialog-B6UeBCE7.js} +2 -2
- package/dist/AppShell/index.js +1 -1
- package/dist/{AppShell-Dd-D4bA2.js → AppShell-CeBmB0Q9.js} +2 -2
- package/dist/Avatar/index.d.ts +1 -1
- package/dist/Avatar/index.js +1 -1
- package/dist/{Avatar-jmHInHwj.js → Avatar-BB4Z4LF1.js} +10 -4
- package/dist/AvatarGroup/index.d.ts +1 -1
- package/dist/Banner/index.d.ts +1 -1
- package/dist/BottomSheet/index.d.ts +2 -2
- package/dist/BottomSheet/index.js +3 -2
- package/dist/{BottomSheet-Dg95HB1s.js → BottomSheet-BV6vfgGu.js} +82 -22
- package/dist/BottomSheet-o7xw-TOi.js +153 -0
- package/dist/Breadcrumbs/index.d.ts +2 -2
- package/dist/Breadcrumbs/index.js +2 -2
- package/dist/{Breadcrumbs-CWGfgLNK.js → Breadcrumbs-D6G7f5WL.js} +1 -1
- package/dist/Button/index.d.ts +1 -1
- package/dist/ButtonGroup/index.d.ts +1 -1
- package/dist/Calendar/index.d.ts +1 -1
- package/dist/Calendar/index.js +1 -1
- package/dist/{Calendar-CnOsSjMY.js → Calendar-DmTeM7PO.js} +2 -2
- package/dist/Carousel/index.js +1 -1
- package/dist/{Carousel-JA7ilqI_.js → Carousel-CIKrcA2r.js} +1 -1
- package/dist/Chat/index.js +1 -1
- package/dist/{Chat-C7WrCOE4.js → Chat-BFox3u9D.js} +1 -1
- package/dist/CheckboxInput/index.d.ts +1 -1
- package/dist/CheckboxList/index.d.ts +1 -1
- package/dist/CheckboxList/index.js +1 -1
- package/dist/{CheckboxList-CnCGnkZk.js → CheckboxList-BlPf7vPe.js} +4 -4
- package/dist/Citation/index.js +1 -1
- package/dist/{Citation-CtwrU33I.js → Citation-BG-vg9ia.js} +1 -1
- package/dist/ClickableCard/index.d.ts +1 -1
- package/dist/Code/index.d.ts +3 -3
- package/dist/Code/index.js +4 -4
- package/dist/{Code-BvefYRpx.js → Code-XnPuGxey.js} +1 -1
- package/dist/{CodeBlock-BZGzYeoL.js → CodeBlock-B2pnEOJY.js} +145 -15
- package/dist/CommandPalette/index.js +1 -1
- package/dist/{CommandPalette-BNbM9T9y.js → CommandPalette-DKgHzmJk.js} +10 -10
- package/dist/ComplexSelector/index.js +1 -1
- package/dist/{ComplexSelector-LtbLlrcj.js → ComplexSelector-Dv44FFhN.js} +1 -1
- package/dist/ContextMenu/index.d.ts +2 -2
- package/dist/ContextMenu/index.js +2 -2
- package/dist/{ContextMenu-DVQl0xL5.js → ContextMenu-BeJO5HYx.js} +4 -369
- package/dist/DateInput/index.d.ts +1 -1
- package/dist/DateInput/index.js +1 -1
- package/dist/{DateInput-zm8sNc0t.js → DateInput-D4XFAEMp.js} +3 -3
- package/dist/DateRangeInput/index.d.ts +1 -1
- package/dist/DateRangeInput/index.js +1 -1
- package/dist/{DateRangeInput-DlVFzrf7.js → DateRangeInput-Cp6AZfew.js} +2 -2
- package/dist/DateTimeInput/index.d.ts +1 -1
- package/dist/DateTimeInput/index.js +1 -1
- package/dist/{DateTimeInput-C7Z-p6Yd.js → DateTimeInput-B6MPPp76.js} +3 -3
- package/dist/DropdownMenu/index.d.ts +2 -2
- package/dist/DropdownMenu/index.js +3 -3
- package/dist/{DropdownMenu-BoZChdev.js → DropdownMenu--lnUeJEG.js} +3 -3
- package/dist/{DropdownMenu-u1psFjis.js → DropdownMenu-6E9jFdFe.js} +4 -4
- package/dist/{DropdownMenuRadioItem.vue-uVM0FD2f.d.ts → DropdownMenuRadioItem.vue-CXEURBcq.d.ts} +1 -1
- package/dist/EmptyState/index.js +1 -1
- package/dist/{EmptyState-CUJdTYKV.js → EmptyState-0RWymQUS.js} +2 -2
- package/dist/FileInput/index.d.ts +1 -1
- package/dist/FileInput/index.js +1 -1
- package/dist/{FileInput-QdlZn7qK.js → FileInput-DuNwdbAo.js} +1 -1
- package/dist/Grid/index.d.ts +1 -1
- package/dist/Heading/index.d.ts +2 -2
- package/dist/Heading/index.js +1 -1
- package/dist/Heading-B9C3LZlS.js +94 -0
- package/dist/Indicator/index.d.ts +2 -2
- package/dist/InputGroup/index.d.ts +1 -1
- package/dist/Item-DrYJL1TG.js +590 -0
- package/dist/Lightbox/index.js +1 -1
- package/dist/{Lightbox-BSzfqZ-u.js → Lightbox-Br3o0SyQ.js} +1 -1
- package/dist/Link/index.d.ts +3 -2
- package/dist/Link/index.js +1 -1
- package/dist/Link-DCZ6922-.js +196 -0
- package/dist/List/index.d.ts +3 -3
- package/dist/List/index.js +2 -2
- package/dist/{ListItem-pGxvn6QJ.js → ListItem-CcRHWuEm.js} +8 -2
- package/dist/Markdown/index.d.ts +2 -2
- package/dist/Markdown/index.js +2 -2
- package/dist/{Markdown-B6tSqenv.js → Markdown-Bz0R3kNj.js} +274 -30
- package/dist/MetadataList/index.js +1 -1
- package/dist/{MetadataList-aN1tRn6W.js → MetadataList-CFaocx6j.js} +1 -1
- package/dist/MobileNav/index.js +1 -1
- package/dist/{MobileNavToggle-fqcSafkc.js → MobileNavToggle-Dh3uLivq.js} +1 -1
- package/dist/MoreMenu/index.d.ts +1 -1
- package/dist/MoreMenu/index.js +1 -1
- package/dist/{MoreMenu-B3brqdK_.js → MoreMenu-B95nRSe8.js} +2 -2
- package/dist/MultiSelector/index.d.ts +1 -1
- package/dist/MultiSelector/index.js +1 -1
- package/dist/{MultiSelector-BD5PMgez.js → MultiSelector-DuF5TECE.js} +4 -4
- package/dist/{NavDisclosure-DbYLDXK0.js → NavDisclosure-C6sPZ89n.js} +4 -1
- package/dist/NavHeadingSurface-Cb3x9iDx.js +287 -0
- package/dist/NavItem/index.d.ts +1 -1
- package/dist/NavMenu/index.d.ts +2 -2
- package/dist/NavMenu/index.js +4 -3
- package/dist/NavMenu-ClIgMaxE.js +176 -0
- package/dist/{NavMenuItem-DrwIMHKO.js → NavMenuItem-E7S8gBh-.js} +1 -1
- package/dist/NumberInput/index.d.ts +1 -1
- package/dist/NumberInput/index.js +1 -1
- package/dist/{NumberInput-CBeU4lEl.js → NumberInput-B4IL3s_8.js} +1 -1
- package/dist/Outline/index.js +1 -1
- package/dist/{Outline--HVMSB6i.js → Outline-DBUuchi9.js} +1 -1
- package/dist/OverflowList/index.d.ts +1 -1
- package/dist/OverflowList/index.js +1 -1
- package/dist/{OverflowList-FMh7r-r_.js → OverflowList-aDd_oem0.js} +3 -3
- package/dist/Pagination/index.d.ts +1 -1
- package/dist/Pagination/index.js +1 -1
- package/dist/{Pagination-DlIvESjx.js → Pagination-CNe9F6Fl.js} +181 -45
- package/dist/Popover/index.d.ts +1 -1
- package/dist/PowerSearch/index.d.ts +1 -1
- package/dist/PowerSearch/index.js +1 -1
- package/dist/{PowerSearch-CMG7Rb69.js → PowerSearch-C6U8Sq1Y.js} +13 -13
- package/dist/ProgressBar/index.d.ts +2 -2
- package/dist/ProgressBar/index.js +1 -1
- package/dist/{ProgressBar-DO9Chic6.js → ProgressBar-DF6WZNCI.js} +45 -6
- package/dist/Radio/index.d.ts +1 -1
- package/dist/RadioList/index.d.ts +1 -1
- package/dist/Resizable/index.d.ts +1 -1
- package/dist/Resizable/index.js +1 -1
- package/dist/{Resizable-CXpvj1TZ.js → ResizeHandle-DYy0e3v9.js} +1 -1
- package/dist/ScrollableArea/index.d.ts +1 -1
- package/dist/SelectableCard/index.d.ts +1 -1
- package/dist/Selector/index.d.ts +1 -1
- package/dist/Selector/index.js +1 -1
- package/dist/{Selector-BpPnuWH3.js → Selector-5N-hq2nF.js} +3 -3
- package/dist/SideNav/index.d.ts +2 -2
- package/dist/SideNav/index.js +1 -1
- package/dist/{SideNav-D4TupqgE.js → SideNav-CT9lfspi.js} +225 -229
- package/dist/Stack/index.d.ts +1 -1
- package/dist/Stepper/index.js +1 -1
- package/dist/{Stepper-H-6-T5Ps.js → Stepper-BqhVCgC-.js} +1 -1
- package/dist/Switch/index.d.ts +1 -1
- package/dist/Table/index.js +1 -1
- package/dist/{Table-nqA_njNz.js → Table-CsdH8fCB.js} +4 -4
- package/dist/Text/index.d.ts +3 -3
- package/dist/Text/index.js +1 -1
- package/dist/Text-DIzZw6FA.js +86 -0
- package/dist/TextArea/index.d.ts +1 -1
- package/dist/TextInput/index.d.ts +1 -1
- package/dist/Theme/index.d.ts +3 -3
- package/dist/Theme/index.js +2 -2
- package/dist/Theme-CtaUWo4g.js +1246 -0
- package/dist/Thumbnail/index.js +1 -1
- package/dist/{Thumbnail-CXb3m_Hv.js → Thumbnail-BnQwX1cQ.js} +2 -2
- package/dist/{TimeField-B3cndWb0.js → TimeField-Biiuv0hB.js} +1 -1
- package/dist/TimeInput/index.d.ts +1 -1
- package/dist/TimeInput/index.js +1 -1
- package/dist/{TimeInput-BHQ_LKGm.js → TimeInput-C9gptCOK.js} +1 -1
- package/dist/Timer/index.d.ts +1 -1
- package/dist/Timer/index.js +1 -1
- package/dist/{Timer-B7GV6hqd.js → Timer-kxzQx3tp.js} +1 -1
- package/dist/Timestamp/index.d.ts +1 -1
- package/dist/Timestamp/index.js +1 -1
- package/dist/{Timestamp-Cfuxbb3i.js → Timestamp-D7bd_nF3.js} +2 -2
- package/dist/ToggleButton/index.d.ts +1 -1
- package/dist/Token/index.d.ts +1 -1
- package/dist/Token/index.js +1 -1
- package/dist/{Token-CdVLH0_H.js → Token-D2GsI_Ei.js} +1 -1
- package/dist/Tokenizer/index.js +1 -1
- package/dist/{Tokenizer-DlD-S_8-.js → Tokenizer-rwzamZg4.js} +3 -3
- package/dist/Toolbar/index.d.ts +1 -1
- package/dist/Tooltip/index.d.ts +1 -1
- package/dist/Tooltip/index.js +1 -1
- package/dist/{Tooltip-mp0NMh_Y.js → Tooltip-C2fh9anJ.js} +23 -8
- package/dist/TopNav/index.d.ts +1 -1
- package/dist/TopNav/index.js +1 -1
- package/dist/{TopNav-DzV874G7.js → TopNav-arWFLTBM.js} +112 -42
- package/dist/TreeList/index.js +1 -1
- package/dist/{TreeList-DEwvlZRV.js → TreeList-C9xvMpJZ.js} +1 -1
- package/dist/Typeahead/index.d.ts +2 -2
- package/dist/Typeahead/index.js +3 -2
- package/dist/Typeahead-_V11btpv.js +499 -0
- package/dist/{TypeaheadMenu-CGvo0Tud.js → TypeaheadMenu-BEObzonz.js} +46 -10
- package/dist/composables/index.d.ts +2 -2
- package/dist/composables/index.js +4 -4
- package/dist/composables-CWw6t-RJ.js +520 -0
- package/dist/{context-DmOLCubj.js → context-CPh7kE-a.js} +58 -10
- package/dist/{index-BRfR0lhb.d.ts → index-12QYAbiz.d.ts} +1 -1
- package/dist/{index-D1Twv_fL.d.ts → index-4TRnFGxv.d.ts} +6 -6
- package/dist/{index-BTAgQRP0.d.ts → index-B9rqmYxh.d.ts} +150 -62
- package/dist/index-BBtJt5_A.d.ts +26 -0
- package/dist/{index-Ch6BbxCP.d.ts → index-BH9PzQ1F.d.ts} +13 -8
- package/dist/{index-C2sfHfBw.d.ts → index-BK9T1TPZ.d.ts} +4 -4
- package/dist/{index-D_UEJIU5.d.ts → index-BPwD6aBv.d.ts} +1 -1
- package/dist/{index-B1x05arQ.d.ts → index-BlOIC_AM.d.ts} +1 -1
- package/dist/{index-C5p2NeCr.d.ts → index-Blm197N_.d.ts} +11 -2
- package/dist/{index-Bu3oXIIS.d.ts → index-BmmdzwT9.d.ts} +6 -0
- package/dist/{index-MPcg1Pm4.d.ts → index-BpH4wvsg.d.ts} +2 -2
- package/dist/{index-BMn9ghAX.d.ts → index-C1HIqW_H.d.ts} +2 -2
- package/dist/{index-LIyvJTW3.d.ts → index-C3GaPqvJ.d.ts} +84 -8
- package/dist/{index-DkVEBdWa.d.ts → index-CB9Srua5.d.ts} +1 -1
- package/dist/{index-C8wDPDcP.d.ts → index-CLmKfnqf.d.ts} +49 -7
- package/dist/{index-DMQG6kdM.d.ts → index-CPwzSbQQ.d.ts} +2 -2
- package/dist/{index-DAiGhkNZ.d.ts → index-D4I_obqR.d.ts} +1 -1
- package/dist/{index-foQMNKZO.d.ts → index-D5N9ikrS.d.ts} +48 -2
- package/dist/{index-D8o50qOE.d.ts → index-DFbvnBlf.d.ts} +31 -2
- package/dist/{index-Cm_TiLXU.d.ts → index-Dgg0bHVM.d.ts} +7 -3
- package/dist/{index-ViSV0RBx.d.ts → index-DjMwF8ET.d.ts} +11 -1
- package/dist/{index-nCEmW6wa.d.ts → index-DtePJ_w_.d.ts} +1 -1
- package/dist/index-DxR1FChm.d.ts +158 -0
- package/dist/{index-f4NGT-e2.d.ts → index-EFqQF2Bx.d.ts} +1 -1
- package/dist/{index-BB5yVIN-.d.ts → index-JL4auphT.d.ts} +2 -2
- package/dist/{index-B9f1rUEv.d.ts → index-XuAAcYiP.d.ts} +1 -1
- package/dist/{index-D0TlUOtG.d.ts → index-YmSe1ujk.d.ts} +76 -3
- package/dist/{index-BMrggCw-.d.ts → index-bvr3WHvs.d.ts} +1 -1
- package/dist/{index-CDDMDHJM.d.ts → index-c67ca7eJ.d.ts} +1 -1
- package/dist/{index-CGZ2xi3r.d.ts → index-eshFLli0.d.ts} +40 -3
- package/dist/{index-DxsKyAxq.d.ts → index-vizlhXVs.d.ts} +131 -2
- package/dist/{index-DfgHJE7H.d.ts → index-z3uLM1O6.d.ts} +153 -24
- package/dist/index.d.ts +80 -79
- package/dist/index.js +118 -115
- package/dist/locale/index.d.ts +2 -2
- package/dist/locale/index.js +3 -3
- package/dist/locale-sLw5Caia.js +917 -0
- package/dist/{searchResultMessage-DN0HeRRB.js → searchResultMessage-CCnq-_ce.js} +1 -1
- package/dist/syntaxTheme-CwVEcVDk.d.ts +57 -0
- package/dist/{syntaxTheme-ClpWALZX.js → syntaxTheme-R7xnu5x5.js} +24 -3
- package/dist/{types-Bt-lSgYX.d.ts → types-D9nP_X-c.d.ts} +14 -1
- package/dist/{types-CAZY4Xua.d.ts → types-DGYHIu4I.d.ts} +30 -1
- package/dist/types-D_J66aPN.d.ts +85 -0
- package/dist/types-gKsEkk2g.d.ts +320 -0
- package/dist/{useMenuDrillIn-OaEwjK44.js → useMenuDrillIn-BgjJcY3K.js} +1 -1
- package/dist/useMenuPress-DUmEy4TB.js +425 -0
- package/dist/{composables-DDI08XFF.js → useResizable-B3ahKLoZ.js} +73 -248
- package/dist/useTruncation-B5qXQzAP.js +53 -0
- package/locales/SOURCE.json +37 -0
- package/locales/af-ZA.json +1482 -0
- package/locales/ar-SA.json +1482 -0
- package/locales/ca-ES.json +1482 -0
- package/locales/cs-CZ.json +1482 -0
- package/locales/da-DK.json +1482 -0
- package/locales/de-DE.json +1482 -0
- package/locales/el-GR.json +1482 -0
- package/locales/en.json +1646 -0
- package/locales/es-ES.json +1482 -0
- package/locales/fi-FI.json +1482 -0
- package/locales/fr-FR.json +1482 -0
- package/locales/he-IL.json +1482 -0
- package/locales/hu-HU.json +1482 -0
- package/locales/it-IT.json +1482 -0
- package/locales/ja-JP.json +1482 -0
- package/locales/ko-KR.json +1482 -0
- package/locales/nl-NL.json +1482 -0
- package/locales/no-NO.json +1482 -0
- package/locales/pl-PL.json +1482 -0
- package/locales/pt-BR.json +1482 -0
- package/locales/pt-PT.json +1482 -0
- package/locales/ro-RO.json +1482 -0
- package/locales/ru-RU.json +1482 -0
- package/locales/sr-SP.json +1482 -0
- package/locales/sv-SE.json +1482 -0
- package/locales/tr-TR.json +1482 -0
- package/locales/uk-UA.json +1482 -0
- package/locales/vi-VN.json +1482 -0
- package/locales/zh-CN.json +1482 -0
- package/locales/zh-TW.json +1482 -0
- package/package.json +4 -2
- package/styles/bottom-sheet.css +27 -0
- package/styles/code.css +62 -0
- package/styles/container-reveal.css +104 -0
- package/styles/heading.css +47 -0
- package/styles/keyboard-hint.css +28 -0
- package/styles/link.css +34 -0
- package/styles/list.css +88 -1
- package/styles/markdown.css +12 -0
- package/styles/pagination.css +30 -0
- package/styles/progress-bar.css +49 -0
- package/styles/side-nav.css +36 -1
- package/styles/text.css +18 -0
- package/styles/top-nav.css +145 -6
- package/styles/typeahead.css +24 -0
- package/styles.css +2 -0
- package/dist/Heading-Dugosn6j.js +0 -43
- package/dist/Item-C1z6gXn8.js +0 -289
- package/dist/Link-DqdQZ37C.js +0 -141
- package/dist/Text-BHVghsWo.js +0 -53
- package/dist/Theme-CejS9MHm.js +0 -447
- package/dist/Typeahead-DQ3tmqYe.js +0 -375
- package/dist/index-Bqb_Fyju.d.ts +0 -80
- package/dist/index-Dg3ZmwEg.d.ts +0 -75
- package/dist/locale-CCwVnyMZ.js +0 -42
- package/dist/syntaxTheme-Bcs1YMF7.d.ts +0 -38
- package/dist/types-jmqqnkKA.d.ts +0 -163
- package/dist/useHotkeys-dABSK1o9.js +0 -80
- package/dist/useLongPress-Cyxwa73s.js +0 -60
- package/dist/{index-BXkNZF3q.d.ts → index-CpiWVbRZ.d.ts} +1 -1
|
@@ -0,0 +1,520 @@
|
|
|
1
|
+
import { t as useMediaQuery } from "./useMediaQuery-GMmgp28-.js";
|
|
2
|
+
import { t as _sfc_main$1 } from "./Kbd-BB-Dw6zE.js";
|
|
3
|
+
import { o as useAstryxMessages } from "./context-CPh7kE-a.js";
|
|
4
|
+
import { Fragment, computed, createBlock, createElementBlock, createElementVNode, defineComponent, h, normalizeStyle, onBeforeUnmount, onMounted, onScopeDispose, openBlock, ref, renderList, toDisplayString, toValue, unref, vShow, watch, withDirectives } from "vue";
|
|
5
|
+
import "../styles/keyboard-hint.css";
|
|
6
|
+
//#region src/composables/useContainerReveal.ts
|
|
7
|
+
function useContainerReveal(options = {}) {
|
|
8
|
+
function containerProps(reveal = {}) {
|
|
9
|
+
if (toValue(options.isEnabled) === false) return {};
|
|
10
|
+
return {
|
|
11
|
+
class: {
|
|
12
|
+
"astryx-reveal": true,
|
|
13
|
+
"astryx-reveal--inactive": reveal.forceState === "inactive",
|
|
14
|
+
"astryx-reveal--active": reveal.forceState === "active"
|
|
15
|
+
},
|
|
16
|
+
style: reveal.hoverDelay ? { "--_hover-delay": `${reveal.hoverDelay}ms` } : void 0
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function contentProps(reveal = {}) {
|
|
20
|
+
if (toValue(options.isEnabled) === false) return {};
|
|
21
|
+
const inverted = reveal.isRevealInverted === true;
|
|
22
|
+
const preserved = reveal.isLayoutPreserved === true;
|
|
23
|
+
return { class: {
|
|
24
|
+
"astryx-reveal__content": !inverted,
|
|
25
|
+
"astryx-reveal__content--preserve": !inverted && preserved,
|
|
26
|
+
"astryx-reveal__conceal": inverted,
|
|
27
|
+
"astryx-reveal__conceal--preserve": inverted && preserved,
|
|
28
|
+
"astryx-reveal__shown": reveal.forceVisibility === "shown",
|
|
29
|
+
"astryx-reveal__hidden": reveal.forceVisibility === "hidden" && !preserved,
|
|
30
|
+
"astryx-reveal__hidden--preserve": reveal.forceVisibility === "hidden" && preserved
|
|
31
|
+
} };
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
containerProps,
|
|
35
|
+
contentProps
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region src/composables/useControllableState.ts
|
|
40
|
+
/**
|
|
41
|
+
* 受控或自己管的 v-model。
|
|
42
|
+
*
|
|
43
|
+
* Astryx 没有同名 hook。各组件原来各自判断「外面传了值就听外面的,没传就自己记」,
|
|
44
|
+
* 这里收成一个函数,方便以后的 v-model 共用。
|
|
45
|
+
*/
|
|
46
|
+
function useControllableState(options) {
|
|
47
|
+
const { modelValue, onChange } = options;
|
|
48
|
+
const controlled = modelValue.value !== void 0;
|
|
49
|
+
const local = ref(toValue(options.defaultValue));
|
|
50
|
+
const isControlled = computed(() => controlled);
|
|
51
|
+
const value = computed(() => controlled ? modelValue.value : local.value);
|
|
52
|
+
function setValue(next) {
|
|
53
|
+
if (Object.is(value.value, next)) return;
|
|
54
|
+
if (controlled) modelValue.value = next;
|
|
55
|
+
else local.value = next;
|
|
56
|
+
onChange?.(next);
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
isControlled,
|
|
60
|
+
setValue,
|
|
61
|
+
value
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region src/composables/useGridRovingFocus.ts
|
|
66
|
+
/**
|
|
67
|
+
* 网格式导航(roving tabindex):用方向键在二维网格中移动焦点。
|
|
68
|
+
* 供 Calendar、Pagination(如果需要)等组件复用。
|
|
69
|
+
*/
|
|
70
|
+
function useGridRovingFocus(options) {
|
|
71
|
+
const { rows, columns, activeIndex, isEnabled = ref(true), isDisabled, onChange } = options;
|
|
72
|
+
const row = ref(0);
|
|
73
|
+
const column = ref(0);
|
|
74
|
+
watch(activeIndex, (index) => {
|
|
75
|
+
const cols = columns.value;
|
|
76
|
+
if (cols > 0) {
|
|
77
|
+
row.value = Math.floor(index / cols);
|
|
78
|
+
column.value = index % cols;
|
|
79
|
+
}
|
|
80
|
+
}, { immediate: true });
|
|
81
|
+
function indexFromRowCol(r, c) {
|
|
82
|
+
return r * columns.value + c;
|
|
83
|
+
}
|
|
84
|
+
function moveTo(targetRow, targetCol) {
|
|
85
|
+
if (!isEnabled.value) return;
|
|
86
|
+
const r = Math.max(0, Math.min(targetRow, rows.value - 1));
|
|
87
|
+
const c = Math.max(0, Math.min(targetCol, columns.value - 1));
|
|
88
|
+
if (isDisabled?.(r, c)) return;
|
|
89
|
+
const index = indexFromRowCol(r, c);
|
|
90
|
+
onChange(index);
|
|
91
|
+
}
|
|
92
|
+
function moveUp() {
|
|
93
|
+
moveTo(row.value - 1, column.value);
|
|
94
|
+
}
|
|
95
|
+
function moveDown() {
|
|
96
|
+
moveTo(row.value + 1, column.value);
|
|
97
|
+
}
|
|
98
|
+
function moveLeft() {
|
|
99
|
+
moveTo(row.value, column.value - 1);
|
|
100
|
+
}
|
|
101
|
+
function moveRight() {
|
|
102
|
+
moveTo(row.value, column.value + 1);
|
|
103
|
+
}
|
|
104
|
+
function moveToFirstInRow() {
|
|
105
|
+
moveTo(row.value, 0);
|
|
106
|
+
}
|
|
107
|
+
function moveToLastInRow() {
|
|
108
|
+
moveTo(row.value, columns.value - 1);
|
|
109
|
+
}
|
|
110
|
+
function moveToFirstInColumn() {
|
|
111
|
+
moveTo(0, column.value);
|
|
112
|
+
}
|
|
113
|
+
function moveToLastInColumn() {
|
|
114
|
+
moveTo(rows.value - 1, column.value);
|
|
115
|
+
}
|
|
116
|
+
function onKeyDown(event) {
|
|
117
|
+
if (!isEnabled.value) return;
|
|
118
|
+
switch (event.key) {
|
|
119
|
+
case "ArrowUp":
|
|
120
|
+
event.preventDefault();
|
|
121
|
+
moveUp();
|
|
122
|
+
break;
|
|
123
|
+
case "ArrowDown":
|
|
124
|
+
event.preventDefault();
|
|
125
|
+
moveDown();
|
|
126
|
+
break;
|
|
127
|
+
case "ArrowLeft":
|
|
128
|
+
event.preventDefault();
|
|
129
|
+
moveLeft();
|
|
130
|
+
break;
|
|
131
|
+
case "ArrowRight":
|
|
132
|
+
event.preventDefault();
|
|
133
|
+
moveRight();
|
|
134
|
+
break;
|
|
135
|
+
case "Home":
|
|
136
|
+
event.preventDefault();
|
|
137
|
+
if (event.ctrlKey) moveTo(0, 0);
|
|
138
|
+
else moveToFirstInRow();
|
|
139
|
+
break;
|
|
140
|
+
case "End":
|
|
141
|
+
event.preventDefault();
|
|
142
|
+
if (event.ctrlKey) moveTo(rows.value - 1, columns.value - 1);
|
|
143
|
+
else moveToLastInRow();
|
|
144
|
+
break;
|
|
145
|
+
case "PageUp":
|
|
146
|
+
event.preventDefault();
|
|
147
|
+
moveToFirstInColumn();
|
|
148
|
+
break;
|
|
149
|
+
case "PageDown":
|
|
150
|
+
event.preventDefault();
|
|
151
|
+
moveToLastInColumn();
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return {
|
|
155
|
+
row,
|
|
156
|
+
column,
|
|
157
|
+
onKeyDown,
|
|
158
|
+
moveTo
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
//#endregion
|
|
162
|
+
//#region src/composables/useImageMode.ts
|
|
163
|
+
/**
|
|
164
|
+
* APCA 感知亮度。先把 sRGB 按 2.4 线性化,再用接近 BT.709 的系数合成,
|
|
165
|
+
* 最后做 0.56 次方,让 0.5 接近视觉上的中灰。饱和色比简单的伽马亮度更准。
|
|
166
|
+
*/
|
|
167
|
+
function perceptualLightness(r, g, b) {
|
|
168
|
+
const linear = (channel) => (channel / 255) ** 2.4;
|
|
169
|
+
return (.2126729 * linear(r) + .7151522 * linear(g) + .072175 * linear(b)) ** .56;
|
|
170
|
+
}
|
|
171
|
+
/** 一组采样像素的平均亮度,再和阈值比出深浅。 */
|
|
172
|
+
function imageModeFromPixels(pixels, threshold = .5) {
|
|
173
|
+
let red = 0;
|
|
174
|
+
let green = 0;
|
|
175
|
+
let blue = 0;
|
|
176
|
+
let count = 0;
|
|
177
|
+
for (let index = 0; index < pixels.length; index += 4) {
|
|
178
|
+
red += pixels[index] ?? 0;
|
|
179
|
+
green += pixels[index + 1] ?? 0;
|
|
180
|
+
blue += pixels[index + 2] ?? 0;
|
|
181
|
+
count += 1;
|
|
182
|
+
}
|
|
183
|
+
const safeCount = count || 1;
|
|
184
|
+
return perceptualLightness(red / safeCount, green / safeCount, blue / safeCount) > threshold ? "light" : "dark";
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* 按图片亮度判断该用深色还是浅色前景。采样走 OffscreenCanvas,不往页面上画。
|
|
188
|
+
* 跨域或网络失败时返回 `fallback`。
|
|
189
|
+
*/
|
|
190
|
+
function useImageMode(src, options = {}) {
|
|
191
|
+
const mode = ref(toValue(options).fallback ?? null);
|
|
192
|
+
let request = 0;
|
|
193
|
+
async function detect(url) {
|
|
194
|
+
const current = ++request;
|
|
195
|
+
const settings = toValue(options);
|
|
196
|
+
const threshold = settings.threshold ?? .5;
|
|
197
|
+
const fallback = settings.fallback ?? null;
|
|
198
|
+
mode.value = fallback;
|
|
199
|
+
try {
|
|
200
|
+
const response = await fetch(url);
|
|
201
|
+
if (!response.ok) throw new Error(`image ${response.status}`);
|
|
202
|
+
const bitmap = await createImageBitmap(await response.blob());
|
|
203
|
+
if (current !== request) return;
|
|
204
|
+
const region = settings.region;
|
|
205
|
+
const sx = region ? Math.round(region.x * bitmap.width) : 0;
|
|
206
|
+
const sy = region ? Math.round(region.y * bitmap.height) : 0;
|
|
207
|
+
const sw = region ? Math.max(1, Math.round(region.width * bitmap.width)) : bitmap.width;
|
|
208
|
+
const sh = region ? Math.max(1, Math.round(region.height * bitmap.height)) : bitmap.height;
|
|
209
|
+
const sample = 10;
|
|
210
|
+
const context = new OffscreenCanvas(sample, sample).getContext("2d");
|
|
211
|
+
if (!context) return;
|
|
212
|
+
context.drawImage(bitmap, sx, sy, sw, sh, 0, 0, sample, sample);
|
|
213
|
+
const pixels = context.getImageData(0, 0, sample, sample).data;
|
|
214
|
+
if (current !== request) return;
|
|
215
|
+
mode.value = imageModeFromPixels(pixels, threshold);
|
|
216
|
+
} catch {
|
|
217
|
+
if (current === request) mode.value = fallback;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
watch(() => toValue(src), (url) => {
|
|
221
|
+
if (!url) {
|
|
222
|
+
request += 1;
|
|
223
|
+
mode.value = toValue(options).fallback ?? null;
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
detect(url);
|
|
227
|
+
}, { immediate: true });
|
|
228
|
+
onScopeDispose(() => {
|
|
229
|
+
request += 1;
|
|
230
|
+
});
|
|
231
|
+
return mode;
|
|
232
|
+
}
|
|
233
|
+
//#endregion
|
|
234
|
+
//#region src/composables/KeyboardHint.vue
|
|
235
|
+
const _hoisted_1 = { class: "astryx-keyboard-hint__keys" };
|
|
236
|
+
const _hoisted_2 = { class: "astryx-keyboard-hint__label" };
|
|
237
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
238
|
+
__name: "KeyboardHint",
|
|
239
|
+
props: {
|
|
240
|
+
visible: { type: Boolean },
|
|
241
|
+
anchor: {},
|
|
242
|
+
orientation: {}
|
|
243
|
+
},
|
|
244
|
+
setup(__props) {
|
|
245
|
+
const props = __props;
|
|
246
|
+
const messages = useAstryxMessages();
|
|
247
|
+
const hint = ref(null);
|
|
248
|
+
const position = ref({
|
|
249
|
+
top: 0,
|
|
250
|
+
left: 0
|
|
251
|
+
});
|
|
252
|
+
const keys = computed(() => {
|
|
253
|
+
if (props.orientation === "vertical") return ["up", "down"];
|
|
254
|
+
if (props.orientation === "both") return [
|
|
255
|
+
"left",
|
|
256
|
+
"right",
|
|
257
|
+
"up",
|
|
258
|
+
"down"
|
|
259
|
+
];
|
|
260
|
+
return ["left", "right"];
|
|
261
|
+
});
|
|
262
|
+
const style = computed(() => ({
|
|
263
|
+
top: `${position.value.top}px`,
|
|
264
|
+
left: `${position.value.left}px`
|
|
265
|
+
}));
|
|
266
|
+
function place() {
|
|
267
|
+
const anchor = props.anchor;
|
|
268
|
+
const element = hint.value;
|
|
269
|
+
if (!anchor || !element) return;
|
|
270
|
+
const rect = anchor.getBoundingClientRect();
|
|
271
|
+
const hintRect = element.getBoundingClientRect();
|
|
272
|
+
const top = Math.max(8, rect.top - hintRect.height - 8);
|
|
273
|
+
const left = Math.min(window.innerWidth - hintRect.width - 8, Math.max(8, rect.left + rect.width / 2 - hintRect.width / 2));
|
|
274
|
+
position.value = {
|
|
275
|
+
top,
|
|
276
|
+
left
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
watch(() => [props.visible, props.anchor], () => {
|
|
280
|
+
if (!props.visible) return;
|
|
281
|
+
requestAnimationFrame(() => place());
|
|
282
|
+
});
|
|
283
|
+
function onScroll() {
|
|
284
|
+
if (props.visible) place();
|
|
285
|
+
}
|
|
286
|
+
onMounted(() => {
|
|
287
|
+
window.addEventListener("scroll", onScroll, true);
|
|
288
|
+
window.addEventListener("resize", onScroll);
|
|
289
|
+
});
|
|
290
|
+
onBeforeUnmount(() => {
|
|
291
|
+
window.removeEventListener("scroll", onScroll, true);
|
|
292
|
+
window.removeEventListener("resize", onScroll);
|
|
293
|
+
});
|
|
294
|
+
return (_ctx, _cache) => {
|
|
295
|
+
return withDirectives((openBlock(), createElementBlock("div", {
|
|
296
|
+
ref_key: "hint",
|
|
297
|
+
ref: hint,
|
|
298
|
+
class: "astryx-keyboard-hint",
|
|
299
|
+
"aria-hidden": "true",
|
|
300
|
+
style: normalizeStyle(style.value)
|
|
301
|
+
}, [createElementVNode("span", _hoisted_1, [(openBlock(true), createElementBlock(Fragment, null, renderList(keys.value, (key) => {
|
|
302
|
+
return openBlock(), createBlock(_sfc_main$1, {
|
|
303
|
+
key,
|
|
304
|
+
keys: key
|
|
305
|
+
}, null, 8, ["keys"]);
|
|
306
|
+
}), 128))]), createElementVNode("span", _hoisted_2, toDisplayString(unref(messages).keyboardHint.navigate), 1)], 4)), [[vShow, __props.visible]]);
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
//#endregion
|
|
311
|
+
//#region src/composables/useKeyboardHint.ts
|
|
312
|
+
const ARROW_KEYS = /* @__PURE__ */ new Set([
|
|
313
|
+
"ArrowLeft",
|
|
314
|
+
"ArrowRight",
|
|
315
|
+
"ArrowUp",
|
|
316
|
+
"ArrowDown"
|
|
317
|
+
]);
|
|
318
|
+
/**
|
|
319
|
+
* 一组方向键控件第一次被键盘点进来时,在当前项旁边短暂提示「用方向键移动」。
|
|
320
|
+
* 按过方向键、超时或焦点离开之后不再出现。
|
|
321
|
+
*/
|
|
322
|
+
function useKeyboardHint(options = {}) {
|
|
323
|
+
const visible = ref(false);
|
|
324
|
+
const anchor = ref(null);
|
|
325
|
+
const orientation = computed(() => options.orientation ?? "horizontal");
|
|
326
|
+
let dismissed = false;
|
|
327
|
+
let timer;
|
|
328
|
+
function hide() {
|
|
329
|
+
visible.value = false;
|
|
330
|
+
if (timer != null) {
|
|
331
|
+
clearTimeout(timer);
|
|
332
|
+
timer = void 0;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
function show(target) {
|
|
336
|
+
if (dismissed || options.isEnabled === false) return;
|
|
337
|
+
anchor.value = target;
|
|
338
|
+
visible.value = true;
|
|
339
|
+
if (timer != null) clearTimeout(timer);
|
|
340
|
+
timer = setTimeout(() => {
|
|
341
|
+
dismissed = true;
|
|
342
|
+
hide();
|
|
343
|
+
}, options.dismissAfterMs ?? 3e3);
|
|
344
|
+
}
|
|
345
|
+
function onFocus(event) {
|
|
346
|
+
if (dismissed || options.isEnabled === false) return;
|
|
347
|
+
const target = event.target;
|
|
348
|
+
const current = event.currentTarget;
|
|
349
|
+
if (!(target instanceof HTMLElement) || !(current instanceof HTMLElement)) return;
|
|
350
|
+
if (event.relatedTarget instanceof Node && current.contains(event.relatedTarget)) {
|
|
351
|
+
if (visible.value) anchor.value = target;
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
if (!target.matches(":focus-visible")) return;
|
|
355
|
+
show(target);
|
|
356
|
+
}
|
|
357
|
+
function onBlur(event) {
|
|
358
|
+
const current = event.currentTarget;
|
|
359
|
+
if (!(current instanceof HTMLElement)) return;
|
|
360
|
+
if (event.relatedTarget instanceof Node && current.contains(event.relatedTarget)) return;
|
|
361
|
+
hide();
|
|
362
|
+
}
|
|
363
|
+
function onKeyDown(event) {
|
|
364
|
+
if (!ARROW_KEYS.has(event.key)) return;
|
|
365
|
+
dismissed = true;
|
|
366
|
+
hide();
|
|
367
|
+
}
|
|
368
|
+
onBeforeUnmount(() => {
|
|
369
|
+
if (timer != null) clearTimeout(timer);
|
|
370
|
+
});
|
|
371
|
+
return {
|
|
372
|
+
visible,
|
|
373
|
+
anchor,
|
|
374
|
+
orientation,
|
|
375
|
+
onFocus,
|
|
376
|
+
onBlur,
|
|
377
|
+
onKeyDown,
|
|
378
|
+
Hint: defineComponent({
|
|
379
|
+
name: "AstryxKeyboardHint",
|
|
380
|
+
setup() {
|
|
381
|
+
return () => h(_sfc_main, {
|
|
382
|
+
visible: visible.value,
|
|
383
|
+
anchor: anchor.value,
|
|
384
|
+
orientation: toValue(orientation)
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
})
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
//#endregion
|
|
391
|
+
//#region src/composables/useScrollOverflow.ts
|
|
392
|
+
/**
|
|
393
|
+
* 观察一个横向滚动容器,报告起始边和结束边有没有被挡住。
|
|
394
|
+
* 容差 1px,滚动和尺寸变化都会重新量。
|
|
395
|
+
*/
|
|
396
|
+
function useScrollOverflow() {
|
|
397
|
+
const element = ref(null);
|
|
398
|
+
const overflowStart = ref(false);
|
|
399
|
+
const overflowEnd = ref(false);
|
|
400
|
+
const hasOverflow = ref(false);
|
|
401
|
+
let observer;
|
|
402
|
+
function measure() {
|
|
403
|
+
const node = element.value;
|
|
404
|
+
if (node == null) return;
|
|
405
|
+
const tolerance = 1;
|
|
406
|
+
const maxScroll = node.scrollWidth - node.clientWidth;
|
|
407
|
+
const nextStart = Math.abs(node.scrollLeft) > tolerance;
|
|
408
|
+
const nextEnd = Math.abs(node.scrollLeft) < maxScroll - tolerance;
|
|
409
|
+
const nextHas = node.scrollWidth > node.clientWidth + tolerance;
|
|
410
|
+
overflowStart.value = nextStart;
|
|
411
|
+
overflowEnd.value = nextEnd;
|
|
412
|
+
hasOverflow.value = nextHas;
|
|
413
|
+
}
|
|
414
|
+
function scrollRef(node) {
|
|
415
|
+
element.value?.removeEventListener("scroll", measure);
|
|
416
|
+
observer?.disconnect();
|
|
417
|
+
element.value = node;
|
|
418
|
+
if (node == null) return;
|
|
419
|
+
node.addEventListener("scroll", measure, { passive: true });
|
|
420
|
+
if (typeof ResizeObserver !== "undefined") {
|
|
421
|
+
observer = new ResizeObserver(measure);
|
|
422
|
+
observer.observe(node);
|
|
423
|
+
}
|
|
424
|
+
measure();
|
|
425
|
+
}
|
|
426
|
+
onBeforeUnmount(() => {
|
|
427
|
+
element.value?.removeEventListener("scroll", measure);
|
|
428
|
+
observer?.disconnect();
|
|
429
|
+
});
|
|
430
|
+
return {
|
|
431
|
+
scrollRef,
|
|
432
|
+
overflowStart,
|
|
433
|
+
overflowEnd,
|
|
434
|
+
hasOverflow
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
//#endregion
|
|
438
|
+
//#region src/composables/useStreamingText.ts
|
|
439
|
+
const CHARS_PER_TICK = {
|
|
440
|
+
natural: 10,
|
|
441
|
+
fast: 4,
|
|
442
|
+
instant: Number.POSITIVE_INFINITY
|
|
443
|
+
};
|
|
444
|
+
const FALLBACK_DURATION_MS = 95;
|
|
445
|
+
function parseCssDuration(value) {
|
|
446
|
+
const milliseconds = /^([\d.]+)ms$/.exec(value.trim());
|
|
447
|
+
if (milliseconds?.[1] != null) return Number(milliseconds[1]);
|
|
448
|
+
const seconds = /^([\d.]+)s$/.exec(value.trim());
|
|
449
|
+
if (seconds?.[1] != null) return Number(seconds[1]) * 1e3;
|
|
450
|
+
return null;
|
|
451
|
+
}
|
|
452
|
+
function motionDuration() {
|
|
453
|
+
if (typeof document === "undefined") return FALLBACK_DURATION_MS;
|
|
454
|
+
return parseCssDuration(getComputedStyle(document.documentElement).getPropertyValue("--astryx-duration-fast-min")) ?? FALLBACK_DURATION_MS;
|
|
455
|
+
}
|
|
456
|
+
function tickInterval(speed) {
|
|
457
|
+
if (speed === "instant") return 0;
|
|
458
|
+
const duration = motionDuration();
|
|
459
|
+
const tick = speed === "fast" ? duration / 20 : duration / 10;
|
|
460
|
+
return Math.max(4, Math.round(tick));
|
|
461
|
+
}
|
|
462
|
+
const graphemeSegmenter = typeof Intl.Segmenter === "function" ? new Intl.Segmenter(void 0, { granularity: "grapheme" }) : null;
|
|
463
|
+
function isLowSurrogate(codeUnit) {
|
|
464
|
+
return codeUnit >= 56320 && codeUnit <= 57343;
|
|
465
|
+
}
|
|
466
|
+
/**
|
|
467
|
+
* Move `offset` back to the start of the grapheme it lands inside, so a slice
|
|
468
|
+
* never cuts a surrogate pair, a flag, or a ZWJ sequence in half.
|
|
469
|
+
*/
|
|
470
|
+
function snapToGraphemeBoundary(text, offset) {
|
|
471
|
+
if (offset <= 0 || offset >= text.length) return offset;
|
|
472
|
+
if (graphemeSegmenter != null) return graphemeSegmenter.segment(text).containing(offset)?.index ?? offset;
|
|
473
|
+
return isLowSurrogate(text.charCodeAt(offset)) ? offset - 1 : offset;
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* Smooth a burst of streamed text into a steady reveal.
|
|
477
|
+
* While `isStreaming` is false, or the user prefers reduced motion, the full
|
|
478
|
+
* source is returned. The reveal steps by UTF-16 units and then snaps back to
|
|
479
|
+
* a grapheme boundary.
|
|
480
|
+
*/
|
|
481
|
+
function useStreamingText(targetText, isStreaming = false, options) {
|
|
482
|
+
const displayedLen = ref(0);
|
|
483
|
+
const prefersReducedMotion = useMediaQuery("(prefers-reduced-motion: reduce)");
|
|
484
|
+
const target = computed(() => toValue(targetText));
|
|
485
|
+
const streaming = computed(() => toValue(isStreaming));
|
|
486
|
+
const speed = computed(() => toValue(options)?.speed ?? "natural");
|
|
487
|
+
const instant = computed(() => !streaming.value || speed.value === "instant" || prefersReducedMotion.value);
|
|
488
|
+
watch(target, (next, previous) => {
|
|
489
|
+
if (next.length === 0 && (previous?.length ?? 0) > 0) displayedLen.value = 0;
|
|
490
|
+
});
|
|
491
|
+
watch(streaming, (next) => {
|
|
492
|
+
if (!next) displayedLen.value = target.value.length;
|
|
493
|
+
});
|
|
494
|
+
watch(instant, (isInstant, _, onCleanup) => {
|
|
495
|
+
if (isInstant) return;
|
|
496
|
+
let frame = 0;
|
|
497
|
+
let lastTick = 0;
|
|
498
|
+
const tick = (now) => {
|
|
499
|
+
const interval = tickInterval(speed.value);
|
|
500
|
+
if (now - lastTick >= interval) {
|
|
501
|
+
lastTick = now;
|
|
502
|
+
const goal = target.value.length;
|
|
503
|
+
if (displayedLen.value < goal) {
|
|
504
|
+
const step = CHARS_PER_TICK[speed.value];
|
|
505
|
+
displayedLen.value = Math.min(displayedLen.value + step, goal);
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
frame = requestAnimationFrame(tick);
|
|
509
|
+
};
|
|
510
|
+
frame = requestAnimationFrame(tick);
|
|
511
|
+
onCleanup(() => cancelAnimationFrame(frame));
|
|
512
|
+
}, { immediate: true });
|
|
513
|
+
return computed(() => {
|
|
514
|
+
const text = target.value;
|
|
515
|
+
if (instant.value) return text;
|
|
516
|
+
return text.slice(0, snapToGraphemeBoundary(text, displayedLen.value));
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
//#endregion
|
|
520
|
+
export { imageModeFromPixels as a, useGridRovingFocus as c, useKeyboardHint as i, useControllableState as l, useStreamingText as n, perceptualLightness as o, useScrollOverflow as r, useImageMode as s, snapToGraphemeBoundary as t, useContainerReveal as u };
|
|
@@ -272,6 +272,12 @@ const inputMessages = {
|
|
|
272
272
|
}
|
|
273
273
|
};
|
|
274
274
|
//#endregion
|
|
275
|
+
//#region src/locale/messages/keyboard-hint.ts
|
|
276
|
+
const keyboardHintMessages = {
|
|
277
|
+
"en": { navigate: "to navigate" },
|
|
278
|
+
"zh-CN": { navigate: "移动" }
|
|
279
|
+
};
|
|
280
|
+
//#endregion
|
|
275
281
|
//#region src/locale/messages/layout.ts
|
|
276
282
|
const layoutMessages = {
|
|
277
283
|
"en": {
|
|
@@ -391,7 +397,9 @@ const navMessages = {
|
|
|
391
397
|
moreItems: (count) => `${count} more`,
|
|
392
398
|
expandItem: (label) => `Expand ${label}`,
|
|
393
399
|
collapseItem: (label) => `Collapse ${label}`,
|
|
394
|
-
submenu: (label) => `${label} submenu
|
|
400
|
+
submenu: (label) => `${label} submenu`,
|
|
401
|
+
resizeSidebar: "Resize sidebar",
|
|
402
|
+
opensInNewTab: "(opens in new tab)"
|
|
395
403
|
},
|
|
396
404
|
"zh-CN": {
|
|
397
405
|
sideNav: "侧边导航",
|
|
@@ -406,7 +414,9 @@ const navMessages = {
|
|
|
406
414
|
moreItems: (count) => `还有 ${count} 项`,
|
|
407
415
|
expandItem: (label) => `展开${label}`,
|
|
408
416
|
collapseItem: (label) => `收起${label}`,
|
|
409
|
-
submenu: (label) => `${label}
|
|
417
|
+
submenu: (label) => `${label}子菜单`,
|
|
418
|
+
resizeSidebar: "调整侧栏宽度",
|
|
419
|
+
opensInNewTab: "(在新标签页打开)"
|
|
410
420
|
}
|
|
411
421
|
};
|
|
412
422
|
//#endregion
|
|
@@ -440,7 +450,14 @@ const paginationMessages = {
|
|
|
440
450
|
pageSize: (count) => `${count} / page`,
|
|
441
451
|
total: (total, from, to) => `${from}–${to} of ${total}`,
|
|
442
452
|
compact: (page, totalPages) => `${page} / ${totalPages}`,
|
|
443
|
-
pageOf: (page, totalPages) => `Page ${page} of ${totalPages}
|
|
453
|
+
pageOf: (page, totalPages) => `Page ${page} of ${totalPages}`,
|
|
454
|
+
first: "First page",
|
|
455
|
+
last: "Last page",
|
|
456
|
+
previousBy: (step) => `Back ${step} pages`,
|
|
457
|
+
nextBy: (step) => `Forward ${step} pages`,
|
|
458
|
+
pageLabel: "Page",
|
|
459
|
+
goToPage: "Go to page",
|
|
460
|
+
ofTotal: (totalPages) => `/ ${totalPages}`
|
|
444
461
|
},
|
|
445
462
|
"zh-CN": {
|
|
446
463
|
nav: "分页导航",
|
|
@@ -452,7 +469,14 @@ const paginationMessages = {
|
|
|
452
469
|
pageSize: (count) => `${count} 条/页`,
|
|
453
470
|
total: (total, from, to) => `共 ${total} 条,显示 ${from}-${to}`,
|
|
454
471
|
compact: (page, totalPages) => `${page} / ${totalPages}`,
|
|
455
|
-
pageOf: (page, totalPages) => `第 ${page} 页,共 ${totalPages}
|
|
472
|
+
pageOf: (page, totalPages) => `第 ${page} 页,共 ${totalPages} 页`,
|
|
473
|
+
first: "第一页",
|
|
474
|
+
last: "最后一页",
|
|
475
|
+
previousBy: (step) => `后退 ${step} 页`,
|
|
476
|
+
nextBy: (step) => `前进 ${step} 页`,
|
|
477
|
+
pageLabel: "页",
|
|
478
|
+
goToPage: "跳转到页",
|
|
479
|
+
ofTotal: (totalPages) => `/ ${totalPages}`
|
|
456
480
|
}
|
|
457
481
|
};
|
|
458
482
|
const powerSearchMessages = {
|
|
@@ -823,6 +847,7 @@ const astryxMessages = {
|
|
|
823
847
|
dropdownMenu: dropdownMenuMessages.en,
|
|
824
848
|
fileInput: fileInputMessages.en,
|
|
825
849
|
input: inputMessages.en,
|
|
850
|
+
keyboardHint: keyboardHintMessages.en,
|
|
826
851
|
layout: layoutMessages.en,
|
|
827
852
|
lightbox: lightboxMessages.en,
|
|
828
853
|
markdown: markdownMessages.en,
|
|
@@ -857,6 +882,7 @@ const astryxMessages = {
|
|
|
857
882
|
dropdownMenu: dropdownMenuMessages["zh-CN"],
|
|
858
883
|
fileInput: fileInputMessages["zh-CN"],
|
|
859
884
|
input: inputMessages["zh-CN"],
|
|
885
|
+
keyboardHint: keyboardHintMessages["zh-CN"],
|
|
860
886
|
layout: layoutMessages["zh-CN"],
|
|
861
887
|
lightbox: lightboxMessages["zh-CN"],
|
|
862
888
|
markdown: markdownMessages["zh-CN"],
|
|
@@ -882,13 +908,31 @@ const astryxMessages = {
|
|
|
882
908
|
//#endregion
|
|
883
909
|
//#region src/locale/context.ts
|
|
884
910
|
const astryxLocaleKey = Symbol("astryx-locale");
|
|
911
|
+
const astryxMessagesKey = Symbol("astryx-messages");
|
|
912
|
+
/**
|
|
913
|
+
* 把语言标签收成组件能用的写法。
|
|
914
|
+
* `en` 和 `en-*` 收成 `en`。`zh`、`zh-CN`、`zh-Hans` 收成 `zh-CN`。
|
|
915
|
+
* `zh-TW` 以及其他标签保留规范写法,用来接 `loadAstryxCatalog` 的结果。
|
|
916
|
+
* 空值和解析不了的标签回到 `en`。
|
|
917
|
+
*/
|
|
885
918
|
function normalizeLocale(locale) {
|
|
886
|
-
const
|
|
887
|
-
if (
|
|
888
|
-
|
|
919
|
+
const trimmed = locale?.trim() ?? "";
|
|
920
|
+
if (trimmed === "") return "en";
|
|
921
|
+
let parsed;
|
|
922
|
+
try {
|
|
923
|
+
parsed = new Intl.Locale(trimmed);
|
|
924
|
+
} catch {
|
|
925
|
+
return "en";
|
|
926
|
+
}
|
|
927
|
+
const base = parsed.baseName;
|
|
928
|
+
const lower = base.toLowerCase();
|
|
929
|
+
if (lower === "en" || lower.startsWith("en-")) return "en";
|
|
930
|
+
if (lower === "zh" || lower === "zh-cn" || lower === "zh-hans" || lower.startsWith("zh-hans-")) return "zh-CN";
|
|
931
|
+
return base;
|
|
889
932
|
}
|
|
890
|
-
function provideAstryxLocale(locale) {
|
|
933
|
+
function provideAstryxLocale(locale, messages) {
|
|
891
934
|
provide(astryxLocaleKey, computed(() => normalizeLocale(toValue(locale))));
|
|
935
|
+
if (messages !== void 0) provide(astryxMessagesKey, computed(() => toValue(messages)));
|
|
892
936
|
}
|
|
893
937
|
function useAstryxLocale() {
|
|
894
938
|
const injected = inject(astryxLocaleKey, void 0);
|
|
@@ -896,7 +940,11 @@ function useAstryxLocale() {
|
|
|
896
940
|
}
|
|
897
941
|
function useAstryxMessages() {
|
|
898
942
|
const locale = useAstryxLocale();
|
|
899
|
-
|
|
943
|
+
const provided = inject(astryxMessagesKey, void 0);
|
|
944
|
+
return computed(() => {
|
|
945
|
+
if (provided != null) return toValue(provided);
|
|
946
|
+
return locale.value === "zh-CN" ? astryxMessages["zh-CN"] : astryxMessages.en;
|
|
947
|
+
});
|
|
900
948
|
}
|
|
901
949
|
//#endregion
|
|
902
|
-
export {
|
|
950
|
+
export { useAstryxLocale as a, provideAstryxLocale as i, astryxMessagesKey as n, useAstryxMessages as o, normalizeLocale as r, astryxMessages as s, astryxLocaleKey as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as LayerPlacement, t as LayerAlignment } from "./position-DFW5ymAF.js";
|
|
2
|
-
import { A as DropdownMenuSize, F as DropdownMenuSubMenuSlots, N as DropdownMenuSubMenuPresentation, P as DropdownMenuSubMenuProps, _ as DropdownMenuItemSlots, b as DropdownMenuPresentation, f as DropdownMenuGroupProps, g as DropdownMenuItemProps, i as DropdownMenuButtonProps, j as DropdownMenuSlots, p as DropdownMenuGroupSlots, v as DropdownMenuItemVariant, x as DropdownMenuProps } from "./DropdownMenuRadioItem.vue-
|
|
2
|
+
import { A as DropdownMenuSize, F as DropdownMenuSubMenuSlots, N as DropdownMenuSubMenuPresentation, P as DropdownMenuSubMenuProps, _ as DropdownMenuItemSlots, b as DropdownMenuPresentation, f as DropdownMenuGroupProps, g as DropdownMenuItemProps, i as DropdownMenuButtonProps, j as DropdownMenuSlots, p as DropdownMenuGroupSlots, v as DropdownMenuItemVariant, x as DropdownMenuProps } from "./DropdownMenuRadioItem.vue-CXEURBcq.js";
|
|
3
3
|
import { ComputedRef, InjectionKey, Ref } from "vue";
|
|
4
4
|
//#region src/DropdownMenu/useMenuDrillIn.d.ts
|
|
5
5
|
/**
|
|
@@ -143,18 +143,18 @@ declare const __VLS_base: import("vue").DefineComponent<MultiSelectorProps, {
|
|
|
143
143
|
}>, {
|
|
144
144
|
variant: MultiSelectorVariant;
|
|
145
145
|
required: boolean;
|
|
146
|
-
status: MultiSelectorStatus;
|
|
147
|
-
isLoading: boolean;
|
|
148
146
|
size: MultiSelectorSize;
|
|
147
|
+
isLoading: boolean;
|
|
148
|
+
status: MultiSelectorStatus;
|
|
149
149
|
modelValue: readonly (string | number)[];
|
|
150
150
|
statusVariant: MultiSelectorStatusVariant;
|
|
151
151
|
disabled: boolean;
|
|
152
|
-
labelHidden: boolean;
|
|
153
|
-
clearable: boolean;
|
|
154
|
-
optional: boolean;
|
|
155
|
-
isReadOnly: boolean;
|
|
156
152
|
presentation: MultiSelectorPresentation;
|
|
157
153
|
searchable: boolean;
|
|
154
|
+
clearable: boolean;
|
|
155
|
+
isReadOnly: boolean;
|
|
156
|
+
labelHidden: boolean;
|
|
157
|
+
optional: boolean;
|
|
158
158
|
selectAll: boolean;
|
|
159
159
|
triggerDisplay: MultiSelectorTriggerDisplay;
|
|
160
160
|
maxBadges: number;
|