@astryx-vue/core 0.29.0 → 0.30.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-B195FgtL.js → AlertDialog-D_lrpZz_.js} +4 -4
- package/dist/AppShell/index.d.ts +1 -1
- package/dist/Avatar/index.js +1 -1
- package/dist/{Avatar-DpFHPRlE.js → Avatar-IVvsyeGV.js} +1 -1
- package/dist/AvatarGroup/index.d.ts +1 -1
- package/dist/Banner/index.d.ts +1 -1
- package/dist/Banner/index.js +1 -1
- package/dist/{Banner-DVU5-fWC.js → Banner-Ctg1puM6.js} +1 -1
- package/dist/BottomSheet/index.d.ts +1 -1
- package/dist/BottomSheet/index.js +2 -2
- package/dist/{BottomSheet-DVe5Nw9Z.js → BottomSheet-CmNOXlZO.js} +39 -29
- package/dist/{BottomSheet-D3893Ymj.js → BottomSheet-_K41Oliv.js} +8 -2
- package/dist/Breadcrumbs/index.js +1 -1
- package/dist/{Breadcrumbs-CQa-Jjnn.js → Breadcrumbs-CdGqhFKU.js} +1 -1
- package/dist/Button/index.d.ts +1 -1
- package/dist/Button/index.js +1 -1
- package/dist/{Button-yJiHoWps.js → Button-CvHeZGf1.js} +3 -3
- package/dist/ButtonGroup/index.d.ts +1 -1
- package/dist/{ButtonTooltip-CNKOQHYR.js → ButtonTooltip-ZpQP-aQg.js} +1 -1
- package/dist/Calendar/index.d.ts +1 -1
- package/dist/Card/index.d.ts +1 -1
- package/dist/Carousel/index.d.ts +1 -1
- package/dist/Carousel/index.js +1 -1
- package/dist/{Carousel-DPhwOTjx.js → Carousel-CbdHb8MD.js} +1 -1
- package/dist/Chat/index.d.ts +1 -1
- package/dist/Chat/index.js +1 -1
- package/dist/{Chat-Bg1IuDMt.js → Chat-B7ccEmTR.js} +3 -3
- package/dist/CheckboxInput/index.d.ts +1 -1
- package/dist/CheckboxInput/index.js +1 -1
- package/dist/{CheckboxInput-C-UseBJo.js → CheckboxInput-5r6VWqId.js} +2 -2
- package/dist/CheckboxList/index.d.ts +1 -1
- package/dist/CheckboxList/index.js +1 -1
- package/dist/{CheckboxList-DGM-cgX5.js → CheckboxListItem-CKeQzQ0W.js} +3 -3
- package/dist/ClickableCard/index.d.ts +1 -1
- package/dist/Code/index.d.ts +1 -1
- package/dist/Code/index.js +1 -1
- package/dist/{CodeBlock-3QLhu3jZ.js → CodeBlock-4i1vvmOc.js} +1 -1
- package/dist/Collapsible/index.d.ts +1 -1
- package/dist/CommandPalette/index.d.ts +1 -1
- package/dist/CommandPalette/index.js +1 -1
- package/dist/{CommandPalette-CtY5ZCR7.js → CommandPalette-BMwvTjff.js} +1 -1
- package/dist/ComplexSelector/index.d.ts +1 -1
- package/dist/ComplexSelector/index.js +1 -1
- package/dist/{ComplexSelector-CZiUA6Gm.js → ComplexSelector-B4iFyilD.js} +4 -4
- package/dist/ContextMenu/index.d.ts +1 -1
- package/dist/ContextMenu/index.js +1 -1
- package/dist/{ContextMenu-8I420g7H.js → ContextMenu-DquYeIEF.js} +2 -2
- package/dist/DateInput/index.d.ts +1 -1
- package/dist/DateInput/index.js +1 -1
- package/dist/{DateInput-KZF_A_31.js → DateInput-MNNyi4XK.js} +4 -4
- package/dist/DateRangeInput/index.d.ts +1 -1
- package/dist/DateRangeInput/index.js +1 -1
- package/dist/{DateRangeInput-4GCWgLFN.js → DateRangeInput-DOHntScL.js} +4 -4
- package/dist/DateTimeInput/index.d.ts +1 -1
- package/dist/DateTimeInput/index.js +1 -1
- package/dist/{DateTimeInput-BGcdOmRp.js → DateTimeInput-BaghFHW6.js} +5 -5
- package/dist/Dialog/index.d.ts +1 -1
- package/dist/Dialog/index.js +3 -3
- package/dist/{Dialog-DjhG_vpE.js → Dialog-CGf64DqF.js} +1 -1
- package/dist/{Dialog-CKDlXonX.js → Dialog-Ctha_b_L.js} +1 -1
- package/dist/{DialogHeader-C1Bz4Knk.js → DialogHeader-BxTV37GT.js} +2 -2
- package/dist/Divider/index.d.ts +1 -1
- package/dist/Drawer/index.d.ts +1 -1
- package/dist/Drawer/index.js +1 -1
- package/dist/{Drawer-BqcPP0z7.js → Drawer-DAnc2ut9.js} +2 -2
- package/dist/DropdownMenu/index.js +2 -2
- package/dist/{DropdownMenu-CSqkl-Xl.js → DropdownMenu-BPi0pm0w.js} +2 -2
- package/dist/{DropdownMenu-B-dBiomz.js → DropdownMenu-DuSVFQoS.js} +3 -3
- package/dist/EmptyState/index.js +1 -1
- package/dist/{EmptyState-DNjqNAT3.js → EmptyState-BGo1nrnT.js} +2 -2
- package/dist/Field/index.js +3 -3
- package/dist/{Field-DrUMz0oj.js → Field-d5R_kRMv.js} +1 -1
- package/dist/{FieldInfoTip-DmDOcxU1.js → FieldInfoTip-BhKtjq3g.js} +2 -2
- package/dist/{FieldLabel-DsFZnW1l.js → FieldLabel-BHNpYFx7.js} +1 -1
- package/dist/FileInput/index.js +1 -1
- package/dist/{FileInput-0u4zjJfx.js → FileInput-BCg4HROm.js} +4 -4
- package/dist/Heading/index.d.ts +1 -1
- package/dist/Heading/index.js +1 -1
- package/dist/{Heading-BG1PBVkf.js → Heading-BFK3PftX.js} +1 -1
- package/dist/HoverCard/index.d.ts +1 -1
- package/dist/HoverCard/index.js +1 -1
- package/dist/{HoverCard-Fr6RLRR8.js → HoverCard-DGjsPn-Q.js} +3 -3
- package/dist/IconButton/index.js +1 -1
- package/dist/{IconButton-CEjiXpUg.js → IconButton-BZgU_THt.js} +1 -1
- package/dist/InfoTip/index.d.ts +1 -1
- package/dist/InfoTip/index.js +1 -1
- package/dist/{InfoTip-CKRaCO6I.js → InfoTip-E2-OzKti.js} +1 -1
- package/dist/{InputClearButton-ByUJXRmY.js → InputClearButton-B62_uexC.js} +1 -1
- package/dist/InputGroup/index.js +1 -1
- package/dist/{InputGroup-H8DP0TAG.js → InputGroup-DKBqRYFf.js} +1 -1
- package/dist/Lightbox/index.js +1 -1
- package/dist/{Lightbox-LI6h7LFn.js → Lightbox-Bou1gTfv.js} +1 -1
- package/dist/Link/index.d.ts +1 -1
- package/dist/Link/index.js +1 -1
- package/dist/{Link-Dx2ql41g.js → Link-CaJ5lmKk.js} +1 -1
- package/dist/List/index.d.ts +1 -1
- package/dist/Markdown/index.js +1 -1
- package/dist/{Markdown-BHWf2IOO.js → Markdown-BE6vdvPG.js} +3 -3
- package/dist/MetadataList/index.d.ts +1 -1
- package/dist/MoreMenu/index.d.ts +1 -1
- package/dist/MoreMenu/index.js +1 -1
- package/dist/{MoreMenu-GPcHAauX.js → MoreMenu-CNzTagqr.js} +4 -4
- package/dist/MultiSelector/index.d.ts +1 -1
- package/dist/MultiSelector/index.js +1 -1
- package/dist/{MultiSelector-BSA613nO.js → MultiSelector-MGEiRi1W.js} +6 -6
- package/dist/{NavDisclosure-B66SHKdd.js → NavDisclosure-DsUYuMJr.js} +1 -1
- package/dist/{NavHeadingSurface-BZCzkCPJ.js → NavHeadingSurface-QdM33nOf.js} +1 -1
- package/dist/NavItem/index.d.ts +1 -1
- package/dist/NavMenu/index.js +3 -3
- package/dist/{NavMenu-BoKuJq-K.js → NavMenu-ZN5cqCxO.js} +1 -1
- package/dist/{NavMenuItem-Ez3_K8iI.js → NavMenuItem-xm3e0V8q.js} +1 -1
- package/dist/NumberInput/index.d.ts +1 -1
- package/dist/NumberInput/index.js +1 -1
- package/dist/{NumberInput-lqUmTsqB.js → NumberInput-D4ECOHh_.js} +4 -4
- package/dist/OverflowList/index.d.ts +1 -1
- package/dist/OverflowList/index.js +1 -1
- package/dist/{OverflowList-B6En7wIj.js → OverflowList-m1tf_fR1.js} +2 -2
- 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-DWfvdCpK.js → Pagination-BdjxuxM3.js} +2 -2
- package/dist/Popover/index.d.ts +1 -1
- package/dist/Popover/index.js +1 -1
- package/dist/{Popover-CB5UYJZc.js → Popover-DEj8xWN-.js} +5 -5
- package/dist/PowerSearch/index.d.ts +2 -2
- package/dist/PowerSearch/index.js +1 -1
- package/dist/PowerSearch-BJDFietK.js +4829 -0
- package/dist/ProgressBar/index.d.ts +1 -1
- package/dist/ProgressBar/index.js +1 -1
- package/dist/{ProgressBar-yw2BCtB_.js → ProgressBar-DCAEXJuP.js} +1 -1
- package/dist/Radio/index.d.ts +1 -1
- package/dist/Radio/index.js +1 -1
- package/dist/{RadioGroup-B8QoJyJu.js → RadioGroup-B3UoJrOA.js} +2 -2
- package/dist/RadioList/index.d.ts +1 -1
- package/dist/RadioList/index.js +1 -1
- package/dist/{RadioList-BEv82wbs.js → RadioListItem-CD7kUGlN.js} +1 -1
- package/dist/Resizable/index.d.ts +1 -1
- package/dist/ScrollableArea/index.d.ts +1 -1
- package/dist/SegmentedControl/index.js +1 -1
- package/dist/{SegmentedControl-BkWz-I2J.js → SegmentedControl-DGd6JlaD.js} +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-4sexgsUO.js → Selector-BD0u-5Fy.js} +5 -5
- package/dist/SideNav/index.d.ts +1 -1
- package/dist/SideNav/index.js +1 -1
- package/dist/{SideNav-B_0Fv-ZU.js → SideNav-DoqCLRiX.js} +4 -4
- package/dist/Slider/index.js +1 -1
- package/dist/{Slider-Bmksx8ng.js → Slider-DHR7HZ7N.js} +2 -2
- package/dist/Stack/index.d.ts +1 -1
- package/dist/StatusDot/index.js +1 -1
- package/dist/{StatusDot-Bz4l43St.js → StatusDot-DFJavm30.js} +1 -1
- package/dist/Stepper/index.d.ts +1 -1
- package/dist/Switch/index.d.ts +1 -1
- package/dist/Switch/index.js +1 -1
- package/dist/{Switch-CeNEvvTn.js → Switch-CnFC7jGw.js} +2 -2
- package/dist/TabList/index.d.ts +1 -1
- package/dist/TabList/index.js +1 -1
- package/dist/{TabList-BLLxHXwu.js → TabList-fMlX8m6n.js} +1 -1
- package/dist/Table/index.d.ts +1 -1
- package/dist/Table/index.js +1 -1
- package/dist/{Table-Ck4haR13.js → Table-DoKmVdhZ.js} +11 -11
- package/dist/Text/index.d.ts +1 -1
- package/dist/Text/index.js +1 -1
- package/dist/{Text-DkSHitKh.js → Text-D48QFTtL.js} +1 -1
- package/dist/TextArea/index.d.ts +1 -1
- package/dist/TextArea/index.js +1 -1
- package/dist/{TextArea-CAcjMvls.js → TextArea-y9mmYAIy.js} +5 -5
- package/dist/TextInput/index.d.ts +1 -1
- package/dist/TextInput/index.js +1 -1
- package/dist/{TextInput-BvQQTG75.js → TextInput-BLGEh7vE.js} +5 -5
- package/dist/Thumbnail/index.js +1 -1
- package/dist/{Thumbnail-Bv-M13fy.js → Thumbnail-Dm8krgGF.js} +2 -2
- package/dist/{TimeField-B83zAjAA.js → TimeField-DS30hnty.js} +4 -4
- package/dist/TimeInput/index.d.ts +1 -1
- package/dist/TimeInput/index.js +1 -1
- package/dist/{TimeInput-BoIZG-dF.js → TimeInput-DcY4b3dg.js} +2 -2
- package/dist/Timer/index.d.ts +1 -1
- package/dist/Timer/index.js +1 -1
- package/dist/{Timer-qjI_QrCz.js → Timer-DgQdZAEa.js} +1 -1
- package/dist/Timestamp/index.d.ts +1 -1
- package/dist/Timestamp/index.js +1 -1
- package/dist/{Timestamp-CJ_HUcek.js → Timestamp-BhBuBHu8.js} +3 -3
- package/dist/Toast/index.js +1 -1
- package/dist/{Toast-CFpOSuAr.js → Toast-CnLk7LzS.js} +1 -1
- package/dist/ToggleButton/index.d.ts +1 -1
- package/dist/ToggleButton/index.js +1 -1
- package/dist/{ToggleButton-BtXMvoOA.js → ToggleButton-B9IJcpdJ.js} +1 -1
- package/dist/Token/index.d.ts +1 -1
- package/dist/Tokenizer/index.d.ts +1 -1
- package/dist/Tokenizer/index.js +1 -1
- package/dist/{Tokenizer-DrkIayoF.js → Tokenizer-D7ZCTbnf.js} +165 -154
- package/dist/Toolbar/index.d.ts +1 -1
- package/dist/Tooltip/index.d.ts +1 -1
- package/dist/Tooltip/index.js +2 -2
- package/dist/{Tooltip-ByLqPCP7.js → Tooltip-CxzlUVN0.js} +1 -1
- package/dist/TopNav/index.d.ts +1 -1
- package/dist/TopNav/index.js +1 -1
- package/dist/{TopNav-Rcz2zriX.js → TopNav-CK_F6Ud5.js} +3 -3
- package/dist/TreeList/index.d.ts +1 -1
- package/dist/Typeahead/index.d.ts +1 -1
- package/dist/Typeahead/index.js +2 -2
- package/dist/{Typeahead-D2O3n477.js → Typeahead-Cs-46obm.js} +5 -5
- package/dist/composables/index.js +4 -4
- package/dist/{index-X4S7_dmq.d.ts → index-BA8exXNP.d.ts} +1 -1
- package/dist/{index-BuubzuE8.d.ts → index-BDZCJ9ri.d.ts} +2 -2
- package/dist/{index-DIkdln91.d.ts → index-BIqW3_GP.d.ts} +2 -2
- package/dist/{index-6fLylXRI.d.ts → index-BL9fE6gs.d.ts} +8 -8
- package/dist/{index-Ct8M2d4q.d.ts → index-BVeTS-R5.d.ts} +7 -7
- package/dist/{index-BR3MOBYd.d.ts → index-BgT6mH3U.d.ts} +2 -2
- package/dist/{index-CTjkJP4x.d.ts → index-Bgk1Rj2A.d.ts} +1 -1
- package/dist/{index-ChqMaV6N.d.ts → index-Bzi3A980.d.ts} +1 -1
- package/dist/{index-BjqoHLMq.d.ts → index-C1e8LNx2.d.ts} +1 -1
- package/dist/{index-I64GPV90.d.ts → index-C6IcBhAn.d.ts} +3 -3
- package/dist/{index-C4S65SAW.d.ts → index-CKnr0JlT.d.ts} +1 -1
- package/dist/{index-DVX2jlTQ.d.ts → index-CUuUoX3h.d.ts} +1 -1
- package/dist/{index-mK1ICsVg.d.ts → index-Cm36VS1A.d.ts} +2 -2
- package/dist/{index-C8wfe0Mr.d.ts → index-D05JGsT3.d.ts} +1 -1
- package/dist/{index-BFGtLIp8.d.ts → index-D14kSf-g.d.ts} +2 -2
- package/dist/{index-In41wHf3.d.ts → index-DGe-ApvN.d.ts} +4 -4
- package/dist/{index-D8l_CmL-.d.ts → index-DIw5D3zj.d.ts} +2 -2
- package/dist/{index-BqQlY3fL.d.ts → index-DQ3akoRZ.d.ts} +4 -4
- package/dist/{index-ZXrvTM3A.d.ts → index-DVS4jM-l.d.ts} +2 -2
- package/dist/{index-DPhQZXYw.d.ts → index-DYabo8TI.d.ts} +1 -1
- package/dist/{index-BtqvPjAf.d.ts → index-DofC9Rll.d.ts} +1 -1
- package/dist/{index-aHC2C89h.d.ts → index-Ea2V_FSK.d.ts} +4 -4
- package/dist/{index-CBOv5j3c.d.ts → index-FeZXsFO-.d.ts} +3 -3
- package/dist/{index-DPklTi3o.d.ts → index-Q1oG9yIT.d.ts} +1 -1
- package/dist/{index-DCyYldjP.d.ts → index-T5bzxQ30.d.ts} +1 -1
- package/dist/{index-CdvmnNMH.d.ts → index-YKCx03zD.d.ts} +1 -1
- package/dist/{index-NOxH5oYj.d.ts → index-etx25Eq-.d.ts} +1 -1
- package/dist/{index-B9iQwixh.d.ts → index-hUa5oQ5O.d.ts} +97 -86
- package/dist/{index-yQc-te9a.d.ts → index-ql9ApSTF.d.ts} +2 -2
- package/dist/{index-CtYlR9Cu.d.ts → index-rdwI-mcm.d.ts} +1 -1
- package/dist/{index-NOXYEdOI.d.ts → index-utZGF4GR.d.ts} +1 -1
- package/dist/{index-C89cIh4E.d.ts → index-waTkqxTz.d.ts} +1 -1
- package/dist/index.d.ts +34 -34
- package/dist/index.js +79 -77
- package/dist/{lazyBottomSheet-BK8yIqcZ.js → lazyBottomSheet-Cmd-WMEE.js} +1 -1
- package/dist/{useLayerMountTarget-BmZyeKWE.js → mount-7R_s-bHB.js} +15 -42
- package/dist/{stillPointerGate-D3loXLh7.js → stillPointerGate-BbMABRyU.js} +1 -1
- package/dist/{tooltipFocusRules-DvVDuqZI.js → tooltipFocusRules-CpUOvFEU.js} +1 -1
- package/dist/{tooltipTriggerRules-DyPyWOdP.js → tooltipTriggerRules-zN2xGd9K.js} +1 -1
- package/dist/{triggerVariant-DG0VhG-X.js → triggerVariant-DPuBmzpp.js} +1 -1
- package/dist/{useDismiss-C7_S7qUA.js → useDismiss-BKtyCwx4.js} +1 -1
- package/dist/{useInputStatusIcon-CGj9gMj8.js → useInputStatusIcon-BngSzjVd.js} +1 -1
- package/dist/useLayerMountTarget-zwZQglr2.js +44 -0
- package/dist/{useTooltip-Bsm43vbi.js → useTooltip-DvBKna-w.js} +3 -3
- package/dist/{useTruncationTooltip-wc6Lzz34.js → useTruncationTooltip-DNAii2Nv.js} +3 -3
- package/dist/{useTypeaheadMenuConfig-Do0jOyEm.js → useTypeaheadMenuConfig-BT9Lwsu7.js} +1 -1
- package/package.json +1 -1
- package/styles/bottom-sheet.css +5 -0
- package/styles/power-search-sheet.css +205 -0
- package/styles.css +1 -0
- package/dist/PowerSearch-q3jvh5Tw.js +0 -2797
- package/dist/{index-BqhgeAT4.d.ts → index-D8lv2BiD.d.ts} +1 -1
|
@@ -1,2797 +0,0 @@
|
|
|
1
|
-
import { t as _sfc_main$5 } from "./Icon-Dk0jccgU.js";
|
|
2
|
-
import { i as useSize } from "./SizeContext-BbaF-SEx.js";
|
|
3
|
-
import { t as _sfc_main$6 } from "./Button-yJiHoWps.js";
|
|
4
|
-
import { i as useLayerGutter } from "./context-M-er0-Rk.js";
|
|
5
|
-
import { t as useDismiss } from "./useDismiss-C7_S7qUA.js";
|
|
6
|
-
import { r as truncateCharacters, t as characterCount } from "./characters-wTnzjkkR.js";
|
|
7
|
-
import { n as isDevBuild, t as devPropError } from "./devBuild-G249YcdZ.js";
|
|
8
|
-
import { t as useAnnounce } from "./announce-GU01Oix2.js";
|
|
9
|
-
import { t as createStaticSource } from "./useAsyncSource-7GTcK8ep.js";
|
|
10
|
-
import { t as useInputStatusIcon } from "./useInputStatusIcon-CGj9gMj8.js";
|
|
11
|
-
import { a as useAstryxLocale, o as useComponentMessages } from "./context-B8IEFCDR.js";
|
|
12
|
-
import { t as useOverflow } from "./useOverflow-GU0pxGaU.js";
|
|
13
|
-
import { t as useResolvedLabelHidden } from "./useResolvedLabelHidden-B2rlWiaI.js";
|
|
14
|
-
import { t as _sfc_main$7 } from "./Tooltip-ByLqPCP7.js";
|
|
15
|
-
import { t as useScrollbars } from "./useScrollbars-Ch0xqJWO.js";
|
|
16
|
-
import { r as useCalendarSystem } from "./calendar-C7py_wtb.js";
|
|
17
|
-
import { r as formatCalendarInstant } from "./calendarFormat-_CEZIMZG.js";
|
|
18
|
-
import { t as _sfc_main$8 } from "./Field-DrUMz0oj.js";
|
|
19
|
-
import { t as useFieldPartStyling } from "./fieldParts-CuE5V12i.js";
|
|
20
|
-
import { t as _sfc_main$9 } from "./DateInput-KZF_A_31.js";
|
|
21
|
-
import { l as powerSearchMessages, u as powerSearchSheetMessages } from "./loadCatalog-FwMzmCx1.js";
|
|
22
|
-
import { t as _sfc_main$10 } from "./DateRangeInput-4GCWgLFN.js";
|
|
23
|
-
import { t as _sfc_main$11 } from "./DateTimeInput-BGcdOmRp.js";
|
|
24
|
-
import { n as tokenNamingKey, t as _sfc_main$12 } from "./Token-C7Dt5ygK.js";
|
|
25
|
-
import { n as scrollOptionIntoView, r as useAnchoredListbox } from "./stillPointerGate-D3loXLh7.js";
|
|
26
|
-
import { t as _sfc_main$13 } from "./MultiSelector-BSA613nO.js";
|
|
27
|
-
import { n as resolveNumberInputCommit, t as _sfc_main$14 } from "./NumberInput-lqUmTsqB.js";
|
|
28
|
-
import { t as _sfc_main$15 } from "./Selector-4sexgsUO.js";
|
|
29
|
-
import { o as useTypeaheadMenu } from "./useTypeaheadMenuConfig-Do0jOyEm.js";
|
|
30
|
-
import { n as useTokenRemoveTap, t as _sfc_main$16 } from "./Tokenizer-DrkIayoF.js";
|
|
31
|
-
import { t as _sfc_main$17 } from "./TextInput-BvQQTG75.js";
|
|
32
|
-
import { t as _sfc_main$18 } from "./TimeInput-BoIZG-dF.js";
|
|
33
|
-
import { t as _sfc_main$19 } from "./Typeahead-D2O3n477.js";
|
|
34
|
-
import { Fragment, Teleport, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createSlots, createVNode, defineComponent, mergeProps, nextTick, normalizeClass, normalizeProps, normalizeStyle, onMounted, openBlock, provide, ref, renderList, renderSlot, resolveComponent, resolveDynamicComponent, toDisplayString, unref, useAttrs, useId, useSlots, useTemplateRef, vShow, watch, withCtx, withDirectives, withModifiers } from "vue";
|
|
35
|
-
import "../styles/layer.css";
|
|
36
|
-
import "../styles/visually-hidden-utility.css";
|
|
37
|
-
import "../styles/typeahead.css";
|
|
38
|
-
import "../styles/power-search.css";
|
|
39
|
-
//#region src/PowerSearch/complete.ts
|
|
40
|
-
function nestedChildren(partial) {
|
|
41
|
-
if (partial.children != null) return partial.children;
|
|
42
|
-
if (partial.value?.type === "nested") return partial.value.value;
|
|
43
|
-
return [];
|
|
44
|
-
}
|
|
45
|
-
function isFilled(value) {
|
|
46
|
-
switch (value.type) {
|
|
47
|
-
case "empty": return true;
|
|
48
|
-
case "string":
|
|
49
|
-
case "date_relative":
|
|
50
|
-
case "time":
|
|
51
|
-
case "enum":
|
|
52
|
-
case "custom": return value.value.trim() !== "";
|
|
53
|
-
case "string_list":
|
|
54
|
-
case "enum_list":
|
|
55
|
-
case "entity_list": return value.value.length > 0;
|
|
56
|
-
case "integer":
|
|
57
|
-
case "float": return Number.isFinite(value.value);
|
|
58
|
-
case "date_absolute": return Number.isFinite(value.unixSeconds);
|
|
59
|
-
case "date_range": return value.value.start != null && value.value.end != null;
|
|
60
|
-
case "nested": return value.value.length > 0;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
/** 条件齐全才返回可保存的筛选。嵌套里有没填完的子条件时返回空。 */
|
|
64
|
-
function completePowerSearchFilter(partial, lookup) {
|
|
65
|
-
if (partial.field === "" || partial.operator == null || partial.operator === "") return null;
|
|
66
|
-
const operator = lookup.getOperator(partial.field, partial.operator);
|
|
67
|
-
if (operator == null) return null;
|
|
68
|
-
if (operator.value.type === "empty") return {
|
|
69
|
-
field: partial.field,
|
|
70
|
-
operator: partial.operator,
|
|
71
|
-
value: { type: "empty" },
|
|
72
|
-
isReadOnly: partial.isReadOnly
|
|
73
|
-
};
|
|
74
|
-
if (operator.value.type === "nested") {
|
|
75
|
-
const children = nestedChildren(partial);
|
|
76
|
-
if (children.length === 0) return null;
|
|
77
|
-
const complete = children.map((child) => completePowerSearchFilter(child, lookup));
|
|
78
|
-
if (complete.some((child) => child == null)) return null;
|
|
79
|
-
return {
|
|
80
|
-
field: partial.field,
|
|
81
|
-
operator: partial.operator,
|
|
82
|
-
value: {
|
|
83
|
-
type: "nested",
|
|
84
|
-
value: complete.filter((child) => child != null)
|
|
85
|
-
},
|
|
86
|
-
isReadOnly: partial.isReadOnly
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
if (partial.value == null || partial.value.type !== operator.value.type || !isFilled(partial.value)) return null;
|
|
90
|
-
return {
|
|
91
|
-
field: partial.field,
|
|
92
|
-
operator: partial.operator,
|
|
93
|
-
value: partial.value,
|
|
94
|
-
isReadOnly: partial.isReadOnly
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
//#endregion
|
|
98
|
-
//#region src/PowerSearch/config.ts
|
|
99
|
-
function createPowerSearchLookup(config) {
|
|
100
|
-
const fieldMap = /* @__PURE__ */ new Map();
|
|
101
|
-
const operatorMap = /* @__PURE__ */ new Map();
|
|
102
|
-
for (const field of config.fields) {
|
|
103
|
-
fieldMap.set(field.key, field);
|
|
104
|
-
const operators = /* @__PURE__ */ new Map();
|
|
105
|
-
for (const operator of field.operators) operators.set(operator.key, operator);
|
|
106
|
-
operatorMap.set(field.key, operators);
|
|
107
|
-
}
|
|
108
|
-
return {
|
|
109
|
-
config,
|
|
110
|
-
getField(key) {
|
|
111
|
-
return fieldMap.get(key);
|
|
112
|
-
},
|
|
113
|
-
getOperator(fieldKey, operatorKey) {
|
|
114
|
-
return operatorMap.get(fieldKey)?.get(operatorKey);
|
|
115
|
-
},
|
|
116
|
-
getDefaultOperator(fieldKey) {
|
|
117
|
-
const field = fieldMap.get(fieldKey);
|
|
118
|
-
if (field == null) return void 0;
|
|
119
|
-
if (field.defaultOperator) return operatorMap.get(fieldKey)?.get(field.defaultOperator) ?? field.operators[0];
|
|
120
|
-
return field.operators[0];
|
|
121
|
-
},
|
|
122
|
-
getVisibleFields() {
|
|
123
|
-
return config.fields;
|
|
124
|
-
},
|
|
125
|
-
getVisibleOperators(fieldKey) {
|
|
126
|
-
return fieldMap.get(fieldKey)?.operators ?? [];
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
//#endregion
|
|
131
|
-
//#region src/PowerSearch/range.ts
|
|
132
|
-
const SECONDS_BY_UNIT = {
|
|
133
|
-
second: 1,
|
|
134
|
-
minute: 60,
|
|
135
|
-
hour: 3600,
|
|
136
|
-
day: 86400,
|
|
137
|
-
week: 604800,
|
|
138
|
-
month: 2592e3,
|
|
139
|
-
year: 31536e3
|
|
140
|
-
};
|
|
141
|
-
/** 把绝对、当前和相对的区间端点折成同一时刻上的 Unix 秒。 */
|
|
142
|
-
function resolveDateTimeRangePart(part, nowSeconds = Date.now() / 1e3) {
|
|
143
|
-
switch (part.type) {
|
|
144
|
-
case "NOW": return Math.floor(nowSeconds);
|
|
145
|
-
case "ABSOLUTE": return part.unixSeconds;
|
|
146
|
-
case "RELATIVE": return Math.floor(nowSeconds - part.backValue * SECONDS_BY_UNIT[part.unit]);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
//#endregion
|
|
150
|
-
//#region src/PowerSearch/dates.ts
|
|
151
|
-
function pad$1(value) {
|
|
152
|
-
return String(value).padStart(2, "0");
|
|
153
|
-
}
|
|
154
|
-
function unixToIsoDate(unixSeconds, timeZone) {
|
|
155
|
-
const date = /* @__PURE__ */ new Date(unixSeconds * 1e3);
|
|
156
|
-
if (!timeZone) return `${date.getFullYear()}-${pad$1(date.getMonth() + 1)}-${pad$1(date.getDate())}`;
|
|
157
|
-
const parts = new Intl.DateTimeFormat("en-US", {
|
|
158
|
-
timeZone,
|
|
159
|
-
year: "numeric",
|
|
160
|
-
month: "2-digit",
|
|
161
|
-
day: "2-digit"
|
|
162
|
-
}).formatToParts(date);
|
|
163
|
-
return `${parts.find((part) => part.type === "year")?.value ?? "1970"}-${parts.find((part) => part.type === "month")?.value ?? "01"}-${parts.find((part) => part.type === "day")?.value ?? "01"}`;
|
|
164
|
-
}
|
|
165
|
-
function unixToDateTimeLocal(unixSeconds, timeZone) {
|
|
166
|
-
const date = /* @__PURE__ */ new Date(unixSeconds * 1e3);
|
|
167
|
-
if (!timeZone) return `${date.getFullYear()}-${pad$1(date.getMonth() + 1)}-${pad$1(date.getDate())}T${pad$1(date.getHours())}:${pad$1(date.getMinutes())}`;
|
|
168
|
-
const parts = new Intl.DateTimeFormat("en-US", {
|
|
169
|
-
timeZone,
|
|
170
|
-
year: "numeric",
|
|
171
|
-
month: "2-digit",
|
|
172
|
-
day: "2-digit",
|
|
173
|
-
hour: "2-digit",
|
|
174
|
-
minute: "2-digit",
|
|
175
|
-
hourCycle: "h23"
|
|
176
|
-
}).formatToParts(date);
|
|
177
|
-
const read = (type) => parts.find((part) => part.type === type)?.value ?? "00";
|
|
178
|
-
return `${read("year")}-${read("month")}-${read("day")}T${read("hour")}:${read("minute")}`;
|
|
179
|
-
}
|
|
180
|
-
function dateTimeLocalToUnix(value, timeZone) {
|
|
181
|
-
if (!timeZone) return Math.floor(new Date(value).getTime() / 1e3);
|
|
182
|
-
const [datePart, timePart] = value.split("T");
|
|
183
|
-
const [year, month, day] = (datePart ?? "").split("-").map(Number);
|
|
184
|
-
const [hour, minute] = (timePart ?? "00:00").split(":").map(Number);
|
|
185
|
-
const utcGuess = Date.UTC(year ?? 1970, (month ?? 1) - 1, day ?? 1, hour ?? 0, minute ?? 0);
|
|
186
|
-
const offset = timeZoneOffset(new Date(utcGuess), timeZone);
|
|
187
|
-
return Math.floor((utcGuess - offset) / 1e3);
|
|
188
|
-
}
|
|
189
|
-
function timeZoneOffset(date, timeZone) {
|
|
190
|
-
const parts = new Intl.DateTimeFormat("en-US", {
|
|
191
|
-
timeZone,
|
|
192
|
-
year: "numeric",
|
|
193
|
-
month: "2-digit",
|
|
194
|
-
day: "2-digit",
|
|
195
|
-
hour: "2-digit",
|
|
196
|
-
minute: "2-digit",
|
|
197
|
-
second: "2-digit",
|
|
198
|
-
hourCycle: "h23"
|
|
199
|
-
}).formatToParts(date);
|
|
200
|
-
const read = (type) => Number(parts.find((part) => part.type === type)?.value ?? 0);
|
|
201
|
-
return Date.UTC(read("year"), read("month") - 1, read("day"), read("hour"), read("minute"), read("second")) - date.getTime();
|
|
202
|
-
}
|
|
203
|
-
function rangePartToIso(part, timeZone, nowSeconds = Date.now() / 1e3) {
|
|
204
|
-
return unixToIsoDate(resolveDateTimeRangePart(part, nowSeconds), timeZone);
|
|
205
|
-
}
|
|
206
|
-
//#endregion
|
|
207
|
-
//#region src/PowerSearch/dateZone.ts
|
|
208
|
-
/**
|
|
209
|
-
* 日期值读写用的时区。
|
|
210
|
-
*
|
|
211
|
-
* 只有一个日历日(`isDateOnly` 没写或为 true)的值,按 `timeZone` 里的那一天读和写,
|
|
212
|
-
* 以那一天的零点存;没给 `timeZone` 就是 UTC 的那一天,早先没带时区写入的值日子不变。
|
|
213
|
-
* 带时刻的值(`isDateOnly: false`)在 `timeZone` 里读写,没给就用查看者所在的时区,
|
|
214
|
-
* 这时返回 `undefined`(`Intl` 和 `Date` 默认就是查看者的时区)。
|
|
215
|
-
*/
|
|
216
|
-
function resolveDateZone(timeZone, isDateOnly) {
|
|
217
|
-
if (timeZone) return timeZone;
|
|
218
|
-
return isDateOnly ? "UTC" : void 0;
|
|
219
|
-
}
|
|
220
|
-
/** 这个运算符的绝对日期值是不是一个日历日(没写 `isDateOnly` 也算)。 */
|
|
221
|
-
function isDateOnlyOperator(operatorValue) {
|
|
222
|
-
return operatorValue.type === "date_absolute" && operatorValue.isDateOnly !== false;
|
|
223
|
-
}
|
|
224
|
-
/** 一个时刻在 `zone` 里是哪一天,写成选择框用的本地零点 `Date`。 */
|
|
225
|
-
function unixToPickerDate(unixSeconds, zone) {
|
|
226
|
-
const [year, month, day] = unixToIsoDate(unixSeconds, zone).split("-").map(Number);
|
|
227
|
-
return new Date(year ?? 1970, (month ?? 1) - 1, day ?? 1);
|
|
228
|
-
}
|
|
229
|
-
function pad(value) {
|
|
230
|
-
return String(value).padStart(2, "0");
|
|
231
|
-
}
|
|
232
|
-
function localIsoDate(date) {
|
|
233
|
-
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`;
|
|
234
|
-
}
|
|
235
|
-
/** 选择框选中的那一天,在 `zone` 里零点的时刻。 */
|
|
236
|
-
function pickerDateToUnix(date, zone) {
|
|
237
|
-
return dateTimeLocalToUnix(`${localIsoDate(date)}T00:00`, zone);
|
|
238
|
-
}
|
|
239
|
-
/** `YYYY-MM-DD` 这一天在 `zone` 里零点的时刻。 */
|
|
240
|
-
function isoDateToZonedUnix(iso, zone) {
|
|
241
|
-
return dateTimeLocalToUnix(`${iso}T00:00`, zone);
|
|
242
|
-
}
|
|
243
|
-
/** `YYYY-MM-DD` 这一天在 `zone` 里的最后一秒(夏令时的 23 或 25 小时也对)。 */
|
|
244
|
-
function isoDateEndToZonedUnix(iso, zone) {
|
|
245
|
-
const [year, month, day] = iso.split("-").map(Number);
|
|
246
|
-
const next = new Date(Date.UTC(year ?? 1970, (month ?? 1) - 1, (day ?? 1) + 1));
|
|
247
|
-
return isoDateToZonedUnix(`${next.getUTCFullYear()}-${pad(next.getUTCMonth() + 1)}-${pad(next.getUTCDate())}`, zone) - 1;
|
|
248
|
-
}
|
|
249
|
-
/** 两个 `YYYY-MM-DD` 之间的绝对区间:开始那天 `zone` 里的零点,到结束那天的最后一秒。 */
|
|
250
|
-
function absoluteRange(start, end, zone) {
|
|
251
|
-
return {
|
|
252
|
-
start: {
|
|
253
|
-
type: "ABSOLUTE",
|
|
254
|
-
unixSeconds: isoDateToZonedUnix(start, zone)
|
|
255
|
-
},
|
|
256
|
-
end: {
|
|
257
|
-
type: "ABSOLUTE",
|
|
258
|
-
unixSeconds: isoDateEndToZonedUnix(end, zone)
|
|
259
|
-
}
|
|
260
|
-
};
|
|
261
|
-
}
|
|
262
|
-
//#endregion
|
|
263
|
-
//#region src/PowerSearch/format.ts
|
|
264
|
-
function truncate(value, maxLength) {
|
|
265
|
-
return truncateCharacters(value, maxLength);
|
|
266
|
-
}
|
|
267
|
-
function enumLabel(value, values) {
|
|
268
|
-
return values.find((item) => item.value === value)?.label ?? value;
|
|
269
|
-
}
|
|
270
|
-
function formatNumber(value, locale, units) {
|
|
271
|
-
const formatted = new Intl.NumberFormat(locale).format(value);
|
|
272
|
-
return units ? `${formatted} ${units}` : formatted;
|
|
273
|
-
}
|
|
274
|
-
/** 带时刻的日期,例如 "Oct 30, 2026, 3:00 PM"。日期按 `calendar` 写,默认公历。 */
|
|
275
|
-
function formatDateAbsolute(unixSeconds, locale, timeZone, calendar = "gregory") {
|
|
276
|
-
return formatCalendarInstant(calendar, /* @__PURE__ */ new Date(unixSeconds * 1e3), {
|
|
277
|
-
year: "numeric",
|
|
278
|
-
month: "short",
|
|
279
|
-
day: "numeric",
|
|
280
|
-
hour: "numeric",
|
|
281
|
-
minute: "2-digit"
|
|
282
|
-
}, locale, timeZone || void 0);
|
|
283
|
-
}
|
|
284
|
-
/** 只有日期,例如 "Oct 30, 2026"。日期按 `calendar` 写,默认公历。 */
|
|
285
|
-
function formatDateAbsoluteCompact(unixSeconds, locale, timeZone, calendar = "gregory") {
|
|
286
|
-
return formatCalendarInstant(calendar, /* @__PURE__ */ new Date(unixSeconds * 1e3), {
|
|
287
|
-
year: "numeric",
|
|
288
|
-
month: "short",
|
|
289
|
-
day: "numeric"
|
|
290
|
-
}, locale, timeZone || void 0);
|
|
291
|
-
}
|
|
292
|
-
function joinOrCount(labels, maxLength, countLabel) {
|
|
293
|
-
if (labels.length === 0) return "";
|
|
294
|
-
if (labels.length === 1) return truncate(labels[0] ?? "", maxLength);
|
|
295
|
-
const joined = labels.join(", ");
|
|
296
|
-
if (characterCount(joined) <= maxLength) return joined;
|
|
297
|
-
return countLabel(labels.length);
|
|
298
|
-
}
|
|
299
|
-
function formatFilterValue(operatorValue, filterValue, maxLength, messages, locale, timeZone, calendar = "gregory") {
|
|
300
|
-
switch (filterValue.type) {
|
|
301
|
-
case "empty": return "";
|
|
302
|
-
case "string": return truncate(filterValue.value, maxLength);
|
|
303
|
-
case "integer": return formatNumber(filterValue.value, locale, operatorValue.type === "integer" ? operatorValue.units : void 0);
|
|
304
|
-
case "float": return formatNumber(filterValue.value, locale, operatorValue.type === "float" ? operatorValue.units : void 0);
|
|
305
|
-
case "enum": return truncate(operatorValue.type === "enum" ? enumLabel(filterValue.value, operatorValue.values) : filterValue.value, maxLength);
|
|
306
|
-
case "string_list": return joinOrCount(filterValue.value, maxLength, messages.itemsCount);
|
|
307
|
-
case "enum_list": return joinOrCount(operatorValue.type === "enum_list" ? filterValue.value.map((value) => enumLabel(value, operatorValue.values)) : filterValue.value, maxLength, messages.itemsCount);
|
|
308
|
-
case "entity_list": return joinOrCount(filterValue.value.map((entity) => entity.label), maxLength, messages.entitiesCount);
|
|
309
|
-
case "time": return filterValue.value;
|
|
310
|
-
case "date_absolute": return truncate(isDateOnlyOperator(operatorValue) ? formatDateAbsoluteCompact(filterValue.unixSeconds, locale, resolveDateZone(timeZone, true), calendar) : formatDateAbsolute(filterValue.unixSeconds, locale, timeZone, calendar), maxLength);
|
|
311
|
-
case "date_relative": return filterValue.value;
|
|
312
|
-
case "date_range": return messages.dateRange;
|
|
313
|
-
case "custom": return truncate(operatorValue.type === "custom" ? operatorValue.getString(filterValue.value) : filterValue.value, maxLength);
|
|
314
|
-
case "nested": return messages.filtersCount(filterValue.value.length);
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
//#endregion
|
|
318
|
-
//#region src/PowerSearch/operators.ts
|
|
319
|
-
const OPERATOR_MESSAGE_KEYS = {
|
|
320
|
-
contains: "contains",
|
|
321
|
-
notContains: "notContains",
|
|
322
|
-
not_contains: "notContains",
|
|
323
|
-
startsWith: "startsWith",
|
|
324
|
-
starts_with: "startsWith",
|
|
325
|
-
notStartsWith: "notStartsWith",
|
|
326
|
-
not_starts_with: "notStartsWith",
|
|
327
|
-
endsWith: "endsWith",
|
|
328
|
-
ends_with: "endsWith",
|
|
329
|
-
notEndsWith: "notEndsWith",
|
|
330
|
-
not_ends_with: "notEndsWith",
|
|
331
|
-
is: "is",
|
|
332
|
-
isNot: "isNot",
|
|
333
|
-
is_not: "isNot",
|
|
334
|
-
equals: "equals",
|
|
335
|
-
notEquals: "notEquals",
|
|
336
|
-
not_equals: "notEquals",
|
|
337
|
-
greaterThan: "greaterThan",
|
|
338
|
-
greater_than: "greaterThan",
|
|
339
|
-
lessThan: "lessThan",
|
|
340
|
-
less_than: "lessThan",
|
|
341
|
-
greaterThanOrEqual: "greaterThanOrEqual",
|
|
342
|
-
greater_than_or_equal: "greaterThanOrEqual",
|
|
343
|
-
lessThanOrEqual: "lessThanOrEqual",
|
|
344
|
-
less_than_or_equal: "lessThanOrEqual",
|
|
345
|
-
before: "before",
|
|
346
|
-
after: "after",
|
|
347
|
-
between: "between",
|
|
348
|
-
isTrue: "isTrue",
|
|
349
|
-
is_true: "isTrue",
|
|
350
|
-
isFalse: "isFalse",
|
|
351
|
-
is_false: "isFalse",
|
|
352
|
-
isAnyOf: "isAnyOf",
|
|
353
|
-
is_any_of: "isAnyOf",
|
|
354
|
-
isNoneOf: "isNoneOf",
|
|
355
|
-
is_none_of: "isNoneOf"
|
|
356
|
-
};
|
|
357
|
-
function resolveOperatorLabel(operator, messages) {
|
|
358
|
-
if ("label" in operator && operator.label != null) return operator.label;
|
|
359
|
-
const raw = operator.i18nKey ?? "";
|
|
360
|
-
const leaf = raw.split(".").pop() ?? raw;
|
|
361
|
-
const key = OPERATOR_MESSAGE_KEYS[leaf] ?? OPERATOR_MESSAGE_KEYS[raw];
|
|
362
|
-
return key ? messages.operators[key] : leaf;
|
|
363
|
-
}
|
|
364
|
-
/**
|
|
365
|
-
* 编辑器宽度取外层宽度,再夹在 400 到 720 之间。
|
|
366
|
-
* 视口放不下 400 时,下限让给视口。只有被 720 压窄时,才改贴打开控件更近的外缘。
|
|
367
|
-
*/
|
|
368
|
-
function resolveEditorPlacement(input) {
|
|
369
|
-
const fallback = input.viewportInset ?? 16;
|
|
370
|
-
const inlineStart = input.inlineStart ?? fallback;
|
|
371
|
-
const inlineEnd = input.inlineEnd ?? fallback;
|
|
372
|
-
const blockInset = input.blockInset ?? fallback;
|
|
373
|
-
const available = Math.max(0, input.viewportWidth - inlineStart - inlineEnd);
|
|
374
|
-
const floor = Math.min(400, available);
|
|
375
|
-
const ceiling = Math.min(720, available);
|
|
376
|
-
let width = input.outer.width;
|
|
377
|
-
if (width < floor) width = floor;
|
|
378
|
-
if (width > ceiling) width = ceiling;
|
|
379
|
-
const capped = width + .5 < input.outer.width;
|
|
380
|
-
let edge;
|
|
381
|
-
if (!capped) edge = input.direction === "rtl" ? "right" : "left";
|
|
382
|
-
else {
|
|
383
|
-
const gapLeft = input.control.left - input.outer.left;
|
|
384
|
-
const gapRight = input.outer.right - input.control.right;
|
|
385
|
-
if (gapLeft < gapRight) edge = "left";
|
|
386
|
-
else if (gapRight < gapLeft) edge = "right";
|
|
387
|
-
else edge = input.direction === "rtl" ? "right" : "left";
|
|
388
|
-
}
|
|
389
|
-
let left = edge === "left" ? input.outer.left : input.outer.right - width;
|
|
390
|
-
const maxLeft = input.viewportWidth - inlineEnd - width;
|
|
391
|
-
if (left < inlineStart) left = inlineStart;
|
|
392
|
-
if (left > maxLeft) left = Math.max(inlineStart, maxLeft);
|
|
393
|
-
const gap = 4;
|
|
394
|
-
const estimatedHeight = 280;
|
|
395
|
-
let top = input.anchorBottom + gap;
|
|
396
|
-
if (top + estimatedHeight > input.viewportHeight - blockInset && input.anchorTop - gap - estimatedHeight > blockInset) top = input.anchorTop - gap - estimatedHeight;
|
|
397
|
-
return {
|
|
398
|
-
width,
|
|
399
|
-
capped,
|
|
400
|
-
edge,
|
|
401
|
-
top,
|
|
402
|
-
left
|
|
403
|
-
};
|
|
404
|
-
}
|
|
405
|
-
//#endregion
|
|
406
|
-
//#region src/PowerSearch/menuPresentation.ts
|
|
407
|
-
function powerSearchGroupLabel(entries, index) {
|
|
408
|
-
const group = entries[index]?.item.auxiliaryData?.group;
|
|
409
|
-
if (group == null || group === "") return void 0;
|
|
410
|
-
return group !== (index > 0 ? entries[index - 1]?.item.auxiliaryData?.group : void 0) ? group : void 0;
|
|
411
|
-
}
|
|
412
|
-
function powerSearchItemIcon(item, lookup) {
|
|
413
|
-
const data = item.auxiliaryData;
|
|
414
|
-
const type = (data?.operatorKey ? lookup.getOperator(data.fieldKey, data.operatorKey) : void 0)?.value.type;
|
|
415
|
-
if (type === "date_absolute" || type === "date_range" || type === "date_relative") return "calendar";
|
|
416
|
-
if (type === "time") return "clock";
|
|
417
|
-
if (type === "enum" || type === "enum_list") return "funnel";
|
|
418
|
-
return "search";
|
|
419
|
-
}
|
|
420
|
-
//#endregion
|
|
421
|
-
//#region src/PowerSearch/menuStyle.ts
|
|
422
|
-
/** 结果数的显示文字:数字走本地化的“N 个结果”,字符串原样,没给就空。 */
|
|
423
|
-
function resultCountText(count, format) {
|
|
424
|
-
if (count == null) return "";
|
|
425
|
-
return typeof count === "number" ? format(count) : count;
|
|
426
|
-
}
|
|
427
|
-
/** 菜单宽度固定时,宽度、最小宽度和最大宽度都锁在同一个值上,且不超过视口上限。 */
|
|
428
|
-
function menuStyleWithWidth(base, menuWidth) {
|
|
429
|
-
if (menuWidth == null) return base;
|
|
430
|
-
const width = `min(${menuWidth}px, var(--astryx-layer-max-inline-size, calc(100vw - 32px)))`;
|
|
431
|
-
return {
|
|
432
|
-
...base,
|
|
433
|
-
width,
|
|
434
|
-
minWidth: width,
|
|
435
|
-
maxWidth: width
|
|
436
|
-
};
|
|
437
|
-
}
|
|
438
|
-
//#endregion
|
|
439
|
-
//#region src/PowerSearch/formatTokenText.ts
|
|
440
|
-
/** 筛选标签的文字:字段和运算符由一条文案拼成,语言可以调换顺序和标点。没有运算符文字时只显示字段。 */
|
|
441
|
-
function formatTokenLabel(messages, fieldLabel, operatorLabel) {
|
|
442
|
-
return operatorLabel === "" ? fieldLabel : messages.token.fieldOperator(fieldLabel, operatorLabel);
|
|
443
|
-
}
|
|
444
|
-
/** 筛选标签的全文:「字段: 运算符」和值,由一条文案拼成。 */
|
|
445
|
-
function formatTokenText(messages, label, value) {
|
|
446
|
-
return messages.token.labelValue(label, value);
|
|
447
|
-
}
|
|
448
|
-
const LABEL_MARK = "";
|
|
449
|
-
const VALUE_MARK = "";
|
|
450
|
-
/**
|
|
451
|
-
* 语言是不是把全文写成「标签、空格、值」。只有这样,标签才能把标签和加粗的值分成两段显示,
|
|
452
|
-
* 读起来仍是给它命名的那句全文。
|
|
453
|
-
*/
|
|
454
|
-
function tokenTextKeepsParts(messages) {
|
|
455
|
-
return new RegExp(`^${LABEL_MARK}\\s+${VALUE_MARK}$`).test(formatTokenText(messages, LABEL_MARK, VALUE_MARK));
|
|
456
|
-
}
|
|
457
|
-
//#endregion
|
|
458
|
-
//#region src/PowerSearch/PowerSearchToken.vue
|
|
459
|
-
const _hoisted_1$4 = {
|
|
460
|
-
key: 0,
|
|
461
|
-
class: "astryx-power-search-token-value"
|
|
462
|
-
};
|
|
463
|
-
const _hoisted_2$4 = ["id"];
|
|
464
|
-
const _sfc_main$4 = /*@__PURE__*/ defineComponent({
|
|
465
|
-
name: "AstryxPowerSearchToken",
|
|
466
|
-
__name: "PowerSearchToken",
|
|
467
|
-
props: {
|
|
468
|
-
fieldLabel: {},
|
|
469
|
-
operator: {},
|
|
470
|
-
filter: {},
|
|
471
|
-
maxLength: {},
|
|
472
|
-
messages: {},
|
|
473
|
-
locale: {},
|
|
474
|
-
timeZone: {},
|
|
475
|
-
size: {},
|
|
476
|
-
disabled: { type: Boolean },
|
|
477
|
-
removable: { type: Boolean },
|
|
478
|
-
opensEditor: { type: Boolean },
|
|
479
|
-
expanded: { type: Boolean },
|
|
480
|
-
nameId: {}
|
|
481
|
-
},
|
|
482
|
-
emits: ["activate", "remove"],
|
|
483
|
-
setup(__props, { emit: __emit }) {
|
|
484
|
-
const props = __props;
|
|
485
|
-
const emit = __emit;
|
|
486
|
-
const calendar = useCalendarSystem(void 0, "PowerSearch");
|
|
487
|
-
const operatorLabel = computed(() => resolveOperatorLabel(props.operator, props.messages));
|
|
488
|
-
const tokenLabel = computed(() => formatTokenLabel(props.messages, props.fieldLabel, operatorLabel.value));
|
|
489
|
-
const valueText = computed(() => {
|
|
490
|
-
const room = Math.max(props.maxLength - characterCount(props.fieldLabel) - characterCount(operatorLabel.value), 10);
|
|
491
|
-
return formatFilterValue(props.operator.value, props.filter.value, room, props.messages, props.locale, props.timeZone, calendar.value);
|
|
492
|
-
});
|
|
493
|
-
/** 标签的全部可见文字:字段、运算符和值。按钮、删除按钮和编辑器都按它命名,同一字段的两个条件读出来不再一样。 */
|
|
494
|
-
const visibleText = computed(() => valueText.value ? formatTokenText(props.messages, tokenLabel.value, valueText.value) : tokenLabel.value);
|
|
495
|
-
/** 语言把全文写成「标签 值」以外的形状时,标签上不再把值单独加粗,整句作为一段文字显示。 */
|
|
496
|
-
const showsParts = computed(() => !valueText.value || tokenTextKeepsParts(props.messages));
|
|
497
|
-
provide(tokenNamingKey, computed(() => ({
|
|
498
|
-
actionName: visibleText.value,
|
|
499
|
-
removeName: visibleText.value
|
|
500
|
-
})));
|
|
501
|
-
return (_ctx, _cache) => {
|
|
502
|
-
return openBlock(), createBlock(_sfc_main$12, {
|
|
503
|
-
label: showsParts.value ? tokenLabel.value : visibleText.value,
|
|
504
|
-
size: __props.size,
|
|
505
|
-
disabled: __props.disabled,
|
|
506
|
-
removable: __props.removable,
|
|
507
|
-
"aria-haspopup": __props.opensEditor ? "dialog" : void 0,
|
|
508
|
-
"aria-expanded": __props.opensEditor ? Boolean(__props.expanded) : void 0,
|
|
509
|
-
onClick: _cache[0] || (_cache[0] = ($event) => emit("activate")),
|
|
510
|
-
onRemove: _cache[1] || (_cache[1] = ($event) => emit("remove"))
|
|
511
|
-
}, createSlots({ _: 2 }, [showsParts.value && valueText.value || __props.nameId ? {
|
|
512
|
-
name: "end",
|
|
513
|
-
fn: withCtx(() => [showsParts.value && valueText.value ? (openBlock(), createElementBlock("span", _hoisted_1$4, toDisplayString(valueText.value), 1)) : createCommentVNode("v-if", true), __props.nameId ? (openBlock(), createElementBlock("span", {
|
|
514
|
-
key: 1,
|
|
515
|
-
id: __props.nameId,
|
|
516
|
-
hidden: ""
|
|
517
|
-
}, toDisplayString(visibleText.value), 9, _hoisted_2$4)) : createCommentVNode("v-if", true)]),
|
|
518
|
-
key: "0"
|
|
519
|
-
} : void 0]), 1032, [
|
|
520
|
-
"label",
|
|
521
|
-
"size",
|
|
522
|
-
"disabled",
|
|
523
|
-
"removable",
|
|
524
|
-
"aria-haspopup",
|
|
525
|
-
"aria-expanded"
|
|
526
|
-
]);
|
|
527
|
-
};
|
|
528
|
-
}
|
|
529
|
-
});
|
|
530
|
-
//#endregion
|
|
531
|
-
//#region src/PowerSearch/source.ts
|
|
532
|
-
const MAX_BROWSE_ITEMS = 1e3;
|
|
533
|
-
function resolveValueMatches(operator, rawValue) {
|
|
534
|
-
const kind = operator.value.type;
|
|
535
|
-
if (kind === "string") return [{
|
|
536
|
-
displayValue: rawValue,
|
|
537
|
-
filterValue: {
|
|
538
|
-
type: "string",
|
|
539
|
-
value: rawValue
|
|
540
|
-
},
|
|
541
|
-
quoted: true
|
|
542
|
-
}];
|
|
543
|
-
if (kind === "string_list") return [{
|
|
544
|
-
displayValue: rawValue,
|
|
545
|
-
filterValue: {
|
|
546
|
-
type: "string_list",
|
|
547
|
-
value: [rawValue]
|
|
548
|
-
},
|
|
549
|
-
quoted: true
|
|
550
|
-
}];
|
|
551
|
-
if (kind === "enum" || kind === "enum_list") {
|
|
552
|
-
const lower = rawValue.toLowerCase();
|
|
553
|
-
return operator.value.values.filter((item) => item.label.toLowerCase().includes(lower)).map((item) => ({
|
|
554
|
-
displayValue: item.label,
|
|
555
|
-
filterValue: kind === "enum" ? {
|
|
556
|
-
type: "enum",
|
|
557
|
-
value: item.value
|
|
558
|
-
} : {
|
|
559
|
-
type: "enum_list",
|
|
560
|
-
value: [item.value]
|
|
561
|
-
},
|
|
562
|
-
quoted: false
|
|
563
|
-
}));
|
|
564
|
-
}
|
|
565
|
-
return [];
|
|
566
|
-
}
|
|
567
|
-
function browseItems(lookup) {
|
|
568
|
-
const grouped = /* @__PURE__ */ new Map();
|
|
569
|
-
const ungrouped = [];
|
|
570
|
-
for (const field of lookup.getVisibleFields()) {
|
|
571
|
-
const operator = lookup.getDefaultOperator(field.key);
|
|
572
|
-
const item = {
|
|
573
|
-
id: field.key,
|
|
574
|
-
label: field.label,
|
|
575
|
-
description: field.description,
|
|
576
|
-
auxiliaryData: {
|
|
577
|
-
fieldKey: field.key,
|
|
578
|
-
operatorKey: operator?.key,
|
|
579
|
-
group: field.group
|
|
580
|
-
}
|
|
581
|
-
};
|
|
582
|
-
if (field.group) {
|
|
583
|
-
const bucket = grouped.get(field.group) ?? [];
|
|
584
|
-
bucket.push(item);
|
|
585
|
-
grouped.set(field.group, bucket);
|
|
586
|
-
} else ungrouped.push(item);
|
|
587
|
-
}
|
|
588
|
-
const ordered = [...ungrouped];
|
|
589
|
-
for (const items of grouped.values()) ordered.push(...items);
|
|
590
|
-
return ordered.slice(0, MAX_BROWSE_ITEMS);
|
|
591
|
-
}
|
|
592
|
-
function searchPowerSearchFields(lookup, query, messages, maxTypedResults) {
|
|
593
|
-
const trimmed = query.trim();
|
|
594
|
-
if (trimmed === "") return browseItems(lookup);
|
|
595
|
-
const lower = trimmed.toLowerCase();
|
|
596
|
-
const results = [];
|
|
597
|
-
const seen = /* @__PURE__ */ new Set();
|
|
598
|
-
const labelOf = (operator) => resolveOperatorLabel(operator, messages);
|
|
599
|
-
for (const field of lookup.getVisibleFields()) {
|
|
600
|
-
if (field.typeaheadMinQueryLength != null && lower.length < field.typeaheadMinQueryLength) continue;
|
|
601
|
-
if ((field.label.toLowerCase().includes(lower) || field.typeaheadAliases?.some((alias) => alias.toLowerCase().includes(lower)) === true) && !seen.has(field.key)) {
|
|
602
|
-
seen.add(field.key);
|
|
603
|
-
const operator = lookup.getDefaultOperator(field.key);
|
|
604
|
-
results.push({
|
|
605
|
-
id: field.key,
|
|
606
|
-
label: field.label,
|
|
607
|
-
description: field.description,
|
|
608
|
-
auxiliaryData: {
|
|
609
|
-
fieldKey: field.key,
|
|
610
|
-
operatorKey: operator?.key,
|
|
611
|
-
group: field.group
|
|
612
|
-
}
|
|
613
|
-
});
|
|
614
|
-
}
|
|
615
|
-
for (const operator of field.operators) {
|
|
616
|
-
const combined = `${field.label} ${labelOf(operator)}`.toLowerCase();
|
|
617
|
-
const id = `${field.key}:${operator.key}`;
|
|
618
|
-
if (combined.includes(lower) && !seen.has(id)) {
|
|
619
|
-
seen.add(id);
|
|
620
|
-
results.push({
|
|
621
|
-
id,
|
|
622
|
-
label: `${field.label} ${labelOf(operator)}`,
|
|
623
|
-
description: field.description,
|
|
624
|
-
auxiliaryData: {
|
|
625
|
-
fieldKey: field.key,
|
|
626
|
-
operatorKey: operator.key,
|
|
627
|
-
group: field.group
|
|
628
|
-
}
|
|
629
|
-
});
|
|
630
|
-
}
|
|
631
|
-
}
|
|
632
|
-
}
|
|
633
|
-
for (const field of lookup.getVisibleFields()) {
|
|
634
|
-
if (field.isValueMatchAllowed === false) continue;
|
|
635
|
-
const fieldLabel = field.label.toLowerCase();
|
|
636
|
-
let exactOperator = false;
|
|
637
|
-
for (const operator of field.operators) {
|
|
638
|
-
const prefix = `${fieldLabel} ${labelOf(operator).toLowerCase()} `;
|
|
639
|
-
if (!lower.startsWith(prefix) || lower.length <= prefix.length) continue;
|
|
640
|
-
const matches = resolveValueMatches(operator, trimmed.slice(prefix.length));
|
|
641
|
-
if (matches.length > 0) exactOperator = true;
|
|
642
|
-
for (const match of matches) {
|
|
643
|
-
const id = `${field.key}:${operator.key}:value:${match.displayValue}`;
|
|
644
|
-
if (seen.has(id)) continue;
|
|
645
|
-
seen.add(id);
|
|
646
|
-
const shown = match.quoted ? `"${match.displayValue}"` : match.displayValue;
|
|
647
|
-
results.push({
|
|
648
|
-
id,
|
|
649
|
-
label: `${field.label} ${labelOf(operator)} ${shown}`,
|
|
650
|
-
auxiliaryData: {
|
|
651
|
-
fieldKey: field.key,
|
|
652
|
-
operatorKey: operator.key,
|
|
653
|
-
filterValue: match.filterValue
|
|
654
|
-
}
|
|
655
|
-
});
|
|
656
|
-
}
|
|
657
|
-
}
|
|
658
|
-
const fieldPrefix = `${fieldLabel} `;
|
|
659
|
-
if (!exactOperator && lower.startsWith(fieldPrefix) && lower.length > fieldPrefix.length) {
|
|
660
|
-
const remainder = lower.slice(fieldPrefix.length);
|
|
661
|
-
if (!field.operators.some((operator) => labelOf(operator).toLowerCase().startsWith(remainder))) {
|
|
662
|
-
const rawValue = trimmed.slice(fieldPrefix.length);
|
|
663
|
-
for (const operator of field.operators) for (const match of resolveValueMatches(operator, rawValue)) {
|
|
664
|
-
const id = `${field.key}:${operator.key}:value:${match.displayValue}`;
|
|
665
|
-
if (seen.has(id)) continue;
|
|
666
|
-
seen.add(id);
|
|
667
|
-
const shown = match.quoted ? `"${match.displayValue}"` : match.displayValue;
|
|
668
|
-
results.push({
|
|
669
|
-
id,
|
|
670
|
-
label: `${field.label} ${labelOf(operator)} ${shown}`,
|
|
671
|
-
auxiliaryData: {
|
|
672
|
-
fieldKey: field.key,
|
|
673
|
-
operatorKey: operator.key,
|
|
674
|
-
filterValue: match.filterValue
|
|
675
|
-
}
|
|
676
|
-
});
|
|
677
|
-
}
|
|
678
|
-
}
|
|
679
|
-
}
|
|
680
|
-
}
|
|
681
|
-
const contentKey = lookup.config.contentSearchFieldKey;
|
|
682
|
-
const exact = lookup.getVisibleFields().some((field) => field.label.toLowerCase() === lower || field.operators.some((operator) => `${field.label} ${labelOf(operator)}`.toLowerCase() === lower));
|
|
683
|
-
if (contentKey && !exact) {
|
|
684
|
-
const field = lookup.getField(contentKey);
|
|
685
|
-
const operator = lookup.getDefaultOperator(contentKey);
|
|
686
|
-
if (field && operator) results.unshift({
|
|
687
|
-
id: `__content_search__:${trimmed}`,
|
|
688
|
-
label: `"${trimmed}"`,
|
|
689
|
-
auxiliaryData: {
|
|
690
|
-
fieldKey: contentKey,
|
|
691
|
-
operatorKey: operator.key,
|
|
692
|
-
filterValue: {
|
|
693
|
-
type: "string",
|
|
694
|
-
value: trimmed
|
|
695
|
-
}
|
|
696
|
-
}
|
|
697
|
-
});
|
|
698
|
-
}
|
|
699
|
-
return results.slice(0, maxTypedResults);
|
|
700
|
-
}
|
|
701
|
-
//#endregion
|
|
702
|
-
//#region src/PowerSearch/useFilterTokenNaming.ts
|
|
703
|
-
/**
|
|
704
|
-
* 内置筛选标签的弹层状态和编辑器名称。
|
|
705
|
-
*
|
|
706
|
-
* 标签按钮带 `aria-haspopup="dialog"` 和 `aria-expanded`,编辑器是一个以标签全部可见文字
|
|
707
|
-
* 命名的非模态对话框。换掉了标签的调用方自己命名,编辑器保持普通浮层。
|
|
708
|
-
*/
|
|
709
|
-
function useFilterTokenNaming(options) {
|
|
710
|
-
function nameId(index) {
|
|
711
|
-
return `${options.idPrefix()}-token-${index}-name`;
|
|
712
|
-
}
|
|
713
|
-
function tokenProps(filter, index) {
|
|
714
|
-
const session = options.session.value;
|
|
715
|
-
return {
|
|
716
|
-
nameId: nameId(index),
|
|
717
|
-
opensEditor: options.opensEditor(filter),
|
|
718
|
-
expanded: session?.mode === "edit" && session.index === index
|
|
719
|
-
};
|
|
720
|
-
}
|
|
721
|
-
return {
|
|
722
|
-
tokenProps,
|
|
723
|
-
editorAttrs: computed(() => {
|
|
724
|
-
const session = options.session.value;
|
|
725
|
-
const filter = session?.mode === "edit" ? options.filters.value[session.index] : void 0;
|
|
726
|
-
if (session == null || filter == null || !options.isBuiltIn(filter)) return {};
|
|
727
|
-
return {
|
|
728
|
-
"role": "dialog",
|
|
729
|
-
"aria-labelledby": nameId(session.index)
|
|
730
|
-
};
|
|
731
|
-
})
|
|
732
|
-
};
|
|
733
|
-
}
|
|
734
|
-
//#endregion
|
|
735
|
-
//#region src/PowerSearch/relativeDates.ts
|
|
736
|
-
const RELATIVE_DATE_UNITS = [
|
|
737
|
-
{
|
|
738
|
-
unit: "day",
|
|
739
|
-
amounts: [
|
|
740
|
-
1,
|
|
741
|
-
3,
|
|
742
|
-
7,
|
|
743
|
-
14,
|
|
744
|
-
30
|
|
745
|
-
],
|
|
746
|
-
ago: "relativeDaysAgo",
|
|
747
|
-
fromNow: "relativeDaysFromNow"
|
|
748
|
-
},
|
|
749
|
-
{
|
|
750
|
-
unit: "week",
|
|
751
|
-
amounts: [
|
|
752
|
-
1,
|
|
753
|
-
2,
|
|
754
|
-
4
|
|
755
|
-
],
|
|
756
|
-
ago: "relativeWeeksAgo",
|
|
757
|
-
fromNow: "relativeWeeksFromNow"
|
|
758
|
-
},
|
|
759
|
-
{
|
|
760
|
-
unit: "month",
|
|
761
|
-
amounts: [
|
|
762
|
-
1,
|
|
763
|
-
3,
|
|
764
|
-
6,
|
|
765
|
-
12
|
|
766
|
-
],
|
|
767
|
-
ago: "relativeMonthsAgo",
|
|
768
|
-
fromNow: "relativeMonthsFromNow"
|
|
769
|
-
}
|
|
770
|
-
];
|
|
771
|
-
/**
|
|
772
|
-
* 相对日期运算符提供的选项,按显示顺序排列。桌面浮层的 Selector 和底部弹层的单选行共用这一份,
|
|
773
|
-
* 两边列出的值一样。值写成 `3d_ago`、`2w_from_now` 这种形式;`isPastAllowed` / `isFutureAllowed`
|
|
774
|
-
* 写 false 时去掉对应方向的选项。
|
|
775
|
-
*/
|
|
776
|
-
function buildRelativeDateOptions(operatorValue, messages) {
|
|
777
|
-
const options = [];
|
|
778
|
-
for (const { unit, amounts, ago, fromNow } of RELATIVE_DATE_UNITS) for (const amount of amounts) {
|
|
779
|
-
if (operatorValue.isPastAllowed !== false) options.push({
|
|
780
|
-
value: `${amount}${unit[0]}_ago`,
|
|
781
|
-
label: messages[ago](amount)
|
|
782
|
-
});
|
|
783
|
-
if (operatorValue.isFutureAllowed !== false) options.push({
|
|
784
|
-
value: `${amount}${unit[0]}_from_now`,
|
|
785
|
-
label: messages[fromNow](amount)
|
|
786
|
-
});
|
|
787
|
-
}
|
|
788
|
-
return options;
|
|
789
|
-
}
|
|
790
|
-
//#endregion
|
|
791
|
-
//#region src/PowerSearch/PowerSearchValueField.vue
|
|
792
|
-
const _hoisted_1$3 = {
|
|
793
|
-
key: 8,
|
|
794
|
-
class: "astryx-power-search-value__stack"
|
|
795
|
-
};
|
|
796
|
-
const _hoisted_2$3 = ["aria-label"];
|
|
797
|
-
const _hoisted_3$3 = ["disabled", "onClick"];
|
|
798
|
-
const _sfc_main$3 = /*@__PURE__*/ defineComponent({
|
|
799
|
-
name: "AstryxPowerSearchValueField",
|
|
800
|
-
__name: "PowerSearchValueField",
|
|
801
|
-
props: {
|
|
802
|
-
operatorValue: {},
|
|
803
|
-
filterValue: {},
|
|
804
|
-
messages: {},
|
|
805
|
-
disabled: { type: Boolean },
|
|
806
|
-
timeZone: {},
|
|
807
|
-
maxMenuItems: {}
|
|
808
|
-
},
|
|
809
|
-
emits: ["change"],
|
|
810
|
-
setup(__props, { emit: __emit }) {
|
|
811
|
-
const props = __props;
|
|
812
|
-
const emit = __emit;
|
|
813
|
-
const text = computed(() => props.messages.value);
|
|
814
|
-
const locale = useAstryxLocale();
|
|
815
|
-
const sheetMessages = useComponentMessages({ powerSearchSheet: powerSearchSheetMessages });
|
|
816
|
-
const numberDecision = ref(null);
|
|
817
|
-
function rememberNumberDraft(event) {
|
|
818
|
-
const target = event.target;
|
|
819
|
-
const operator = props.operatorValue;
|
|
820
|
-
if (!(target instanceof HTMLInputElement) || target.getAttribute("role") !== "spinbutton") return;
|
|
821
|
-
if (operator.type !== "integer" && operator.type !== "float") return;
|
|
822
|
-
numberDecision.value = resolveNumberInputCommit(target.value, {
|
|
823
|
-
min: operator.minValue,
|
|
824
|
-
max: operator.maxValue,
|
|
825
|
-
isIntegerOnly: operator.type === "integer",
|
|
826
|
-
locale: locale.value,
|
|
827
|
-
hasClear: false
|
|
828
|
-
});
|
|
829
|
-
}
|
|
830
|
-
function onNumberKeydown(event) {
|
|
831
|
-
if (event.key !== "Enter" || event.isComposing) return;
|
|
832
|
-
const decision = numberDecision.value;
|
|
833
|
-
numberDecision.value = null;
|
|
834
|
-
if (decision != null && decision.type !== "commit") event.stopPropagation();
|
|
835
|
-
}
|
|
836
|
-
const stringValue = computed(() => props.filterValue?.type === "string" ? props.filterValue.value : "");
|
|
837
|
-
const numberValue = computed(() => props.filterValue?.type === "integer" || props.filterValue?.type === "float" ? props.filterValue.value : null);
|
|
838
|
-
const timeValue = computed(() => props.filterValue?.type === "time" ? props.filterValue.value : null);
|
|
839
|
-
const enumValue = computed(() => props.filterValue?.type === "enum" ? props.filterValue.value : null);
|
|
840
|
-
const enumList = computed(() => props.filterValue?.type === "enum_list" ? [...props.filterValue.value] : []);
|
|
841
|
-
const relativeValue = computed(() => props.filterValue?.type === "date_relative" ? props.filterValue.value : "");
|
|
842
|
-
const customValue = computed(() => props.filterValue?.type === "custom" ? props.filterValue.value : "");
|
|
843
|
-
const stringItems = computed(() => {
|
|
844
|
-
if (props.filterValue?.type !== "string_list") return [];
|
|
845
|
-
return props.filterValue.value.map((value) => ({
|
|
846
|
-
id: value,
|
|
847
|
-
label: value
|
|
848
|
-
}));
|
|
849
|
-
});
|
|
850
|
-
const entityItems = computed(() => {
|
|
851
|
-
if (props.filterValue?.type !== "entity_list") return [];
|
|
852
|
-
return props.filterValue.value.map((entity) => ({
|
|
853
|
-
id: entity.id,
|
|
854
|
-
label: entity.label,
|
|
855
|
-
auxiliaryData: entity
|
|
856
|
-
}));
|
|
857
|
-
});
|
|
858
|
-
const selectedStringItem = computed(() => stringValue.value ? {
|
|
859
|
-
id: stringValue.value,
|
|
860
|
-
label: stringValue.value
|
|
861
|
-
} : null);
|
|
862
|
-
const enumOptions = computed(() => {
|
|
863
|
-
const value = props.operatorValue;
|
|
864
|
-
if (value.type !== "enum" && value.type !== "enum_list") return [];
|
|
865
|
-
return value.values.map((item) => ({
|
|
866
|
-
value: item.value,
|
|
867
|
-
label: item.label,
|
|
868
|
-
icon: item.icon
|
|
869
|
-
}));
|
|
870
|
-
});
|
|
871
|
-
const relativeOptions = computed(() => props.operatorValue.type === "date_relative" ? buildRelativeDateOptions(props.operatorValue, sheetMessages.value.powerSearchSheet) : []);
|
|
872
|
-
const dateOnly = computed(() => isDateOnlyOperator(props.operatorValue));
|
|
873
|
-
/** 日历日按 `timeZone` 里的那一天读写;没给时区就是 UTC 的那一天。 */
|
|
874
|
-
const dayZone = computed(() => resolveDateZone(props.timeZone, true));
|
|
875
|
-
const absoluteDate = computed(() => {
|
|
876
|
-
if (props.filterValue?.type !== "date_absolute") return null;
|
|
877
|
-
return unixToPickerDate(props.filterValue.unixSeconds, dayZone.value);
|
|
878
|
-
});
|
|
879
|
-
const absoluteLocal = computed(() => props.filterValue?.type === "date_absolute" ? unixToDateTimeLocal(props.filterValue.unixSeconds, props.timeZone) : null);
|
|
880
|
-
const rangeModel = computed(() => {
|
|
881
|
-
if (props.filterValue?.type !== "date_range") return null;
|
|
882
|
-
return {
|
|
883
|
-
start: rangePartToIso(props.filterValue.value.start, dayZone.value),
|
|
884
|
-
end: rangePartToIso(props.filterValue.value.end, dayZone.value)
|
|
885
|
-
};
|
|
886
|
-
});
|
|
887
|
-
const stringSource = computed(() => props.operatorValue.type === "string" || props.operatorValue.type === "string_list" ? props.operatorValue.searchSource ?? createStaticSource([]) : createStaticSource([]));
|
|
888
|
-
const entitySource = computed(() => props.operatorValue.type === "entity_list" ? props.operatorValue.searchSource ?? createStaticSource([]) : createStaticSource([]));
|
|
889
|
-
const stringCreatable = computed(() => {
|
|
890
|
-
const value = props.operatorValue;
|
|
891
|
-
if (value.type !== "string_list" && value.type !== "entity_list") return false;
|
|
892
|
-
return value.isArbitraryStringAllowed === true || value.searchSource == null;
|
|
893
|
-
});
|
|
894
|
-
function commitStringList(items) {
|
|
895
|
-
emit("change", {
|
|
896
|
-
type: "string_list",
|
|
897
|
-
value: items.map((item) => item.label)
|
|
898
|
-
});
|
|
899
|
-
}
|
|
900
|
-
function commitEntities(items) {
|
|
901
|
-
const entities = items.map((item) => ({
|
|
902
|
-
id: item.id,
|
|
903
|
-
label: item.label,
|
|
904
|
-
photo: typeof item.auxiliaryData === "object" && item.auxiliaryData && "photo" in item.auxiliaryData ? String(item.auxiliaryData.photo ?? "") : void 0
|
|
905
|
-
}));
|
|
906
|
-
emit("change", {
|
|
907
|
-
type: "entity_list",
|
|
908
|
-
value: entities
|
|
909
|
-
});
|
|
910
|
-
}
|
|
911
|
-
function onPaste(event) {
|
|
912
|
-
const value = props.operatorValue;
|
|
913
|
-
if (value.type !== "string_list" && value.type !== "entity_list") return;
|
|
914
|
-
const pattern = value.tokenization?.regex;
|
|
915
|
-
if (!pattern) return;
|
|
916
|
-
const pasted = event.clipboardData?.getData("text") ?? "";
|
|
917
|
-
if (!pasted) return;
|
|
918
|
-
let pieces = [];
|
|
919
|
-
try {
|
|
920
|
-
pieces = pasted.match(new RegExp(pattern, "g")) ?? [];
|
|
921
|
-
} catch {
|
|
922
|
-
return;
|
|
923
|
-
}
|
|
924
|
-
if (pieces.length === 0) return;
|
|
925
|
-
event.preventDefault();
|
|
926
|
-
if (value.tokenization?.sort) pieces.sort((left, right) => left.localeCompare(right));
|
|
927
|
-
if (value.type === "string_list") {
|
|
928
|
-
const current = stringItems.value.map((item) => item.label);
|
|
929
|
-
emit("change", {
|
|
930
|
-
type: "string_list",
|
|
931
|
-
value: [...current, ...pieces]
|
|
932
|
-
});
|
|
933
|
-
return;
|
|
934
|
-
}
|
|
935
|
-
const current = entityItems.value.map((item) => ({
|
|
936
|
-
id: item.id,
|
|
937
|
-
label: item.label
|
|
938
|
-
}));
|
|
939
|
-
emit("change", {
|
|
940
|
-
type: "entity_list",
|
|
941
|
-
value: [...current, ...pieces.map((piece) => ({
|
|
942
|
-
id: piece,
|
|
943
|
-
label: piece
|
|
944
|
-
}))]
|
|
945
|
-
});
|
|
946
|
-
}
|
|
947
|
-
function onRange(value) {
|
|
948
|
-
if (value == null || typeof value !== "object" || !("start" in value) || !("end" in value)) return;
|
|
949
|
-
const start = value.start;
|
|
950
|
-
const end = value.end;
|
|
951
|
-
if (typeof start !== "string" || typeof end !== "string") return;
|
|
952
|
-
emit("change", {
|
|
953
|
-
type: "date_range",
|
|
954
|
-
value: absoluteRange(start, end, dayZone.value)
|
|
955
|
-
});
|
|
956
|
-
}
|
|
957
|
-
function onTime(value) {
|
|
958
|
-
if (typeof value === "string" && value !== "") emit("change", {
|
|
959
|
-
type: "time",
|
|
960
|
-
value
|
|
961
|
-
});
|
|
962
|
-
}
|
|
963
|
-
function onAbsoluteDate(value) {
|
|
964
|
-
if (!(value instanceof Date)) return;
|
|
965
|
-
emit("change", {
|
|
966
|
-
type: "date_absolute",
|
|
967
|
-
unixSeconds: pickerDateToUnix(value, dayZone.value)
|
|
968
|
-
});
|
|
969
|
-
}
|
|
970
|
-
function onAbsoluteDateTime(value) {
|
|
971
|
-
if (typeof value !== "string" || value === "") return;
|
|
972
|
-
emit("change", {
|
|
973
|
-
type: "date_absolute",
|
|
974
|
-
unixSeconds: dateTimeLocalToUnix(value, props.timeZone)
|
|
975
|
-
});
|
|
976
|
-
}
|
|
977
|
-
function onCustomValue(value) {
|
|
978
|
-
emit("change", {
|
|
979
|
-
type: "custom",
|
|
980
|
-
value: value == null ? "" : String(value)
|
|
981
|
-
});
|
|
982
|
-
}
|
|
983
|
-
function applyPreset(range) {
|
|
984
|
-
emit("change", {
|
|
985
|
-
type: "date_range",
|
|
986
|
-
value: range
|
|
987
|
-
}, true);
|
|
988
|
-
}
|
|
989
|
-
return (_ctx, _cache) => {
|
|
990
|
-
return openBlock(), createElementBlock("div", {
|
|
991
|
-
class: "astryx-power-search-value",
|
|
992
|
-
onPaste
|
|
993
|
-
}, [__props.operatorValue.type === "string" && __props.operatorValue.searchSource ? (openBlock(), createBlock(_sfc_main$19, {
|
|
994
|
-
key: 0,
|
|
995
|
-
label: text.value.value,
|
|
996
|
-
"label-hidden": "",
|
|
997
|
-
"search-source": stringSource.value,
|
|
998
|
-
"model-value": selectedStringItem.value,
|
|
999
|
-
placeholder: text.value.searchPlaceholder,
|
|
1000
|
-
disabled: __props.disabled,
|
|
1001
|
-
"max-menu-items": __props.maxMenuItems,
|
|
1002
|
-
"onUpdate:modelValue": _cache[0] || (_cache[0] = (item) => emit("change", {
|
|
1003
|
-
type: "string",
|
|
1004
|
-
value: item?.label ?? ""
|
|
1005
|
-
}, Boolean(item)))
|
|
1006
|
-
}, null, 8, [
|
|
1007
|
-
"label",
|
|
1008
|
-
"search-source",
|
|
1009
|
-
"model-value",
|
|
1010
|
-
"placeholder",
|
|
1011
|
-
"disabled",
|
|
1012
|
-
"max-menu-items"
|
|
1013
|
-
])) : __props.operatorValue.type === "string" ? (openBlock(), createBlock(_sfc_main$17, {
|
|
1014
|
-
key: 1,
|
|
1015
|
-
label: text.value.value,
|
|
1016
|
-
"is-label-hidden": "",
|
|
1017
|
-
"model-value": stringValue.value,
|
|
1018
|
-
placeholder: text.value.enterValuePlaceholder,
|
|
1019
|
-
disabled: __props.disabled,
|
|
1020
|
-
"onUpdate:modelValue": _cache[1] || (_cache[1] = (value) => emit("change", {
|
|
1021
|
-
type: "string",
|
|
1022
|
-
value: String(value ?? "")
|
|
1023
|
-
}))
|
|
1024
|
-
}, null, 8, [
|
|
1025
|
-
"label",
|
|
1026
|
-
"model-value",
|
|
1027
|
-
"placeholder",
|
|
1028
|
-
"disabled"
|
|
1029
|
-
])) : __props.operatorValue.type === "string_list" ? (openBlock(), createBlock(_sfc_main$16, {
|
|
1030
|
-
key: 2,
|
|
1031
|
-
presentation: "popover",
|
|
1032
|
-
label: text.value.values,
|
|
1033
|
-
"label-hidden": "",
|
|
1034
|
-
"search-source": stringSource.value,
|
|
1035
|
-
"model-value": stringItems.value,
|
|
1036
|
-
placeholder: text.value.addValuesPlaceholder,
|
|
1037
|
-
disabled: __props.disabled,
|
|
1038
|
-
creatable: stringCreatable.value,
|
|
1039
|
-
"max-menu-items": __props.maxMenuItems,
|
|
1040
|
-
"onUpdate:modelValue": commitStringList
|
|
1041
|
-
}, null, 8, [
|
|
1042
|
-
"label",
|
|
1043
|
-
"search-source",
|
|
1044
|
-
"model-value",
|
|
1045
|
-
"placeholder",
|
|
1046
|
-
"disabled",
|
|
1047
|
-
"creatable",
|
|
1048
|
-
"max-menu-items"
|
|
1049
|
-
])) : __props.operatorValue.type === "integer" || __props.operatorValue.type === "float" ? (openBlock(), createElementBlock(Fragment, { key: 3 }, [createCommentVNode(" eslint-disable-next-line vue-a11y/no-static-element-interactions -- 只听里面数字框冒上来的输入和回车,自己不是控件。 "), createElementVNode("div", {
|
|
1050
|
-
class: "astryx-power-search-value",
|
|
1051
|
-
onFocusin: _cache[3] || (_cache[3] = ($event) => numberDecision.value = null),
|
|
1052
|
-
onInput: rememberNumberDraft,
|
|
1053
|
-
onKeydown: onNumberKeydown
|
|
1054
|
-
}, [createVNode(_sfc_main$14, {
|
|
1055
|
-
label: text.value.value,
|
|
1056
|
-
"is-label-hidden": "",
|
|
1057
|
-
"model-value": numberValue.value,
|
|
1058
|
-
placeholder: text.value.enterNumberPlaceholder,
|
|
1059
|
-
disabled: __props.disabled,
|
|
1060
|
-
min: __props.operatorValue.minValue,
|
|
1061
|
-
max: __props.operatorValue.maxValue,
|
|
1062
|
-
step: __props.operatorValue.type === "integer" ? 1 : void 0,
|
|
1063
|
-
units: __props.operatorValue.units,
|
|
1064
|
-
"onUpdate:modelValue": _cache[2] || (_cache[2] = (value) => value != null && emit("change", {
|
|
1065
|
-
type: __props.operatorValue.type === "integer" ? "integer" : "float",
|
|
1066
|
-
value
|
|
1067
|
-
}))
|
|
1068
|
-
}, null, 8, [
|
|
1069
|
-
"label",
|
|
1070
|
-
"model-value",
|
|
1071
|
-
"placeholder",
|
|
1072
|
-
"disabled",
|
|
1073
|
-
"min",
|
|
1074
|
-
"max",
|
|
1075
|
-
"step",
|
|
1076
|
-
"units"
|
|
1077
|
-
])], 32)], 2112)) : __props.operatorValue.type === "time" ? (openBlock(), createBlock(_sfc_main$18, {
|
|
1078
|
-
key: 4,
|
|
1079
|
-
label: text.value.time,
|
|
1080
|
-
"is-label-hidden": "",
|
|
1081
|
-
"model-value": timeValue.value,
|
|
1082
|
-
min: __props.operatorValue.minValue,
|
|
1083
|
-
max: __props.operatorValue.maxValue,
|
|
1084
|
-
"is-disabled": __props.disabled,
|
|
1085
|
-
"entry-error-behavior": "complete",
|
|
1086
|
-
"onUpdate:modelValue": onTime
|
|
1087
|
-
}, null, 8, [
|
|
1088
|
-
"label",
|
|
1089
|
-
"model-value",
|
|
1090
|
-
"min",
|
|
1091
|
-
"max",
|
|
1092
|
-
"is-disabled"
|
|
1093
|
-
])) : __props.operatorValue.type === "date_absolute" && dateOnly.value ? (openBlock(), createBlock(_sfc_main$9, {
|
|
1094
|
-
key: 5,
|
|
1095
|
-
label: text.value.date,
|
|
1096
|
-
"is-label-hidden": "",
|
|
1097
|
-
"model-value": absoluteDate.value,
|
|
1098
|
-
"is-disabled": __props.disabled,
|
|
1099
|
-
"entry-error-behavior": "complete",
|
|
1100
|
-
"onUpdate:modelValue": onAbsoluteDate
|
|
1101
|
-
}, null, 8, [
|
|
1102
|
-
"label",
|
|
1103
|
-
"model-value",
|
|
1104
|
-
"is-disabled"
|
|
1105
|
-
])) : __props.operatorValue.type === "date_absolute" ? (openBlock(), createBlock(_sfc_main$11, {
|
|
1106
|
-
key: 6,
|
|
1107
|
-
label: text.value.date,
|
|
1108
|
-
"is-label-hidden": "",
|
|
1109
|
-
"model-value": absoluteLocal.value,
|
|
1110
|
-
"is-disabled": __props.disabled,
|
|
1111
|
-
"entry-error-behavior": "complete",
|
|
1112
|
-
"onUpdate:modelValue": onAbsoluteDateTime
|
|
1113
|
-
}, null, 8, [
|
|
1114
|
-
"label",
|
|
1115
|
-
"model-value",
|
|
1116
|
-
"is-disabled"
|
|
1117
|
-
])) : __props.operatorValue.type === "date_relative" ? (openBlock(), createBlock(_sfc_main$15, {
|
|
1118
|
-
key: 7,
|
|
1119
|
-
label: text.value.relativeDate,
|
|
1120
|
-
"is-label-hidden": "",
|
|
1121
|
-
options: relativeOptions.value,
|
|
1122
|
-
"model-value": relativeValue.value || null,
|
|
1123
|
-
placeholder: text.value.selectPlaceholder,
|
|
1124
|
-
disabled: __props.disabled,
|
|
1125
|
-
"onUpdate:modelValue": _cache[4] || (_cache[4] = (value) => emit("change", {
|
|
1126
|
-
type: "date_relative",
|
|
1127
|
-
value: String(value ?? "")
|
|
1128
|
-
}, true))
|
|
1129
|
-
}, null, 8, [
|
|
1130
|
-
"label",
|
|
1131
|
-
"options",
|
|
1132
|
-
"model-value",
|
|
1133
|
-
"placeholder",
|
|
1134
|
-
"disabled"
|
|
1135
|
-
])) : __props.operatorValue.type === "date_range" ? (openBlock(), createElementBlock("div", _hoisted_1$3, [__props.operatorValue.intervalDatePresets?.length ? (openBlock(), createElementBlock("div", {
|
|
1136
|
-
key: 0,
|
|
1137
|
-
class: "astryx-power-search-presets",
|
|
1138
|
-
role: "group",
|
|
1139
|
-
"aria-label": text.value.date
|
|
1140
|
-
}, [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.operatorValue.intervalDatePresets, (preset) => {
|
|
1141
|
-
return openBlock(), createElementBlock("button", {
|
|
1142
|
-
key: preset.label,
|
|
1143
|
-
type: "button",
|
|
1144
|
-
class: "astryx-power-search-preset",
|
|
1145
|
-
disabled: __props.disabled,
|
|
1146
|
-
onClick: ($event) => applyPreset(preset.value)
|
|
1147
|
-
}, toDisplayString(preset.label), 9, _hoisted_3$3);
|
|
1148
|
-
}), 128))], 8, _hoisted_2$3)) : createCommentVNode("v-if", true), createVNode(_sfc_main$10, {
|
|
1149
|
-
label: text.value.date,
|
|
1150
|
-
"is-label-hidden": "",
|
|
1151
|
-
"model-value": rangeModel.value,
|
|
1152
|
-
"is-disabled": __props.disabled,
|
|
1153
|
-
"onUpdate:modelValue": onRange
|
|
1154
|
-
}, null, 8, [
|
|
1155
|
-
"label",
|
|
1156
|
-
"model-value",
|
|
1157
|
-
"is-disabled"
|
|
1158
|
-
])])) : __props.operatorValue.type === "enum" ? (openBlock(), createBlock(_sfc_main$15, {
|
|
1159
|
-
key: 9,
|
|
1160
|
-
label: text.value.value,
|
|
1161
|
-
"is-label-hidden": "",
|
|
1162
|
-
options: enumOptions.value,
|
|
1163
|
-
"model-value": enumValue.value,
|
|
1164
|
-
placeholder: text.value.selectPlaceholder,
|
|
1165
|
-
disabled: __props.disabled,
|
|
1166
|
-
"onUpdate:modelValue": _cache[5] || (_cache[5] = (value) => emit("change", {
|
|
1167
|
-
type: "enum",
|
|
1168
|
-
value: String(value ?? "")
|
|
1169
|
-
}, true))
|
|
1170
|
-
}, null, 8, [
|
|
1171
|
-
"label",
|
|
1172
|
-
"options",
|
|
1173
|
-
"model-value",
|
|
1174
|
-
"placeholder",
|
|
1175
|
-
"disabled"
|
|
1176
|
-
])) : __props.operatorValue.type === "enum_list" ? (openBlock(), createBlock(_sfc_main$13, {
|
|
1177
|
-
key: 10,
|
|
1178
|
-
label: text.value.values,
|
|
1179
|
-
"label-hidden": "",
|
|
1180
|
-
options: enumOptions.value,
|
|
1181
|
-
"model-value": enumList.value,
|
|
1182
|
-
placeholder: text.value.selectValuesPlaceholder,
|
|
1183
|
-
disabled: __props.disabled,
|
|
1184
|
-
"onUpdate:modelValue": _cache[6] || (_cache[6] = (value) => emit("change", {
|
|
1185
|
-
type: "enum_list",
|
|
1186
|
-
value: value.map(String)
|
|
1187
|
-
}))
|
|
1188
|
-
}, null, 8, [
|
|
1189
|
-
"label",
|
|
1190
|
-
"options",
|
|
1191
|
-
"model-value",
|
|
1192
|
-
"placeholder",
|
|
1193
|
-
"disabled"
|
|
1194
|
-
])) : __props.operatorValue.type === "entity_list" ? (openBlock(), createBlock(_sfc_main$16, {
|
|
1195
|
-
key: 11,
|
|
1196
|
-
presentation: "popover",
|
|
1197
|
-
label: text.value.entities,
|
|
1198
|
-
"label-hidden": "",
|
|
1199
|
-
"search-source": entitySource.value,
|
|
1200
|
-
"model-value": entityItems.value,
|
|
1201
|
-
placeholder: text.value.searchPlaceholder,
|
|
1202
|
-
disabled: __props.disabled,
|
|
1203
|
-
creatable: stringCreatable.value,
|
|
1204
|
-
"max-menu-items": __props.maxMenuItems,
|
|
1205
|
-
"onUpdate:modelValue": commitEntities
|
|
1206
|
-
}, null, 8, [
|
|
1207
|
-
"label",
|
|
1208
|
-
"search-source",
|
|
1209
|
-
"model-value",
|
|
1210
|
-
"placeholder",
|
|
1211
|
-
"disabled",
|
|
1212
|
-
"creatable",
|
|
1213
|
-
"max-menu-items"
|
|
1214
|
-
])) : __props.operatorValue.type === "custom" ? (openBlock(), createBlock(resolveDynamicComponent(__props.operatorValue.Editor), {
|
|
1215
|
-
key: 12,
|
|
1216
|
-
"model-value": customValue.value,
|
|
1217
|
-
value: customValue.value,
|
|
1218
|
-
placeholder: text.value.enterValuePlaceholder,
|
|
1219
|
-
disabled: __props.disabled,
|
|
1220
|
-
"is-disabled": __props.disabled,
|
|
1221
|
-
"onUpdate:modelValue": onCustomValue,
|
|
1222
|
-
onChange: onCustomValue
|
|
1223
|
-
}, null, 40, [
|
|
1224
|
-
"model-value",
|
|
1225
|
-
"value",
|
|
1226
|
-
"placeholder",
|
|
1227
|
-
"disabled",
|
|
1228
|
-
"is-disabled"
|
|
1229
|
-
])) : createCommentVNode("v-if", true)], 32);
|
|
1230
|
-
};
|
|
1231
|
-
}
|
|
1232
|
-
});
|
|
1233
|
-
//#endregion
|
|
1234
|
-
//#region src/PowerSearch/PowerSearchNestedRows.vue
|
|
1235
|
-
const _hoisted_1$2 = { class: "astryx-power-search-nested" };
|
|
1236
|
-
const _hoisted_2$2 = { class: "astryx-power-search-editor-row" };
|
|
1237
|
-
const _hoisted_3$2 = ["aria-label", "onClick"];
|
|
1238
|
-
const _sfc_main$2 = /*@__PURE__*/ defineComponent({
|
|
1239
|
-
name: "AstryxPowerSearchNestedRows",
|
|
1240
|
-
__name: "PowerSearchNestedRows",
|
|
1241
|
-
props: {
|
|
1242
|
-
config: {},
|
|
1243
|
-
modelValue: {},
|
|
1244
|
-
disabled: { type: Boolean },
|
|
1245
|
-
timeZone: {},
|
|
1246
|
-
maxMenuItems: {}
|
|
1247
|
-
},
|
|
1248
|
-
emits: ["update:modelValue"],
|
|
1249
|
-
setup(__props, { emit: __emit }) {
|
|
1250
|
-
const props = __props;
|
|
1251
|
-
const emit = __emit;
|
|
1252
|
-
const messages = useComponentMessages({ powerSearch: powerSearchMessages });
|
|
1253
|
-
const lookup = computed(() => createPowerSearchLookup(props.config));
|
|
1254
|
-
const text = computed(() => messages.value.powerSearch);
|
|
1255
|
-
const fieldOptions = computed(() => lookup.value.getVisibleFields().map((field) => ({
|
|
1256
|
-
value: field.key,
|
|
1257
|
-
label: field.label
|
|
1258
|
-
})));
|
|
1259
|
-
function operatorOptions(fieldKey) {
|
|
1260
|
-
return lookup.value.getVisibleOperators(fieldKey).map((operator) => ({
|
|
1261
|
-
value: operator.key,
|
|
1262
|
-
label: resolveOperatorLabel(operator, messages.value.powerSearch)
|
|
1263
|
-
}));
|
|
1264
|
-
}
|
|
1265
|
-
function operatorOf(row) {
|
|
1266
|
-
if (row.operator == null) return void 0;
|
|
1267
|
-
return lookup.value.getOperator(row.field, row.operator);
|
|
1268
|
-
}
|
|
1269
|
-
function replace(index, next) {
|
|
1270
|
-
const rows = props.modelValue.map((row, rowIndex) => rowIndex === index ? next : row);
|
|
1271
|
-
emit("update:modelValue", [...rows]);
|
|
1272
|
-
}
|
|
1273
|
-
function onField(index, fieldKey) {
|
|
1274
|
-
const key = String(fieldKey ?? "");
|
|
1275
|
-
if (key === "") return;
|
|
1276
|
-
const operator = lookup.value.getDefaultOperator(key);
|
|
1277
|
-
replace(index, {
|
|
1278
|
-
field: key,
|
|
1279
|
-
operator: operator?.key,
|
|
1280
|
-
children: operator?.value.type === "nested" ? [] : void 0
|
|
1281
|
-
});
|
|
1282
|
-
}
|
|
1283
|
-
function onOperator(index, row, operatorKey) {
|
|
1284
|
-
const key = String(operatorKey ?? "");
|
|
1285
|
-
const next = lookup.value.getOperator(row.field, key);
|
|
1286
|
-
const previous = operatorOf(row);
|
|
1287
|
-
const keep = next != null && previous != null && next.value.type === previous.value.type;
|
|
1288
|
-
replace(index, {
|
|
1289
|
-
field: row.field,
|
|
1290
|
-
operator: key,
|
|
1291
|
-
value: keep && next?.value.type !== "nested" ? row.value : void 0,
|
|
1292
|
-
children: keep && next?.value.type === "nested" ? row.children ?? [] : next?.value.type === "nested" ? [] : void 0,
|
|
1293
|
-
isReadOnly: row.isReadOnly
|
|
1294
|
-
});
|
|
1295
|
-
}
|
|
1296
|
-
function onValue(index, row, value) {
|
|
1297
|
-
replace(index, {
|
|
1298
|
-
...row,
|
|
1299
|
-
value
|
|
1300
|
-
});
|
|
1301
|
-
}
|
|
1302
|
-
function nestedRows(row) {
|
|
1303
|
-
return [...row.children ?? []];
|
|
1304
|
-
}
|
|
1305
|
-
function onNested(index, row, rows) {
|
|
1306
|
-
replace(index, {
|
|
1307
|
-
...row,
|
|
1308
|
-
children: rows
|
|
1309
|
-
});
|
|
1310
|
-
}
|
|
1311
|
-
function onNestedUpdate(index, row, rows) {
|
|
1312
|
-
onNested(index, row, rows);
|
|
1313
|
-
}
|
|
1314
|
-
function add() {
|
|
1315
|
-
const field = lookup.value.getVisibleFields()[0];
|
|
1316
|
-
if (field == null) return;
|
|
1317
|
-
const operator = lookup.value.getDefaultOperator(field.key);
|
|
1318
|
-
emit("update:modelValue", [...props.modelValue, {
|
|
1319
|
-
field: field.key,
|
|
1320
|
-
operator: operator?.key,
|
|
1321
|
-
children: operator?.value.type === "nested" ? [] : void 0
|
|
1322
|
-
}]);
|
|
1323
|
-
}
|
|
1324
|
-
function remove(index) {
|
|
1325
|
-
emit("update:modelValue", props.modelValue.filter((_, rowIndex) => rowIndex !== index));
|
|
1326
|
-
}
|
|
1327
|
-
return (_ctx, _cache) => {
|
|
1328
|
-
const _component_PowerSearchNestedRows = resolveComponent("PowerSearchNestedRows", true);
|
|
1329
|
-
return openBlock(), createElementBlock("div", _hoisted_1$2, [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.modelValue, (row, index) => {
|
|
1330
|
-
return openBlock(), createElementBlock("div", {
|
|
1331
|
-
key: `${row.field}-${index}`,
|
|
1332
|
-
class: "astryx-power-search-nested-row"
|
|
1333
|
-
}, [createElementVNode("div", _hoisted_2$2, [
|
|
1334
|
-
createVNode(_sfc_main$15, {
|
|
1335
|
-
label: text.value.editor.field,
|
|
1336
|
-
"is-label-hidden": "",
|
|
1337
|
-
options: fieldOptions.value,
|
|
1338
|
-
"model-value": row.field,
|
|
1339
|
-
disabled: __props.disabled,
|
|
1340
|
-
"onUpdate:modelValue": (value) => onField(index, value)
|
|
1341
|
-
}, null, 8, [
|
|
1342
|
-
"label",
|
|
1343
|
-
"options",
|
|
1344
|
-
"model-value",
|
|
1345
|
-
"disabled",
|
|
1346
|
-
"onUpdate:modelValue"
|
|
1347
|
-
]),
|
|
1348
|
-
operatorOptions(row.field).length > 0 ? (openBlock(), createBlock(_sfc_main$15, {
|
|
1349
|
-
key: 0,
|
|
1350
|
-
label: text.value.editor.operator,
|
|
1351
|
-
"is-label-hidden": "",
|
|
1352
|
-
options: operatorOptions(row.field),
|
|
1353
|
-
"model-value": row.operator ?? null,
|
|
1354
|
-
disabled: __props.disabled,
|
|
1355
|
-
"onUpdate:modelValue": (value) => onOperator(index, row, value)
|
|
1356
|
-
}, null, 8, [
|
|
1357
|
-
"label",
|
|
1358
|
-
"options",
|
|
1359
|
-
"model-value",
|
|
1360
|
-
"disabled",
|
|
1361
|
-
"onUpdate:modelValue"
|
|
1362
|
-
])) : createCommentVNode("v-if", true),
|
|
1363
|
-
operatorOf(row) && operatorOf(row)?.value.type !== "empty" && operatorOf(row)?.value.type !== "nested" ? (openBlock(), createBlock(_sfc_main$3, {
|
|
1364
|
-
key: `${row.field}:${row.operator ?? ""}`,
|
|
1365
|
-
"operator-value": operatorOf(row).value,
|
|
1366
|
-
"filter-value": row.value,
|
|
1367
|
-
messages: unref(messages).powerSearch,
|
|
1368
|
-
disabled: __props.disabled,
|
|
1369
|
-
"time-zone": __props.timeZone,
|
|
1370
|
-
"max-menu-items": __props.maxMenuItems,
|
|
1371
|
-
onChange: (filterValue) => onValue(index, row, filterValue)
|
|
1372
|
-
}, null, 8, [
|
|
1373
|
-
"operator-value",
|
|
1374
|
-
"filter-value",
|
|
1375
|
-
"messages",
|
|
1376
|
-
"disabled",
|
|
1377
|
-
"time-zone",
|
|
1378
|
-
"max-menu-items",
|
|
1379
|
-
"onChange"
|
|
1380
|
-
])) : createCommentVNode("v-if", true),
|
|
1381
|
-
!__props.disabled ? (openBlock(), createElementBlock("button", {
|
|
1382
|
-
key: 2,
|
|
1383
|
-
type: "button",
|
|
1384
|
-
class: "astryx-power-search-icon-button",
|
|
1385
|
-
"aria-label": text.value.editor.removeFilter,
|
|
1386
|
-
onClick: ($event) => remove(index)
|
|
1387
|
-
}, [createVNode(_sfc_main$5, {
|
|
1388
|
-
icon: "close",
|
|
1389
|
-
size: "sm"
|
|
1390
|
-
})], 8, _hoisted_3$2)) : createCommentVNode("v-if", true)
|
|
1391
|
-
]), operatorOf(row)?.value.type === "nested" ? (openBlock(), createBlock(_component_PowerSearchNestedRows, {
|
|
1392
|
-
key: 0,
|
|
1393
|
-
config: __props.config,
|
|
1394
|
-
"model-value": nestedRows(row),
|
|
1395
|
-
disabled: __props.disabled,
|
|
1396
|
-
"time-zone": __props.timeZone,
|
|
1397
|
-
"max-menu-items": __props.maxMenuItems,
|
|
1398
|
-
"onUpdate:modelValue": ($event) => onNestedUpdate(index, row, $event)
|
|
1399
|
-
}, null, 8, [
|
|
1400
|
-
"config",
|
|
1401
|
-
"model-value",
|
|
1402
|
-
"disabled",
|
|
1403
|
-
"time-zone",
|
|
1404
|
-
"max-menu-items",
|
|
1405
|
-
"onUpdate:modelValue"
|
|
1406
|
-
])) : createCommentVNode("v-if", true)]);
|
|
1407
|
-
}), 128)), !__props.disabled ? (openBlock(), createBlock(_sfc_main$6, {
|
|
1408
|
-
key: 0,
|
|
1409
|
-
label: text.value.editor.addFilter,
|
|
1410
|
-
variant: "ghost",
|
|
1411
|
-
size: "sm",
|
|
1412
|
-
onClick: add
|
|
1413
|
-
}, null, 8, ["label"])) : createCommentVNode("v-if", true)]);
|
|
1414
|
-
};
|
|
1415
|
-
}
|
|
1416
|
-
});
|
|
1417
|
-
//#endregion
|
|
1418
|
-
//#region src/PowerSearch/PowerSearchEditor.vue
|
|
1419
|
-
const _hoisted_1$1 = ["aria-label"];
|
|
1420
|
-
const _hoisted_2$1 = { class: "astryx-power-search-editor-row" };
|
|
1421
|
-
const _hoisted_3$1 = {
|
|
1422
|
-
key: 0,
|
|
1423
|
-
class: "astryx-power-search-editor-nested"
|
|
1424
|
-
};
|
|
1425
|
-
const _hoisted_4$1 = { class: "astryx-power-search-editor-group" };
|
|
1426
|
-
const _hoisted_5$1 = {
|
|
1427
|
-
key: 1,
|
|
1428
|
-
class: "astryx-power-search-editor-footer"
|
|
1429
|
-
};
|
|
1430
|
-
const _hoisted_6$1 = { key: 1 };
|
|
1431
|
-
const _hoisted_7$1 = { class: "astryx-power-search-editor-actions" };
|
|
1432
|
-
const focusable = "input:not([disabled]), button:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex=\"-1\"])";
|
|
1433
|
-
const _sfc_main$1 = /*@__PURE__*/ defineComponent({
|
|
1434
|
-
name: "AstryxPowerSearchEditor",
|
|
1435
|
-
__name: "PowerSearchEditor",
|
|
1436
|
-
props: {
|
|
1437
|
-
config: {},
|
|
1438
|
-
filter: {},
|
|
1439
|
-
mode: {},
|
|
1440
|
-
saveLabel: {},
|
|
1441
|
-
readOnly: { type: Boolean },
|
|
1442
|
-
timeZone: {},
|
|
1443
|
-
maxMenuItems: {},
|
|
1444
|
-
onSave: { type: Function },
|
|
1445
|
-
onCancel: { type: Function }
|
|
1446
|
-
},
|
|
1447
|
-
setup(__props) {
|
|
1448
|
-
const props = __props;
|
|
1449
|
-
if (isDevBuild() && props.config == null) throw devPropError("PowerSearchEditor", "config", "is required: the same config as the PowerSearch it edits.");
|
|
1450
|
-
const messages = useComponentMessages({ powerSearch: powerSearchMessages });
|
|
1451
|
-
const lookup = computed(() => createPowerSearchLookup(props.config));
|
|
1452
|
-
const text = computed(() => messages.value.powerSearch);
|
|
1453
|
-
const root = useTemplateRef("root");
|
|
1454
|
-
const valueRoot = useTemplateRef("valueRoot");
|
|
1455
|
-
const fieldKey = ref(props.filter.field);
|
|
1456
|
-
const operatorKey = ref(props.filter.operator ?? lookup.value.getDefaultOperator(props.filter.field)?.key ?? "");
|
|
1457
|
-
const draft = ref(props.filter.value?.type === "nested" ? void 0 : props.filter.value);
|
|
1458
|
-
const children = ref(props.filter.value?.type === "nested" ? [...props.filter.value.value] : []);
|
|
1459
|
-
const fieldOptions = computed(() => lookup.value.getVisibleFields().map((field) => ({
|
|
1460
|
-
value: field.key,
|
|
1461
|
-
label: field.label
|
|
1462
|
-
})));
|
|
1463
|
-
const operatorOptions = computed(() => lookup.value.getVisibleOperators(fieldKey.value).map((operator) => ({
|
|
1464
|
-
value: operator.key,
|
|
1465
|
-
label: resolveOperatorLabel(operator, messages.value.powerSearch)
|
|
1466
|
-
})));
|
|
1467
|
-
const operatorValue = computed(() => lookup.value.getOperator(fieldKey.value, operatorKey.value)?.value);
|
|
1468
|
-
const partial = computed(() => ({
|
|
1469
|
-
field: fieldKey.value,
|
|
1470
|
-
operator: operatorKey.value || void 0,
|
|
1471
|
-
value: operatorValue.value?.type === "nested" ? void 0 : draft.value,
|
|
1472
|
-
children: operatorValue.value?.type === "nested" ? children.value : void 0,
|
|
1473
|
-
isReadOnly: props.filter.isReadOnly
|
|
1474
|
-
}));
|
|
1475
|
-
const completed = computed(() => completePowerSearchFilter(partial.value, lookup.value));
|
|
1476
|
-
const showFooter = computed(() => operatorValue.value != null && operatorValue.value.type !== "empty");
|
|
1477
|
-
function focusWithin(element) {
|
|
1478
|
-
element?.querySelector(focusable)?.focus();
|
|
1479
|
-
}
|
|
1480
|
-
function saveIfEmpty(field, operatorKeyValue) {
|
|
1481
|
-
const operator = operatorKeyValue ? lookup.value.getOperator(field, operatorKeyValue) : void 0;
|
|
1482
|
-
if (operator?.value.type !== "empty") return;
|
|
1483
|
-
queueMicrotask(() => {
|
|
1484
|
-
props.onSave({
|
|
1485
|
-
field,
|
|
1486
|
-
operator: operator.key,
|
|
1487
|
-
value: { type: "empty" },
|
|
1488
|
-
isReadOnly: props.filter.isReadOnly
|
|
1489
|
-
});
|
|
1490
|
-
});
|
|
1491
|
-
}
|
|
1492
|
-
function onField(next) {
|
|
1493
|
-
const key = String(next ?? "");
|
|
1494
|
-
if (key === "" || key === fieldKey.value) return;
|
|
1495
|
-
const operator = lookup.value.getDefaultOperator(key);
|
|
1496
|
-
fieldKey.value = key;
|
|
1497
|
-
operatorKey.value = operator?.key ?? "";
|
|
1498
|
-
children.value = [];
|
|
1499
|
-
draft.value = void 0;
|
|
1500
|
-
saveIfEmpty(key, operator?.key);
|
|
1501
|
-
}
|
|
1502
|
-
function onOperator(next) {
|
|
1503
|
-
const key = String(next ?? "");
|
|
1504
|
-
if (key === "" || key === operatorKey.value) return;
|
|
1505
|
-
const nextOperator = lookup.value.getOperator(fieldKey.value, key);
|
|
1506
|
-
const previous = lookup.value.getOperator(fieldKey.value, operatorKey.value);
|
|
1507
|
-
const keep = nextOperator != null && previous != null && nextOperator.value.type === previous.value.type;
|
|
1508
|
-
operatorKey.value = key;
|
|
1509
|
-
if (!keep) {
|
|
1510
|
-
children.value = [];
|
|
1511
|
-
draft.value = void 0;
|
|
1512
|
-
}
|
|
1513
|
-
saveIfEmpty(fieldKey.value, key);
|
|
1514
|
-
}
|
|
1515
|
-
function onValue(value, shouldSave) {
|
|
1516
|
-
draft.value = value;
|
|
1517
|
-
if (shouldSave) save();
|
|
1518
|
-
}
|
|
1519
|
-
function save() {
|
|
1520
|
-
const filter = completePowerSearchFilter({
|
|
1521
|
-
field: fieldKey.value,
|
|
1522
|
-
operator: operatorKey.value,
|
|
1523
|
-
value: draft.value,
|
|
1524
|
-
isReadOnly: props.filter.isReadOnly
|
|
1525
|
-
}, lookup.value);
|
|
1526
|
-
if (filter) props.onSave(filter);
|
|
1527
|
-
}
|
|
1528
|
-
function onKeydown(event) {
|
|
1529
|
-
if (event.isComposing || event.key === "Process") return;
|
|
1530
|
-
if (event.key === "Escape" && !event.defaultPrevented) {
|
|
1531
|
-
event.preventDefault();
|
|
1532
|
-
props.onCancel();
|
|
1533
|
-
return;
|
|
1534
|
-
}
|
|
1535
|
-
if (event.key === "Enter" && event.target instanceof HTMLButtonElement) return;
|
|
1536
|
-
if (event.key === "Enter" && completed.value && !event.defaultPrevented) {
|
|
1537
|
-
event.preventDefault();
|
|
1538
|
-
save();
|
|
1539
|
-
}
|
|
1540
|
-
}
|
|
1541
|
-
watch([fieldKey, operatorKey], () => {
|
|
1542
|
-
nextTick(() => {
|
|
1543
|
-
requestAnimationFrame(() => focusWithin(valueRoot.value));
|
|
1544
|
-
});
|
|
1545
|
-
});
|
|
1546
|
-
onMounted(() => {
|
|
1547
|
-
nextTick(() => {
|
|
1548
|
-
requestAnimationFrame(() => focusWithin(valueRoot.value ?? root.value));
|
|
1549
|
-
});
|
|
1550
|
-
});
|
|
1551
|
-
return (_ctx, _cache) => {
|
|
1552
|
-
return openBlock(), createElementBlock(Fragment, null, [createCommentVNode(" eslint-disable-next-line vue-a11y/no-static-element-interactions -- 编辑器整组接收 Enter 和 Escape。 "), createElementVNode("div", {
|
|
1553
|
-
ref_key: "root",
|
|
1554
|
-
ref: root,
|
|
1555
|
-
class: "astryx-power-search-editor-body",
|
|
1556
|
-
role: "group",
|
|
1557
|
-
"aria-label": text.value.editor.editing,
|
|
1558
|
-
tabindex: "-1",
|
|
1559
|
-
onKeydown
|
|
1560
|
-
}, [
|
|
1561
|
-
createElementVNode("div", _hoisted_2$1, [
|
|
1562
|
-
createVNode(_sfc_main$15, {
|
|
1563
|
-
label: text.value.editor.field,
|
|
1564
|
-
"is-label-hidden": "",
|
|
1565
|
-
options: fieldOptions.value,
|
|
1566
|
-
"model-value": fieldKey.value,
|
|
1567
|
-
disabled: __props.readOnly,
|
|
1568
|
-
"onUpdate:modelValue": onField
|
|
1569
|
-
}, null, 8, [
|
|
1570
|
-
"label",
|
|
1571
|
-
"options",
|
|
1572
|
-
"model-value",
|
|
1573
|
-
"disabled"
|
|
1574
|
-
]),
|
|
1575
|
-
operatorOptions.value.length > 1 || operatorValue.value?.type !== "empty" ? (openBlock(), createBlock(_sfc_main$15, {
|
|
1576
|
-
key: 0,
|
|
1577
|
-
label: text.value.editor.operator,
|
|
1578
|
-
"is-label-hidden": "",
|
|
1579
|
-
options: operatorOptions.value,
|
|
1580
|
-
"model-value": operatorKey.value || null,
|
|
1581
|
-
disabled: __props.readOnly,
|
|
1582
|
-
"onUpdate:modelValue": onOperator
|
|
1583
|
-
}, null, 8, [
|
|
1584
|
-
"label",
|
|
1585
|
-
"options",
|
|
1586
|
-
"model-value",
|
|
1587
|
-
"disabled"
|
|
1588
|
-
])) : createCommentVNode("v-if", true),
|
|
1589
|
-
operatorValue.value && operatorValue.value.type !== "empty" && operatorValue.value.type !== "nested" ? (openBlock(), createElementBlock("div", {
|
|
1590
|
-
key: 1,
|
|
1591
|
-
ref_key: "valueRoot",
|
|
1592
|
-
ref: valueRoot,
|
|
1593
|
-
class: "astryx-power-search-editor-value"
|
|
1594
|
-
}, [(openBlock(), createBlock(_sfc_main$3, {
|
|
1595
|
-
key: `${fieldKey.value}:${operatorKey.value}`,
|
|
1596
|
-
"operator-value": operatorValue.value,
|
|
1597
|
-
"filter-value": draft.value,
|
|
1598
|
-
messages: unref(messages).powerSearch,
|
|
1599
|
-
disabled: __props.readOnly,
|
|
1600
|
-
"time-zone": __props.timeZone,
|
|
1601
|
-
"max-menu-items": __props.maxMenuItems,
|
|
1602
|
-
onChange: onValue
|
|
1603
|
-
}, null, 8, [
|
|
1604
|
-
"operator-value",
|
|
1605
|
-
"filter-value",
|
|
1606
|
-
"messages",
|
|
1607
|
-
"disabled",
|
|
1608
|
-
"time-zone",
|
|
1609
|
-
"max-menu-items"
|
|
1610
|
-
]))], 512)) : createCommentVNode("v-if", true)
|
|
1611
|
-
]),
|
|
1612
|
-
operatorValue.value?.type === "nested" ? (openBlock(), createElementBlock("div", _hoisted_3$1, [createElementVNode("div", _hoisted_4$1, toDisplayString(text.value.editor.group), 1), createVNode(_sfc_main$2, {
|
|
1613
|
-
config: __props.config,
|
|
1614
|
-
"model-value": children.value,
|
|
1615
|
-
disabled: __props.readOnly,
|
|
1616
|
-
"time-zone": __props.timeZone,
|
|
1617
|
-
"max-menu-items": __props.maxMenuItems,
|
|
1618
|
-
"onUpdate:modelValue": _cache[0] || (_cache[0] = (rows) => children.value = rows)
|
|
1619
|
-
}, null, 8, [
|
|
1620
|
-
"config",
|
|
1621
|
-
"model-value",
|
|
1622
|
-
"disabled",
|
|
1623
|
-
"time-zone",
|
|
1624
|
-
"max-menu-items"
|
|
1625
|
-
])])) : createCommentVNode("v-if", true),
|
|
1626
|
-
showFooter.value ? (openBlock(), createElementBlock("div", _hoisted_5$1, [__props.mode === "edit" && !__props.readOnly ? (openBlock(), createBlock(_sfc_main$6, {
|
|
1627
|
-
key: 0,
|
|
1628
|
-
label: text.value.editor.delete,
|
|
1629
|
-
variant: "ghost",
|
|
1630
|
-
size: "sm",
|
|
1631
|
-
onClick: _cache[1] || (_cache[1] = ($event) => __props.onSave(null))
|
|
1632
|
-
}, null, 8, ["label"])) : (openBlock(), createElementBlock("span", _hoisted_6$1)), createElementVNode("div", _hoisted_7$1, [createVNode(_sfc_main$6, {
|
|
1633
|
-
label: text.value.editor.cancel,
|
|
1634
|
-
variant: "ghost",
|
|
1635
|
-
size: "sm",
|
|
1636
|
-
onClick: __props.onCancel
|
|
1637
|
-
}, null, 8, ["label", "onClick"]), createVNode(_sfc_main$6, {
|
|
1638
|
-
label: __props.saveLabel || text.value.editor.apply,
|
|
1639
|
-
variant: "primary",
|
|
1640
|
-
size: "sm",
|
|
1641
|
-
"is-disabled": completed.value == null,
|
|
1642
|
-
onClick: save
|
|
1643
|
-
}, null, 8, ["label", "is-disabled"])])])) : createCommentVNode("v-if", true)
|
|
1644
|
-
], 40, _hoisted_1$1)], 2112);
|
|
1645
|
-
};
|
|
1646
|
-
}
|
|
1647
|
-
});
|
|
1648
|
-
//#endregion
|
|
1649
|
-
//#region src/PowerSearch/usePowerSearchActions.ts
|
|
1650
|
-
function usePowerSearchActions(options) {
|
|
1651
|
-
const { props, emit, menu, lookup, text, announce } = options;
|
|
1652
|
-
const removeTap = useTokenRemoveTap({
|
|
1653
|
-
root: options.anchorRef,
|
|
1654
|
-
input: options.inputRef,
|
|
1655
|
-
tokenSelector: ".astryx-power-search-token"
|
|
1656
|
-
});
|
|
1657
|
-
const gutter = useLayerGutter();
|
|
1658
|
-
const internal = ref([]);
|
|
1659
|
-
const filters = computed(() => props.filters ?? internal.value);
|
|
1660
|
-
const session = ref(null);
|
|
1661
|
-
const openingControl = ref(null);
|
|
1662
|
-
const editorOpen = computed(() => session.value != null);
|
|
1663
|
-
const tokenEls = /* @__PURE__ */ new Map();
|
|
1664
|
-
const editorStyle = computed(() => {
|
|
1665
|
-
const place = session.value?.placement;
|
|
1666
|
-
if (place == null) return void 0;
|
|
1667
|
-
return {
|
|
1668
|
-
top: `${place.top}px`,
|
|
1669
|
-
left: `${place.left}px`,
|
|
1670
|
-
width: `${place.width}px`
|
|
1671
|
-
};
|
|
1672
|
-
});
|
|
1673
|
-
const editorComponent = computed(() => {
|
|
1674
|
-
const filter = session.value?.filter;
|
|
1675
|
-
if (filter?.operator == null) return _sfc_main$1;
|
|
1676
|
-
const type = lookup.value.getOperator(filter.field, filter.operator)?.value.type;
|
|
1677
|
-
return (type ? props.components?.[type]?.editor : void 0) ?? _sfc_main$1;
|
|
1678
|
-
});
|
|
1679
|
-
function commit(next, changeType, index) {
|
|
1680
|
-
internal.value = next;
|
|
1681
|
-
emit("update:filters", next);
|
|
1682
|
-
emit("change", next, changeType, index);
|
|
1683
|
-
}
|
|
1684
|
-
function operatorFor(filter) {
|
|
1685
|
-
return lookup.value.getOperator(filter.field, filter.operator);
|
|
1686
|
-
}
|
|
1687
|
-
function fieldFor(filter) {
|
|
1688
|
-
return lookup.value.getField(filter.field);
|
|
1689
|
-
}
|
|
1690
|
-
function emptyEditorOverridden(components) {
|
|
1691
|
-
return Boolean(components?.empty?.editor || options.hasCustomEditor());
|
|
1692
|
-
}
|
|
1693
|
-
function canEdit(filter) {
|
|
1694
|
-
if (props.disabled || props.readOnly || filter.isReadOnly) return false;
|
|
1695
|
-
const operator = operatorFor(filter);
|
|
1696
|
-
if (operator == null) return false;
|
|
1697
|
-
if (operator.value.type !== "empty") return true;
|
|
1698
|
-
return emptyEditorOverridden(props.components);
|
|
1699
|
-
}
|
|
1700
|
-
function canRemove(filter) {
|
|
1701
|
-
return !props.disabled && !props.readOnly && filter.isReadOnly !== true;
|
|
1702
|
-
}
|
|
1703
|
-
function tokenComponent(filter) {
|
|
1704
|
-
const type = operatorFor(filter)?.value.type;
|
|
1705
|
-
return type ? props.components?.[type]?.token : void 0;
|
|
1706
|
-
}
|
|
1707
|
-
function measure(control) {
|
|
1708
|
-
const outer = options.anchorRef.value;
|
|
1709
|
-
if (outer == null) return null;
|
|
1710
|
-
const target = control ?? outer;
|
|
1711
|
-
const outerRect = outer.getBoundingClientRect();
|
|
1712
|
-
const controlRect = target.getBoundingClientRect();
|
|
1713
|
-
const edges = gutter.value;
|
|
1714
|
-
return resolveEditorPlacement({
|
|
1715
|
-
outer: {
|
|
1716
|
-
left: outerRect.left,
|
|
1717
|
-
right: outerRect.right,
|
|
1718
|
-
width: outerRect.width
|
|
1719
|
-
},
|
|
1720
|
-
control: {
|
|
1721
|
-
left: controlRect.left,
|
|
1722
|
-
right: controlRect.right,
|
|
1723
|
-
width: controlRect.width
|
|
1724
|
-
},
|
|
1725
|
-
viewportWidth: window.innerWidth,
|
|
1726
|
-
viewportHeight: window.innerHeight,
|
|
1727
|
-
inlineStart: edges.inlineStart,
|
|
1728
|
-
inlineEnd: edges.inlineEnd,
|
|
1729
|
-
blockInset: edges.blockStart,
|
|
1730
|
-
direction: getComputedStyle(outer).direction === "rtl" ? "rtl" : "ltr",
|
|
1731
|
-
anchorTop: controlRect.top,
|
|
1732
|
-
anchorBottom: controlRect.bottom
|
|
1733
|
-
});
|
|
1734
|
-
}
|
|
1735
|
-
function openEditor(mode, filter, index, control) {
|
|
1736
|
-
const placement = measure(control);
|
|
1737
|
-
if (placement == null) return;
|
|
1738
|
-
menu.close();
|
|
1739
|
-
openingControl.value = control;
|
|
1740
|
-
session.value = {
|
|
1741
|
-
mode,
|
|
1742
|
-
index,
|
|
1743
|
-
filter,
|
|
1744
|
-
placement,
|
|
1745
|
-
ready: false,
|
|
1746
|
-
control
|
|
1747
|
-
};
|
|
1748
|
-
nextTick(() => {
|
|
1749
|
-
requestAnimationFrame(() => {
|
|
1750
|
-
if (session.value) session.value = {
|
|
1751
|
-
...session.value,
|
|
1752
|
-
ready: true
|
|
1753
|
-
};
|
|
1754
|
-
});
|
|
1755
|
-
});
|
|
1756
|
-
}
|
|
1757
|
-
function closeEditor(restore) {
|
|
1758
|
-
const control = session.value?.control;
|
|
1759
|
-
session.value = null;
|
|
1760
|
-
openingControl.value = null;
|
|
1761
|
-
if (!restore) return;
|
|
1762
|
-
nextTick(() => {
|
|
1763
|
-
if (control instanceof HTMLElement) control.focus();
|
|
1764
|
-
else options.inputRef.value?.focus();
|
|
1765
|
-
});
|
|
1766
|
-
}
|
|
1767
|
-
function focusInput() {
|
|
1768
|
-
nextTick(() => options.inputRef.value?.focus());
|
|
1769
|
-
}
|
|
1770
|
-
function pick(item) {
|
|
1771
|
-
const data = item.auxiliaryData;
|
|
1772
|
-
if (data == null) return;
|
|
1773
|
-
const field = lookup.value.getField(data.fieldKey);
|
|
1774
|
-
const operator = (data.operatorKey ? lookup.value.getOperator(data.fieldKey, data.operatorKey) : void 0) ?? lookup.value.getDefaultOperator(data.fieldKey);
|
|
1775
|
-
if (field == null || operator == null) return;
|
|
1776
|
-
menu.setQuery("");
|
|
1777
|
-
menu.close();
|
|
1778
|
-
if (data.filterValue != null || operator.value.type === "empty") {
|
|
1779
|
-
const value = data.filterValue ?? { type: "empty" };
|
|
1780
|
-
const next = [...filters.value, {
|
|
1781
|
-
field: field.key,
|
|
1782
|
-
operator: operator.key,
|
|
1783
|
-
value
|
|
1784
|
-
}];
|
|
1785
|
-
commit(next, "add", next.length - 1);
|
|
1786
|
-
announce(`${field.label}: ${operator.key}`);
|
|
1787
|
-
focusInput();
|
|
1788
|
-
return;
|
|
1789
|
-
}
|
|
1790
|
-
openEditor("create", {
|
|
1791
|
-
field: field.key,
|
|
1792
|
-
operator: operator.key
|
|
1793
|
-
}, filters.value.length, options.inputRef.value);
|
|
1794
|
-
}
|
|
1795
|
-
function onEditorSave(filter) {
|
|
1796
|
-
const current = session.value;
|
|
1797
|
-
if (current == null) return;
|
|
1798
|
-
if (filter == null) {
|
|
1799
|
-
if (current.mode === "edit") {
|
|
1800
|
-
const dropped = filters.value[current.index];
|
|
1801
|
-
commit(filters.value.filter((_, index) => index !== current.index), "remove", current.index);
|
|
1802
|
-
announce(text.value.removeFilter(dropped ? fieldFor(dropped)?.label ?? dropped.field : ""));
|
|
1803
|
-
}
|
|
1804
|
-
closeEditor(false);
|
|
1805
|
-
focusInput();
|
|
1806
|
-
return;
|
|
1807
|
-
}
|
|
1808
|
-
if (current.mode === "edit") commit(filters.value.map((item, index) => index === current.index ? filter : item), "edit", current.index);
|
|
1809
|
-
else {
|
|
1810
|
-
const next = [...filters.value, filter];
|
|
1811
|
-
commit(next, "add", next.length - 1);
|
|
1812
|
-
}
|
|
1813
|
-
const field = lookup.value.getField(filter.field);
|
|
1814
|
-
announce(field?.label ?? filter.field);
|
|
1815
|
-
closeEditor(false);
|
|
1816
|
-
focusInput();
|
|
1817
|
-
}
|
|
1818
|
-
function removeAt(index) {
|
|
1819
|
-
const filter = filters.value[index];
|
|
1820
|
-
if (filter == null || !canRemove(filter)) return;
|
|
1821
|
-
commit(filters.value.filter((_, itemIndex) => itemIndex !== index), "remove", index);
|
|
1822
|
-
announce(text.value.removeFilter(fieldFor(filter)?.label ?? filter.field));
|
|
1823
|
-
if (removeTap.shouldFocusInputAfterRemove()) focusInput();
|
|
1824
|
-
}
|
|
1825
|
-
function clearAll(event) {
|
|
1826
|
-
event?.stopPropagation();
|
|
1827
|
-
if (props.disabled || props.readOnly) return;
|
|
1828
|
-
const firstRemoved = filters.value.findIndex((filter) => filter.isReadOnly !== true);
|
|
1829
|
-
if (firstRemoved < 0) return;
|
|
1830
|
-
const kept = filters.value.filter((filter) => filter.isReadOnly === true);
|
|
1831
|
-
commit(kept, "remove", firstRemoved);
|
|
1832
|
-
announce(kept.length > 0 ? text.value.editableFiltersRemoved : text.value.allFiltersRemoved);
|
|
1833
|
-
menu.close();
|
|
1834
|
-
options.inputRef.value?.focus();
|
|
1835
|
-
}
|
|
1836
|
-
function activate(index) {
|
|
1837
|
-
const filter = filters.value[index];
|
|
1838
|
-
if (filter == null || props.disabled || props.readOnly || filter.isReadOnly) return;
|
|
1839
|
-
if (operatorFor(filter)?.value.type === "empty" && !emptyEditorOverridden(props.components)) {
|
|
1840
|
-
commit(filters.value.map((item, itemIndex) => itemIndex === index ? {
|
|
1841
|
-
field: item.field,
|
|
1842
|
-
operator: item.operator,
|
|
1843
|
-
value: { type: "empty" },
|
|
1844
|
-
isReadOnly: item.isReadOnly
|
|
1845
|
-
} : item), "edit", index);
|
|
1846
|
-
return;
|
|
1847
|
-
}
|
|
1848
|
-
if (!canEdit(filter)) return;
|
|
1849
|
-
openEditor("edit", filter, index, tokenEls.get(index) ?? null);
|
|
1850
|
-
}
|
|
1851
|
-
function setTokenEl(index, element) {
|
|
1852
|
-
if (element instanceof HTMLElement) tokenEls.set(index, element);
|
|
1853
|
-
else tokenEls.delete(index);
|
|
1854
|
-
}
|
|
1855
|
-
function focusToken(index) {
|
|
1856
|
-
nextTick(() => tokenEls.get(index)?.focus());
|
|
1857
|
-
}
|
|
1858
|
-
function onInput(event) {
|
|
1859
|
-
if (props.disabled || props.readOnly) return;
|
|
1860
|
-
menu.setQuery(event.target.value);
|
|
1861
|
-
}
|
|
1862
|
-
function onInputKeyDown(event) {
|
|
1863
|
-
if (session.value != null) return;
|
|
1864
|
-
const input = options.inputRef.value;
|
|
1865
|
-
if (event.key === "Backspace" && menu.query.value === "" && filters.value.length > 0 && canRemove(filters.value[filters.value.length - 1])) {
|
|
1866
|
-
event.preventDefault();
|
|
1867
|
-
removeAt(filters.value.length - 1);
|
|
1868
|
-
return;
|
|
1869
|
-
}
|
|
1870
|
-
if (event.key === "ArrowLeft" && input && input.selectionStart === 0 && input.selectionEnd === 0 && filters.value.length > 0) {
|
|
1871
|
-
event.preventDefault();
|
|
1872
|
-
focusToken(Math.min(options.visibleCount(), filters.value.length) - 1);
|
|
1873
|
-
return;
|
|
1874
|
-
}
|
|
1875
|
-
if (event.key === "ArrowRight" && input && menu.query.value === "" && input.selectionStart === 0) return;
|
|
1876
|
-
menu.onKeyDown(event);
|
|
1877
|
-
}
|
|
1878
|
-
function onTokenKeyDown(event, index) {
|
|
1879
|
-
const shown = options.visibleCount();
|
|
1880
|
-
if (event.key === "ArrowLeft" && index > 0) {
|
|
1881
|
-
event.preventDefault();
|
|
1882
|
-
focusToken(index - 1);
|
|
1883
|
-
} else if (event.key === "ArrowRight") {
|
|
1884
|
-
event.preventDefault();
|
|
1885
|
-
if (index < shown - 1) focusToken(index + 1);
|
|
1886
|
-
else options.inputRef.value?.focus();
|
|
1887
|
-
} else if (event.key === "Escape") options.inputRef.value?.focus();
|
|
1888
|
-
else if ((event.key === "Backspace" || event.key === "Delete") && canRemove(filters.value[index])) {
|
|
1889
|
-
event.preventDefault();
|
|
1890
|
-
removeAt(index);
|
|
1891
|
-
if (index > 0) focusToken(index - 1);
|
|
1892
|
-
} else if (event.key === "Enter") {
|
|
1893
|
-
event.preventDefault();
|
|
1894
|
-
activate(index);
|
|
1895
|
-
}
|
|
1896
|
-
}
|
|
1897
|
-
return {
|
|
1898
|
-
activate,
|
|
1899
|
-
canEdit,
|
|
1900
|
-
canRemove,
|
|
1901
|
-
clearAll,
|
|
1902
|
-
closeEditor,
|
|
1903
|
-
editorComponent,
|
|
1904
|
-
editorOpen,
|
|
1905
|
-
editorStyle,
|
|
1906
|
-
fieldFor,
|
|
1907
|
-
filters,
|
|
1908
|
-
onEditorSave,
|
|
1909
|
-
onInput,
|
|
1910
|
-
onInputKeyDown,
|
|
1911
|
-
onTokenKeyDown,
|
|
1912
|
-
openingControl,
|
|
1913
|
-
operatorFor,
|
|
1914
|
-
pick,
|
|
1915
|
-
removeAt,
|
|
1916
|
-
session,
|
|
1917
|
-
setTokenEl,
|
|
1918
|
-
tokenComponent
|
|
1919
|
-
};
|
|
1920
|
-
}
|
|
1921
|
-
//#endregion
|
|
1922
|
-
//#region src/PowerSearch/useResultCountAnnouncement.ts
|
|
1923
|
-
/**
|
|
1924
|
-
* 结果数变化时给读屏的播报文字。挂载时已经有的数不念,只念之后的变化:
|
|
1925
|
-
* 数字交给 `format` 写成句子,字符串原样念。
|
|
1926
|
-
*/
|
|
1927
|
-
function useResultCountAnnouncement(count, format) {
|
|
1928
|
-
const liveText = ref("");
|
|
1929
|
-
let sawCount = false;
|
|
1930
|
-
watch(count, (value) => {
|
|
1931
|
-
if (!sawCount) {
|
|
1932
|
-
sawCount = true;
|
|
1933
|
-
return;
|
|
1934
|
-
}
|
|
1935
|
-
if (typeof value === "number") liveText.value = format(value);
|
|
1936
|
-
else if (typeof value === "string") liveText.value = value;
|
|
1937
|
-
}, { immediate: true });
|
|
1938
|
-
return liveText;
|
|
1939
|
-
}
|
|
1940
|
-
//#endregion
|
|
1941
|
-
//#region src/PowerSearch/PowerSearch.vue
|
|
1942
|
-
const _hoisted_1 = {
|
|
1943
|
-
key: 0,
|
|
1944
|
-
class: "astryx-power-search-icon",
|
|
1945
|
-
"aria-hidden": "true"
|
|
1946
|
-
};
|
|
1947
|
-
const _hoisted_2 = ["onKeydown"];
|
|
1948
|
-
const _hoisted_3 = {
|
|
1949
|
-
key: 0,
|
|
1950
|
-
class: "astryx-power-search-more"
|
|
1951
|
-
};
|
|
1952
|
-
const _hoisted_4 = {
|
|
1953
|
-
"data-overflow-indicator": "",
|
|
1954
|
-
class: "astryx-power-search-more"
|
|
1955
|
-
};
|
|
1956
|
-
const _hoisted_5 = [
|
|
1957
|
-
"id",
|
|
1958
|
-
"placeholder",
|
|
1959
|
-
"value",
|
|
1960
|
-
"disabled",
|
|
1961
|
-
"readonly",
|
|
1962
|
-
"aria-disabled",
|
|
1963
|
-
"aria-expanded",
|
|
1964
|
-
"aria-controls",
|
|
1965
|
-
"aria-activedescendant",
|
|
1966
|
-
"aria-describedby"
|
|
1967
|
-
];
|
|
1968
|
-
const _hoisted_6 = {
|
|
1969
|
-
key: 1,
|
|
1970
|
-
class: "astryx-power-search-end"
|
|
1971
|
-
};
|
|
1972
|
-
const _hoisted_7 = {
|
|
1973
|
-
key: 0,
|
|
1974
|
-
class: "astryx-power-search-count"
|
|
1975
|
-
};
|
|
1976
|
-
const _hoisted_8 = ["aria-label"];
|
|
1977
|
-
const _hoisted_9 = ["id"];
|
|
1978
|
-
const _hoisted_10 = {
|
|
1979
|
-
class: "astryx-visually-hidden",
|
|
1980
|
-
"aria-live": "polite"
|
|
1981
|
-
};
|
|
1982
|
-
const _hoisted_11 = [
|
|
1983
|
-
"id",
|
|
1984
|
-
"aria-label",
|
|
1985
|
-
"data-placement"
|
|
1986
|
-
];
|
|
1987
|
-
const _hoisted_12 = {
|
|
1988
|
-
class: "astryx-typeahead-menu",
|
|
1989
|
-
role: "presentation"
|
|
1990
|
-
};
|
|
1991
|
-
const _hoisted_13 = {
|
|
1992
|
-
key: 0,
|
|
1993
|
-
class: "astryx-typeahead-state"
|
|
1994
|
-
};
|
|
1995
|
-
const _hoisted_14 = {
|
|
1996
|
-
key: 1,
|
|
1997
|
-
class: "astryx-typeahead-options",
|
|
1998
|
-
role: "presentation"
|
|
1999
|
-
};
|
|
2000
|
-
const _hoisted_15 = {
|
|
2001
|
-
key: 0,
|
|
2002
|
-
class: "astryx-power-search-menu-group"
|
|
2003
|
-
};
|
|
2004
|
-
const _hoisted_16 = [
|
|
2005
|
-
"id",
|
|
2006
|
-
"aria-selected",
|
|
2007
|
-
"data-option-id",
|
|
2008
|
-
"onMouseenter",
|
|
2009
|
-
"onClick"
|
|
2010
|
-
];
|
|
2011
|
-
const _hoisted_17 = { class: "astryx-typeahead-option-copy" };
|
|
2012
|
-
const _hoisted_18 = { class: "astryx-typeahead-option-label" };
|
|
2013
|
-
const _hoisted_19 = {
|
|
2014
|
-
key: 0,
|
|
2015
|
-
class: "astryx-typeahead-option-description"
|
|
2016
|
-
};
|
|
2017
|
-
const _hoisted_20 = ["data-ready"];
|
|
2018
|
-
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
2019
|
-
name: "AstryxPowerSearch",
|
|
2020
|
-
inheritAttrs: false,
|
|
2021
|
-
__name: "PowerSearch",
|
|
2022
|
-
props: {
|
|
2023
|
-
config: {},
|
|
2024
|
-
filters: {},
|
|
2025
|
-
label: {},
|
|
2026
|
-
isLabelHidden: { type: Boolean },
|
|
2027
|
-
labelHidden: {
|
|
2028
|
-
type: Boolean,
|
|
2029
|
-
default: true
|
|
2030
|
-
},
|
|
2031
|
-
placeholder: {},
|
|
2032
|
-
autofocus: { type: Boolean },
|
|
2033
|
-
hasClear: {
|
|
2034
|
-
type: Boolean,
|
|
2035
|
-
default: true
|
|
2036
|
-
},
|
|
2037
|
-
clearable: {
|
|
2038
|
-
type: Boolean,
|
|
2039
|
-
default: true
|
|
2040
|
-
},
|
|
2041
|
-
readOnly: {
|
|
2042
|
-
type: Boolean,
|
|
2043
|
-
default: false
|
|
2044
|
-
},
|
|
2045
|
-
disabled: {
|
|
2046
|
-
type: Boolean,
|
|
2047
|
-
default: false
|
|
2048
|
-
},
|
|
2049
|
-
disabledMessage: {},
|
|
2050
|
-
disabledReason: {},
|
|
2051
|
-
status: { default: "default" },
|
|
2052
|
-
statusMessage: {},
|
|
2053
|
-
statusVariant: { default: "attached" },
|
|
2054
|
-
maxTokenLength: { default: 40 },
|
|
2055
|
-
maxOperatorMenuItems: {},
|
|
2056
|
-
maxSearchResults: { default: 10 },
|
|
2057
|
-
menuWidth: {},
|
|
2058
|
-
popoverSaveButtonLabel: {},
|
|
2059
|
-
saveLabel: {},
|
|
2060
|
-
timezoneID: {},
|
|
2061
|
-
timeZone: {},
|
|
2062
|
-
overflow: { default: "none" },
|
|
2063
|
-
resultCount: {},
|
|
2064
|
-
size: {},
|
|
2065
|
-
components: {},
|
|
2066
|
-
containerClass: { type: [
|
|
2067
|
-
Boolean,
|
|
2068
|
-
null,
|
|
2069
|
-
String,
|
|
2070
|
-
Object,
|
|
2071
|
-
Array
|
|
2072
|
-
] },
|
|
2073
|
-
containerStyle: { type: [
|
|
2074
|
-
Boolean,
|
|
2075
|
-
null,
|
|
2076
|
-
String,
|
|
2077
|
-
Object,
|
|
2078
|
-
Array
|
|
2079
|
-
] },
|
|
2080
|
-
controlClass: { type: [
|
|
2081
|
-
Boolean,
|
|
2082
|
-
null,
|
|
2083
|
-
String,
|
|
2084
|
-
Object,
|
|
2085
|
-
Array
|
|
2086
|
-
] },
|
|
2087
|
-
controlStyle: { type: [
|
|
2088
|
-
Boolean,
|
|
2089
|
-
null,
|
|
2090
|
-
String,
|
|
2091
|
-
Object,
|
|
2092
|
-
Array
|
|
2093
|
-
] }
|
|
2094
|
-
},
|
|
2095
|
-
emits: [
|
|
2096
|
-
"update:filters",
|
|
2097
|
-
"change",
|
|
2098
|
-
"focus",
|
|
2099
|
-
"blur"
|
|
2100
|
-
],
|
|
2101
|
-
setup(__props, { expose: __expose, emit: __emit }) {
|
|
2102
|
-
const props = __props;
|
|
2103
|
-
const emit = __emit;
|
|
2104
|
-
const slots = useSlots();
|
|
2105
|
-
if (isDevBuild() && props.config == null) throw devPropError("PowerSearch", "config", "is required: the fields people can filter by, for example :config=\"{ fields: [...] }\".");
|
|
2106
|
-
const size = useSize(() => props.size, "md");
|
|
2107
|
-
const attrs = useAttrs();
|
|
2108
|
-
const parts = useFieldPartStyling({
|
|
2109
|
-
component: "PowerSearch",
|
|
2110
|
-
props,
|
|
2111
|
-
attrs,
|
|
2112
|
-
reservedAttrs: [
|
|
2113
|
-
"id",
|
|
2114
|
-
"type",
|
|
2115
|
-
"role",
|
|
2116
|
-
"value",
|
|
2117
|
-
"disabled",
|
|
2118
|
-
"readonly",
|
|
2119
|
-
"placeholder",
|
|
2120
|
-
"autocomplete",
|
|
2121
|
-
"aria-expanded",
|
|
2122
|
-
"aria-controls",
|
|
2123
|
-
"aria-autocomplete",
|
|
2124
|
-
"aria-activedescendant",
|
|
2125
|
-
"aria-describedby",
|
|
2126
|
-
"aria-disabled"
|
|
2127
|
-
]
|
|
2128
|
-
});
|
|
2129
|
-
const hideLabel = useResolvedLabelHidden(() => props.isLabelHidden, () => props.labelHidden, true);
|
|
2130
|
-
const messages = useComponentMessages({ powerSearch: powerSearchMessages });
|
|
2131
|
-
const locale = useAstryxLocale();
|
|
2132
|
-
const announce = useAnnounce();
|
|
2133
|
-
const generatedId = `astryx-power-search-${useId()}`;
|
|
2134
|
-
const passedId = computed(() => typeof attrs.id === "string" && attrs.id !== "" ? attrs.id : void 0);
|
|
2135
|
-
const inputId = computed(() => passedId.value ?? generatedId);
|
|
2136
|
-
const listboxId = computed(() => `${inputId.value}-listbox`);
|
|
2137
|
-
const disabledId = computed(() => `${inputId.value}-disabled`);
|
|
2138
|
-
const focused = ref(false);
|
|
2139
|
-
const placeholderHeight = ref(0);
|
|
2140
|
-
const queryMirror = ref("");
|
|
2141
|
-
const anchorRef = useTemplateRef("anchorRef");
|
|
2142
|
-
const listboxRef = useTemplateRef("listboxRef");
|
|
2143
|
-
useScrollbars(listboxRef);
|
|
2144
|
-
const inputRef = useTemplateRef("inputRef");
|
|
2145
|
-
const editorRef = useTemplateRef("editorRef");
|
|
2146
|
-
const visibleCountOf = { current: () => 0 };
|
|
2147
|
-
const text = computed(() => messages.value.powerSearch);
|
|
2148
|
-
const liveText = useResultCountAnnouncement(() => props.resultCount, (count) => text.value.resultCount(count));
|
|
2149
|
-
const label = computed(() => props.label ?? text.value.label);
|
|
2150
|
-
const placeholder = computed(() => props.placeholder ?? text.value.placeholder);
|
|
2151
|
-
const disabledMessage = computed(() => (props.disabledMessage ?? props.disabledReason)?.trim() || void 0);
|
|
2152
|
-
const focusableDisabled = computed(() => props.disabled && disabledMessage.value != null);
|
|
2153
|
-
const showsClear = computed(() => props.hasClear && props.clearable);
|
|
2154
|
-
const resolvedSaveLabel = computed(() => props.popoverSaveButtonLabel ?? props.saveLabel);
|
|
2155
|
-
const resolvedTimeZone = computed(() => props.timezoneID ?? props.timeZone);
|
|
2156
|
-
const collapsed = computed(() => props.overflow !== "none" && !focused.value);
|
|
2157
|
-
const floating = computed(() => props.overflow === "unfocused-layer" && focused.value);
|
|
2158
|
-
const lookup = computed(() => createPowerSearchLookup(props.config));
|
|
2159
|
-
const fieldStatus = computed(() => !props.statusMessage || props.status === "default" ? void 0 : {
|
|
2160
|
-
type: props.status,
|
|
2161
|
-
message: props.statusMessage
|
|
2162
|
-
});
|
|
2163
|
-
const { statusIcon, statusIconProps } = useInputStatusIcon({
|
|
2164
|
-
status: () => fieldStatus.value,
|
|
2165
|
-
statusVariant: () => props.statusVariant
|
|
2166
|
-
});
|
|
2167
|
-
const externalDescribedBy = computed(() => typeof attrs["aria-describedby"] === "string" ? attrs["aria-describedby"] : void 0);
|
|
2168
|
-
const describedBy = computed(() => [
|
|
2169
|
-
externalDescribedBy.value,
|
|
2170
|
-
focusableDisabled.value ? disabledId.value : void 0,
|
|
2171
|
-
props.statusMessage ? `${inputId.value}-status` : void 0
|
|
2172
|
-
].filter(Boolean).join(" ") || void 0);
|
|
2173
|
-
const source = computed(() => ({ search(query) {
|
|
2174
|
-
const limit = query.trim() === "" ? 1e3 : props.maxSearchResults;
|
|
2175
|
-
return searchPowerSearchFields(lookup.value, query, text.value, limit);
|
|
2176
|
-
} }));
|
|
2177
|
-
const bridge = {
|
|
2178
|
-
pick: (_item) => {},
|
|
2179
|
-
sessionOpen: () => false,
|
|
2180
|
-
closeEditor: (_restore) => {}
|
|
2181
|
-
};
|
|
2182
|
-
const menu = useTypeaheadMenu({
|
|
2183
|
-
source: () => source.value,
|
|
2184
|
-
debounceMs: 0,
|
|
2185
|
-
showOnFocus: () => !props.readOnly,
|
|
2186
|
-
maxItems: () => queryMirror.value.trim() === "" ? 1e3 : props.maxSearchResults,
|
|
2187
|
-
disabled: () => props.disabled || props.readOnly || bridge.sessionOpen(),
|
|
2188
|
-
onSelect: (entry) => bridge.pick(entry.item),
|
|
2189
|
-
onQueryChange: (query) => {
|
|
2190
|
-
queryMirror.value = query;
|
|
2191
|
-
}
|
|
2192
|
-
});
|
|
2193
|
-
const anchored = useAnchoredListbox({
|
|
2194
|
-
anchor: anchorRef,
|
|
2195
|
-
layer: listboxRef,
|
|
2196
|
-
isOpen: menu.combobox.isOpen,
|
|
2197
|
-
onDismiss: () => menu.close()
|
|
2198
|
-
});
|
|
2199
|
-
const { activate, canEdit, canRemove, clearAll, closeEditor, editorComponent, editorOpen, editorStyle, fieldFor, filters, onEditorSave, onInput, onInputKeyDown, onTokenKeyDown, openingControl, operatorFor, pick, removeAt, session, setTokenEl, tokenComponent } = usePowerSearchActions({
|
|
2200
|
-
props,
|
|
2201
|
-
emit,
|
|
2202
|
-
hasCustomEditor: () => slots.editor != null,
|
|
2203
|
-
menu: {
|
|
2204
|
-
query: menu.query,
|
|
2205
|
-
close: () => menu.close(),
|
|
2206
|
-
setQuery: (value) => {
|
|
2207
|
-
menu.query.value = value;
|
|
2208
|
-
},
|
|
2209
|
-
onKeyDown: (event) => menu.onKeyDown(event)
|
|
2210
|
-
},
|
|
2211
|
-
anchorRef,
|
|
2212
|
-
inputRef,
|
|
2213
|
-
lookup,
|
|
2214
|
-
text,
|
|
2215
|
-
announce,
|
|
2216
|
-
visibleCount: () => visibleCountOf.current()
|
|
2217
|
-
});
|
|
2218
|
-
const naming = useFilterTokenNaming({
|
|
2219
|
-
idPrefix: () => inputId.value,
|
|
2220
|
-
session,
|
|
2221
|
-
filters,
|
|
2222
|
-
opensEditor: canEdit,
|
|
2223
|
-
isBuiltIn: (filter) => !slots.token && !tokenComponent(filter)
|
|
2224
|
-
});
|
|
2225
|
-
bridge.pick = pick;
|
|
2226
|
-
bridge.sessionOpen = () => session.value != null;
|
|
2227
|
-
bridge.closeEditor = closeEditor;
|
|
2228
|
-
useDismiss({
|
|
2229
|
-
container: editorRef,
|
|
2230
|
-
trigger: openingControl,
|
|
2231
|
-
isEnabled: editorOpen,
|
|
2232
|
-
dismissOnEscape: "ignore",
|
|
2233
|
-
onDismiss: () => closeEditor(true)
|
|
2234
|
-
});
|
|
2235
|
-
const tokenCount = computed(() => filters.value.length);
|
|
2236
|
-
const overflowState = useOverflow(tokenCount, { gap: 4 });
|
|
2237
|
-
const visibleCount = computed(() => collapsed.value ? overflowState.visibleCount.value : tokenCount.value);
|
|
2238
|
-
visibleCountOf.current = () => visibleCount.value;
|
|
2239
|
-
const hiddenCount = computed(() => Math.max(0, tokenCount.value - visibleCount.value));
|
|
2240
|
-
watch(collapsed, () => {
|
|
2241
|
-
nextTick(() => overflowState.remeasure());
|
|
2242
|
-
});
|
|
2243
|
-
watch(() => menu.combobox.activeIndex.value, (index) => {
|
|
2244
|
-
if (!menu.combobox.isOpen.value || index < 0) return;
|
|
2245
|
-
nextTick(() => scrollOptionIntoView(listboxRef.value, menu.entries.value[index]?.id));
|
|
2246
|
-
});
|
|
2247
|
-
const visibleFilters = computed(() => filters.value.slice(0, visibleCount.value));
|
|
2248
|
-
const hasClearButton = computed(() => showsClear.value && filters.value.some((filter) => filter.isReadOnly !== true) && !props.disabled && !props.readOnly);
|
|
2249
|
-
const displayCount = computed(() => resultCountText(props.resultCount, text.value.resultCount));
|
|
2250
|
-
const menuStyle = computed(() => menuStyleWithWidth(anchored.style.value, props.menuWidth));
|
|
2251
|
-
function onInputFocus(event) {
|
|
2252
|
-
emit("focus", event);
|
|
2253
|
-
if (!props.disabled && !props.readOnly && session.value == null) menu.open();
|
|
2254
|
-
}
|
|
2255
|
-
function onFocusIn() {
|
|
2256
|
-
if (!focused.value && props.overflow === "unfocused-layer") placeholderHeight.value = anchorRef.value?.offsetHeight ?? 0;
|
|
2257
|
-
focused.value = true;
|
|
2258
|
-
}
|
|
2259
|
-
function onFocusOut(event) {
|
|
2260
|
-
const next = event.relatedTarget;
|
|
2261
|
-
if (next instanceof Node && (anchorRef.value?.contains(next) || listboxRef.value?.contains(next) || editorRef.value?.contains(next))) return;
|
|
2262
|
-
focused.value = false;
|
|
2263
|
-
if (session.value == null) menu.close();
|
|
2264
|
-
}
|
|
2265
|
-
function onFieldClick(event) {
|
|
2266
|
-
if (props.disabled && !focusableDisabled.value) return;
|
|
2267
|
-
const target = event.target;
|
|
2268
|
-
if (target instanceof Element && target.closest("button, a")) return;
|
|
2269
|
-
inputRef.value?.focus();
|
|
2270
|
-
}
|
|
2271
|
-
function highlight(index) {
|
|
2272
|
-
const entry = menu.entries.value[index];
|
|
2273
|
-
if (entry && !entry.disabled) menu.combobox.activeIndex.value = index;
|
|
2274
|
-
}
|
|
2275
|
-
function optionId(index) {
|
|
2276
|
-
return `${listboxId.value}-option-${index}`;
|
|
2277
|
-
}
|
|
2278
|
-
onMounted(() => {
|
|
2279
|
-
if (props.autofocus) inputRef.value?.focus();
|
|
2280
|
-
});
|
|
2281
|
-
__expose({
|
|
2282
|
-
focusTypeahead: () => inputRef.value?.focus(),
|
|
2283
|
-
blurTypeahead: () => inputRef.value?.blur()
|
|
2284
|
-
});
|
|
2285
|
-
return (_ctx, _cache) => {
|
|
2286
|
-
return openBlock(), createElementBlock(Fragment, null, [createVNode(_sfc_main$8, {
|
|
2287
|
-
class: normalizeClass(["astryx-power-search", [
|
|
2288
|
-
unref(parts).containerClass.value,
|
|
2289
|
-
`size-${unref(size)}`,
|
|
2290
|
-
{ "is-floating": floating.value }
|
|
2291
|
-
]]),
|
|
2292
|
-
style: normalizeStyle(unref(parts).containerStyle.value),
|
|
2293
|
-
label: label.value,
|
|
2294
|
-
"input-id": inputId.value,
|
|
2295
|
-
"is-label-hidden": unref(hideLabel),
|
|
2296
|
-
"is-disabled": __props.disabled && !focusableDisabled.value,
|
|
2297
|
-
status: fieldStatus.value,
|
|
2298
|
-
"status-variant": __props.statusVariant
|
|
2299
|
-
}, {
|
|
2300
|
-
default: withCtx(() => [
|
|
2301
|
-
floating.value ? (openBlock(), createElementBlock("div", {
|
|
2302
|
-
key: 0,
|
|
2303
|
-
class: "astryx-power-search-placeholder",
|
|
2304
|
-
style: normalizeStyle({ height: `${placeholderHeight.value}px` })
|
|
2305
|
-
}, null, 4)) : createCommentVNode("v-if", true),
|
|
2306
|
-
createVNode(_sfc_main$7, {
|
|
2307
|
-
content: disabledMessage.value,
|
|
2308
|
-
"is-enabled": focusableDisabled.value
|
|
2309
|
-
}, {
|
|
2310
|
-
default: withCtx(() => [createCommentVNode(" eslint-disable-next-line vue-a11y/click-events-have-key-events, vue-a11y/no-static-element-interactions -- 点空白处把焦点交给输入框。 "), createElementVNode("div", {
|
|
2311
|
-
ref_key: "anchorRef",
|
|
2312
|
-
ref: anchorRef,
|
|
2313
|
-
class: normalizeClass(["astryx-power-search-control", [
|
|
2314
|
-
unref(parts).controlClass(),
|
|
2315
|
-
`status-${__props.status}`,
|
|
2316
|
-
{
|
|
2317
|
-
"is-open": unref(menu).combobox.isOpen.value,
|
|
2318
|
-
"is-disabled": __props.disabled,
|
|
2319
|
-
"is-floating": floating.value
|
|
2320
|
-
}
|
|
2321
|
-
]]),
|
|
2322
|
-
style: normalizeStyle(unref(parts).controlStyle()),
|
|
2323
|
-
onClick: onFieldClick,
|
|
2324
|
-
onFocusin: onFocusIn,
|
|
2325
|
-
onFocusout: onFocusOut
|
|
2326
|
-
}, [
|
|
2327
|
-
slots.icon ? (openBlock(), createElementBlock("span", _hoisted_1, [renderSlot(_ctx.$slots, "icon")])) : createCommentVNode("v-if", true),
|
|
2328
|
-
createElementVNode("span", {
|
|
2329
|
-
ref: unref(overflowState).containerRef,
|
|
2330
|
-
class: normalizeClass(["astryx-power-search-tokens", { "is-collapsed": collapsed.value }])
|
|
2331
|
-
}, [
|
|
2332
|
-
createCommentVNode(" eslint-disable-next-line vue-a11y/no-static-element-interactions -- 方向键在条件之间移动焦点。 "),
|
|
2333
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(visibleFilters.value, (filter, index) => {
|
|
2334
|
-
return openBlock(), createElementBlock("span", {
|
|
2335
|
-
key: `${filter.field}-${filter.operator}-${index}`,
|
|
2336
|
-
ref_for: true,
|
|
2337
|
-
ref: (element) => unref(setTokenEl)(index, element),
|
|
2338
|
-
class: "astryx-power-search-token",
|
|
2339
|
-
tabindex: "-1",
|
|
2340
|
-
onKeydown: ($event) => unref(onTokenKeyDown)($event, index)
|
|
2341
|
-
}, [renderSlot(_ctx.$slots, "token", {
|
|
2342
|
-
config: __props.config,
|
|
2343
|
-
filter,
|
|
2344
|
-
field: unref(fieldFor)(filter),
|
|
2345
|
-
operator: unref(operatorFor)(filter),
|
|
2346
|
-
maxLength: __props.maxTokenLength,
|
|
2347
|
-
disabled: __props.disabled,
|
|
2348
|
-
onClick: () => unref(activate)(index),
|
|
2349
|
-
onRemove: () => unref(removeAt)(index)
|
|
2350
|
-
}, () => [unref(tokenComponent)(filter) ? (openBlock(), createBlock(resolveDynamicComponent(unref(tokenComponent)(filter)), {
|
|
2351
|
-
key: 0,
|
|
2352
|
-
config: __props.config,
|
|
2353
|
-
filter,
|
|
2354
|
-
field: unref(fieldFor)(filter),
|
|
2355
|
-
operator: unref(operatorFor)(filter),
|
|
2356
|
-
"max-length": __props.maxTokenLength,
|
|
2357
|
-
disabled: __props.disabled,
|
|
2358
|
-
"on-click": () => unref(activate)(index),
|
|
2359
|
-
"on-remove": () => unref(removeAt)(index)
|
|
2360
|
-
}, null, 40, [
|
|
2361
|
-
"config",
|
|
2362
|
-
"filter",
|
|
2363
|
-
"field",
|
|
2364
|
-
"operator",
|
|
2365
|
-
"max-length",
|
|
2366
|
-
"disabled",
|
|
2367
|
-
"on-click",
|
|
2368
|
-
"on-remove"
|
|
2369
|
-
])) : unref(fieldFor)(filter) && unref(operatorFor)(filter) ? (openBlock(), createBlock(_sfc_main$4, mergeProps({
|
|
2370
|
-
key: 1,
|
|
2371
|
-
"field-label": unref(fieldFor)(filter).label,
|
|
2372
|
-
operator: unref(operatorFor)(filter),
|
|
2373
|
-
filter,
|
|
2374
|
-
"max-length": __props.maxTokenLength,
|
|
2375
|
-
messages: text.value,
|
|
2376
|
-
locale: unref(locale),
|
|
2377
|
-
"time-zone": resolvedTimeZone.value,
|
|
2378
|
-
size: unref(size),
|
|
2379
|
-
disabled: __props.disabled,
|
|
2380
|
-
removable: unref(canRemove)(filter)
|
|
2381
|
-
}, { ref_for: true }, unref(naming).tokenProps(filter, index), {
|
|
2382
|
-
onActivate: ($event) => unref(activate)(index),
|
|
2383
|
-
onRemove: ($event) => unref(removeAt)(index)
|
|
2384
|
-
}), null, 16, [
|
|
2385
|
-
"field-label",
|
|
2386
|
-
"operator",
|
|
2387
|
-
"filter",
|
|
2388
|
-
"max-length",
|
|
2389
|
-
"messages",
|
|
2390
|
-
"locale",
|
|
2391
|
-
"time-zone",
|
|
2392
|
-
"size",
|
|
2393
|
-
"disabled",
|
|
2394
|
-
"removable",
|
|
2395
|
-
"onActivate",
|
|
2396
|
-
"onRemove"
|
|
2397
|
-
])) : createCommentVNode("v-if", true)])], 40, _hoisted_2);
|
|
2398
|
-
}), 128)),
|
|
2399
|
-
collapsed.value && hiddenCount.value > 0 ? (openBlock(), createElementBlock("span", _hoisted_3, toDisplayString(text.value.more(hiddenCount.value)), 1)) : createCommentVNode("v-if", true)
|
|
2400
|
-
], 2),
|
|
2401
|
-
createElementVNode("span", {
|
|
2402
|
-
ref: unref(overflowState).measureRef,
|
|
2403
|
-
class: "astryx-power-search-measure",
|
|
2404
|
-
"aria-hidden": "true"
|
|
2405
|
-
}, [(openBlock(true), createElementBlock(Fragment, null, renderList(unref(filters), (filter, index) => {
|
|
2406
|
-
return openBlock(), createElementBlock("span", {
|
|
2407
|
-
key: `${filter.field}-${index}`,
|
|
2408
|
-
class: "astryx-power-search-token"
|
|
2409
|
-
}, [unref(fieldFor)(filter) && unref(operatorFor)(filter) ? (openBlock(), createBlock(_sfc_main$4, {
|
|
2410
|
-
key: 0,
|
|
2411
|
-
"field-label": unref(fieldFor)(filter).label,
|
|
2412
|
-
operator: unref(operatorFor)(filter),
|
|
2413
|
-
filter,
|
|
2414
|
-
"max-length": __props.maxTokenLength,
|
|
2415
|
-
messages: text.value,
|
|
2416
|
-
locale: unref(locale),
|
|
2417
|
-
size: unref(size),
|
|
2418
|
-
removable: ""
|
|
2419
|
-
}, null, 8, [
|
|
2420
|
-
"field-label",
|
|
2421
|
-
"operator",
|
|
2422
|
-
"filter",
|
|
2423
|
-
"max-length",
|
|
2424
|
-
"messages",
|
|
2425
|
-
"locale",
|
|
2426
|
-
"size"
|
|
2427
|
-
])) : createCommentVNode("v-if", true)]);
|
|
2428
|
-
}), 128)), createElementVNode("span", _hoisted_4, toDisplayString(text.value.more(Math.max(hiddenCount.value, 1))), 1)], 512),
|
|
2429
|
-
createElementVNode("input", mergeProps(unref(parts).forwardedAttrs(), {
|
|
2430
|
-
id: inputId.value,
|
|
2431
|
-
ref_key: "inputRef",
|
|
2432
|
-
ref: inputRef,
|
|
2433
|
-
class: "astryx-power-search-input",
|
|
2434
|
-
type: "text",
|
|
2435
|
-
role: "combobox",
|
|
2436
|
-
autocomplete: "off",
|
|
2437
|
-
autocapitalize: "off",
|
|
2438
|
-
autocorrect: "off",
|
|
2439
|
-
enterkeyhint: "search",
|
|
2440
|
-
placeholder: unref(filters).length === 0 ? placeholder.value : void 0,
|
|
2441
|
-
value: unref(menu).query.value,
|
|
2442
|
-
disabled: __props.disabled && !focusableDisabled.value,
|
|
2443
|
-
readonly: __props.readOnly || focusableDisabled.value || void 0,
|
|
2444
|
-
"aria-disabled": __props.disabled ? "true" : void 0,
|
|
2445
|
-
"aria-expanded": unref(menu).combobox.isOpen.value,
|
|
2446
|
-
"aria-controls": listboxId.value,
|
|
2447
|
-
"aria-autocomplete": "list",
|
|
2448
|
-
"aria-activedescendant": unref(menu).activeId.value ? optionId(unref(menu).combobox.activeIndex.value) : void 0,
|
|
2449
|
-
"aria-describedby": describedBy.value,
|
|
2450
|
-
onInput: _cache[0] || (_cache[0] = (...args) => unref(onInput) && unref(onInput)(...args)),
|
|
2451
|
-
onKeydown: _cache[1] || (_cache[1] = (...args) => unref(onInputKeyDown) && unref(onInputKeyDown)(...args)),
|
|
2452
|
-
onFocus: onInputFocus,
|
|
2453
|
-
onBlur: _cache[2] || (_cache[2] = ($event) => emit("blur", $event))
|
|
2454
|
-
}), null, 16, _hoisted_5),
|
|
2455
|
-
createCommentVNode(" 同上游 Tokenizer 的 endSection:计数、endContent、清除按钮并成一组,距边框 8px、间距 8px。 "),
|
|
2456
|
-
displayCount.value || slots.endContent || slots.end || hasClearButton.value || unref(statusIcon) ? (openBlock(), createElementBlock("span", _hoisted_6, [
|
|
2457
|
-
displayCount.value ? (openBlock(), createElementBlock("span", _hoisted_7, toDisplayString(displayCount.value), 1)) : createCommentVNode("v-if", true),
|
|
2458
|
-
slots.endContent ? renderSlot(_ctx.$slots, "endContent", {}, void 0, void 0, 1) : renderSlot(_ctx.$slots, "end", {}, void 0, void 0, 2),
|
|
2459
|
-
hasClearButton.value ? (openBlock(), createElementBlock("button", {
|
|
2460
|
-
key: 3,
|
|
2461
|
-
type: "button",
|
|
2462
|
-
class: "astryx-power-search-clear",
|
|
2463
|
-
"aria-label": text.value.clear,
|
|
2464
|
-
onClick: _cache[3] || (_cache[3] = (...args) => unref(clearAll) && unref(clearAll)(...args))
|
|
2465
|
-
}, [createVNode(_sfc_main$5, {
|
|
2466
|
-
icon: "close",
|
|
2467
|
-
size: "sm"
|
|
2468
|
-
})], 8, _hoisted_8)) : createCommentVNode("v-if", true),
|
|
2469
|
-
unref(statusIcon) ? (openBlock(), createBlock(resolveDynamicComponent(unref(statusIcon)), normalizeProps(mergeProps({ key: 4 }, unref(statusIconProps))), null, 16)) : createCommentVNode("v-if", true)
|
|
2470
|
-
])) : createCommentVNode("v-if", true),
|
|
2471
|
-
focusableDisabled.value ? (openBlock(), createElementBlock("span", {
|
|
2472
|
-
key: 2,
|
|
2473
|
-
id: disabledId.value,
|
|
2474
|
-
class: "astryx-visually-hidden"
|
|
2475
|
-
}, toDisplayString(disabledMessage.value), 9, _hoisted_9)) : createCommentVNode("v-if", true)
|
|
2476
|
-
], 38)]),
|
|
2477
|
-
_: 3
|
|
2478
|
-
}, 8, ["content", "is-enabled"]),
|
|
2479
|
-
createElementVNode("span", _hoisted_10, toDisplayString(unref(liveText)), 1)
|
|
2480
|
-
]),
|
|
2481
|
-
_: 3
|
|
2482
|
-
}, 8, [
|
|
2483
|
-
"class",
|
|
2484
|
-
"style",
|
|
2485
|
-
"label",
|
|
2486
|
-
"input-id",
|
|
2487
|
-
"is-label-hidden",
|
|
2488
|
-
"is-disabled",
|
|
2489
|
-
"status",
|
|
2490
|
-
"status-variant"
|
|
2491
|
-
]), (openBlock(), createBlock(Teleport, { to: "body" }, [withDirectives(createElementVNode("div", {
|
|
2492
|
-
id: listboxId.value,
|
|
2493
|
-
ref_key: "listboxRef",
|
|
2494
|
-
ref: listboxRef,
|
|
2495
|
-
class: "astryx-typeahead-listbox astryx-layer",
|
|
2496
|
-
role: "listbox",
|
|
2497
|
-
"aria-label": text.value.results,
|
|
2498
|
-
"data-placement": unref(anchored).position.value.placement,
|
|
2499
|
-
style: normalizeStyle(menuStyle.value),
|
|
2500
|
-
tabindex: "-1"
|
|
2501
|
-
}, [createElementVNode("div", _hoisted_12, [unref(menu).entries.value.length === 0 ? (openBlock(), createElementBlock("div", _hoisted_13, toDisplayString(text.value.empty), 1)) : (openBlock(), createElementBlock("div", _hoisted_14, [(openBlock(true), createElementBlock(Fragment, null, renderList(unref(menu).entries.value, (entry, index) => {
|
|
2502
|
-
return openBlock(), createElementBlock(Fragment, { key: entry.id }, [
|
|
2503
|
-
unref(powerSearchGroupLabel)(unref(menu).entries.value, index) ? (openBlock(), createElementBlock("div", _hoisted_15, toDisplayString(unref(powerSearchGroupLabel)(unref(menu).entries.value, index)), 1)) : createCommentVNode("v-if", true),
|
|
2504
|
-
createCommentVNode(" eslint-disable-next-line vue-a11y/click-events-have-key-events, vue-a11y/mouse-events-have-key-events -- 选项不进 Tab 序。 "),
|
|
2505
|
-
createElementVNode("div", {
|
|
2506
|
-
id: optionId(index),
|
|
2507
|
-
class: normalizeClass(["astryx-typeahead-option", {
|
|
2508
|
-
"is-active": index === unref(menu).combobox.activeIndex.value,
|
|
2509
|
-
"is-disabled": entry.disabled
|
|
2510
|
-
}]),
|
|
2511
|
-
role: "option",
|
|
2512
|
-
"aria-selected": index === unref(menu).combobox.activeIndex.value ? "true" : "false",
|
|
2513
|
-
"data-option-id": entry.id,
|
|
2514
|
-
tabindex: "-1",
|
|
2515
|
-
onMousedown: _cache[4] || (_cache[4] = withModifiers(() => {}, ["prevent"])),
|
|
2516
|
-
onMouseenter: ($event) => highlight(index),
|
|
2517
|
-
onClick: ($event) => unref(pick)(entry.item)
|
|
2518
|
-
}, [createVNode(_sfc_main$5, {
|
|
2519
|
-
icon: unref(powerSearchItemIcon)(entry.item, lookup.value),
|
|
2520
|
-
size: "sm"
|
|
2521
|
-
}, null, 8, ["icon"]), createElementVNode("span", _hoisted_17, [createElementVNode("span", _hoisted_18, toDisplayString(entry.label), 1), entry.description ? (openBlock(), createElementBlock("span", _hoisted_19, toDisplayString(entry.description), 1)) : createCommentVNode("v-if", true)])], 42, _hoisted_16)
|
|
2522
|
-
], 64);
|
|
2523
|
-
}), 128))]))])], 12, _hoisted_11), [[vShow, unref(menu).combobox.isOpen.value]]), unref(session) ? (openBlock(), createElementBlock("div", mergeProps({
|
|
2524
|
-
key: 0,
|
|
2525
|
-
ref_key: "editorRef",
|
|
2526
|
-
ref: editorRef
|
|
2527
|
-
}, unref(naming).editorAttrs.value, {
|
|
2528
|
-
class: "astryx-power-search-editor astryx-layer",
|
|
2529
|
-
"data-ready": unref(session).ready ? "true" : "false",
|
|
2530
|
-
style: unref(editorStyle)
|
|
2531
|
-
}), [renderSlot(_ctx.$slots, "editor", {
|
|
2532
|
-
config: __props.config,
|
|
2533
|
-
filter: unref(session).filter,
|
|
2534
|
-
mode: unref(session).mode,
|
|
2535
|
-
saveLabel: resolvedSaveLabel.value,
|
|
2536
|
-
readOnly: __props.readOnly,
|
|
2537
|
-
timeZone: resolvedTimeZone.value,
|
|
2538
|
-
maxMenuItems: __props.maxOperatorMenuItems,
|
|
2539
|
-
onSave: unref(onEditorSave),
|
|
2540
|
-
onCancel: () => unref(closeEditor)(true)
|
|
2541
|
-
}, () => [(openBlock(), createBlock(resolveDynamicComponent(unref(editorComponent)), {
|
|
2542
|
-
config: __props.config,
|
|
2543
|
-
filter: unref(session).filter,
|
|
2544
|
-
mode: unref(session).mode,
|
|
2545
|
-
"save-label": resolvedSaveLabel.value,
|
|
2546
|
-
"read-only": __props.readOnly,
|
|
2547
|
-
"time-zone": resolvedTimeZone.value,
|
|
2548
|
-
"max-menu-items": __props.maxOperatorMenuItems,
|
|
2549
|
-
"on-save": unref(onEditorSave),
|
|
2550
|
-
"on-cancel": () => unref(closeEditor)(true)
|
|
2551
|
-
}, null, 40, [
|
|
2552
|
-
"config",
|
|
2553
|
-
"filter",
|
|
2554
|
-
"mode",
|
|
2555
|
-
"save-label",
|
|
2556
|
-
"read-only",
|
|
2557
|
-
"time-zone",
|
|
2558
|
-
"max-menu-items",
|
|
2559
|
-
"on-save",
|
|
2560
|
-
"on-cancel"
|
|
2561
|
-
]))])], 16, _hoisted_20)) : createCommentVNode("v-if", true)]))], 64);
|
|
2562
|
-
};
|
|
2563
|
-
}
|
|
2564
|
-
});
|
|
2565
|
-
//#endregion
|
|
2566
|
-
//#region src/PowerSearch/fieldBuilders.ts
|
|
2567
|
-
function i18n(key, message, value) {
|
|
2568
|
-
return {
|
|
2569
|
-
key,
|
|
2570
|
-
i18nKey: `@astryx.powersearch.operator.${message}`,
|
|
2571
|
-
value
|
|
2572
|
-
};
|
|
2573
|
-
}
|
|
2574
|
-
function stringField(key, label) {
|
|
2575
|
-
return {
|
|
2576
|
-
key,
|
|
2577
|
-
label,
|
|
2578
|
-
defaultOperator: "contains",
|
|
2579
|
-
operators: [
|
|
2580
|
-
i18n("contains", "contains", { type: "string" }),
|
|
2581
|
-
i18n("not_contains", "notContains", { type: "string" }),
|
|
2582
|
-
i18n("starts_with", "startsWith", { type: "string" }),
|
|
2583
|
-
i18n("not_starts_with", "notStartsWith", { type: "string" }),
|
|
2584
|
-
i18n("ends_with", "endsWith", { type: "string" }),
|
|
2585
|
-
i18n("not_ends_with", "notEndsWith", { type: "string" }),
|
|
2586
|
-
i18n("is", "is", { type: "string" }),
|
|
2587
|
-
i18n("is_not", "isNot", { type: "string" })
|
|
2588
|
-
]
|
|
2589
|
-
};
|
|
2590
|
-
}
|
|
2591
|
-
function numberField(key, label) {
|
|
2592
|
-
const value = { type: "float" };
|
|
2593
|
-
return {
|
|
2594
|
-
key,
|
|
2595
|
-
label,
|
|
2596
|
-
defaultOperator: "equals",
|
|
2597
|
-
operators: [
|
|
2598
|
-
i18n("equals", "equals", value),
|
|
2599
|
-
i18n("not_equals", "notEquals", value),
|
|
2600
|
-
i18n("greater_than", "greaterThan", value),
|
|
2601
|
-
i18n("less_than", "lessThan", value),
|
|
2602
|
-
i18n("greater_than_or_equal", "greaterThanOrEqual", value),
|
|
2603
|
-
i18n("less_than_or_equal", "lessThanOrEqual", value)
|
|
2604
|
-
]
|
|
2605
|
-
};
|
|
2606
|
-
}
|
|
2607
|
-
function dateField(key, label) {
|
|
2608
|
-
return {
|
|
2609
|
-
key,
|
|
2610
|
-
label,
|
|
2611
|
-
defaultOperator: "after",
|
|
2612
|
-
operators: [
|
|
2613
|
-
i18n("before", "before", { type: "date_absolute" }),
|
|
2614
|
-
i18n("after", "after", { type: "date_absolute" }),
|
|
2615
|
-
i18n("between", "between", { type: "date_range" })
|
|
2616
|
-
]
|
|
2617
|
-
};
|
|
2618
|
-
}
|
|
2619
|
-
function booleanField(key, label) {
|
|
2620
|
-
return {
|
|
2621
|
-
key,
|
|
2622
|
-
label,
|
|
2623
|
-
defaultOperator: "is_true",
|
|
2624
|
-
operators: [i18n("is_true", "isTrue", { type: "empty" }), i18n("is_false", "isFalse", { type: "empty" })]
|
|
2625
|
-
};
|
|
2626
|
-
}
|
|
2627
|
-
function enumField(key, label, values) {
|
|
2628
|
-
return {
|
|
2629
|
-
key,
|
|
2630
|
-
label,
|
|
2631
|
-
defaultOperator: "is",
|
|
2632
|
-
operators: [
|
|
2633
|
-
i18n("is", "is", {
|
|
2634
|
-
type: "enum",
|
|
2635
|
-
values
|
|
2636
|
-
}),
|
|
2637
|
-
i18n("is_not", "isNot", {
|
|
2638
|
-
type: "enum",
|
|
2639
|
-
values
|
|
2640
|
-
}),
|
|
2641
|
-
i18n("is_any_of", "isAnyOf", {
|
|
2642
|
-
type: "enum_list",
|
|
2643
|
-
values
|
|
2644
|
-
}),
|
|
2645
|
-
i18n("is_none_of", "isNoneOf", {
|
|
2646
|
-
type: "enum_list",
|
|
2647
|
-
values
|
|
2648
|
-
})
|
|
2649
|
-
]
|
|
2650
|
-
};
|
|
2651
|
-
}
|
|
2652
|
-
function enumListField(key, label, values) {
|
|
2653
|
-
return {
|
|
2654
|
-
key,
|
|
2655
|
-
label,
|
|
2656
|
-
defaultOperator: "is_any_of",
|
|
2657
|
-
operators: [i18n("is_any_of", "isAnyOf", {
|
|
2658
|
-
type: "enum_list",
|
|
2659
|
-
values
|
|
2660
|
-
}), i18n("is_none_of", "isNoneOf", {
|
|
2661
|
-
type: "enum_list",
|
|
2662
|
-
values
|
|
2663
|
-
})]
|
|
2664
|
-
};
|
|
2665
|
-
}
|
|
2666
|
-
function stringListField(key, label) {
|
|
2667
|
-
return {
|
|
2668
|
-
key,
|
|
2669
|
-
label,
|
|
2670
|
-
defaultOperator: "is_any_of",
|
|
2671
|
-
operators: [i18n("is_any_of", "isAnyOf", { type: "string_list" }), i18n("is_none_of", "isNoneOf", { type: "string_list" })]
|
|
2672
|
-
};
|
|
2673
|
-
}
|
|
2674
|
-
function buildPowerSearchField(definition) {
|
|
2675
|
-
const label = definition.label ?? definition.key;
|
|
2676
|
-
switch (definition.type) {
|
|
2677
|
-
case "string": return stringField(definition.key, label);
|
|
2678
|
-
case "number": return numberField(definition.key, label);
|
|
2679
|
-
case "date": return dateField(definition.key, label);
|
|
2680
|
-
case "boolean": return booleanField(definition.key, label);
|
|
2681
|
-
case "enum": return enumField(definition.key, label, definition.enumValues ?? []);
|
|
2682
|
-
case "enum_list": return enumListField(definition.key, label, definition.enumValues ?? []);
|
|
2683
|
-
case "string_list": return stringListField(definition.key, label);
|
|
2684
|
-
}
|
|
2685
|
-
}
|
|
2686
|
-
//#endregion
|
|
2687
|
-
//#region src/PowerSearch/query.ts
|
|
2688
|
-
const stringHandlers = {
|
|
2689
|
-
contains: (value, target) => value.includes(target),
|
|
2690
|
-
not_contains: (value, target) => !value.includes(target),
|
|
2691
|
-
starts_with: (value, target) => value.startsWith(target),
|
|
2692
|
-
not_starts_with: (value, target) => !value.startsWith(target),
|
|
2693
|
-
ends_with: (value, target) => value.endsWith(target),
|
|
2694
|
-
not_ends_with: (value, target) => !value.endsWith(target),
|
|
2695
|
-
is: (value, target) => value === target,
|
|
2696
|
-
is_not: (value, target) => value !== target
|
|
2697
|
-
};
|
|
2698
|
-
const numberHandlers = {
|
|
2699
|
-
equals: (value, target) => value === target,
|
|
2700
|
-
not_equals: (value, target) => value !== target,
|
|
2701
|
-
greater_than: (value, target) => value > target,
|
|
2702
|
-
less_than: (value, target) => value < target,
|
|
2703
|
-
greater_than_or_equal: (value, target) => value >= target,
|
|
2704
|
-
less_than_or_equal: (value, target) => value <= target
|
|
2705
|
-
};
|
|
2706
|
-
function toUnixSeconds(value) {
|
|
2707
|
-
return value instanceof Date ? Math.floor(value.getTime() / 1e3) : value;
|
|
2708
|
-
}
|
|
2709
|
-
function toStringValues(value) {
|
|
2710
|
-
if (typeof value === "string") return [value];
|
|
2711
|
-
if (Array.isArray(value) && value.every((item) => typeof item === "string")) return value;
|
|
2712
|
-
return null;
|
|
2713
|
-
}
|
|
2714
|
-
function isAnyOperator(operator) {
|
|
2715
|
-
return operator === "or" || operator === "any" || operator === "any_of" || operator.includes("any");
|
|
2716
|
-
}
|
|
2717
|
-
function matchesNested(row, value, operator) {
|
|
2718
|
-
if (value.type !== "nested") return true;
|
|
2719
|
-
const checks = value.value.map((filter) => matchesPowerSearchFilter(row, filter));
|
|
2720
|
-
if (checks.length === 0) return true;
|
|
2721
|
-
return isAnyOperator(operator) ? checks.some(Boolean) : checks.every(Boolean);
|
|
2722
|
-
}
|
|
2723
|
-
function matchesPowerSearchFilter(row, filter) {
|
|
2724
|
-
const fieldValue = row[filter.field];
|
|
2725
|
-
const { operator, value } = filter;
|
|
2726
|
-
switch (value.type) {
|
|
2727
|
-
case "empty":
|
|
2728
|
-
if (operator === "is_true") return Boolean(fieldValue) === true;
|
|
2729
|
-
if (operator === "is_false") return Boolean(fieldValue) === false;
|
|
2730
|
-
return true;
|
|
2731
|
-
case "string": {
|
|
2732
|
-
if (typeof fieldValue !== "string") return false;
|
|
2733
|
-
const handler = stringHandlers[operator];
|
|
2734
|
-
return handler ? handler(fieldValue.toLowerCase(), value.value.toLowerCase()) : true;
|
|
2735
|
-
}
|
|
2736
|
-
case "integer":
|
|
2737
|
-
case "float": {
|
|
2738
|
-
if (typeof fieldValue !== "number") return false;
|
|
2739
|
-
const handler = numberHandlers[operator];
|
|
2740
|
-
return handler ? handler(fieldValue, value.value) : true;
|
|
2741
|
-
}
|
|
2742
|
-
case "date_absolute": {
|
|
2743
|
-
if (!(fieldValue instanceof Date) && typeof fieldValue !== "number") return false;
|
|
2744
|
-
const stamp = toUnixSeconds(fieldValue);
|
|
2745
|
-
if (operator === "before") return stamp < value.unixSeconds;
|
|
2746
|
-
if (operator === "after") return stamp > value.unixSeconds;
|
|
2747
|
-
return true;
|
|
2748
|
-
}
|
|
2749
|
-
case "date_range": {
|
|
2750
|
-
if (!(fieldValue instanceof Date) && typeof fieldValue !== "number") return false;
|
|
2751
|
-
if (operator !== "between") return true;
|
|
2752
|
-
const now = Date.now() / 1e3;
|
|
2753
|
-
const stamp = toUnixSeconds(fieldValue);
|
|
2754
|
-
const start = resolveDateTimeRangePart(value.value.start, now);
|
|
2755
|
-
const end = resolveDateTimeRangePart(value.value.end, now);
|
|
2756
|
-
return stamp >= start && stamp <= end;
|
|
2757
|
-
}
|
|
2758
|
-
case "enum":
|
|
2759
|
-
if (typeof fieldValue !== "string") return false;
|
|
2760
|
-
if (operator === "is") return fieldValue === value.value;
|
|
2761
|
-
if (operator === "is_not") return fieldValue !== value.value;
|
|
2762
|
-
return true;
|
|
2763
|
-
case "enum_list":
|
|
2764
|
-
case "string_list": {
|
|
2765
|
-
const values = toStringValues(fieldValue);
|
|
2766
|
-
if (values == null) return false;
|
|
2767
|
-
if (operator === "is_any_of") return values.some((item) => value.value.includes(item));
|
|
2768
|
-
if (operator === "is_none_of") return values.every((item) => !value.value.includes(item));
|
|
2769
|
-
return true;
|
|
2770
|
-
}
|
|
2771
|
-
case "nested": return matchesNested(row, value, operator);
|
|
2772
|
-
case "time":
|
|
2773
|
-
case "date_relative":
|
|
2774
|
-
case "entity_list":
|
|
2775
|
-
case "custom": return true;
|
|
2776
|
-
}
|
|
2777
|
-
}
|
|
2778
|
-
function applyPowerSearchFilters(filters, data) {
|
|
2779
|
-
if (filters.length === 0) return [...data];
|
|
2780
|
-
return data.filter((row) => filters.every((filter) => matchesPowerSearchFilter(row, filter)));
|
|
2781
|
-
}
|
|
2782
|
-
function createPowerSearchConfig(definitions, configName) {
|
|
2783
|
-
return {
|
|
2784
|
-
config: {
|
|
2785
|
-
name: configName ?? "PowerSearchConfig",
|
|
2786
|
-
fields: definitions.map((definition) => buildPowerSearchField(definition))
|
|
2787
|
-
},
|
|
2788
|
-
applyFilters(filters, data) {
|
|
2789
|
-
return applyPowerSearchFilters(filters, data);
|
|
2790
|
-
}
|
|
2791
|
-
};
|
|
2792
|
-
}
|
|
2793
|
-
function usePowerSearchConfig(definitions, configName) {
|
|
2794
|
-
return createPowerSearchConfig(definitions, configName);
|
|
2795
|
-
}
|
|
2796
|
-
//#endregion
|
|
2797
|
-
export { searchPowerSearchFields as a, formatDateAbsolute as c, createPowerSearchLookup as d, completePowerSearchFilter as f, _sfc_main as i, formatDateAbsoluteCompact as l, createPowerSearchConfig as n, resolveEditorPlacement as o, usePowerSearchConfig as r, resolveOperatorLabel as s, applyPowerSearchFilters as t, formatFilterValue as u };
|