@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
|
@@ -0,0 +1,4829 @@
|
|
|
1
|
+
import { t as _sfc_main$13 } from "./Icon-Dk0jccgU.js";
|
|
2
|
+
import { i as useSize } from "./SizeContext-BbaF-SEx.js";
|
|
3
|
+
import { t as _sfc_main$14 } from "./Button-CvHeZGf1.js";
|
|
4
|
+
import { i as useLayerGutter } from "./context-M-er0-Rk.js";
|
|
5
|
+
import { t as useDismiss } from "./useDismiss-BKtyCwx4.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 _sfc_main$15 } from "./IconButton-BZgU_THt.js";
|
|
11
|
+
import { t as useInputStatusIcon } from "./useInputStatusIcon-BngSzjVd.js";
|
|
12
|
+
import { a as useAstryxLocale, o as useComponentMessages } from "./context-B8IEFCDR.js";
|
|
13
|
+
import { t as useOverflow } from "./useOverflow-GU0pxGaU.js";
|
|
14
|
+
import { t as useResolvedLabelHidden } from "./useResolvedLabelHidden-B2rlWiaI.js";
|
|
15
|
+
import { t as _sfc_main$16 } from "./Tooltip-CxzlUVN0.js";
|
|
16
|
+
import { t as _sfc_main$17 } from "./Heading-BFK3PftX.js";
|
|
17
|
+
import { t as useScrollbars } from "./useScrollbars-Ch0xqJWO.js";
|
|
18
|
+
import { t as _sfc_main$18 } from "./Text-D48QFTtL.js";
|
|
19
|
+
import { t as LazyBottomSheet } from "./lazyBottomSheet-Cmd-WMEE.js";
|
|
20
|
+
import { r as useCalendarSystem } from "./calendar-C7py_wtb.js";
|
|
21
|
+
import { r as formatCalendarInstant } from "./calendarFormat-_CEZIMZG.js";
|
|
22
|
+
import { t as _sfc_main$19 } from "./Calendar-CUMnYIhe.js";
|
|
23
|
+
import { t as _sfc_main$20 } from "./Field-d5R_kRMv.js";
|
|
24
|
+
import { t as useFieldPartStyling } from "./fieldParts-CuE5V12i.js";
|
|
25
|
+
import { n as _sfc_main$21, t as _sfc_main$22 } from "./ListItem-BlrEngDO.js";
|
|
26
|
+
import { n as _sfc_main$23, t as _sfc_main$24 } from "./CheckboxListItem-CKeQzQ0W.js";
|
|
27
|
+
import { t as _sfc_main$25 } from "./DateInput-MNNyi4XK.js";
|
|
28
|
+
import { t as tokenizerMessages } from "./tokenizer-C1y-55Ft.js";
|
|
29
|
+
import { l as powerSearchMessages, u as powerSearchSheetMessages } from "./loadCatalog-FwMzmCx1.js";
|
|
30
|
+
import { t as _sfc_main$26 } from "./DateRangeInput-DOHntScL.js";
|
|
31
|
+
import { t as _sfc_main$27 } from "./DateTimeInput-BaghFHW6.js";
|
|
32
|
+
import { t as _sfc_main$28 } from "./EmptyState-BGo1nrnT.js";
|
|
33
|
+
import { n as tokenNamingKey, t as _sfc_main$29 } from "./Token-C7Dt5ygK.js";
|
|
34
|
+
import { n as scrollOptionIntoView, r as useAnchoredListbox } from "./stillPointerGate-BbMABRyU.js";
|
|
35
|
+
import { t as _sfc_main$30 } from "./MultiSelector-MGEiRi1W.js";
|
|
36
|
+
import { n as resolveNumberInputCommit, t as _sfc_main$31 } from "./NumberInput-D4ECOHh_.js";
|
|
37
|
+
import { t as _sfc_main$32 } from "./Selector-BD0u-5Fy.js";
|
|
38
|
+
import { o as useTypeaheadMenu } from "./useTypeaheadMenuConfig-BT9Lwsu7.js";
|
|
39
|
+
import { a as _sfc_main$34, i as dismissSearchOnTouchDrag, n as useSheetPresentation, r as useTokenRemoveTap, t as _sfc_main$33 } from "./Tokenizer-D7ZCTbnf.js";
|
|
40
|
+
import { t as _sfc_main$35 } from "./TextInput-BLGEh7vE.js";
|
|
41
|
+
import { n as _sfc_main$36, t as _sfc_main$37 } from "./RadioListItem-CD7kUGlN.js";
|
|
42
|
+
import { t as _sfc_main$38 } from "./TimeInput-DcY4b3dg.js";
|
|
43
|
+
import { t as _sfc_main$39 } from "./Typeahead-Cs-46obm.js";
|
|
44
|
+
import { Fragment, Teleport, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createSlots, createTextVNode, createVNode, defineComponent, guardReactiveProps, h, mergeModels, mergeProps, nextTick, normalizeClass, normalizeProps, normalizeStyle, onMounted, openBlock, provide, reactive, ref, renderList, renderSlot, resolveComponent, resolveDynamicComponent, shallowRef, toDisplayString, toHandlers, unref, useAttrs, useId, useModel, useSlots, useTemplateRef, vShow, watch, withCtx, withDirectives, withModifiers } from "vue";
|
|
45
|
+
import "../styles/layer.css";
|
|
46
|
+
import "../styles/visually-hidden-utility.css";
|
|
47
|
+
import "../styles/typeahead.css";
|
|
48
|
+
import "../styles/power-search-sheet.css";
|
|
49
|
+
import "../styles/power-search.css";
|
|
50
|
+
//#region src/PowerSearch/complete.ts
|
|
51
|
+
function nestedChildren(partial) {
|
|
52
|
+
if (partial.children != null) return partial.children;
|
|
53
|
+
if (partial.value?.type === "nested") return partial.value.value;
|
|
54
|
+
return [];
|
|
55
|
+
}
|
|
56
|
+
function isFilled(value) {
|
|
57
|
+
switch (value.type) {
|
|
58
|
+
case "empty": return true;
|
|
59
|
+
case "string":
|
|
60
|
+
case "date_relative":
|
|
61
|
+
case "time":
|
|
62
|
+
case "enum":
|
|
63
|
+
case "custom": return value.value.trim() !== "";
|
|
64
|
+
case "string_list":
|
|
65
|
+
case "enum_list":
|
|
66
|
+
case "entity_list": return value.value.length > 0;
|
|
67
|
+
case "integer":
|
|
68
|
+
case "float": return Number.isFinite(value.value);
|
|
69
|
+
case "date_absolute": return Number.isFinite(value.unixSeconds);
|
|
70
|
+
case "date_range": return value.value.start != null && value.value.end != null;
|
|
71
|
+
case "nested": return value.value.length > 0;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/** 条件齐全才返回可保存的筛选。嵌套里有没填完的子条件时返回空。 */
|
|
75
|
+
function completePowerSearchFilter(partial, lookup) {
|
|
76
|
+
if (partial.field === "" || partial.operator == null || partial.operator === "") return null;
|
|
77
|
+
const operator = lookup.getOperator(partial.field, partial.operator);
|
|
78
|
+
if (operator == null) return null;
|
|
79
|
+
if (operator.value.type === "empty") return {
|
|
80
|
+
field: partial.field,
|
|
81
|
+
operator: partial.operator,
|
|
82
|
+
value: { type: "empty" },
|
|
83
|
+
isReadOnly: partial.isReadOnly
|
|
84
|
+
};
|
|
85
|
+
if (operator.value.type === "nested") {
|
|
86
|
+
const children = nestedChildren(partial);
|
|
87
|
+
if (children.length === 0) return null;
|
|
88
|
+
const complete = children.map((child) => completePowerSearchFilter(child, lookup));
|
|
89
|
+
if (complete.some((child) => child == null)) return null;
|
|
90
|
+
return {
|
|
91
|
+
field: partial.field,
|
|
92
|
+
operator: partial.operator,
|
|
93
|
+
value: {
|
|
94
|
+
type: "nested",
|
|
95
|
+
value: complete.filter((child) => child != null)
|
|
96
|
+
},
|
|
97
|
+
isReadOnly: partial.isReadOnly
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
if (partial.value == null || partial.value.type !== operator.value.type || !isFilled(partial.value)) return null;
|
|
101
|
+
return {
|
|
102
|
+
field: partial.field,
|
|
103
|
+
operator: partial.operator,
|
|
104
|
+
value: partial.value,
|
|
105
|
+
isReadOnly: partial.isReadOnly
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
//#endregion
|
|
109
|
+
//#region src/PowerSearch/config.ts
|
|
110
|
+
function createPowerSearchLookup(config) {
|
|
111
|
+
const fieldMap = /* @__PURE__ */ new Map();
|
|
112
|
+
const operatorMap = /* @__PURE__ */ new Map();
|
|
113
|
+
for (const field of config.fields) {
|
|
114
|
+
fieldMap.set(field.key, field);
|
|
115
|
+
const operators = /* @__PURE__ */ new Map();
|
|
116
|
+
for (const operator of field.operators) operators.set(operator.key, operator);
|
|
117
|
+
operatorMap.set(field.key, operators);
|
|
118
|
+
}
|
|
119
|
+
return {
|
|
120
|
+
config,
|
|
121
|
+
getField(key) {
|
|
122
|
+
return fieldMap.get(key);
|
|
123
|
+
},
|
|
124
|
+
getOperator(fieldKey, operatorKey) {
|
|
125
|
+
return operatorMap.get(fieldKey)?.get(operatorKey);
|
|
126
|
+
},
|
|
127
|
+
getDefaultOperator(fieldKey) {
|
|
128
|
+
const field = fieldMap.get(fieldKey);
|
|
129
|
+
if (field == null) return void 0;
|
|
130
|
+
if (field.defaultOperator) return operatorMap.get(fieldKey)?.get(field.defaultOperator) ?? field.operators[0];
|
|
131
|
+
return field.operators[0];
|
|
132
|
+
},
|
|
133
|
+
getVisibleFields() {
|
|
134
|
+
return config.fields;
|
|
135
|
+
},
|
|
136
|
+
getVisibleOperators(fieldKey) {
|
|
137
|
+
return fieldMap.get(fieldKey)?.operators ?? [];
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
//#endregion
|
|
142
|
+
//#region src/PowerSearch/range.ts
|
|
143
|
+
const SECONDS_BY_UNIT = {
|
|
144
|
+
second: 1,
|
|
145
|
+
minute: 60,
|
|
146
|
+
hour: 3600,
|
|
147
|
+
day: 86400,
|
|
148
|
+
week: 604800,
|
|
149
|
+
month: 2592e3,
|
|
150
|
+
year: 31536e3
|
|
151
|
+
};
|
|
152
|
+
/** 把绝对、当前和相对的区间端点折成同一时刻上的 Unix 秒。 */
|
|
153
|
+
function resolveDateTimeRangePart(part, nowSeconds = Date.now() / 1e3) {
|
|
154
|
+
switch (part.type) {
|
|
155
|
+
case "NOW": return Math.floor(nowSeconds);
|
|
156
|
+
case "ABSOLUTE": return part.unixSeconds;
|
|
157
|
+
case "RELATIVE": return Math.floor(nowSeconds - part.backValue * SECONDS_BY_UNIT[part.unit]);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
//#endregion
|
|
161
|
+
//#region src/PowerSearch/dates.ts
|
|
162
|
+
function pad$1(value) {
|
|
163
|
+
return String(value).padStart(2, "0");
|
|
164
|
+
}
|
|
165
|
+
function unixToIsoDate(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())}`;
|
|
168
|
+
const parts = new Intl.DateTimeFormat("en-US", {
|
|
169
|
+
timeZone,
|
|
170
|
+
year: "numeric",
|
|
171
|
+
month: "2-digit",
|
|
172
|
+
day: "2-digit"
|
|
173
|
+
}).formatToParts(date);
|
|
174
|
+
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"}`;
|
|
175
|
+
}
|
|
176
|
+
function unixToDateTimeLocal(unixSeconds, timeZone) {
|
|
177
|
+
const date = /* @__PURE__ */ new Date(unixSeconds * 1e3);
|
|
178
|
+
if (!timeZone) return `${date.getFullYear()}-${pad$1(date.getMonth() + 1)}-${pad$1(date.getDate())}T${pad$1(date.getHours())}:${pad$1(date.getMinutes())}`;
|
|
179
|
+
const parts = new Intl.DateTimeFormat("en-US", {
|
|
180
|
+
timeZone,
|
|
181
|
+
year: "numeric",
|
|
182
|
+
month: "2-digit",
|
|
183
|
+
day: "2-digit",
|
|
184
|
+
hour: "2-digit",
|
|
185
|
+
minute: "2-digit",
|
|
186
|
+
hourCycle: "h23"
|
|
187
|
+
}).formatToParts(date);
|
|
188
|
+
const read = (type) => parts.find((part) => part.type === type)?.value ?? "00";
|
|
189
|
+
return `${read("year")}-${read("month")}-${read("day")}T${read("hour")}:${read("minute")}`;
|
|
190
|
+
}
|
|
191
|
+
function dateTimeLocalToUnix(value, timeZone) {
|
|
192
|
+
if (!timeZone) return Math.floor(new Date(value).getTime() / 1e3);
|
|
193
|
+
const [datePart, timePart] = value.split("T");
|
|
194
|
+
const [year, month, day] = (datePart ?? "").split("-").map(Number);
|
|
195
|
+
const [hour, minute] = (timePart ?? "00:00").split(":").map(Number);
|
|
196
|
+
const utcGuess = Date.UTC(year ?? 1970, (month ?? 1) - 1, day ?? 1, hour ?? 0, minute ?? 0);
|
|
197
|
+
const offset = timeZoneOffset(new Date(utcGuess), timeZone);
|
|
198
|
+
return Math.floor((utcGuess - offset) / 1e3);
|
|
199
|
+
}
|
|
200
|
+
function timeZoneOffset(date, timeZone) {
|
|
201
|
+
const parts = new Intl.DateTimeFormat("en-US", {
|
|
202
|
+
timeZone,
|
|
203
|
+
year: "numeric",
|
|
204
|
+
month: "2-digit",
|
|
205
|
+
day: "2-digit",
|
|
206
|
+
hour: "2-digit",
|
|
207
|
+
minute: "2-digit",
|
|
208
|
+
second: "2-digit",
|
|
209
|
+
hourCycle: "h23"
|
|
210
|
+
}).formatToParts(date);
|
|
211
|
+
const read = (type) => Number(parts.find((part) => part.type === type)?.value ?? 0);
|
|
212
|
+
return Date.UTC(read("year"), read("month") - 1, read("day"), read("hour"), read("minute"), read("second")) - date.getTime();
|
|
213
|
+
}
|
|
214
|
+
function rangePartToIso(part, timeZone, nowSeconds = Date.now() / 1e3) {
|
|
215
|
+
return unixToIsoDate(resolveDateTimeRangePart(part, nowSeconds), timeZone);
|
|
216
|
+
}
|
|
217
|
+
//#endregion
|
|
218
|
+
//#region src/PowerSearch/dateZone.ts
|
|
219
|
+
/**
|
|
220
|
+
* 日期值读写用的时区。
|
|
221
|
+
*
|
|
222
|
+
* 只有一个日历日(`isDateOnly` 没写或为 true)的值,按 `timeZone` 里的那一天读和写,
|
|
223
|
+
* 以那一天的零点存;没给 `timeZone` 就是 UTC 的那一天,早先没带时区写入的值日子不变。
|
|
224
|
+
* 带时刻的值(`isDateOnly: false`)在 `timeZone` 里读写,没给就用查看者所在的时区,
|
|
225
|
+
* 这时返回 `undefined`(`Intl` 和 `Date` 默认就是查看者的时区)。
|
|
226
|
+
*/
|
|
227
|
+
function resolveDateZone(timeZone, isDateOnly) {
|
|
228
|
+
if (timeZone) return timeZone;
|
|
229
|
+
return isDateOnly ? "UTC" : void 0;
|
|
230
|
+
}
|
|
231
|
+
/** 这个运算符的绝对日期值是不是一个日历日(没写 `isDateOnly` 也算)。 */
|
|
232
|
+
function isDateOnlyOperator(operatorValue) {
|
|
233
|
+
return operatorValue.type === "date_absolute" && operatorValue.isDateOnly !== false;
|
|
234
|
+
}
|
|
235
|
+
/** 一个时刻在 `zone` 里是哪一天,写成选择框用的本地零点 `Date`。 */
|
|
236
|
+
function unixToPickerDate(unixSeconds, zone) {
|
|
237
|
+
const [year, month, day] = unixToIsoDate(unixSeconds, zone).split("-").map(Number);
|
|
238
|
+
return new Date(year ?? 1970, (month ?? 1) - 1, day ?? 1);
|
|
239
|
+
}
|
|
240
|
+
function pad(value) {
|
|
241
|
+
return String(value).padStart(2, "0");
|
|
242
|
+
}
|
|
243
|
+
function localIsoDate(date) {
|
|
244
|
+
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`;
|
|
245
|
+
}
|
|
246
|
+
/** 区间两端在 `zone` 里各是哪一天,读成日历上的本地日期。 */
|
|
247
|
+
function rangeToPickerRange(range, zone, nowSeconds = Date.now() / 1e3) {
|
|
248
|
+
return {
|
|
249
|
+
start: unixToPickerDate(resolveDateTimeRangePart(range.start, nowSeconds), zone),
|
|
250
|
+
end: unixToPickerDate(resolveDateTimeRangePart(range.end, nowSeconds), zone)
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
/** 日历上选的一段日子:`zone` 里起始日零点到结束日最后一刻。 */
|
|
254
|
+
function pickerRangeToRange(start, end, zone) {
|
|
255
|
+
return absoluteRange(localIsoDate(start), localIsoDate(end), zone);
|
|
256
|
+
}
|
|
257
|
+
/** 选择框选中的那一天,在 `zone` 里零点的时刻。 */
|
|
258
|
+
function pickerDateToUnix(date, zone) {
|
|
259
|
+
return dateTimeLocalToUnix(`${localIsoDate(date)}T00:00`, zone);
|
|
260
|
+
}
|
|
261
|
+
/** `YYYY-MM-DD` 这一天在 `zone` 里零点的时刻。 */
|
|
262
|
+
function isoDateToZonedUnix(iso, zone) {
|
|
263
|
+
return dateTimeLocalToUnix(`${iso}T00:00`, zone);
|
|
264
|
+
}
|
|
265
|
+
/** `YYYY-MM-DD` 这一天在 `zone` 里的最后一秒(夏令时的 23 或 25 小时也对)。 */
|
|
266
|
+
function isoDateEndToZonedUnix(iso, zone) {
|
|
267
|
+
const [year, month, day] = iso.split("-").map(Number);
|
|
268
|
+
const next = new Date(Date.UTC(year ?? 1970, (month ?? 1) - 1, (day ?? 1) + 1));
|
|
269
|
+
return isoDateToZonedUnix(`${next.getUTCFullYear()}-${pad(next.getUTCMonth() + 1)}-${pad(next.getUTCDate())}`, zone) - 1;
|
|
270
|
+
}
|
|
271
|
+
/** 两个 `YYYY-MM-DD` 之间的绝对区间:开始那天 `zone` 里的零点,到结束那天的最后一秒。 */
|
|
272
|
+
function absoluteRange(start, end, zone) {
|
|
273
|
+
return {
|
|
274
|
+
start: {
|
|
275
|
+
type: "ABSOLUTE",
|
|
276
|
+
unixSeconds: isoDateToZonedUnix(start, zone)
|
|
277
|
+
},
|
|
278
|
+
end: {
|
|
279
|
+
type: "ABSOLUTE",
|
|
280
|
+
unixSeconds: isoDateEndToZonedUnix(end, zone)
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
//#endregion
|
|
285
|
+
//#region src/PowerSearch/format.ts
|
|
286
|
+
function truncate(value, maxLength) {
|
|
287
|
+
return truncateCharacters(value, maxLength);
|
|
288
|
+
}
|
|
289
|
+
function enumLabel(value, values) {
|
|
290
|
+
return values.find((item) => item.value === value)?.label ?? value;
|
|
291
|
+
}
|
|
292
|
+
function formatNumber(value, locale, units) {
|
|
293
|
+
const formatted = new Intl.NumberFormat(locale).format(value);
|
|
294
|
+
return units ? `${formatted} ${units}` : formatted;
|
|
295
|
+
}
|
|
296
|
+
/** 带时刻的日期,例如 "Oct 30, 2026, 3:00 PM"。日期按 `calendar` 写,默认公历。 */
|
|
297
|
+
function formatDateAbsolute(unixSeconds, locale, timeZone, calendar = "gregory") {
|
|
298
|
+
return formatCalendarInstant(calendar, /* @__PURE__ */ new Date(unixSeconds * 1e3), {
|
|
299
|
+
year: "numeric",
|
|
300
|
+
month: "short",
|
|
301
|
+
day: "numeric",
|
|
302
|
+
hour: "numeric",
|
|
303
|
+
minute: "2-digit"
|
|
304
|
+
}, locale, timeZone || void 0);
|
|
305
|
+
}
|
|
306
|
+
/** 只有日期,例如 "Oct 30, 2026"。日期按 `calendar` 写,默认公历。 */
|
|
307
|
+
function formatDateAbsoluteCompact(unixSeconds, locale, timeZone, calendar = "gregory") {
|
|
308
|
+
return formatCalendarInstant(calendar, /* @__PURE__ */ new Date(unixSeconds * 1e3), {
|
|
309
|
+
year: "numeric",
|
|
310
|
+
month: "short",
|
|
311
|
+
day: "numeric"
|
|
312
|
+
}, locale, timeZone || void 0);
|
|
313
|
+
}
|
|
314
|
+
function joinOrCount(labels, maxLength, countLabel) {
|
|
315
|
+
if (labels.length === 0) return "";
|
|
316
|
+
if (labels.length === 1) return truncate(labels[0] ?? "", maxLength);
|
|
317
|
+
const joined = labels.join(", ");
|
|
318
|
+
if (characterCount(joined) <= maxLength) return joined;
|
|
319
|
+
return countLabel(labels.length);
|
|
320
|
+
}
|
|
321
|
+
function formatFilterValue(operatorValue, filterValue, maxLength, messages, locale, timeZone, calendar = "gregory") {
|
|
322
|
+
switch (filterValue.type) {
|
|
323
|
+
case "empty": return "";
|
|
324
|
+
case "string": return truncate(filterValue.value, maxLength);
|
|
325
|
+
case "integer": return formatNumber(filterValue.value, locale, operatorValue.type === "integer" ? operatorValue.units : void 0);
|
|
326
|
+
case "float": return formatNumber(filterValue.value, locale, operatorValue.type === "float" ? operatorValue.units : void 0);
|
|
327
|
+
case "enum": return truncate(operatorValue.type === "enum" ? enumLabel(filterValue.value, operatorValue.values) : filterValue.value, maxLength);
|
|
328
|
+
case "string_list": return joinOrCount(filterValue.value, maxLength, messages.itemsCount);
|
|
329
|
+
case "enum_list": return joinOrCount(operatorValue.type === "enum_list" ? filterValue.value.map((value) => enumLabel(value, operatorValue.values)) : filterValue.value, maxLength, messages.itemsCount);
|
|
330
|
+
case "entity_list": return joinOrCount(filterValue.value.map((entity) => entity.label), maxLength, messages.entitiesCount);
|
|
331
|
+
case "time": return filterValue.value;
|
|
332
|
+
case "date_absolute": return truncate(isDateOnlyOperator(operatorValue) ? formatDateAbsoluteCompact(filterValue.unixSeconds, locale, resolveDateZone(timeZone, true), calendar) : formatDateAbsolute(filterValue.unixSeconds, locale, timeZone, calendar), maxLength);
|
|
333
|
+
case "date_relative": return filterValue.value;
|
|
334
|
+
case "date_range": return messages.dateRange;
|
|
335
|
+
case "custom": return truncate(operatorValue.type === "custom" ? operatorValue.getString(filterValue.value) : filterValue.value, maxLength);
|
|
336
|
+
case "nested": return messages.filtersCount(filterValue.value.length);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
//#endregion
|
|
340
|
+
//#region src/PowerSearch/operators.ts
|
|
341
|
+
const OPERATOR_MESSAGE_KEYS = {
|
|
342
|
+
contains: "contains",
|
|
343
|
+
notContains: "notContains",
|
|
344
|
+
not_contains: "notContains",
|
|
345
|
+
startsWith: "startsWith",
|
|
346
|
+
starts_with: "startsWith",
|
|
347
|
+
notStartsWith: "notStartsWith",
|
|
348
|
+
not_starts_with: "notStartsWith",
|
|
349
|
+
endsWith: "endsWith",
|
|
350
|
+
ends_with: "endsWith",
|
|
351
|
+
notEndsWith: "notEndsWith",
|
|
352
|
+
not_ends_with: "notEndsWith",
|
|
353
|
+
is: "is",
|
|
354
|
+
isNot: "isNot",
|
|
355
|
+
is_not: "isNot",
|
|
356
|
+
equals: "equals",
|
|
357
|
+
notEquals: "notEquals",
|
|
358
|
+
not_equals: "notEquals",
|
|
359
|
+
greaterThan: "greaterThan",
|
|
360
|
+
greater_than: "greaterThan",
|
|
361
|
+
lessThan: "lessThan",
|
|
362
|
+
less_than: "lessThan",
|
|
363
|
+
greaterThanOrEqual: "greaterThanOrEqual",
|
|
364
|
+
greater_than_or_equal: "greaterThanOrEqual",
|
|
365
|
+
lessThanOrEqual: "lessThanOrEqual",
|
|
366
|
+
less_than_or_equal: "lessThanOrEqual",
|
|
367
|
+
before: "before",
|
|
368
|
+
after: "after",
|
|
369
|
+
between: "between",
|
|
370
|
+
isTrue: "isTrue",
|
|
371
|
+
is_true: "isTrue",
|
|
372
|
+
isFalse: "isFalse",
|
|
373
|
+
is_false: "isFalse",
|
|
374
|
+
isAnyOf: "isAnyOf",
|
|
375
|
+
is_any_of: "isAnyOf",
|
|
376
|
+
isNoneOf: "isNoneOf",
|
|
377
|
+
is_none_of: "isNoneOf"
|
|
378
|
+
};
|
|
379
|
+
function resolveOperatorLabel(operator, messages) {
|
|
380
|
+
if ("label" in operator && operator.label != null) return operator.label;
|
|
381
|
+
const raw = operator.i18nKey ?? "";
|
|
382
|
+
const leaf = raw.split(".").pop() ?? raw;
|
|
383
|
+
const key = OPERATOR_MESSAGE_KEYS[leaf] ?? OPERATOR_MESSAGE_KEYS[raw];
|
|
384
|
+
return key ? messages.operators[key] : leaf;
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* 编辑器宽度取外层宽度,再夹在 400 到 720 之间。
|
|
388
|
+
* 视口放不下 400 时,下限让给视口。只有被 720 压窄时,才改贴打开控件更近的外缘。
|
|
389
|
+
*/
|
|
390
|
+
function resolveEditorPlacement(input) {
|
|
391
|
+
const fallback = input.viewportInset ?? 16;
|
|
392
|
+
const inlineStart = input.inlineStart ?? fallback;
|
|
393
|
+
const inlineEnd = input.inlineEnd ?? fallback;
|
|
394
|
+
const blockInset = input.blockInset ?? fallback;
|
|
395
|
+
const available = Math.max(0, input.viewportWidth - inlineStart - inlineEnd);
|
|
396
|
+
const floor = Math.min(400, available);
|
|
397
|
+
const ceiling = Math.min(720, available);
|
|
398
|
+
let width = input.outer.width;
|
|
399
|
+
if (width < floor) width = floor;
|
|
400
|
+
if (width > ceiling) width = ceiling;
|
|
401
|
+
const capped = width + .5 < input.outer.width;
|
|
402
|
+
let edge;
|
|
403
|
+
if (!capped) edge = input.direction === "rtl" ? "right" : "left";
|
|
404
|
+
else {
|
|
405
|
+
const gapLeft = input.control.left - input.outer.left;
|
|
406
|
+
const gapRight = input.outer.right - input.control.right;
|
|
407
|
+
if (gapLeft < gapRight) edge = "left";
|
|
408
|
+
else if (gapRight < gapLeft) edge = "right";
|
|
409
|
+
else edge = input.direction === "rtl" ? "right" : "left";
|
|
410
|
+
}
|
|
411
|
+
let left = edge === "left" ? input.outer.left : input.outer.right - width;
|
|
412
|
+
const maxLeft = input.viewportWidth - inlineEnd - width;
|
|
413
|
+
if (left < inlineStart) left = inlineStart;
|
|
414
|
+
if (left > maxLeft) left = Math.max(inlineStart, maxLeft);
|
|
415
|
+
const gap = 4;
|
|
416
|
+
const estimatedHeight = 280;
|
|
417
|
+
let top = input.anchorBottom + gap;
|
|
418
|
+
if (top + estimatedHeight > input.viewportHeight - blockInset && input.anchorTop - gap - estimatedHeight > blockInset) top = input.anchorTop - gap - estimatedHeight;
|
|
419
|
+
return {
|
|
420
|
+
width,
|
|
421
|
+
capped,
|
|
422
|
+
edge,
|
|
423
|
+
top,
|
|
424
|
+
left
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
//#endregion
|
|
428
|
+
//#region src/PowerSearch/menuStyle.ts
|
|
429
|
+
/** 结果数的显示文字:数字走本地化的“N 个结果”,字符串原样,没给就空。 */
|
|
430
|
+
function resultCountText(count, format) {
|
|
431
|
+
if (count == null) return "";
|
|
432
|
+
return typeof count === "number" ? format(count) : count;
|
|
433
|
+
}
|
|
434
|
+
/** 菜单宽度固定时,宽度、最小宽度和最大宽度都锁在同一个值上,且不超过视口上限。 */
|
|
435
|
+
function menuStyleWithWidth(base, menuWidth) {
|
|
436
|
+
if (menuWidth == null) return base;
|
|
437
|
+
const width = `min(${menuWidth}px, var(--astryx-layer-max-inline-size, calc(100vw - 32px)))`;
|
|
438
|
+
return {
|
|
439
|
+
...base,
|
|
440
|
+
width,
|
|
441
|
+
minWidth: width,
|
|
442
|
+
maxWidth: width
|
|
443
|
+
};
|
|
444
|
+
}
|
|
445
|
+
//#endregion
|
|
446
|
+
//#region src/PowerSearch/formatTokenText.ts
|
|
447
|
+
/** 筛选标签的文字:字段和运算符由一条文案拼成,语言可以调换顺序和标点。没有运算符文字时只显示字段。 */
|
|
448
|
+
function formatTokenLabel(messages, fieldLabel, operatorLabel) {
|
|
449
|
+
return operatorLabel === "" ? fieldLabel : messages.token.fieldOperator(fieldLabel, operatorLabel);
|
|
450
|
+
}
|
|
451
|
+
/** 筛选标签的全文:「字段: 运算符」和值,由一条文案拼成。 */
|
|
452
|
+
function formatTokenText(messages, label, value) {
|
|
453
|
+
return messages.token.labelValue(label, value);
|
|
454
|
+
}
|
|
455
|
+
const LABEL_MARK = "";
|
|
456
|
+
const VALUE_MARK = "";
|
|
457
|
+
/**
|
|
458
|
+
* 语言是不是把全文写成「标签、空格、值」。只有这样,标签才能把标签和加粗的值分成两段显示,
|
|
459
|
+
* 读起来仍是给它命名的那句全文。
|
|
460
|
+
*/
|
|
461
|
+
function tokenTextKeepsParts(messages) {
|
|
462
|
+
return new RegExp(`^${LABEL_MARK}\\s+${VALUE_MARK}$`).test(formatTokenText(messages, LABEL_MARK, VALUE_MARK));
|
|
463
|
+
}
|
|
464
|
+
//#endregion
|
|
465
|
+
//#region src/PowerSearch/PowerSearchToken.vue
|
|
466
|
+
const _hoisted_1$10 = {
|
|
467
|
+
key: 0,
|
|
468
|
+
class: "astryx-power-search-token-value"
|
|
469
|
+
};
|
|
470
|
+
const _hoisted_2$10 = ["id"];
|
|
471
|
+
const _sfc_main$12 = /*@__PURE__*/ defineComponent({
|
|
472
|
+
name: "AstryxPowerSearchToken",
|
|
473
|
+
__name: "PowerSearchToken",
|
|
474
|
+
props: {
|
|
475
|
+
fieldLabel: {},
|
|
476
|
+
operator: {},
|
|
477
|
+
filter: {},
|
|
478
|
+
maxLength: {},
|
|
479
|
+
messages: {},
|
|
480
|
+
locale: {},
|
|
481
|
+
timeZone: {},
|
|
482
|
+
size: {},
|
|
483
|
+
disabled: { type: Boolean },
|
|
484
|
+
removable: { type: Boolean },
|
|
485
|
+
opensEditor: { type: Boolean },
|
|
486
|
+
expanded: { type: Boolean },
|
|
487
|
+
nameId: {},
|
|
488
|
+
displayOnly: { type: Boolean }
|
|
489
|
+
},
|
|
490
|
+
emits: ["activate", "remove"],
|
|
491
|
+
setup(__props, { emit: __emit }) {
|
|
492
|
+
const props = __props;
|
|
493
|
+
const emit = __emit;
|
|
494
|
+
const calendar = useCalendarSystem(void 0, "PowerSearch");
|
|
495
|
+
const operatorLabel = computed(() => resolveOperatorLabel(props.operator, props.messages));
|
|
496
|
+
const tokenLabel = computed(() => formatTokenLabel(props.messages, props.fieldLabel, operatorLabel.value));
|
|
497
|
+
const valueText = computed(() => {
|
|
498
|
+
const room = Math.max(props.maxLength - characterCount(props.fieldLabel) - characterCount(operatorLabel.value), 10);
|
|
499
|
+
return formatFilterValue(props.operator.value, props.filter.value, room, props.messages, props.locale, props.timeZone, calendar.value);
|
|
500
|
+
});
|
|
501
|
+
/** 标签的全部可见文字:字段、运算符和值。按钮、删除按钮和编辑器都按它命名,同一字段的两个条件读出来不再一样。 */
|
|
502
|
+
const visibleText = computed(() => valueText.value ? formatTokenText(props.messages, tokenLabel.value, valueText.value) : tokenLabel.value);
|
|
503
|
+
/** 语言把全文写成「标签 值」以外的形状时,标签上不再把值单独加粗,整句作为一段文字显示。 */
|
|
504
|
+
const showsParts = computed(() => !valueText.value || tokenTextKeepsParts(props.messages));
|
|
505
|
+
provide(tokenNamingKey, computed(() => ({
|
|
506
|
+
actionName: visibleText.value,
|
|
507
|
+
removeName: visibleText.value
|
|
508
|
+
})));
|
|
509
|
+
return (_ctx, _cache) => {
|
|
510
|
+
return openBlock(), createBlock(_sfc_main$29, mergeProps({
|
|
511
|
+
label: showsParts.value ? tokenLabel.value : visibleText.value,
|
|
512
|
+
size: __props.size,
|
|
513
|
+
disabled: __props.disabled,
|
|
514
|
+
removable: __props.removable,
|
|
515
|
+
"aria-haspopup": __props.opensEditor ? "dialog" : void 0,
|
|
516
|
+
"aria-expanded": __props.opensEditor ? Boolean(__props.expanded) : void 0
|
|
517
|
+
}, toHandlers(__props.displayOnly ? {} : { click: () => emit("activate") }), { onRemove: _cache[0] || (_cache[0] = ($event) => emit("remove")) }), createSlots({ _: 2 }, [showsParts.value && valueText.value || __props.nameId ? {
|
|
518
|
+
name: "end",
|
|
519
|
+
fn: withCtx(() => [showsParts.value && valueText.value ? (openBlock(), createElementBlock("span", _hoisted_1$10, toDisplayString(valueText.value), 1)) : createCommentVNode("v-if", true), __props.nameId ? (openBlock(), createElementBlock("span", {
|
|
520
|
+
key: 1,
|
|
521
|
+
id: __props.nameId,
|
|
522
|
+
hidden: ""
|
|
523
|
+
}, toDisplayString(visibleText.value), 9, _hoisted_2$10)) : createCommentVNode("v-if", true)]),
|
|
524
|
+
key: "0"
|
|
525
|
+
} : void 0]), 1040, [
|
|
526
|
+
"label",
|
|
527
|
+
"size",
|
|
528
|
+
"disabled",
|
|
529
|
+
"removable",
|
|
530
|
+
"aria-haspopup",
|
|
531
|
+
"aria-expanded"
|
|
532
|
+
]);
|
|
533
|
+
};
|
|
534
|
+
}
|
|
535
|
+
});
|
|
536
|
+
//#endregion
|
|
537
|
+
//#region src/PowerSearch/PowerSearchFilterToken.vue
|
|
538
|
+
const _sfc_main$11 = /*@__PURE__*/ defineComponent({
|
|
539
|
+
name: "AstryxPowerSearchFilterToken",
|
|
540
|
+
inheritAttrs: false,
|
|
541
|
+
__name: "PowerSearchFilterToken",
|
|
542
|
+
props: {
|
|
543
|
+
config: {},
|
|
544
|
+
lookup: {},
|
|
545
|
+
filter: {},
|
|
546
|
+
maxLength: {},
|
|
547
|
+
messages: {},
|
|
548
|
+
locale: {},
|
|
549
|
+
timeZone: {},
|
|
550
|
+
size: {},
|
|
551
|
+
disabled: { type: Boolean },
|
|
552
|
+
removable: { type: Boolean },
|
|
553
|
+
displayOnly: { type: Boolean },
|
|
554
|
+
custom: {}
|
|
555
|
+
},
|
|
556
|
+
emits: ["activate", "remove"],
|
|
557
|
+
setup(__props, { emit: __emit }) {
|
|
558
|
+
/**
|
|
559
|
+
* 一个条件的标签:调用方的 `token` 插槽优先,其次 `components[type].token`,最后是内置标签。
|
|
560
|
+
* 行内字段和底部弹层呈现的字段共用;`displayOnly` 时只展示,不交出点击和删除的回调。
|
|
561
|
+
* 其余属性(命名用的 aria 属性等)落到内置标签上。
|
|
562
|
+
*/
|
|
563
|
+
const props = __props;
|
|
564
|
+
const emit = __emit;
|
|
565
|
+
const field = computed(() => props.lookup.getField(props.filter.field));
|
|
566
|
+
const operator = computed(() => props.lookup.getOperator(props.filter.field, props.filter.operator));
|
|
567
|
+
const tokenProps = computed(() => ({
|
|
568
|
+
config: props.config,
|
|
569
|
+
filter: props.filter,
|
|
570
|
+
field: field.value,
|
|
571
|
+
operator: operator.value,
|
|
572
|
+
maxLength: props.maxLength,
|
|
573
|
+
disabled: props.disabled,
|
|
574
|
+
...props.displayOnly ? {} : {
|
|
575
|
+
onClick: () => emit("activate"),
|
|
576
|
+
onRemove: () => emit("remove")
|
|
577
|
+
}
|
|
578
|
+
}));
|
|
579
|
+
return (_ctx, _cache) => {
|
|
580
|
+
return renderSlot(_ctx.$slots, "token", normalizeProps(guardReactiveProps(tokenProps.value)), () => [__props.custom ? (openBlock(), createBlock(resolveDynamicComponent(__props.custom), normalizeProps(mergeProps({ key: 0 }, tokenProps.value)), null, 16)) : field.value && operator.value ? (openBlock(), createBlock(_sfc_main$12, mergeProps({ key: 1 }, _ctx.$attrs, {
|
|
581
|
+
"field-label": field.value.label,
|
|
582
|
+
operator: operator.value,
|
|
583
|
+
filter: __props.filter,
|
|
584
|
+
"max-length": __props.maxLength,
|
|
585
|
+
messages: __props.messages,
|
|
586
|
+
locale: __props.locale,
|
|
587
|
+
"time-zone": __props.timeZone,
|
|
588
|
+
size: __props.size,
|
|
589
|
+
disabled: __props.disabled,
|
|
590
|
+
removable: __props.removable,
|
|
591
|
+
"display-only": __props.displayOnly,
|
|
592
|
+
onActivate: _cache[0] || (_cache[0] = ($event) => emit("activate")),
|
|
593
|
+
onRemove: _cache[1] || (_cache[1] = ($event) => emit("remove"))
|
|
594
|
+
}), null, 16, [
|
|
595
|
+
"field-label",
|
|
596
|
+
"operator",
|
|
597
|
+
"filter",
|
|
598
|
+
"max-length",
|
|
599
|
+
"messages",
|
|
600
|
+
"locale",
|
|
601
|
+
"time-zone",
|
|
602
|
+
"size",
|
|
603
|
+
"disabled",
|
|
604
|
+
"removable",
|
|
605
|
+
"display-only"
|
|
606
|
+
])) : createCommentVNode("v-if", true)]);
|
|
607
|
+
};
|
|
608
|
+
}
|
|
609
|
+
});
|
|
610
|
+
//#endregion
|
|
611
|
+
//#region src/PowerSearch/menuPresentation.ts
|
|
612
|
+
function powerSearchGroupLabel(entries, index) {
|
|
613
|
+
const group = entries[index]?.item.auxiliaryData?.group;
|
|
614
|
+
if (group == null || group === "") return void 0;
|
|
615
|
+
return group !== (index > 0 ? entries[index - 1]?.item.auxiliaryData?.group : void 0) ? group : void 0;
|
|
616
|
+
}
|
|
617
|
+
function powerSearchItemIcon(item, lookup) {
|
|
618
|
+
const data = item.auxiliaryData;
|
|
619
|
+
const type = (data?.operatorKey ? lookup.getOperator(data.fieldKey, data.operatorKey) : void 0)?.value.type;
|
|
620
|
+
if (type === "date_absolute" || type === "date_range" || type === "date_relative") return "calendar";
|
|
621
|
+
if (type === "time") return "clock";
|
|
622
|
+
if (type === "enum" || type === "enum_list") return "funnel";
|
|
623
|
+
return "search";
|
|
624
|
+
}
|
|
625
|
+
//#endregion
|
|
626
|
+
//#region src/PowerSearch/PowerSearchListbox.vue
|
|
627
|
+
const _hoisted_1$9 = [
|
|
628
|
+
"id",
|
|
629
|
+
"aria-label",
|
|
630
|
+
"data-placement"
|
|
631
|
+
];
|
|
632
|
+
const _hoisted_2$9 = {
|
|
633
|
+
class: "astryx-typeahead-menu",
|
|
634
|
+
role: "presentation"
|
|
635
|
+
};
|
|
636
|
+
const _hoisted_3$8 = {
|
|
637
|
+
key: 0,
|
|
638
|
+
class: "astryx-typeahead-state"
|
|
639
|
+
};
|
|
640
|
+
const _hoisted_4$6 = {
|
|
641
|
+
key: 1,
|
|
642
|
+
class: "astryx-typeahead-options",
|
|
643
|
+
role: "presentation"
|
|
644
|
+
};
|
|
645
|
+
const _hoisted_5$5 = {
|
|
646
|
+
key: 0,
|
|
647
|
+
class: "astryx-power-search-menu-group"
|
|
648
|
+
};
|
|
649
|
+
const _hoisted_6$4 = [
|
|
650
|
+
"id",
|
|
651
|
+
"aria-selected",
|
|
652
|
+
"data-option-id",
|
|
653
|
+
"onMouseenter",
|
|
654
|
+
"onClick"
|
|
655
|
+
];
|
|
656
|
+
const _hoisted_7$3 = { class: "astryx-typeahead-option-copy" };
|
|
657
|
+
const _hoisted_8$1 = { class: "astryx-typeahead-option-label" };
|
|
658
|
+
const _hoisted_9$1 = {
|
|
659
|
+
key: 0,
|
|
660
|
+
class: "astryx-typeahead-option-description"
|
|
661
|
+
};
|
|
662
|
+
const _sfc_main$10 = /*@__PURE__*/ defineComponent({
|
|
663
|
+
name: "AstryxPowerSearchListbox",
|
|
664
|
+
__name: "PowerSearchListbox",
|
|
665
|
+
props: {
|
|
666
|
+
id: {},
|
|
667
|
+
isOpen: { type: Boolean },
|
|
668
|
+
entries: {},
|
|
669
|
+
activeIndex: {},
|
|
670
|
+
label: {},
|
|
671
|
+
emptyText: {},
|
|
672
|
+
placement: {},
|
|
673
|
+
menuStyle: {},
|
|
674
|
+
lookup: {}
|
|
675
|
+
},
|
|
676
|
+
emits: ["highlight", "pick"],
|
|
677
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
678
|
+
const props = __props;
|
|
679
|
+
const emit = __emit;
|
|
680
|
+
const listboxRef = useTemplateRef("listboxRef");
|
|
681
|
+
useScrollbars(listboxRef);
|
|
682
|
+
watch(() => props.activeIndex, (index) => {
|
|
683
|
+
if (!props.isOpen || index < 0) return;
|
|
684
|
+
nextTick(() => scrollOptionIntoView(listboxRef.value, props.entries[index]?.id));
|
|
685
|
+
});
|
|
686
|
+
function onHover(index) {
|
|
687
|
+
if (!props.entries[index]?.disabled) emit("highlight", index);
|
|
688
|
+
}
|
|
689
|
+
__expose({ element: listboxRef });
|
|
690
|
+
return (_ctx, _cache) => {
|
|
691
|
+
return openBlock(), createBlock(Teleport, { to: "body" }, [withDirectives(createElementVNode("div", {
|
|
692
|
+
id: __props.id,
|
|
693
|
+
ref_key: "listboxRef",
|
|
694
|
+
ref: listboxRef,
|
|
695
|
+
class: "astryx-typeahead-listbox astryx-layer",
|
|
696
|
+
role: "listbox",
|
|
697
|
+
"aria-label": __props.label,
|
|
698
|
+
"data-placement": __props.placement,
|
|
699
|
+
style: normalizeStyle(__props.menuStyle),
|
|
700
|
+
tabindex: "-1"
|
|
701
|
+
}, [createElementVNode("div", _hoisted_2$9, [__props.entries.length === 0 ? (openBlock(), createElementBlock("div", _hoisted_3$8, toDisplayString(__props.emptyText), 1)) : (openBlock(), createElementBlock("div", _hoisted_4$6, [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.entries, (entry, index) => {
|
|
702
|
+
return openBlock(), createElementBlock(Fragment, { key: entry.id }, [
|
|
703
|
+
unref(powerSearchGroupLabel)(__props.entries, index) ? (openBlock(), createElementBlock("div", _hoisted_5$5, toDisplayString(unref(powerSearchGroupLabel)(__props.entries, index)), 1)) : createCommentVNode("v-if", true),
|
|
704
|
+
createCommentVNode(" eslint-disable-next-line vue-a11y/click-events-have-key-events, vue-a11y/mouse-events-have-key-events -- 选项不进 Tab 序。 "),
|
|
705
|
+
createElementVNode("div", {
|
|
706
|
+
id: `${__props.id}-option-${index}`,
|
|
707
|
+
class: normalizeClass(["astryx-typeahead-option", {
|
|
708
|
+
"is-active": index === __props.activeIndex,
|
|
709
|
+
"is-disabled": entry.disabled
|
|
710
|
+
}]),
|
|
711
|
+
role: "option",
|
|
712
|
+
"aria-selected": index === __props.activeIndex ? "true" : "false",
|
|
713
|
+
"data-option-id": entry.id,
|
|
714
|
+
tabindex: "-1",
|
|
715
|
+
onMousedown: _cache[0] || (_cache[0] = withModifiers(() => {}, ["prevent"])),
|
|
716
|
+
onMouseenter: ($event) => onHover(index),
|
|
717
|
+
onClick: ($event) => emit("pick", entry.item)
|
|
718
|
+
}, [createVNode(_sfc_main$13, {
|
|
719
|
+
icon: unref(powerSearchItemIcon)(entry.item, __props.lookup),
|
|
720
|
+
size: "sm"
|
|
721
|
+
}, null, 8, ["icon"]), createElementVNode("span", _hoisted_7$3, [createElementVNode("span", _hoisted_8$1, toDisplayString(entry.label), 1), entry.description ? (openBlock(), createElementBlock("span", _hoisted_9$1, toDisplayString(entry.description), 1)) : createCommentVNode("v-if", true)])], 42, _hoisted_6$4)
|
|
722
|
+
], 64);
|
|
723
|
+
}), 128))]))])], 12, _hoisted_1$9), [[vShow, __props.isOpen]])]);
|
|
724
|
+
};
|
|
725
|
+
}
|
|
726
|
+
});
|
|
727
|
+
//#endregion
|
|
728
|
+
//#region src/PowerSearch/sheetFilterIdentity.ts
|
|
729
|
+
/** 字段名或别名里含有搜索词(已转小写)就算匹配;空搜索词匹配所有字段。 */
|
|
730
|
+
function fieldMatchesQuery(field, normalizedQuery) {
|
|
731
|
+
if (normalizedQuery === "") return true;
|
|
732
|
+
if (field.label.toLowerCase().includes(normalizedQuery)) return true;
|
|
733
|
+
return field.typeaheadAliases?.some((alias) => alias.toLowerCase().includes(normalizedQuery)) ?? false;
|
|
734
|
+
}
|
|
735
|
+
function stableSerialize(value) {
|
|
736
|
+
if (Array.isArray(value)) return `[${value.map(stableSerialize).join(",")}]`;
|
|
737
|
+
if (value != null && typeof value === "object") return `{${Object.entries(value).sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0).map(([key, entry]) => `${JSON.stringify(key)}:${stableSerialize(entry)}`).join(",")}}`;
|
|
738
|
+
return JSON.stringify(value) ?? "undefined";
|
|
739
|
+
}
|
|
740
|
+
/** 条件的结构快照,和键的顺序无关;父组件每次改动都克隆一份值时,靠它认出是同一个条件。 */
|
|
741
|
+
function filterSignature(filter) {
|
|
742
|
+
return stableSerialize({
|
|
743
|
+
field: filter.field,
|
|
744
|
+
operator: filter.operator,
|
|
745
|
+
value: filter.value,
|
|
746
|
+
isReadOnly: filter.isReadOnly ?? false
|
|
747
|
+
});
|
|
748
|
+
}
|
|
749
|
+
/**
|
|
750
|
+
* 给「筛选条件」列表的每一行一个稳定编号,父组件重新排序、删掉上面一行或克隆值时,
|
|
751
|
+
* 行还是那一行(焦点也不丢)。见过的对象沿用编号;新对象认领上一轮签名相同、
|
|
752
|
+
* 还没人认领的编号;都不是就发新号。两个一样的条件按先后区分。每次渲染用当前列表调一次 `next`。
|
|
753
|
+
*/
|
|
754
|
+
function createFilterIdentities() {
|
|
755
|
+
const byObject = /* @__PURE__ */ new WeakMap();
|
|
756
|
+
let previousBySignature = /* @__PURE__ */ new Map();
|
|
757
|
+
let nextId = 0;
|
|
758
|
+
return { next(filters) {
|
|
759
|
+
const used = /* @__PURE__ */ new Set();
|
|
760
|
+
const ids = filters.map((filter) => {
|
|
761
|
+
const known = byObject.get(filter);
|
|
762
|
+
if (known == null || used.has(known)) return null;
|
|
763
|
+
used.add(known);
|
|
764
|
+
return known;
|
|
765
|
+
});
|
|
766
|
+
const bySignature = /* @__PURE__ */ new Map();
|
|
767
|
+
filters.forEach((filter, index) => {
|
|
768
|
+
const signature = filterSignature(filter);
|
|
769
|
+
let id = ids[index];
|
|
770
|
+
if (id == null) {
|
|
771
|
+
id = previousBySignature.get(signature)?.find((candidate) => !used.has(candidate)) ?? nextId++;
|
|
772
|
+
used.add(id);
|
|
773
|
+
byObject.set(filter, id);
|
|
774
|
+
ids[index] = id;
|
|
775
|
+
}
|
|
776
|
+
bySignature.set(signature, [...bySignature.get(signature) ?? [], id]);
|
|
777
|
+
});
|
|
778
|
+
previousBySignature = bySignature;
|
|
779
|
+
return ids;
|
|
780
|
+
} };
|
|
781
|
+
}
|
|
782
|
+
/**
|
|
783
|
+
* 父组件可能已经重排、克隆或删掉了打开时的那个条件,找回它现在的位置:先按对象,
|
|
784
|
+
* 再看原来的位置是否还是结构相同的条件,最后在全表里找唯一的结构匹配。
|
|
785
|
+
* 找不到或有歧义时返回 null,免得改到别的条件上。
|
|
786
|
+
*/
|
|
787
|
+
function resolveFilterIdentityIndex(filters, sourceFilter, sourceSignature, preferredIndex) {
|
|
788
|
+
const identityIndex = filters.indexOf(sourceFilter);
|
|
789
|
+
if (identityIndex >= 0) return identityIndex;
|
|
790
|
+
const preferred = filters[preferredIndex];
|
|
791
|
+
if (preferred != null && filterSignature(preferred) === sourceSignature) return preferredIndex;
|
|
792
|
+
const matching = filters.flatMap((filter, index) => filterSignature(filter) === sourceSignature ? [index] : []);
|
|
793
|
+
return matching.length === 1 ? matching[0] : null;
|
|
794
|
+
}
|
|
795
|
+
/** 删掉 `removedIndex` 那一行后,焦点落到最近的、还能点的一行上,距离相同时选后面那行。 */
|
|
796
|
+
function nearestEditableIndex(nextFilters, removedIndex, isRowButton = (filter) => !filter.isReadOnly) {
|
|
797
|
+
let nearest;
|
|
798
|
+
nextFilters.forEach((filter, candidate) => {
|
|
799
|
+
if (!isRowButton(filter)) return;
|
|
800
|
+
if (nearest == null) {
|
|
801
|
+
nearest = candidate;
|
|
802
|
+
return;
|
|
803
|
+
}
|
|
804
|
+
const candidateDistance = Math.abs(candidate - removedIndex);
|
|
805
|
+
const nearestDistance = Math.abs(nearest - removedIndex);
|
|
806
|
+
if (candidateDistance < nearestDistance || candidateDistance === nearestDistance && candidate >= removedIndex && nearest < removedIndex) nearest = candidate;
|
|
807
|
+
});
|
|
808
|
+
return nearest;
|
|
809
|
+
}
|
|
810
|
+
//#endregion
|
|
811
|
+
//#region src/PowerSearch/sheetIcons.ts
|
|
812
|
+
/** 「添加筛选条件」按钮和一点就加的字段行末尾的加号。内置图形里没有加号。 */
|
|
813
|
+
const PlusGlyph = () => h("svg", {
|
|
814
|
+
"viewBox": "0 0 24 24",
|
|
815
|
+
"width": "1em",
|
|
816
|
+
"height": "1em",
|
|
817
|
+
"fill": "none",
|
|
818
|
+
"stroke": "currentColor",
|
|
819
|
+
"stroke-width": 2,
|
|
820
|
+
"stroke-linecap": "round",
|
|
821
|
+
"aria-hidden": "true"
|
|
822
|
+
}, [h("path", { d: "M12 5v14M5 12h14" })]);
|
|
823
|
+
//#endregion
|
|
824
|
+
//#region src/PowerSearch/PowerSearchSheetFields.vue
|
|
825
|
+
const _hoisted_1$8 = { class: "astryx-power-search-sheet__header" };
|
|
826
|
+
const _hoisted_2$8 = { class: "astryx-power-search-sheet__header-row" };
|
|
827
|
+
const _hoisted_3$7 = { class: "astryx-power-search-sheet__content" };
|
|
828
|
+
const _hoisted_4$5 = {
|
|
829
|
+
key: 0,
|
|
830
|
+
class: "astryx-power-search-sheet__footer"
|
|
831
|
+
};
|
|
832
|
+
const SEARCHABLE_FIELD_COUNT = 8;
|
|
833
|
+
const MAX_BROWSE_ITEMS$1 = 1e3;
|
|
834
|
+
const _sfc_main$9 = /*@__PURE__*/ defineComponent({
|
|
835
|
+
name: "AstryxPowerSearchSheetFields",
|
|
836
|
+
__name: "PowerSearchSheetFields",
|
|
837
|
+
props: {
|
|
838
|
+
flow: {},
|
|
839
|
+
lookup: {},
|
|
840
|
+
placeholder: {},
|
|
841
|
+
search: { type: Function }
|
|
842
|
+
},
|
|
843
|
+
setup(__props) {
|
|
844
|
+
/**
|
|
845
|
+
* 「添加筛选条件」那一步。配置了 `contentSearchFieldKey`、它的默认运算符取字符串时,顶部是内容搜索,
|
|
846
|
+
* 列出和行内菜单一样的建议,回车选第一条;否则字段多到 8 个时顶部是字段搜索,下面按分组列出字段,
|
|
847
|
+
* 没分组的排最前(「常规」)。只有一个 `empty` 运算符的字段一点就加,行末是加号,其余是箭头。
|
|
848
|
+
* 从触发器直接进来时(没有条件)底下有「完成」。
|
|
849
|
+
*/
|
|
850
|
+
const props = __props;
|
|
851
|
+
/** 字段少于这么多时整张清单都在屏幕上,搜索框只是噪音。 */
|
|
852
|
+
const messages = useComponentMessages({ powerSearchSheet: powerSearchSheetMessages });
|
|
853
|
+
const text = computed(() => messages.value.powerSearchSheet);
|
|
854
|
+
const resultsId = `astryx-power-search-sheet-${useId()}-results`;
|
|
855
|
+
const rootRef = useTemplateRef("rootRef");
|
|
856
|
+
const fields = computed(() => props.lookup.getVisibleFields());
|
|
857
|
+
const hasContentSearch = computed(() => {
|
|
858
|
+
const key = props.lookup.config.contentSearchFieldKey;
|
|
859
|
+
return key != null && props.lookup.getDefaultOperator(key)?.value.type === "string";
|
|
860
|
+
});
|
|
861
|
+
const isFieldSearchShown = computed(() => !hasContentSearch.value && fields.value.length >= SEARCHABLE_FIELD_COUNT);
|
|
862
|
+
const normalizedFieldQuery = computed(() => props.flow.fieldQuery.value.trim().toLowerCase());
|
|
863
|
+
const contentResults = computed(() => {
|
|
864
|
+
if (!hasContentSearch.value || !props.flow.isFieldsSheetOpen.value || !props.flow.isInteractive.value) return [];
|
|
865
|
+
return props.search(props.flow.contentQuery.value).filter((item) => item.auxiliaryData != null && props.lookup.getField(item.auxiliaryData.fieldKey) != null).slice(0, MAX_BROWSE_ITEMS$1);
|
|
866
|
+
});
|
|
867
|
+
const groupedFields = computed(() => {
|
|
868
|
+
const groups = /* @__PURE__ */ new Map([["", []]]);
|
|
869
|
+
for (const field of fields.value) {
|
|
870
|
+
if (!fieldMatchesQuery(field, normalizedFieldQuery.value)) continue;
|
|
871
|
+
const group = field.group ?? "";
|
|
872
|
+
groups.set(group, [...groups.get(group) ?? [], field]);
|
|
873
|
+
}
|
|
874
|
+
return [...groups].filter(([, list]) => list.length > 0);
|
|
875
|
+
});
|
|
876
|
+
const drag = dismissSearchOnTouchDrag(() => [...rootRef.value?.querySelectorAll(".astryx-power-search-sheet__header input") ?? []], () => rootRef.value?.closest("[tabindex=\"-1\"]"));
|
|
877
|
+
function onContentKeydown(event) {
|
|
878
|
+
if (event.isComposing || event.key !== "Enter" || contentResults.value[0] == null) return;
|
|
879
|
+
event.preventDefault();
|
|
880
|
+
props.flow.handleContentSuggestionSelect(contentResults.value[0]);
|
|
881
|
+
}
|
|
882
|
+
return (_ctx, _cache) => {
|
|
883
|
+
return openBlock(), createElementBlock("div", {
|
|
884
|
+
ref_key: "rootRef",
|
|
885
|
+
ref: rootRef,
|
|
886
|
+
class: "astryx-power-search-sheet astryx-power-search-sheet--fixed-footer",
|
|
887
|
+
"data-sheet-step": "fields"
|
|
888
|
+
}, [
|
|
889
|
+
createElementVNode("div", _hoisted_1$8, [createElementVNode("div", _hoisted_2$8, [createVNode(_sfc_main$17, {
|
|
890
|
+
level: 3,
|
|
891
|
+
class: "astryx-power-search-sheet__title"
|
|
892
|
+
}, {
|
|
893
|
+
default: withCtx(() => [createTextVNode(toDisplayString(text.value.addFilter), 1)]),
|
|
894
|
+
_: 1
|
|
895
|
+
})]), hasContentSearch.value ? (openBlock(), createBlock(_sfc_main$35, {
|
|
896
|
+
key: 0,
|
|
897
|
+
"data-sheet-content-search": "",
|
|
898
|
+
"model-value": __props.flow.contentQuery.value,
|
|
899
|
+
label: text.value.search,
|
|
900
|
+
"is-label-hidden": "",
|
|
901
|
+
role: "searchbox",
|
|
902
|
+
"aria-controls": resultsId,
|
|
903
|
+
placeholder: __props.placeholder,
|
|
904
|
+
"start-icon": "search",
|
|
905
|
+
"has-clear": "",
|
|
906
|
+
"is-disabled": !__props.flow.isInteractive.value,
|
|
907
|
+
size: "lg",
|
|
908
|
+
width: "100%",
|
|
909
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => __props.flow.setContentQuery(String($event ?? ""))),
|
|
910
|
+
onKeydown: onContentKeydown
|
|
911
|
+
}, null, 8, [
|
|
912
|
+
"model-value",
|
|
913
|
+
"label",
|
|
914
|
+
"placeholder",
|
|
915
|
+
"is-disabled"
|
|
916
|
+
])) : isFieldSearchShown.value ? (openBlock(), createBlock(_sfc_main$35, {
|
|
917
|
+
key: 1,
|
|
918
|
+
"model-value": __props.flow.fieldQuery.value,
|
|
919
|
+
label: text.value.searchFields,
|
|
920
|
+
"is-label-hidden": "",
|
|
921
|
+
placeholder: text.value.searchFieldsPlaceholder,
|
|
922
|
+
"start-icon": "search",
|
|
923
|
+
"is-disabled": !__props.flow.isInteractive.value,
|
|
924
|
+
size: "lg",
|
|
925
|
+
width: "100%",
|
|
926
|
+
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => __props.flow.setFieldQuery(String($event ?? "")))
|
|
927
|
+
}, null, 8, [
|
|
928
|
+
"model-value",
|
|
929
|
+
"label",
|
|
930
|
+
"placeholder",
|
|
931
|
+
"is-disabled"
|
|
932
|
+
])) : createCommentVNode("v-if", true)]),
|
|
933
|
+
createElementVNode("div", {
|
|
934
|
+
class: "astryx-power-search-sheet__scroll",
|
|
935
|
+
onTouchstart: _cache[2] || (_cache[2] = (...args) => unref(drag).onTouchstart && unref(drag).onTouchstart(...args)),
|
|
936
|
+
onTouchmove: _cache[3] || (_cache[3] = (...args) => unref(drag).onTouchmove && unref(drag).onTouchmove(...args)),
|
|
937
|
+
onTouchend: _cache[4] || (_cache[4] = (...args) => unref(drag).onTouchend && unref(drag).onTouchend(...args)),
|
|
938
|
+
onTouchcancel: _cache[5] || (_cache[5] = (...args) => unref(drag).onTouchcancel && unref(drag).onTouchcancel(...args))
|
|
939
|
+
}, [createElementVNode("div", _hoisted_3$7, [hasContentSearch.value ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [contentResults.value.length > 0 ? (openBlock(), createBlock(_sfc_main$21, {
|
|
940
|
+
key: 0,
|
|
941
|
+
id: resultsId,
|
|
942
|
+
"aria-label": text.value.searchResults,
|
|
943
|
+
"has-dividers": "",
|
|
944
|
+
density: "spacious",
|
|
945
|
+
edge: "bleed"
|
|
946
|
+
}, {
|
|
947
|
+
default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(contentResults.value, (item) => {
|
|
948
|
+
return openBlock(), createBlock(_sfc_main$22, {
|
|
949
|
+
key: item.id,
|
|
950
|
+
label: item.label,
|
|
951
|
+
"is-disabled": !__props.flow.isInteractive.value,
|
|
952
|
+
"on-click": () => __props.flow.handleContentSuggestionSelect(item)
|
|
953
|
+
}, null, 8, [
|
|
954
|
+
"label",
|
|
955
|
+
"is-disabled",
|
|
956
|
+
"on-click"
|
|
957
|
+
]);
|
|
958
|
+
}), 128))]),
|
|
959
|
+
_: 1
|
|
960
|
+
}, 8, ["aria-label"])) : (openBlock(), createElementBlock("div", {
|
|
961
|
+
key: 1,
|
|
962
|
+
id: resultsId,
|
|
963
|
+
class: "astryx-power-search-sheet__results-empty"
|
|
964
|
+
}, [__props.flow.contentQuery.value.trim() !== "" && __props.flow.step.value === "fields" ? (openBlock(), createBlock(_sfc_main$28, {
|
|
965
|
+
key: 0,
|
|
966
|
+
class: "astryx-power-search-sheet__empty",
|
|
967
|
+
title: text.value.noResults,
|
|
968
|
+
description: text.value.tryDifferentSearch,
|
|
969
|
+
"heading-level": 4,
|
|
970
|
+
"is-compact": ""
|
|
971
|
+
}, {
|
|
972
|
+
icon: withCtx(() => [createVNode(_sfc_main$13, {
|
|
973
|
+
icon: "search",
|
|
974
|
+
size: "lg",
|
|
975
|
+
color: "secondary"
|
|
976
|
+
})]),
|
|
977
|
+
_: 1
|
|
978
|
+
}, 8, ["title", "description"])) : createCommentVNode("v-if", true)]))], 64)) : groupedFields.value.length === 0 && normalizedFieldQuery.value !== "" && __props.flow.step.value === "fields" ? (openBlock(), createBlock(_sfc_main$28, {
|
|
979
|
+
key: 1,
|
|
980
|
+
class: "astryx-power-search-sheet__empty",
|
|
981
|
+
title: text.value.noMatchingFields,
|
|
982
|
+
description: text.value.tryDifferentSearch,
|
|
983
|
+
"heading-level": 4,
|
|
984
|
+
"is-compact": ""
|
|
985
|
+
}, {
|
|
986
|
+
icon: withCtx(() => [createVNode(_sfc_main$13, {
|
|
987
|
+
icon: "search",
|
|
988
|
+
size: "lg",
|
|
989
|
+
color: "secondary"
|
|
990
|
+
})]),
|
|
991
|
+
_: 1
|
|
992
|
+
}, 8, ["title", "description"])) : (openBlock(true), createElementBlock(Fragment, { key: 2 }, renderList(groupedFields.value, ([group, groupFields]) => {
|
|
993
|
+
return openBlock(), createBlock(_sfc_main$21, {
|
|
994
|
+
key: group,
|
|
995
|
+
"has-dividers": "",
|
|
996
|
+
density: "spacious",
|
|
997
|
+
edge: "bleed"
|
|
998
|
+
}, {
|
|
999
|
+
header: withCtx(() => [createVNode(_sfc_main$17, { level: 4 }, {
|
|
1000
|
+
default: withCtx(() => [createTextVNode(toDisplayString(group === "" ? text.value.ungroupedFields : group), 1)]),
|
|
1001
|
+
_: 2
|
|
1002
|
+
}, 1024)]),
|
|
1003
|
+
default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(groupFields, (field) => {
|
|
1004
|
+
return openBlock(), createBlock(_sfc_main$22, {
|
|
1005
|
+
key: field.key,
|
|
1006
|
+
"data-sheet-field": field.key,
|
|
1007
|
+
label: field.label,
|
|
1008
|
+
"is-disabled": !__props.flow.isInteractive.value,
|
|
1009
|
+
"on-click": () => __props.flow.handleFieldSelect(field)
|
|
1010
|
+
}, createSlots({
|
|
1011
|
+
endContent: withCtx(() => [__props.flow.isImmediateAddField(field) ? (openBlock(), createBlock(_sfc_main$13, {
|
|
1012
|
+
key: 0,
|
|
1013
|
+
icon: unref(PlusGlyph),
|
|
1014
|
+
size: "sm",
|
|
1015
|
+
color: "secondary"
|
|
1016
|
+
}, null, 8, ["icon"])) : (openBlock(), createBlock(_sfc_main$13, {
|
|
1017
|
+
key: 1,
|
|
1018
|
+
class: "astryx-power-search-sheet__chevron",
|
|
1019
|
+
icon: "chevronRight",
|
|
1020
|
+
size: "sm",
|
|
1021
|
+
color: "secondary"
|
|
1022
|
+
}))]),
|
|
1023
|
+
_: 2
|
|
1024
|
+
}, [field.icon ? {
|
|
1025
|
+
name: "startContent",
|
|
1026
|
+
fn: withCtx(() => [createVNode(_sfc_main$13, {
|
|
1027
|
+
icon: field.icon,
|
|
1028
|
+
size: "sm"
|
|
1029
|
+
}, null, 8, ["icon"])]),
|
|
1030
|
+
key: "0"
|
|
1031
|
+
} : void 0]), 1032, [
|
|
1032
|
+
"data-sheet-field",
|
|
1033
|
+
"label",
|
|
1034
|
+
"is-disabled",
|
|
1035
|
+
"on-click"
|
|
1036
|
+
]);
|
|
1037
|
+
}), 128))]),
|
|
1038
|
+
_: 2
|
|
1039
|
+
}, 1024);
|
|
1040
|
+
}), 128))])], 32),
|
|
1041
|
+
__props.flow.isDirectEntry.value ? (openBlock(), createElementBlock("div", _hoisted_4$5, [createVNode(_sfc_main$14, {
|
|
1042
|
+
class: "astryx-power-search-sheet__footer-action",
|
|
1043
|
+
label: text.value.done,
|
|
1044
|
+
variant: "primary",
|
|
1045
|
+
size: "lg",
|
|
1046
|
+
width: "100%",
|
|
1047
|
+
onClick: __props.flow.commitAndClose
|
|
1048
|
+
}, null, 8, ["label", "onClick"])])) : createCommentVNode("v-if", true)
|
|
1049
|
+
], 512);
|
|
1050
|
+
};
|
|
1051
|
+
}
|
|
1052
|
+
});
|
|
1053
|
+
//#endregion
|
|
1054
|
+
//#region src/PowerSearch/relativeDates.ts
|
|
1055
|
+
const RELATIVE_DATE_UNITS = [
|
|
1056
|
+
{
|
|
1057
|
+
unit: "day",
|
|
1058
|
+
amounts: [
|
|
1059
|
+
1,
|
|
1060
|
+
3,
|
|
1061
|
+
7,
|
|
1062
|
+
14,
|
|
1063
|
+
30
|
|
1064
|
+
],
|
|
1065
|
+
ago: "relativeDaysAgo",
|
|
1066
|
+
fromNow: "relativeDaysFromNow"
|
|
1067
|
+
},
|
|
1068
|
+
{
|
|
1069
|
+
unit: "week",
|
|
1070
|
+
amounts: [
|
|
1071
|
+
1,
|
|
1072
|
+
2,
|
|
1073
|
+
4
|
|
1074
|
+
],
|
|
1075
|
+
ago: "relativeWeeksAgo",
|
|
1076
|
+
fromNow: "relativeWeeksFromNow"
|
|
1077
|
+
},
|
|
1078
|
+
{
|
|
1079
|
+
unit: "month",
|
|
1080
|
+
amounts: [
|
|
1081
|
+
1,
|
|
1082
|
+
3,
|
|
1083
|
+
6,
|
|
1084
|
+
12
|
|
1085
|
+
],
|
|
1086
|
+
ago: "relativeMonthsAgo",
|
|
1087
|
+
fromNow: "relativeMonthsFromNow"
|
|
1088
|
+
}
|
|
1089
|
+
];
|
|
1090
|
+
/**
|
|
1091
|
+
* 相对日期运算符提供的选项,按显示顺序排列。桌面浮层的 Selector 和底部弹层的单选行共用这一份,
|
|
1092
|
+
* 两边列出的值一样。值写成 `3d_ago`、`2w_from_now` 这种形式;`isPastAllowed` / `isFutureAllowed`
|
|
1093
|
+
* 写 false 时去掉对应方向的选项。
|
|
1094
|
+
*/
|
|
1095
|
+
function buildRelativeDateOptions(operatorValue, messages) {
|
|
1096
|
+
const options = [];
|
|
1097
|
+
for (const { unit, amounts, ago, fromNow } of RELATIVE_DATE_UNITS) for (const amount of amounts) {
|
|
1098
|
+
if (operatorValue.isPastAllowed !== false) options.push({
|
|
1099
|
+
value: `${amount}${unit[0]}_ago`,
|
|
1100
|
+
label: messages[ago](amount)
|
|
1101
|
+
});
|
|
1102
|
+
if (operatorValue.isFutureAllowed !== false) options.push({
|
|
1103
|
+
value: `${amount}${unit[0]}_from_now`,
|
|
1104
|
+
label: messages[fromNow](amount)
|
|
1105
|
+
});
|
|
1106
|
+
}
|
|
1107
|
+
return options;
|
|
1108
|
+
}
|
|
1109
|
+
//#endregion
|
|
1110
|
+
//#region src/PowerSearch/sheetFilterText.ts
|
|
1111
|
+
/**
|
|
1112
|
+
* 「筛选条件」一行的两部分文字。配置里已经没有的字段或运算符按原始键显示,和触发器上的标签一致。
|
|
1113
|
+
* 相对日期存的是键(`3d_ago`),这里读成值那一步选项上的文字(「3 天前」)。
|
|
1114
|
+
*/
|
|
1115
|
+
function describeSheetFilterParts(filter, context) {
|
|
1116
|
+
const field = context.lookup.getField(filter.field);
|
|
1117
|
+
const operator = context.lookup.getOperator(filter.field, filter.operator);
|
|
1118
|
+
const fieldLabel = field?.label ?? filter.field;
|
|
1119
|
+
const operatorLabel = operator == null ? filter.operator : resolveOperatorLabel(operator, context.messages);
|
|
1120
|
+
const label = operatorLabel ? context.sheet.fieldOperator(fieldLabel, operatorLabel) : fieldLabel;
|
|
1121
|
+
if (operator == null) return {
|
|
1122
|
+
label,
|
|
1123
|
+
value: null
|
|
1124
|
+
};
|
|
1125
|
+
if (operator.value.type === "date_relative" && filter.value.type === "date_relative") {
|
|
1126
|
+
const relative = filter.value.value;
|
|
1127
|
+
return {
|
|
1128
|
+
label,
|
|
1129
|
+
value: buildRelativeDateOptions(operator.value, context.sheet).find((option) => option.value === relative)?.label ?? relative
|
|
1130
|
+
};
|
|
1131
|
+
}
|
|
1132
|
+
return {
|
|
1133
|
+
label,
|
|
1134
|
+
value: formatFilterValue(operator.value, filter.value, Number.MAX_SAFE_INTEGER, context.messages, context.locale, context.timeZone, context.calendar) || null
|
|
1135
|
+
};
|
|
1136
|
+
}
|
|
1137
|
+
/** 整行读出来的文字:删除时播报用,和行上显示的一致。 */
|
|
1138
|
+
function describeSheetFilter(filter, context) {
|
|
1139
|
+
const parts = describeSheetFilterParts(filter, context);
|
|
1140
|
+
return parts.value ? context.sheet.labelValue(parts.label, parts.value) : parts.label;
|
|
1141
|
+
}
|
|
1142
|
+
/** 私用区码位:不会出现在标签或值里。 */
|
|
1143
|
+
const VALUE_SLOT = "";
|
|
1144
|
+
/** 按语言的 `labelValue` 顺序拆出值前后的文字,值单独加粗显示。 */
|
|
1145
|
+
function splitLabelValue(sheet, label) {
|
|
1146
|
+
const [before = "", after = ""] = sheet.labelValue(label, VALUE_SLOT).split(VALUE_SLOT);
|
|
1147
|
+
return {
|
|
1148
|
+
before,
|
|
1149
|
+
after
|
|
1150
|
+
};
|
|
1151
|
+
}
|
|
1152
|
+
/**
|
|
1153
|
+
* 值那一步的标题:字段名;运算符不在单选组里出现时(只有一个运算符)写成「字段 运算符」;
|
|
1154
|
+
* 字段或运算符在配置里已经没有时按原始键写。
|
|
1155
|
+
*/
|
|
1156
|
+
function sheetEditorTitle(draft, context) {
|
|
1157
|
+
if (draft == null) return context.sheet.addFilter;
|
|
1158
|
+
const field = context.lookup.getField(draft.field);
|
|
1159
|
+
const operator = draft.operator == null ? void 0 : context.lookup.getOperator(draft.field, draft.operator);
|
|
1160
|
+
const operatorLabel = operator == null ? "" : resolveOperatorLabel(operator, context.messages);
|
|
1161
|
+
if (field == null || operator == null && draft.operator != null) return context.sheet.fieldOperator(field?.label ?? draft.field, operatorLabel || (draft.operator ?? "")).trim();
|
|
1162
|
+
const operators = context.lookup.getVisibleOperators(draft.field);
|
|
1163
|
+
return !(operators.length > 1 && operator != null && operators.includes(operator)) && operatorLabel !== "" ? context.sheet.fieldOperator(field.label, operatorLabel) : field.label;
|
|
1164
|
+
}
|
|
1165
|
+
//#endregion
|
|
1166
|
+
//#region src/PowerSearch/PowerSearchSheetFilters.vue
|
|
1167
|
+
const _hoisted_1$7 = {
|
|
1168
|
+
class: "astryx-power-search-sheet astryx-power-search-sheet--fixed-footer",
|
|
1169
|
+
"data-sheet-step": "manage"
|
|
1170
|
+
};
|
|
1171
|
+
const _hoisted_2$7 = { class: "astryx-power-search-sheet__header" };
|
|
1172
|
+
const _hoisted_3$6 = { class: "astryx-power-search-sheet__header-row" };
|
|
1173
|
+
const _hoisted_4$4 = { class: "astryx-power-search-sheet__scroll" };
|
|
1174
|
+
const _hoisted_5$4 = { class: "astryx-power-search-sheet__content" };
|
|
1175
|
+
const _hoisted_6$3 = { class: "astryx-power-search-sheet__row-value" };
|
|
1176
|
+
const _hoisted_7$2 = {
|
|
1177
|
+
key: 0,
|
|
1178
|
+
class: "astryx-power-search-sheet__footer"
|
|
1179
|
+
};
|
|
1180
|
+
const _sfc_main$8 = /*@__PURE__*/ defineComponent({
|
|
1181
|
+
name: "AstryxPowerSearchSheetFilters",
|
|
1182
|
+
__name: "PowerSearchSheetFilters",
|
|
1183
|
+
props: {
|
|
1184
|
+
flow: {},
|
|
1185
|
+
lookup: {},
|
|
1186
|
+
hasClear: { type: Boolean },
|
|
1187
|
+
describeParts: { type: Function }
|
|
1188
|
+
},
|
|
1189
|
+
setup(__props) {
|
|
1190
|
+
/**
|
|
1191
|
+
* 「筛选条件」那一步:草稿里的每个条件一行。能编辑的行点一下进值那一步(一点就加的条件点一下就删),
|
|
1192
|
+
* 末尾的 × 删掉它;只读条件只展示。没有条件时显示空状态和「添加筛选条件」。
|
|
1193
|
+
* 底部的「完成」在有条件或草稿改过时出现,「全部清除」只在有能删的条件时出现。
|
|
1194
|
+
*/
|
|
1195
|
+
const props = __props;
|
|
1196
|
+
const messages = useComponentMessages({ powerSearchSheet: powerSearchSheetMessages });
|
|
1197
|
+
const text = computed(() => messages.value.powerSearchSheet);
|
|
1198
|
+
const identities = createFilterIdentities();
|
|
1199
|
+
const rows = computed(() => {
|
|
1200
|
+
const filters = props.flow.filters.value;
|
|
1201
|
+
const ids = identities.next(filters);
|
|
1202
|
+
return filters.map((filter, index) => {
|
|
1203
|
+
const parts = props.describeParts(filter);
|
|
1204
|
+
const operator = props.lookup.getOperator(filter.field, filter.operator);
|
|
1205
|
+
const fieldLabel = props.lookup.getField(filter.field)?.label ?? filter.field;
|
|
1206
|
+
return {
|
|
1207
|
+
key: `filter-${ids[index]}`,
|
|
1208
|
+
index,
|
|
1209
|
+
parts,
|
|
1210
|
+
split: parts.value ? splitLabelValue(text.value, parts.label) : null,
|
|
1211
|
+
isEditable: props.flow.isRowButton(filter),
|
|
1212
|
+
isOneTap: operator?.value.type === "empty",
|
|
1213
|
+
removeLabel: text.value.removeFilter(fieldLabel)
|
|
1214
|
+
};
|
|
1215
|
+
});
|
|
1216
|
+
});
|
|
1217
|
+
const isClearAllShown = computed(() => props.hasClear && props.flow.isInteractive.value && props.flow.filters.value.some((filter) => !filter.isReadOnly));
|
|
1218
|
+
const isFooterShown = computed(() => rows.value.length > 0 || props.flow.isDraftDirty.value);
|
|
1219
|
+
function onRowClick(row) {
|
|
1220
|
+
if (row.isOneTap) props.flow.handleRemoveFilter(row.index);
|
|
1221
|
+
else props.flow.handleFilterEdit(row.index);
|
|
1222
|
+
}
|
|
1223
|
+
return (_ctx, _cache) => {
|
|
1224
|
+
return openBlock(), createElementBlock("div", _hoisted_1$7, [
|
|
1225
|
+
createElementVNode("div", _hoisted_2$7, [createElementVNode("div", _hoisted_3$6, [createVNode(_sfc_main$17, {
|
|
1226
|
+
level: 3,
|
|
1227
|
+
class: "astryx-power-search-sheet__title"
|
|
1228
|
+
}, {
|
|
1229
|
+
default: withCtx(() => [createTextVNode(toDisplayString(text.value.filtersTitle), 1)]),
|
|
1230
|
+
_: 1
|
|
1231
|
+
}), __props.flow.isInteractive.value && rows.value.length > 0 ? (openBlock(), createBlock(_sfc_main$14, {
|
|
1232
|
+
key: 0,
|
|
1233
|
+
"data-sheet-add": "",
|
|
1234
|
+
label: text.value.addFilter,
|
|
1235
|
+
icon: unref(PlusGlyph),
|
|
1236
|
+
"is-icon-only": "",
|
|
1237
|
+
variant: "secondary",
|
|
1238
|
+
size: "md",
|
|
1239
|
+
onClick: __props.flow.openFieldList
|
|
1240
|
+
}, null, 8, [
|
|
1241
|
+
"label",
|
|
1242
|
+
"icon",
|
|
1243
|
+
"onClick"
|
|
1244
|
+
])) : createCommentVNode("v-if", true)])]),
|
|
1245
|
+
createElementVNode("div", _hoisted_4$4, [createElementVNode("div", _hoisted_5$4, [rows.value.length === 0 ? (openBlock(), createBlock(_sfc_main$28, {
|
|
1246
|
+
key: 0,
|
|
1247
|
+
class: "astryx-power-search-sheet__empty",
|
|
1248
|
+
title: __props.flow.isDraftDirty.value ? text.value.noFiltersInDraft : text.value.noFilters,
|
|
1249
|
+
description: text.value.noFiltersDescription,
|
|
1250
|
+
"heading-level": 4
|
|
1251
|
+
}, createSlots({
|
|
1252
|
+
icon: withCtx(() => [createVNode(_sfc_main$13, {
|
|
1253
|
+
icon: "funnel",
|
|
1254
|
+
size: "lg",
|
|
1255
|
+
color: "secondary"
|
|
1256
|
+
})]),
|
|
1257
|
+
_: 2
|
|
1258
|
+
}, [__props.flow.isInteractive.value ? {
|
|
1259
|
+
name: "actions",
|
|
1260
|
+
fn: withCtx(() => [createVNode(_sfc_main$14, {
|
|
1261
|
+
"data-sheet-add": "",
|
|
1262
|
+
label: text.value.addFilter,
|
|
1263
|
+
icon: unref(PlusGlyph),
|
|
1264
|
+
variant: "primary",
|
|
1265
|
+
size: "lg",
|
|
1266
|
+
onClick: __props.flow.openFieldList
|
|
1267
|
+
}, null, 8, [
|
|
1268
|
+
"label",
|
|
1269
|
+
"icon",
|
|
1270
|
+
"onClick"
|
|
1271
|
+
])]),
|
|
1272
|
+
key: "0"
|
|
1273
|
+
} : void 0]), 1032, ["title", "description"])) : (openBlock(), createBlock(_sfc_main$21, {
|
|
1274
|
+
key: 1,
|
|
1275
|
+
"has-dividers": "",
|
|
1276
|
+
density: "spacious",
|
|
1277
|
+
edge: "bleed"
|
|
1278
|
+
}, {
|
|
1279
|
+
default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(rows.value, (row) => {
|
|
1280
|
+
return openBlock(), createBlock(_sfc_main$22, {
|
|
1281
|
+
key: row.key,
|
|
1282
|
+
"data-sheet-filter": row.index,
|
|
1283
|
+
"on-click": row.isEditable ? () => onRowClick(row) : void 0
|
|
1284
|
+
}, createSlots({
|
|
1285
|
+
label: withCtx(() => [row.split ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
1286
|
+
createTextVNode(toDisplayString(row.split.before), 1),
|
|
1287
|
+
createElementVNode("span", _hoisted_6$3, toDisplayString(row.parts.value), 1),
|
|
1288
|
+
createTextVNode(toDisplayString(row.split.after), 1)
|
|
1289
|
+
], 64)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [createTextVNode(toDisplayString(row.parts.label), 1)], 64))]),
|
|
1290
|
+
_: 2
|
|
1291
|
+
}, [row.isEditable ? {
|
|
1292
|
+
name: "endContent",
|
|
1293
|
+
fn: withCtx(() => [createVNode(_sfc_main$15, {
|
|
1294
|
+
"data-sheet-remove": "",
|
|
1295
|
+
label: row.removeLabel,
|
|
1296
|
+
tooltip: row.removeLabel,
|
|
1297
|
+
icon: "close",
|
|
1298
|
+
variant: "ghost",
|
|
1299
|
+
size: "md",
|
|
1300
|
+
onClick: withModifiers(($event) => __props.flow.handleRemoveFilter(row.index), ["stop"])
|
|
1301
|
+
}, null, 8, [
|
|
1302
|
+
"label",
|
|
1303
|
+
"tooltip",
|
|
1304
|
+
"onClick"
|
|
1305
|
+
])]),
|
|
1306
|
+
key: "0"
|
|
1307
|
+
} : void 0]), 1032, ["data-sheet-filter", "on-click"]);
|
|
1308
|
+
}), 128))]),
|
|
1309
|
+
_: 1
|
|
1310
|
+
}))])]),
|
|
1311
|
+
isFooterShown.value ? (openBlock(), createElementBlock("div", _hoisted_7$2, [isClearAllShown.value ? (openBlock(), createBlock(_sfc_main$14, {
|
|
1312
|
+
key: 0,
|
|
1313
|
+
"data-sheet-clear": "",
|
|
1314
|
+
class: "astryx-power-search-sheet__footer-action",
|
|
1315
|
+
label: text.value.clearAll,
|
|
1316
|
+
variant: "secondary",
|
|
1317
|
+
size: "lg",
|
|
1318
|
+
onClick: __props.flow.openClearConfirmation
|
|
1319
|
+
}, null, 8, ["label", "onClick"])) : createCommentVNode("v-if", true), createVNode(_sfc_main$14, {
|
|
1320
|
+
class: "astryx-power-search-sheet__footer-action",
|
|
1321
|
+
label: text.value.done,
|
|
1322
|
+
variant: "primary",
|
|
1323
|
+
size: "lg",
|
|
1324
|
+
onClick: __props.flow.commitAndClose
|
|
1325
|
+
}, null, 8, ["label", "onClick"])])) : createCommentVNode("v-if", true)
|
|
1326
|
+
]);
|
|
1327
|
+
};
|
|
1328
|
+
}
|
|
1329
|
+
});
|
|
1330
|
+
//#endregion
|
|
1331
|
+
//#region src/PowerSearch/PowerSearchValueField.vue
|
|
1332
|
+
const _hoisted_1$6 = {
|
|
1333
|
+
key: 8,
|
|
1334
|
+
class: "astryx-power-search-value__stack"
|
|
1335
|
+
};
|
|
1336
|
+
const _hoisted_2$6 = ["aria-label"];
|
|
1337
|
+
const _hoisted_3$5 = ["disabled", "onClick"];
|
|
1338
|
+
/**
|
|
1339
|
+
* 一个条件的值输入。`presentation="bottom-sheet"` 是触屏底部弹层的值那一步:里面的 Tokenizer 也用
|
|
1340
|
+
* 底部弹层呈现、以字段标签为名,日期区间换成行内的范围日历,值被清空时发 `unstage`(草稿回到没有值)。
|
|
1341
|
+
*/
|
|
1342
|
+
const _sfc_main$7 = /*@__PURE__*/ defineComponent({
|
|
1343
|
+
name: "AstryxPowerSearchValueField",
|
|
1344
|
+
__name: "PowerSearchValueField",
|
|
1345
|
+
props: {
|
|
1346
|
+
operatorValue: {},
|
|
1347
|
+
filterValue: {},
|
|
1348
|
+
messages: {},
|
|
1349
|
+
disabled: { type: Boolean },
|
|
1350
|
+
timeZone: {},
|
|
1351
|
+
maxMenuItems: {},
|
|
1352
|
+
presentation: {},
|
|
1353
|
+
fieldLabel: {}
|
|
1354
|
+
},
|
|
1355
|
+
emits: ["change", "unstage"],
|
|
1356
|
+
setup(__props, { emit: __emit }) {
|
|
1357
|
+
const props = __props;
|
|
1358
|
+
const emit = __emit;
|
|
1359
|
+
const isSheet = computed(() => props.presentation === "bottom-sheet");
|
|
1360
|
+
const tokenizerPresentation = computed(() => isSheet.value ? "bottom-sheet" : "popover");
|
|
1361
|
+
/** 底部弹层呈现里清空了值就退回「没有值」,保存不可点;浮层编辑器照常记下空值。 */
|
|
1362
|
+
function changeOrUnstage(value, isEmpty, shouldSave) {
|
|
1363
|
+
if (isEmpty && isSheet.value) emit("unstage");
|
|
1364
|
+
else emit("change", value, shouldSave);
|
|
1365
|
+
}
|
|
1366
|
+
const text = computed(() => props.messages.value);
|
|
1367
|
+
const locale = useAstryxLocale();
|
|
1368
|
+
const sheetMessages = useComponentMessages({ powerSearchSheet: powerSearchSheetMessages });
|
|
1369
|
+
const numberDecision = ref(null);
|
|
1370
|
+
function rememberNumberDraft(event) {
|
|
1371
|
+
const target = event.target;
|
|
1372
|
+
const operator = props.operatorValue;
|
|
1373
|
+
if (!(target instanceof HTMLInputElement) || target.getAttribute("role") !== "spinbutton") return;
|
|
1374
|
+
if (operator.type !== "integer" && operator.type !== "float") return;
|
|
1375
|
+
numberDecision.value = resolveNumberInputCommit(target.value, {
|
|
1376
|
+
min: operator.minValue,
|
|
1377
|
+
max: operator.maxValue,
|
|
1378
|
+
isIntegerOnly: operator.type === "integer",
|
|
1379
|
+
locale: locale.value,
|
|
1380
|
+
hasClear: false
|
|
1381
|
+
});
|
|
1382
|
+
}
|
|
1383
|
+
function onNumberKeydown(event) {
|
|
1384
|
+
if (event.key !== "Enter" || event.isComposing) return;
|
|
1385
|
+
const decision = numberDecision.value;
|
|
1386
|
+
numberDecision.value = null;
|
|
1387
|
+
if (decision != null && decision.type !== "commit") event.stopPropagation();
|
|
1388
|
+
}
|
|
1389
|
+
const stringValue = computed(() => props.filterValue?.type === "string" ? props.filterValue.value : "");
|
|
1390
|
+
const numberValue = computed(() => props.filterValue?.type === "integer" || props.filterValue?.type === "float" ? props.filterValue.value : null);
|
|
1391
|
+
const timeValue = computed(() => props.filterValue?.type === "time" ? props.filterValue.value : null);
|
|
1392
|
+
const enumValue = computed(() => props.filterValue?.type === "enum" ? props.filterValue.value : null);
|
|
1393
|
+
const enumList = computed(() => props.filterValue?.type === "enum_list" ? [...props.filterValue.value] : []);
|
|
1394
|
+
const relativeValue = computed(() => props.filterValue?.type === "date_relative" ? props.filterValue.value : "");
|
|
1395
|
+
const customValue = computed(() => props.filterValue?.type === "custom" ? props.filterValue.value : "");
|
|
1396
|
+
const stringItems = computed(() => {
|
|
1397
|
+
if (props.filterValue?.type !== "string_list") return [];
|
|
1398
|
+
return props.filterValue.value.map((value) => ({
|
|
1399
|
+
id: value,
|
|
1400
|
+
label: value
|
|
1401
|
+
}));
|
|
1402
|
+
});
|
|
1403
|
+
const entityItems = computed(() => {
|
|
1404
|
+
if (props.filterValue?.type !== "entity_list") return [];
|
|
1405
|
+
return props.filterValue.value.map((entity) => ({
|
|
1406
|
+
id: entity.id,
|
|
1407
|
+
label: entity.label,
|
|
1408
|
+
auxiliaryData: entity
|
|
1409
|
+
}));
|
|
1410
|
+
});
|
|
1411
|
+
const selectedStringItem = computed(() => stringValue.value ? {
|
|
1412
|
+
id: stringValue.value,
|
|
1413
|
+
label: stringValue.value
|
|
1414
|
+
} : null);
|
|
1415
|
+
const enumOptions = computed(() => {
|
|
1416
|
+
const value = props.operatorValue;
|
|
1417
|
+
if (value.type !== "enum" && value.type !== "enum_list") return [];
|
|
1418
|
+
return value.values.map((item) => ({
|
|
1419
|
+
value: item.value,
|
|
1420
|
+
label: item.label,
|
|
1421
|
+
icon: item.icon
|
|
1422
|
+
}));
|
|
1423
|
+
});
|
|
1424
|
+
const relativeOptions = computed(() => props.operatorValue.type === "date_relative" ? buildRelativeDateOptions(props.operatorValue, sheetMessages.value.powerSearchSheet) : []);
|
|
1425
|
+
const dateOnly = computed(() => isDateOnlyOperator(props.operatorValue));
|
|
1426
|
+
/** 日历日按 `timeZone` 里的那一天读写;没给时区就是 UTC 的那一天。 */
|
|
1427
|
+
const dayZone = computed(() => resolveDateZone(props.timeZone, true));
|
|
1428
|
+
const absoluteDate = computed(() => {
|
|
1429
|
+
if (props.filterValue?.type !== "date_absolute") return null;
|
|
1430
|
+
return unixToPickerDate(props.filterValue.unixSeconds, dayZone.value);
|
|
1431
|
+
});
|
|
1432
|
+
const absoluteLocal = computed(() => props.filterValue?.type === "date_absolute" ? unixToDateTimeLocal(props.filterValue.unixSeconds, props.timeZone) : null);
|
|
1433
|
+
const calendarRange = computed(() => props.filterValue?.type === "date_range" ? rangeToPickerRange(props.filterValue.value, dayZone.value) : null);
|
|
1434
|
+
const rangeModel = computed(() => {
|
|
1435
|
+
if (props.filterValue?.type !== "date_range") return null;
|
|
1436
|
+
return {
|
|
1437
|
+
start: rangePartToIso(props.filterValue.value.start, dayZone.value),
|
|
1438
|
+
end: rangePartToIso(props.filterValue.value.end, dayZone.value)
|
|
1439
|
+
};
|
|
1440
|
+
});
|
|
1441
|
+
const stringSource = computed(() => props.operatorValue.type === "string" || props.operatorValue.type === "string_list" ? props.operatorValue.searchSource ?? createStaticSource([]) : createStaticSource([]));
|
|
1442
|
+
const entitySource = computed(() => props.operatorValue.type === "entity_list" ? props.operatorValue.searchSource ?? createStaticSource([]) : createStaticSource([]));
|
|
1443
|
+
const stringCreatable = computed(() => {
|
|
1444
|
+
const value = props.operatorValue;
|
|
1445
|
+
if (value.type !== "string_list" && value.type !== "entity_list") return false;
|
|
1446
|
+
return value.isArbitraryStringAllowed === true || value.searchSource == null;
|
|
1447
|
+
});
|
|
1448
|
+
function commitStringList(items) {
|
|
1449
|
+
changeOrUnstage({
|
|
1450
|
+
type: "string_list",
|
|
1451
|
+
value: items.map((item) => item.label)
|
|
1452
|
+
}, items.length === 0);
|
|
1453
|
+
}
|
|
1454
|
+
function commitEntities(items) {
|
|
1455
|
+
const entities = items.map((item) => ({
|
|
1456
|
+
id: item.id,
|
|
1457
|
+
label: item.label,
|
|
1458
|
+
photo: typeof item.auxiliaryData === "object" && item.auxiliaryData && "photo" in item.auxiliaryData ? String(item.auxiliaryData.photo ?? "") : void 0
|
|
1459
|
+
}));
|
|
1460
|
+
changeOrUnstage({
|
|
1461
|
+
type: "entity_list",
|
|
1462
|
+
value: entities
|
|
1463
|
+
}, entities.length === 0);
|
|
1464
|
+
}
|
|
1465
|
+
function onPaste(event) {
|
|
1466
|
+
const value = props.operatorValue;
|
|
1467
|
+
if (value.type !== "string_list" && value.type !== "entity_list") return;
|
|
1468
|
+
const pattern = value.tokenization?.regex;
|
|
1469
|
+
if (!pattern) return;
|
|
1470
|
+
const pasted = event.clipboardData?.getData("text") ?? "";
|
|
1471
|
+
if (!pasted) return;
|
|
1472
|
+
let pieces = [];
|
|
1473
|
+
try {
|
|
1474
|
+
pieces = pasted.match(new RegExp(pattern, "g")) ?? [];
|
|
1475
|
+
} catch {
|
|
1476
|
+
return;
|
|
1477
|
+
}
|
|
1478
|
+
if (pieces.length === 0) return;
|
|
1479
|
+
event.preventDefault();
|
|
1480
|
+
if (value.tokenization?.sort) pieces.sort((left, right) => left.localeCompare(right));
|
|
1481
|
+
if (value.type === "string_list") {
|
|
1482
|
+
const current = stringItems.value.map((item) => item.label);
|
|
1483
|
+
emit("change", {
|
|
1484
|
+
type: "string_list",
|
|
1485
|
+
value: [...current, ...pieces]
|
|
1486
|
+
});
|
|
1487
|
+
return;
|
|
1488
|
+
}
|
|
1489
|
+
const current = entityItems.value.map((item) => ({
|
|
1490
|
+
id: item.id,
|
|
1491
|
+
label: item.label
|
|
1492
|
+
}));
|
|
1493
|
+
emit("change", {
|
|
1494
|
+
type: "entity_list",
|
|
1495
|
+
value: [...current, ...pieces.map((piece) => ({
|
|
1496
|
+
id: piece,
|
|
1497
|
+
label: piece
|
|
1498
|
+
}))]
|
|
1499
|
+
});
|
|
1500
|
+
}
|
|
1501
|
+
function onRange(value) {
|
|
1502
|
+
if (value == null || typeof value !== "object" || !("start" in value) || !("end" in value)) return;
|
|
1503
|
+
const start = value.start;
|
|
1504
|
+
const end = value.end;
|
|
1505
|
+
if (typeof start !== "string" || typeof end !== "string") return;
|
|
1506
|
+
emit("change", {
|
|
1507
|
+
type: "date_range",
|
|
1508
|
+
value: absoluteRange(start, end, dayZone.value)
|
|
1509
|
+
});
|
|
1510
|
+
}
|
|
1511
|
+
function onCalendarRange(value) {
|
|
1512
|
+
if (value.start != null && value.end != null) emit("change", {
|
|
1513
|
+
type: "date_range",
|
|
1514
|
+
value: pickerRangeToRange(value.start, value.end, dayZone.value)
|
|
1515
|
+
});
|
|
1516
|
+
else if (isSheet.value) emit("unstage");
|
|
1517
|
+
}
|
|
1518
|
+
function onString(value) {
|
|
1519
|
+
const next = String(value ?? "");
|
|
1520
|
+
changeOrUnstage({
|
|
1521
|
+
type: "string",
|
|
1522
|
+
value: next
|
|
1523
|
+
}, next.trim() === "");
|
|
1524
|
+
}
|
|
1525
|
+
function onNumber(value) {
|
|
1526
|
+
if (value != null) emit("change", {
|
|
1527
|
+
type: props.operatorValue.type === "integer" ? "integer" : "float",
|
|
1528
|
+
value
|
|
1529
|
+
});
|
|
1530
|
+
else if (isSheet.value) emit("unstage");
|
|
1531
|
+
}
|
|
1532
|
+
function onTime(value) {
|
|
1533
|
+
if (typeof value === "string" && value !== "") emit("change", {
|
|
1534
|
+
type: "time",
|
|
1535
|
+
value
|
|
1536
|
+
});
|
|
1537
|
+
else if (isSheet.value) emit("unstage");
|
|
1538
|
+
}
|
|
1539
|
+
function onAbsoluteDate(value) {
|
|
1540
|
+
if (value instanceof Date) emit("change", {
|
|
1541
|
+
type: "date_absolute",
|
|
1542
|
+
unixSeconds: pickerDateToUnix(value, dayZone.value)
|
|
1543
|
+
});
|
|
1544
|
+
else if (isSheet.value) emit("unstage");
|
|
1545
|
+
}
|
|
1546
|
+
function onAbsoluteDateTime(value) {
|
|
1547
|
+
if (typeof value === "string" && value !== "") emit("change", {
|
|
1548
|
+
type: "date_absolute",
|
|
1549
|
+
unixSeconds: dateTimeLocalToUnix(value, props.timeZone)
|
|
1550
|
+
});
|
|
1551
|
+
else if (isSheet.value) emit("unstage");
|
|
1552
|
+
}
|
|
1553
|
+
function onCustomValue(value) {
|
|
1554
|
+
emit("change", {
|
|
1555
|
+
type: "custom",
|
|
1556
|
+
value: value == null ? "" : String(value)
|
|
1557
|
+
});
|
|
1558
|
+
}
|
|
1559
|
+
function applyPreset(range) {
|
|
1560
|
+
emit("change", {
|
|
1561
|
+
type: "date_range",
|
|
1562
|
+
value: range
|
|
1563
|
+
}, true);
|
|
1564
|
+
}
|
|
1565
|
+
return (_ctx, _cache) => {
|
|
1566
|
+
return openBlock(), createElementBlock("div", {
|
|
1567
|
+
class: normalizeClass(["astryx-power-search-value", { "is-sheet": isSheet.value }]),
|
|
1568
|
+
onPaste
|
|
1569
|
+
}, [__props.operatorValue.type === "string" && __props.operatorValue.searchSource ? (openBlock(), createBlock(_sfc_main$39, {
|
|
1570
|
+
key: 0,
|
|
1571
|
+
label: text.value.value,
|
|
1572
|
+
"label-hidden": "",
|
|
1573
|
+
"search-source": stringSource.value,
|
|
1574
|
+
"model-value": selectedStringItem.value,
|
|
1575
|
+
placeholder: text.value.searchPlaceholder,
|
|
1576
|
+
disabled: __props.disabled,
|
|
1577
|
+
"max-menu-items": __props.maxMenuItems,
|
|
1578
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = (item) => changeOrUnstage({
|
|
1579
|
+
type: "string",
|
|
1580
|
+
value: item?.label ?? ""
|
|
1581
|
+
}, item == null, Boolean(item)))
|
|
1582
|
+
}, null, 8, [
|
|
1583
|
+
"label",
|
|
1584
|
+
"search-source",
|
|
1585
|
+
"model-value",
|
|
1586
|
+
"placeholder",
|
|
1587
|
+
"disabled",
|
|
1588
|
+
"max-menu-items"
|
|
1589
|
+
])) : __props.operatorValue.type === "string" ? (openBlock(), createBlock(_sfc_main$35, {
|
|
1590
|
+
key: 1,
|
|
1591
|
+
label: text.value.value,
|
|
1592
|
+
"is-label-hidden": "",
|
|
1593
|
+
"model-value": stringValue.value,
|
|
1594
|
+
placeholder: text.value.enterValuePlaceholder,
|
|
1595
|
+
disabled: __props.disabled,
|
|
1596
|
+
"onUpdate:modelValue": onString
|
|
1597
|
+
}, null, 8, [
|
|
1598
|
+
"label",
|
|
1599
|
+
"model-value",
|
|
1600
|
+
"placeholder",
|
|
1601
|
+
"disabled"
|
|
1602
|
+
])) : __props.operatorValue.type === "string_list" ? (openBlock(), createBlock(_sfc_main$33, {
|
|
1603
|
+
key: 2,
|
|
1604
|
+
presentation: tokenizerPresentation.value,
|
|
1605
|
+
label: isSheet.value && __props.fieldLabel ? __props.fieldLabel : text.value.values,
|
|
1606
|
+
"label-hidden": "",
|
|
1607
|
+
"search-source": stringSource.value,
|
|
1608
|
+
"model-value": stringItems.value,
|
|
1609
|
+
placeholder: text.value.addValuesPlaceholder,
|
|
1610
|
+
disabled: __props.disabled,
|
|
1611
|
+
creatable: stringCreatable.value,
|
|
1612
|
+
"max-menu-items": __props.maxMenuItems,
|
|
1613
|
+
"onUpdate:modelValue": commitStringList
|
|
1614
|
+
}, null, 8, [
|
|
1615
|
+
"presentation",
|
|
1616
|
+
"label",
|
|
1617
|
+
"search-source",
|
|
1618
|
+
"model-value",
|
|
1619
|
+
"placeholder",
|
|
1620
|
+
"disabled",
|
|
1621
|
+
"creatable",
|
|
1622
|
+
"max-menu-items"
|
|
1623
|
+
])) : __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", {
|
|
1624
|
+
class: "astryx-power-search-value",
|
|
1625
|
+
onFocusin: _cache[1] || (_cache[1] = ($event) => numberDecision.value = null),
|
|
1626
|
+
onInput: rememberNumberDraft,
|
|
1627
|
+
onKeydown: onNumberKeydown
|
|
1628
|
+
}, [createVNode(_sfc_main$31, {
|
|
1629
|
+
label: text.value.value,
|
|
1630
|
+
"is-label-hidden": "",
|
|
1631
|
+
"model-value": numberValue.value,
|
|
1632
|
+
placeholder: text.value.enterNumberPlaceholder,
|
|
1633
|
+
disabled: __props.disabled,
|
|
1634
|
+
min: __props.operatorValue.minValue,
|
|
1635
|
+
max: __props.operatorValue.maxValue,
|
|
1636
|
+
step: __props.operatorValue.type === "integer" ? 1 : void 0,
|
|
1637
|
+
units: __props.operatorValue.units,
|
|
1638
|
+
"onUpdate:modelValue": onNumber
|
|
1639
|
+
}, null, 8, [
|
|
1640
|
+
"label",
|
|
1641
|
+
"model-value",
|
|
1642
|
+
"placeholder",
|
|
1643
|
+
"disabled",
|
|
1644
|
+
"min",
|
|
1645
|
+
"max",
|
|
1646
|
+
"step",
|
|
1647
|
+
"units"
|
|
1648
|
+
])], 32)], 2112)) : __props.operatorValue.type === "time" ? (openBlock(), createBlock(_sfc_main$38, {
|
|
1649
|
+
key: 4,
|
|
1650
|
+
label: text.value.time,
|
|
1651
|
+
"is-label-hidden": "",
|
|
1652
|
+
"model-value": timeValue.value,
|
|
1653
|
+
min: __props.operatorValue.minValue,
|
|
1654
|
+
max: __props.operatorValue.maxValue,
|
|
1655
|
+
"is-disabled": __props.disabled,
|
|
1656
|
+
"entry-error-behavior": "complete",
|
|
1657
|
+
"onUpdate:modelValue": onTime
|
|
1658
|
+
}, null, 8, [
|
|
1659
|
+
"label",
|
|
1660
|
+
"model-value",
|
|
1661
|
+
"min",
|
|
1662
|
+
"max",
|
|
1663
|
+
"is-disabled"
|
|
1664
|
+
])) : __props.operatorValue.type === "date_absolute" && dateOnly.value ? (openBlock(), createBlock(_sfc_main$25, {
|
|
1665
|
+
key: 5,
|
|
1666
|
+
label: text.value.date,
|
|
1667
|
+
"is-label-hidden": "",
|
|
1668
|
+
"model-value": absoluteDate.value,
|
|
1669
|
+
"is-disabled": __props.disabled,
|
|
1670
|
+
"entry-error-behavior": "complete",
|
|
1671
|
+
"onUpdate:modelValue": onAbsoluteDate
|
|
1672
|
+
}, null, 8, [
|
|
1673
|
+
"label",
|
|
1674
|
+
"model-value",
|
|
1675
|
+
"is-disabled"
|
|
1676
|
+
])) : __props.operatorValue.type === "date_absolute" ? (openBlock(), createBlock(_sfc_main$27, {
|
|
1677
|
+
key: 6,
|
|
1678
|
+
label: text.value.date,
|
|
1679
|
+
"is-label-hidden": "",
|
|
1680
|
+
"model-value": absoluteLocal.value,
|
|
1681
|
+
"is-disabled": __props.disabled,
|
|
1682
|
+
"entry-error-behavior": "complete",
|
|
1683
|
+
"onUpdate:modelValue": onAbsoluteDateTime
|
|
1684
|
+
}, null, 8, [
|
|
1685
|
+
"label",
|
|
1686
|
+
"model-value",
|
|
1687
|
+
"is-disabled"
|
|
1688
|
+
])) : __props.operatorValue.type === "date_relative" ? (openBlock(), createBlock(_sfc_main$32, {
|
|
1689
|
+
key: 7,
|
|
1690
|
+
label: text.value.relativeDate,
|
|
1691
|
+
"is-label-hidden": "",
|
|
1692
|
+
options: relativeOptions.value,
|
|
1693
|
+
"model-value": relativeValue.value || null,
|
|
1694
|
+
placeholder: text.value.selectPlaceholder,
|
|
1695
|
+
disabled: __props.disabled,
|
|
1696
|
+
"onUpdate:modelValue": _cache[2] || (_cache[2] = (value) => emit("change", {
|
|
1697
|
+
type: "date_relative",
|
|
1698
|
+
value: String(value ?? "")
|
|
1699
|
+
}, true))
|
|
1700
|
+
}, null, 8, [
|
|
1701
|
+
"label",
|
|
1702
|
+
"options",
|
|
1703
|
+
"model-value",
|
|
1704
|
+
"placeholder",
|
|
1705
|
+
"disabled"
|
|
1706
|
+
])) : __props.operatorValue.type === "date_range" ? (openBlock(), createElementBlock("div", _hoisted_1$6, [__props.operatorValue.intervalDatePresets?.length ? (openBlock(), createElementBlock("div", {
|
|
1707
|
+
key: 0,
|
|
1708
|
+
class: "astryx-power-search-presets",
|
|
1709
|
+
role: "group",
|
|
1710
|
+
"aria-label": text.value.date
|
|
1711
|
+
}, [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.operatorValue.intervalDatePresets, (preset) => {
|
|
1712
|
+
return openBlock(), createElementBlock("button", {
|
|
1713
|
+
key: preset.label,
|
|
1714
|
+
type: "button",
|
|
1715
|
+
class: "astryx-power-search-preset",
|
|
1716
|
+
disabled: __props.disabled,
|
|
1717
|
+
onClick: ($event) => applyPreset(preset.value)
|
|
1718
|
+
}, toDisplayString(preset.label), 9, _hoisted_3$5);
|
|
1719
|
+
}), 128))], 8, _hoisted_2$6)) : createCommentVNode("v-if", true), isSheet.value ? (openBlock(), createBlock(_sfc_main$19, {
|
|
1720
|
+
key: 1,
|
|
1721
|
+
mode: "range",
|
|
1722
|
+
label: __props.fieldLabel ?? text.value.date,
|
|
1723
|
+
range: calendarRange.value,
|
|
1724
|
+
disabled: __props.disabled,
|
|
1725
|
+
"onUpdate:range": onCalendarRange
|
|
1726
|
+
}, null, 8, [
|
|
1727
|
+
"label",
|
|
1728
|
+
"range",
|
|
1729
|
+
"disabled"
|
|
1730
|
+
])) : (openBlock(), createBlock(_sfc_main$26, {
|
|
1731
|
+
key: 2,
|
|
1732
|
+
label: text.value.date,
|
|
1733
|
+
"is-label-hidden": "",
|
|
1734
|
+
"model-value": rangeModel.value,
|
|
1735
|
+
"is-disabled": __props.disabled,
|
|
1736
|
+
"onUpdate:modelValue": onRange
|
|
1737
|
+
}, null, 8, [
|
|
1738
|
+
"label",
|
|
1739
|
+
"model-value",
|
|
1740
|
+
"is-disabled"
|
|
1741
|
+
]))])) : __props.operatorValue.type === "enum" ? (openBlock(), createBlock(_sfc_main$32, {
|
|
1742
|
+
key: 9,
|
|
1743
|
+
label: text.value.value,
|
|
1744
|
+
"is-label-hidden": "",
|
|
1745
|
+
options: enumOptions.value,
|
|
1746
|
+
"model-value": enumValue.value,
|
|
1747
|
+
placeholder: text.value.selectPlaceholder,
|
|
1748
|
+
disabled: __props.disabled,
|
|
1749
|
+
"onUpdate:modelValue": _cache[3] || (_cache[3] = (value) => emit("change", {
|
|
1750
|
+
type: "enum",
|
|
1751
|
+
value: String(value ?? "")
|
|
1752
|
+
}, true))
|
|
1753
|
+
}, null, 8, [
|
|
1754
|
+
"label",
|
|
1755
|
+
"options",
|
|
1756
|
+
"model-value",
|
|
1757
|
+
"placeholder",
|
|
1758
|
+
"disabled"
|
|
1759
|
+
])) : __props.operatorValue.type === "enum_list" ? (openBlock(), createBlock(_sfc_main$30, {
|
|
1760
|
+
key: 10,
|
|
1761
|
+
label: text.value.values,
|
|
1762
|
+
"label-hidden": "",
|
|
1763
|
+
options: enumOptions.value,
|
|
1764
|
+
"model-value": enumList.value,
|
|
1765
|
+
placeholder: text.value.selectValuesPlaceholder,
|
|
1766
|
+
disabled: __props.disabled,
|
|
1767
|
+
"onUpdate:modelValue": _cache[4] || (_cache[4] = (value) => emit("change", {
|
|
1768
|
+
type: "enum_list",
|
|
1769
|
+
value: value.map(String)
|
|
1770
|
+
}))
|
|
1771
|
+
}, null, 8, [
|
|
1772
|
+
"label",
|
|
1773
|
+
"options",
|
|
1774
|
+
"model-value",
|
|
1775
|
+
"placeholder",
|
|
1776
|
+
"disabled"
|
|
1777
|
+
])) : __props.operatorValue.type === "entity_list" ? (openBlock(), createBlock(_sfc_main$33, {
|
|
1778
|
+
key: 11,
|
|
1779
|
+
presentation: tokenizerPresentation.value,
|
|
1780
|
+
label: isSheet.value && __props.fieldLabel ? __props.fieldLabel : text.value.entities,
|
|
1781
|
+
"label-hidden": "",
|
|
1782
|
+
"search-source": entitySource.value,
|
|
1783
|
+
"model-value": entityItems.value,
|
|
1784
|
+
placeholder: text.value.searchPlaceholder,
|
|
1785
|
+
disabled: __props.disabled,
|
|
1786
|
+
creatable: stringCreatable.value,
|
|
1787
|
+
"max-menu-items": __props.maxMenuItems,
|
|
1788
|
+
"onUpdate:modelValue": commitEntities
|
|
1789
|
+
}, null, 8, [
|
|
1790
|
+
"presentation",
|
|
1791
|
+
"label",
|
|
1792
|
+
"search-source",
|
|
1793
|
+
"model-value",
|
|
1794
|
+
"placeholder",
|
|
1795
|
+
"disabled",
|
|
1796
|
+
"creatable",
|
|
1797
|
+
"max-menu-items"
|
|
1798
|
+
])) : __props.operatorValue.type === "custom" ? (openBlock(), createBlock(resolveDynamicComponent(__props.operatorValue.Editor), {
|
|
1799
|
+
key: 12,
|
|
1800
|
+
"model-value": customValue.value,
|
|
1801
|
+
value: customValue.value,
|
|
1802
|
+
placeholder: text.value.enterValuePlaceholder,
|
|
1803
|
+
disabled: __props.disabled,
|
|
1804
|
+
"is-disabled": __props.disabled,
|
|
1805
|
+
"onUpdate:modelValue": onCustomValue,
|
|
1806
|
+
onChange: onCustomValue
|
|
1807
|
+
}, null, 40, [
|
|
1808
|
+
"model-value",
|
|
1809
|
+
"value",
|
|
1810
|
+
"placeholder",
|
|
1811
|
+
"disabled",
|
|
1812
|
+
"is-disabled"
|
|
1813
|
+
])) : createCommentVNode("v-if", true)], 34);
|
|
1814
|
+
};
|
|
1815
|
+
}
|
|
1816
|
+
});
|
|
1817
|
+
//#endregion
|
|
1818
|
+
//#region src/PowerSearch/PowerSearchNestedRows.vue
|
|
1819
|
+
const _hoisted_1$5 = { class: "astryx-power-search-nested" };
|
|
1820
|
+
const _hoisted_2$5 = { class: "astryx-power-search-editor-row" };
|
|
1821
|
+
const _hoisted_3$4 = ["aria-label", "onClick"];
|
|
1822
|
+
const _sfc_main$6 = /*@__PURE__*/ defineComponent({
|
|
1823
|
+
name: "AstryxPowerSearchNestedRows",
|
|
1824
|
+
__name: "PowerSearchNestedRows",
|
|
1825
|
+
props: {
|
|
1826
|
+
config: {},
|
|
1827
|
+
modelValue: {},
|
|
1828
|
+
disabled: { type: Boolean },
|
|
1829
|
+
timeZone: {},
|
|
1830
|
+
maxMenuItems: {}
|
|
1831
|
+
},
|
|
1832
|
+
emits: ["update:modelValue"],
|
|
1833
|
+
setup(__props, { emit: __emit }) {
|
|
1834
|
+
const props = __props;
|
|
1835
|
+
const emit = __emit;
|
|
1836
|
+
const messages = useComponentMessages({ powerSearch: powerSearchMessages });
|
|
1837
|
+
const lookup = computed(() => createPowerSearchLookup(props.config));
|
|
1838
|
+
const text = computed(() => messages.value.powerSearch);
|
|
1839
|
+
const fieldOptions = computed(() => lookup.value.getVisibleFields().map((field) => ({
|
|
1840
|
+
value: field.key,
|
|
1841
|
+
label: field.label
|
|
1842
|
+
})));
|
|
1843
|
+
function operatorOptions(fieldKey) {
|
|
1844
|
+
return lookup.value.getVisibleOperators(fieldKey).map((operator) => ({
|
|
1845
|
+
value: operator.key,
|
|
1846
|
+
label: resolveOperatorLabel(operator, messages.value.powerSearch)
|
|
1847
|
+
}));
|
|
1848
|
+
}
|
|
1849
|
+
function operatorOf(row) {
|
|
1850
|
+
if (row.operator == null) return void 0;
|
|
1851
|
+
return lookup.value.getOperator(row.field, row.operator);
|
|
1852
|
+
}
|
|
1853
|
+
function replace(index, next) {
|
|
1854
|
+
const rows = props.modelValue.map((row, rowIndex) => rowIndex === index ? next : row);
|
|
1855
|
+
emit("update:modelValue", [...rows]);
|
|
1856
|
+
}
|
|
1857
|
+
function onField(index, fieldKey) {
|
|
1858
|
+
const key = String(fieldKey ?? "");
|
|
1859
|
+
if (key === "") return;
|
|
1860
|
+
const operator = lookup.value.getDefaultOperator(key);
|
|
1861
|
+
replace(index, {
|
|
1862
|
+
field: key,
|
|
1863
|
+
operator: operator?.key,
|
|
1864
|
+
children: operator?.value.type === "nested" ? [] : void 0
|
|
1865
|
+
});
|
|
1866
|
+
}
|
|
1867
|
+
function onOperator(index, row, operatorKey) {
|
|
1868
|
+
const key = String(operatorKey ?? "");
|
|
1869
|
+
const next = lookup.value.getOperator(row.field, key);
|
|
1870
|
+
const previous = operatorOf(row);
|
|
1871
|
+
const keep = next != null && previous != null && next.value.type === previous.value.type;
|
|
1872
|
+
replace(index, {
|
|
1873
|
+
field: row.field,
|
|
1874
|
+
operator: key,
|
|
1875
|
+
value: keep && next?.value.type !== "nested" ? row.value : void 0,
|
|
1876
|
+
children: keep && next?.value.type === "nested" ? row.children ?? [] : next?.value.type === "nested" ? [] : void 0,
|
|
1877
|
+
isReadOnly: row.isReadOnly
|
|
1878
|
+
});
|
|
1879
|
+
}
|
|
1880
|
+
function onValue(index, row, value) {
|
|
1881
|
+
replace(index, {
|
|
1882
|
+
...row,
|
|
1883
|
+
value
|
|
1884
|
+
});
|
|
1885
|
+
}
|
|
1886
|
+
function nestedRows(row) {
|
|
1887
|
+
return [...row.children ?? []];
|
|
1888
|
+
}
|
|
1889
|
+
function onNested(index, row, rows) {
|
|
1890
|
+
replace(index, {
|
|
1891
|
+
...row,
|
|
1892
|
+
children: rows
|
|
1893
|
+
});
|
|
1894
|
+
}
|
|
1895
|
+
function onNestedUpdate(index, row, rows) {
|
|
1896
|
+
onNested(index, row, rows);
|
|
1897
|
+
}
|
|
1898
|
+
function add() {
|
|
1899
|
+
const field = lookup.value.getVisibleFields()[0];
|
|
1900
|
+
if (field == null) return;
|
|
1901
|
+
const operator = lookup.value.getDefaultOperator(field.key);
|
|
1902
|
+
emit("update:modelValue", [...props.modelValue, {
|
|
1903
|
+
field: field.key,
|
|
1904
|
+
operator: operator?.key,
|
|
1905
|
+
children: operator?.value.type === "nested" ? [] : void 0
|
|
1906
|
+
}]);
|
|
1907
|
+
}
|
|
1908
|
+
function remove(index) {
|
|
1909
|
+
emit("update:modelValue", props.modelValue.filter((_, rowIndex) => rowIndex !== index));
|
|
1910
|
+
}
|
|
1911
|
+
return (_ctx, _cache) => {
|
|
1912
|
+
const _component_PowerSearchNestedRows = resolveComponent("PowerSearchNestedRows", true);
|
|
1913
|
+
return openBlock(), createElementBlock("div", _hoisted_1$5, [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.modelValue, (row, index) => {
|
|
1914
|
+
return openBlock(), createElementBlock("div", {
|
|
1915
|
+
key: `${row.field}-${index}`,
|
|
1916
|
+
class: "astryx-power-search-nested-row"
|
|
1917
|
+
}, [createElementVNode("div", _hoisted_2$5, [
|
|
1918
|
+
createVNode(_sfc_main$32, {
|
|
1919
|
+
label: text.value.editor.field,
|
|
1920
|
+
"is-label-hidden": "",
|
|
1921
|
+
options: fieldOptions.value,
|
|
1922
|
+
"model-value": row.field,
|
|
1923
|
+
disabled: __props.disabled,
|
|
1924
|
+
"onUpdate:modelValue": (value) => onField(index, value)
|
|
1925
|
+
}, null, 8, [
|
|
1926
|
+
"label",
|
|
1927
|
+
"options",
|
|
1928
|
+
"model-value",
|
|
1929
|
+
"disabled",
|
|
1930
|
+
"onUpdate:modelValue"
|
|
1931
|
+
]),
|
|
1932
|
+
operatorOptions(row.field).length > 0 ? (openBlock(), createBlock(_sfc_main$32, {
|
|
1933
|
+
key: 0,
|
|
1934
|
+
label: text.value.editor.operator,
|
|
1935
|
+
"is-label-hidden": "",
|
|
1936
|
+
options: operatorOptions(row.field),
|
|
1937
|
+
"model-value": row.operator ?? null,
|
|
1938
|
+
disabled: __props.disabled,
|
|
1939
|
+
"onUpdate:modelValue": (value) => onOperator(index, row, value)
|
|
1940
|
+
}, null, 8, [
|
|
1941
|
+
"label",
|
|
1942
|
+
"options",
|
|
1943
|
+
"model-value",
|
|
1944
|
+
"disabled",
|
|
1945
|
+
"onUpdate:modelValue"
|
|
1946
|
+
])) : createCommentVNode("v-if", true),
|
|
1947
|
+
operatorOf(row) && operatorOf(row)?.value.type !== "empty" && operatorOf(row)?.value.type !== "nested" ? (openBlock(), createBlock(_sfc_main$7, {
|
|
1948
|
+
key: `${row.field}:${row.operator ?? ""}`,
|
|
1949
|
+
"operator-value": operatorOf(row).value,
|
|
1950
|
+
"filter-value": row.value,
|
|
1951
|
+
messages: unref(messages).powerSearch,
|
|
1952
|
+
disabled: __props.disabled,
|
|
1953
|
+
"time-zone": __props.timeZone,
|
|
1954
|
+
"max-menu-items": __props.maxMenuItems,
|
|
1955
|
+
onChange: (filterValue) => onValue(index, row, filterValue)
|
|
1956
|
+
}, null, 8, [
|
|
1957
|
+
"operator-value",
|
|
1958
|
+
"filter-value",
|
|
1959
|
+
"messages",
|
|
1960
|
+
"disabled",
|
|
1961
|
+
"time-zone",
|
|
1962
|
+
"max-menu-items",
|
|
1963
|
+
"onChange"
|
|
1964
|
+
])) : createCommentVNode("v-if", true),
|
|
1965
|
+
!__props.disabled ? (openBlock(), createElementBlock("button", {
|
|
1966
|
+
key: 2,
|
|
1967
|
+
type: "button",
|
|
1968
|
+
class: "astryx-power-search-icon-button",
|
|
1969
|
+
"aria-label": text.value.editor.removeFilter,
|
|
1970
|
+
onClick: ($event) => remove(index)
|
|
1971
|
+
}, [createVNode(_sfc_main$13, {
|
|
1972
|
+
icon: "close",
|
|
1973
|
+
size: "sm"
|
|
1974
|
+
})], 8, _hoisted_3$4)) : createCommentVNode("v-if", true)
|
|
1975
|
+
]), operatorOf(row)?.value.type === "nested" ? (openBlock(), createBlock(_component_PowerSearchNestedRows, {
|
|
1976
|
+
key: 0,
|
|
1977
|
+
config: __props.config,
|
|
1978
|
+
"model-value": nestedRows(row),
|
|
1979
|
+
disabled: __props.disabled,
|
|
1980
|
+
"time-zone": __props.timeZone,
|
|
1981
|
+
"max-menu-items": __props.maxMenuItems,
|
|
1982
|
+
"onUpdate:modelValue": ($event) => onNestedUpdate(index, row, $event)
|
|
1983
|
+
}, null, 8, [
|
|
1984
|
+
"config",
|
|
1985
|
+
"model-value",
|
|
1986
|
+
"disabled",
|
|
1987
|
+
"time-zone",
|
|
1988
|
+
"max-menu-items",
|
|
1989
|
+
"onUpdate:modelValue"
|
|
1990
|
+
])) : createCommentVNode("v-if", true)]);
|
|
1991
|
+
}), 128)), !__props.disabled ? (openBlock(), createBlock(_sfc_main$14, {
|
|
1992
|
+
key: 0,
|
|
1993
|
+
label: text.value.editor.addFilter,
|
|
1994
|
+
variant: "ghost",
|
|
1995
|
+
size: "sm",
|
|
1996
|
+
onClick: add
|
|
1997
|
+
}, null, 8, ["label"])) : createCommentVNode("v-if", true)]);
|
|
1998
|
+
};
|
|
1999
|
+
}
|
|
2000
|
+
});
|
|
2001
|
+
//#endregion
|
|
2002
|
+
//#region src/PowerSearch/PowerSearchEditor.vue
|
|
2003
|
+
const _hoisted_1$4 = ["aria-label"];
|
|
2004
|
+
const _hoisted_2$4 = { class: "astryx-power-search-editor-row" };
|
|
2005
|
+
const _hoisted_3$3 = {
|
|
2006
|
+
key: 0,
|
|
2007
|
+
class: "astryx-power-search-editor-nested"
|
|
2008
|
+
};
|
|
2009
|
+
const _hoisted_4$3 = { class: "astryx-power-search-editor-group" };
|
|
2010
|
+
const _hoisted_5$3 = {
|
|
2011
|
+
key: 1,
|
|
2012
|
+
class: "astryx-power-search-editor-footer"
|
|
2013
|
+
};
|
|
2014
|
+
const _hoisted_6$2 = { key: 1 };
|
|
2015
|
+
const _hoisted_7$1 = { class: "astryx-power-search-editor-actions" };
|
|
2016
|
+
const focusable = "input:not([disabled]), button:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex=\"-1\"])";
|
|
2017
|
+
const _sfc_main$5 = /*@__PURE__*/ defineComponent({
|
|
2018
|
+
name: "AstryxPowerSearchEditor",
|
|
2019
|
+
__name: "PowerSearchEditor",
|
|
2020
|
+
props: {
|
|
2021
|
+
config: {},
|
|
2022
|
+
filter: {},
|
|
2023
|
+
mode: {},
|
|
2024
|
+
saveLabel: {},
|
|
2025
|
+
readOnly: { type: Boolean },
|
|
2026
|
+
timeZone: {},
|
|
2027
|
+
maxMenuItems: {},
|
|
2028
|
+
onSave: { type: Function },
|
|
2029
|
+
onCancel: { type: Function }
|
|
2030
|
+
},
|
|
2031
|
+
setup(__props) {
|
|
2032
|
+
const props = __props;
|
|
2033
|
+
if (isDevBuild() && props.config == null) throw devPropError("PowerSearchEditor", "config", "is required: the same config as the PowerSearch it edits.");
|
|
2034
|
+
const messages = useComponentMessages({ powerSearch: powerSearchMessages });
|
|
2035
|
+
const lookup = computed(() => createPowerSearchLookup(props.config));
|
|
2036
|
+
const text = computed(() => messages.value.powerSearch);
|
|
2037
|
+
const root = useTemplateRef("root");
|
|
2038
|
+
const valueRoot = useTemplateRef("valueRoot");
|
|
2039
|
+
const fieldKey = ref(props.filter.field);
|
|
2040
|
+
const operatorKey = ref(props.filter.operator ?? lookup.value.getDefaultOperator(props.filter.field)?.key ?? "");
|
|
2041
|
+
const draft = ref(props.filter.value?.type === "nested" ? void 0 : props.filter.value);
|
|
2042
|
+
const children = ref(props.filter.value?.type === "nested" ? [...props.filter.value.value] : []);
|
|
2043
|
+
const fieldOptions = computed(() => lookup.value.getVisibleFields().map((field) => ({
|
|
2044
|
+
value: field.key,
|
|
2045
|
+
label: field.label
|
|
2046
|
+
})));
|
|
2047
|
+
const operatorOptions = computed(() => lookup.value.getVisibleOperators(fieldKey.value).map((operator) => ({
|
|
2048
|
+
value: operator.key,
|
|
2049
|
+
label: resolveOperatorLabel(operator, messages.value.powerSearch)
|
|
2050
|
+
})));
|
|
2051
|
+
const operatorValue = computed(() => lookup.value.getOperator(fieldKey.value, operatorKey.value)?.value);
|
|
2052
|
+
const partial = computed(() => ({
|
|
2053
|
+
field: fieldKey.value,
|
|
2054
|
+
operator: operatorKey.value || void 0,
|
|
2055
|
+
value: operatorValue.value?.type === "nested" ? void 0 : draft.value,
|
|
2056
|
+
children: operatorValue.value?.type === "nested" ? children.value : void 0,
|
|
2057
|
+
isReadOnly: props.filter.isReadOnly
|
|
2058
|
+
}));
|
|
2059
|
+
const completed = computed(() => completePowerSearchFilter(partial.value, lookup.value));
|
|
2060
|
+
const showFooter = computed(() => operatorValue.value != null && operatorValue.value.type !== "empty");
|
|
2061
|
+
function focusWithin(element) {
|
|
2062
|
+
element?.querySelector(focusable)?.focus();
|
|
2063
|
+
}
|
|
2064
|
+
function saveIfEmpty(field, operatorKeyValue) {
|
|
2065
|
+
const operator = operatorKeyValue ? lookup.value.getOperator(field, operatorKeyValue) : void 0;
|
|
2066
|
+
if (operator?.value.type !== "empty") return;
|
|
2067
|
+
queueMicrotask(() => {
|
|
2068
|
+
props.onSave({
|
|
2069
|
+
field,
|
|
2070
|
+
operator: operator.key,
|
|
2071
|
+
value: { type: "empty" },
|
|
2072
|
+
isReadOnly: props.filter.isReadOnly
|
|
2073
|
+
});
|
|
2074
|
+
});
|
|
2075
|
+
}
|
|
2076
|
+
function onField(next) {
|
|
2077
|
+
const key = String(next ?? "");
|
|
2078
|
+
if (key === "" || key === fieldKey.value) return;
|
|
2079
|
+
const operator = lookup.value.getDefaultOperator(key);
|
|
2080
|
+
fieldKey.value = key;
|
|
2081
|
+
operatorKey.value = operator?.key ?? "";
|
|
2082
|
+
children.value = [];
|
|
2083
|
+
draft.value = void 0;
|
|
2084
|
+
saveIfEmpty(key, operator?.key);
|
|
2085
|
+
}
|
|
2086
|
+
function onOperator(next) {
|
|
2087
|
+
const key = String(next ?? "");
|
|
2088
|
+
if (key === "" || key === operatorKey.value) return;
|
|
2089
|
+
const nextOperator = lookup.value.getOperator(fieldKey.value, key);
|
|
2090
|
+
const previous = lookup.value.getOperator(fieldKey.value, operatorKey.value);
|
|
2091
|
+
const keep = nextOperator != null && previous != null && nextOperator.value.type === previous.value.type;
|
|
2092
|
+
operatorKey.value = key;
|
|
2093
|
+
if (!keep) {
|
|
2094
|
+
children.value = [];
|
|
2095
|
+
draft.value = void 0;
|
|
2096
|
+
}
|
|
2097
|
+
saveIfEmpty(fieldKey.value, key);
|
|
2098
|
+
}
|
|
2099
|
+
function onValue(value, shouldSave) {
|
|
2100
|
+
draft.value = value;
|
|
2101
|
+
if (shouldSave) save();
|
|
2102
|
+
}
|
|
2103
|
+
function save() {
|
|
2104
|
+
const filter = completePowerSearchFilter({
|
|
2105
|
+
field: fieldKey.value,
|
|
2106
|
+
operator: operatorKey.value,
|
|
2107
|
+
value: draft.value,
|
|
2108
|
+
isReadOnly: props.filter.isReadOnly
|
|
2109
|
+
}, lookup.value);
|
|
2110
|
+
if (filter) props.onSave(filter);
|
|
2111
|
+
}
|
|
2112
|
+
function onKeydown(event) {
|
|
2113
|
+
if (event.isComposing || event.key === "Process") return;
|
|
2114
|
+
if (event.key === "Escape" && !event.defaultPrevented) {
|
|
2115
|
+
event.preventDefault();
|
|
2116
|
+
props.onCancel();
|
|
2117
|
+
return;
|
|
2118
|
+
}
|
|
2119
|
+
if (event.key === "Enter" && event.target instanceof HTMLButtonElement) return;
|
|
2120
|
+
if (event.key === "Enter" && completed.value && !event.defaultPrevented) {
|
|
2121
|
+
event.preventDefault();
|
|
2122
|
+
save();
|
|
2123
|
+
}
|
|
2124
|
+
}
|
|
2125
|
+
watch([fieldKey, operatorKey], () => {
|
|
2126
|
+
nextTick(() => {
|
|
2127
|
+
requestAnimationFrame(() => focusWithin(valueRoot.value));
|
|
2128
|
+
});
|
|
2129
|
+
});
|
|
2130
|
+
onMounted(() => {
|
|
2131
|
+
nextTick(() => {
|
|
2132
|
+
requestAnimationFrame(() => focusWithin(valueRoot.value ?? root.value));
|
|
2133
|
+
});
|
|
2134
|
+
});
|
|
2135
|
+
return (_ctx, _cache) => {
|
|
2136
|
+
return openBlock(), createElementBlock(Fragment, null, [createCommentVNode(" eslint-disable-next-line vue-a11y/no-static-element-interactions -- 编辑器整组接收 Enter 和 Escape。 "), createElementVNode("div", {
|
|
2137
|
+
ref_key: "root",
|
|
2138
|
+
ref: root,
|
|
2139
|
+
class: "astryx-power-search-editor-body",
|
|
2140
|
+
role: "group",
|
|
2141
|
+
"aria-label": text.value.editor.editing,
|
|
2142
|
+
tabindex: "-1",
|
|
2143
|
+
onKeydown
|
|
2144
|
+
}, [
|
|
2145
|
+
createElementVNode("div", _hoisted_2$4, [
|
|
2146
|
+
createVNode(_sfc_main$32, {
|
|
2147
|
+
label: text.value.editor.field,
|
|
2148
|
+
"is-label-hidden": "",
|
|
2149
|
+
options: fieldOptions.value,
|
|
2150
|
+
"model-value": fieldKey.value,
|
|
2151
|
+
disabled: __props.readOnly,
|
|
2152
|
+
"onUpdate:modelValue": onField
|
|
2153
|
+
}, null, 8, [
|
|
2154
|
+
"label",
|
|
2155
|
+
"options",
|
|
2156
|
+
"model-value",
|
|
2157
|
+
"disabled"
|
|
2158
|
+
]),
|
|
2159
|
+
operatorOptions.value.length > 1 || operatorValue.value?.type !== "empty" ? (openBlock(), createBlock(_sfc_main$32, {
|
|
2160
|
+
key: 0,
|
|
2161
|
+
label: text.value.editor.operator,
|
|
2162
|
+
"is-label-hidden": "",
|
|
2163
|
+
options: operatorOptions.value,
|
|
2164
|
+
"model-value": operatorKey.value || null,
|
|
2165
|
+
disabled: __props.readOnly,
|
|
2166
|
+
"onUpdate:modelValue": onOperator
|
|
2167
|
+
}, null, 8, [
|
|
2168
|
+
"label",
|
|
2169
|
+
"options",
|
|
2170
|
+
"model-value",
|
|
2171
|
+
"disabled"
|
|
2172
|
+
])) : createCommentVNode("v-if", true),
|
|
2173
|
+
operatorValue.value && operatorValue.value.type !== "empty" && operatorValue.value.type !== "nested" ? (openBlock(), createElementBlock("div", {
|
|
2174
|
+
key: 1,
|
|
2175
|
+
ref_key: "valueRoot",
|
|
2176
|
+
ref: valueRoot,
|
|
2177
|
+
class: "astryx-power-search-editor-value"
|
|
2178
|
+
}, [(openBlock(), createBlock(_sfc_main$7, {
|
|
2179
|
+
key: `${fieldKey.value}:${operatorKey.value}`,
|
|
2180
|
+
"operator-value": operatorValue.value,
|
|
2181
|
+
"filter-value": draft.value,
|
|
2182
|
+
messages: unref(messages).powerSearch,
|
|
2183
|
+
disabled: __props.readOnly,
|
|
2184
|
+
"time-zone": __props.timeZone,
|
|
2185
|
+
"max-menu-items": __props.maxMenuItems,
|
|
2186
|
+
onChange: onValue
|
|
2187
|
+
}, null, 8, [
|
|
2188
|
+
"operator-value",
|
|
2189
|
+
"filter-value",
|
|
2190
|
+
"messages",
|
|
2191
|
+
"disabled",
|
|
2192
|
+
"time-zone",
|
|
2193
|
+
"max-menu-items"
|
|
2194
|
+
]))], 512)) : createCommentVNode("v-if", true)
|
|
2195
|
+
]),
|
|
2196
|
+
operatorValue.value?.type === "nested" ? (openBlock(), createElementBlock("div", _hoisted_3$3, [createElementVNode("div", _hoisted_4$3, toDisplayString(text.value.editor.group), 1), createVNode(_sfc_main$6, {
|
|
2197
|
+
config: __props.config,
|
|
2198
|
+
"model-value": children.value,
|
|
2199
|
+
disabled: __props.readOnly,
|
|
2200
|
+
"time-zone": __props.timeZone,
|
|
2201
|
+
"max-menu-items": __props.maxMenuItems,
|
|
2202
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = (rows) => children.value = rows)
|
|
2203
|
+
}, null, 8, [
|
|
2204
|
+
"config",
|
|
2205
|
+
"model-value",
|
|
2206
|
+
"disabled",
|
|
2207
|
+
"time-zone",
|
|
2208
|
+
"max-menu-items"
|
|
2209
|
+
])])) : createCommentVNode("v-if", true),
|
|
2210
|
+
showFooter.value ? (openBlock(), createElementBlock("div", _hoisted_5$3, [__props.mode === "edit" && !__props.readOnly ? (openBlock(), createBlock(_sfc_main$14, {
|
|
2211
|
+
key: 0,
|
|
2212
|
+
label: text.value.editor.delete,
|
|
2213
|
+
variant: "ghost",
|
|
2214
|
+
size: "sm",
|
|
2215
|
+
onClick: _cache[1] || (_cache[1] = ($event) => __props.onSave(null))
|
|
2216
|
+
}, null, 8, ["label"])) : (openBlock(), createElementBlock("span", _hoisted_6$2)), createElementVNode("div", _hoisted_7$1, [createVNode(_sfc_main$14, {
|
|
2217
|
+
label: text.value.editor.cancel,
|
|
2218
|
+
variant: "ghost",
|
|
2219
|
+
size: "sm",
|
|
2220
|
+
onClick: __props.onCancel
|
|
2221
|
+
}, null, 8, ["label", "onClick"]), createVNode(_sfc_main$14, {
|
|
2222
|
+
label: __props.saveLabel || text.value.editor.apply,
|
|
2223
|
+
variant: "primary",
|
|
2224
|
+
size: "sm",
|
|
2225
|
+
"is-disabled": completed.value == null,
|
|
2226
|
+
onClick: save
|
|
2227
|
+
}, null, 8, ["label", "is-disabled"])])])) : createCommentVNode("v-if", true)
|
|
2228
|
+
], 40, _hoisted_1$4)], 2112);
|
|
2229
|
+
};
|
|
2230
|
+
}
|
|
2231
|
+
});
|
|
2232
|
+
//#endregion
|
|
2233
|
+
//#region src/PowerSearch/PowerSearchSheetChoices.vue
|
|
2234
|
+
const _hoisted_1$3 = { class: "astryx-power-search-sheet__choice" };
|
|
2235
|
+
const _hoisted_2$3 = { class: "astryx-power-search-sheet__choice" };
|
|
2236
|
+
const _sfc_main$4 = /*@__PURE__*/ defineComponent({
|
|
2237
|
+
name: "AstryxPowerSearchSheetChoices",
|
|
2238
|
+
__name: "PowerSearchSheetChoices",
|
|
2239
|
+
props: {
|
|
2240
|
+
items: {},
|
|
2241
|
+
selected: {},
|
|
2242
|
+
isMultiple: { type: Boolean },
|
|
2243
|
+
isDisabled: { type: Boolean },
|
|
2244
|
+
label: {}
|
|
2245
|
+
},
|
|
2246
|
+
emits: ["change"],
|
|
2247
|
+
setup(__props, { emit: __emit }) {
|
|
2248
|
+
/**
|
|
2249
|
+
* 封闭的选项在弹层里直接列成行:单选用 RadioList,多选用 CheckboxList。弹层里再叠一层下拉菜单,
|
|
2250
|
+
* 等于在用户已经身处的表面上又盖一层浮层。分组的无障碍名是字段标签。
|
|
2251
|
+
*/
|
|
2252
|
+
const emit = __emit;
|
|
2253
|
+
return (_ctx, _cache) => {
|
|
2254
|
+
return __props.isMultiple ? (openBlock(), createBlock(_sfc_main$23, {
|
|
2255
|
+
key: 0,
|
|
2256
|
+
label: __props.label,
|
|
2257
|
+
"is-label-hidden": "",
|
|
2258
|
+
"is-disabled": __props.isDisabled,
|
|
2259
|
+
"model-value": [...__props.selected],
|
|
2260
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = (values) => emit("change", Array.isArray(values) ? values.map(String) : []))
|
|
2261
|
+
}, {
|
|
2262
|
+
default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.items, (item) => {
|
|
2263
|
+
return openBlock(), createBlock(_sfc_main$24, {
|
|
2264
|
+
key: item.value,
|
|
2265
|
+
value: item.value,
|
|
2266
|
+
label: item.label
|
|
2267
|
+
}, createSlots({ _: 2 }, [item.icon ? {
|
|
2268
|
+
name: "label",
|
|
2269
|
+
fn: withCtx(() => [createElementVNode("span", _hoisted_1$3, [createVNode(_sfc_main$13, {
|
|
2270
|
+
icon: item.icon,
|
|
2271
|
+
size: "sm",
|
|
2272
|
+
"aria-hidden": "true"
|
|
2273
|
+
}, null, 8, ["icon"]), createTextVNode(toDisplayString(item.label), 1)])]),
|
|
2274
|
+
key: "0"
|
|
2275
|
+
} : void 0]), 1032, ["value", "label"]);
|
|
2276
|
+
}), 128))]),
|
|
2277
|
+
_: 1
|
|
2278
|
+
}, 8, [
|
|
2279
|
+
"label",
|
|
2280
|
+
"is-disabled",
|
|
2281
|
+
"model-value"
|
|
2282
|
+
])) : (openBlock(), createBlock(_sfc_main$36, {
|
|
2283
|
+
key: 1,
|
|
2284
|
+
label: __props.label,
|
|
2285
|
+
"is-label-hidden": "",
|
|
2286
|
+
"is-disabled": __props.isDisabled,
|
|
2287
|
+
"model-value": __props.selected[0] ?? "",
|
|
2288
|
+
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => emit("change", [String($event)]))
|
|
2289
|
+
}, {
|
|
2290
|
+
default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.items, (item) => {
|
|
2291
|
+
return openBlock(), createBlock(_sfc_main$37, {
|
|
2292
|
+
key: item.value,
|
|
2293
|
+
value: item.value,
|
|
2294
|
+
label: item.label
|
|
2295
|
+
}, createSlots({ _: 2 }, [item.icon ? {
|
|
2296
|
+
name: "label",
|
|
2297
|
+
fn: withCtx(() => [createElementVNode("span", _hoisted_2$3, [createVNode(_sfc_main$13, {
|
|
2298
|
+
icon: item.icon,
|
|
2299
|
+
size: "sm",
|
|
2300
|
+
"aria-hidden": "true"
|
|
2301
|
+
}, null, 8, ["icon"]), createTextVNode(toDisplayString(item.label), 1)])]),
|
|
2302
|
+
key: "0"
|
|
2303
|
+
} : void 0]), 1032, ["value", "label"]);
|
|
2304
|
+
}), 128))]),
|
|
2305
|
+
_: 1
|
|
2306
|
+
}, 8, [
|
|
2307
|
+
"label",
|
|
2308
|
+
"is-disabled",
|
|
2309
|
+
"model-value"
|
|
2310
|
+
]));
|
|
2311
|
+
};
|
|
2312
|
+
}
|
|
2313
|
+
});
|
|
2314
|
+
//#endregion
|
|
2315
|
+
//#region src/PowerSearch/PowerSearchSheetValue.vue
|
|
2316
|
+
const _hoisted_1$2 = {
|
|
2317
|
+
class: "astryx-power-search-sheet",
|
|
2318
|
+
"data-sheet-step": "value"
|
|
2319
|
+
};
|
|
2320
|
+
const _hoisted_2$2 = { class: "astryx-power-search-sheet__header astryx-power-search-sheet__header--scrolls-to-top" };
|
|
2321
|
+
const _hoisted_3$2 = { class: "astryx-power-search-sheet__header-row" };
|
|
2322
|
+
const _hoisted_4$2 = { class: "astryx-power-search-sheet__body" };
|
|
2323
|
+
const _hoisted_5$2 = {
|
|
2324
|
+
key: 0,
|
|
2325
|
+
class: "astryx-power-search-sheet__section"
|
|
2326
|
+
};
|
|
2327
|
+
const _hoisted_6$1 = {
|
|
2328
|
+
key: 0,
|
|
2329
|
+
class: "astryx-power-search-sheet__footer"
|
|
2330
|
+
};
|
|
2331
|
+
const _sfc_main$3 = /*@__PURE__*/ defineComponent({
|
|
2332
|
+
name: "AstryxPowerSearchSheetValue",
|
|
2333
|
+
__name: "PowerSearchSheetValue",
|
|
2334
|
+
props: {
|
|
2335
|
+
flow: {},
|
|
2336
|
+
lookup: {},
|
|
2337
|
+
config: {},
|
|
2338
|
+
title: {},
|
|
2339
|
+
messages: {},
|
|
2340
|
+
components: {},
|
|
2341
|
+
saveLabel: {},
|
|
2342
|
+
isReadOnly: { type: Boolean },
|
|
2343
|
+
isDisabled: { type: Boolean },
|
|
2344
|
+
timeZone: {},
|
|
2345
|
+
maxOperatorMenuItems: {}
|
|
2346
|
+
},
|
|
2347
|
+
setup(__props) {
|
|
2348
|
+
/**
|
|
2349
|
+
* 值那一步:编辑一个条件的运算符和值。有多个运算符时先列一组单选;封闭的选项(`enum`、`enum_list`、
|
|
2350
|
+
* 相对日期)列成行,其余类型用浮层编辑器的底部弹层呈现。`components[type].editor` 覆盖整个编辑区,
|
|
2351
|
+
* `nested` 条件用内置编辑器。字段或运算符在配置里已经没有时显示不可用的说明。
|
|
2352
|
+
* 只读时只有「取消」;否则「取消」和保存,没有运算符或值时保存不可点。
|
|
2353
|
+
*/
|
|
2354
|
+
const props = __props;
|
|
2355
|
+
const sheetMessages = useComponentMessages({ powerSearchSheet: powerSearchSheetMessages });
|
|
2356
|
+
const sheet = computed(() => sheetMessages.value.powerSearchSheet);
|
|
2357
|
+
const draft = computed(() => props.flow.draft.value);
|
|
2358
|
+
const field = computed(() => draft.value ? props.lookup.getField(draft.value.field) : void 0);
|
|
2359
|
+
const operator = computed(() => draft.value?.operator != null ? props.lookup.getOperator(draft.value.field, draft.value.operator) : void 0);
|
|
2360
|
+
const operators = computed(() => draft.value ? props.lookup.getVisibleOperators(draft.value.field) : []);
|
|
2361
|
+
const isRenderable = computed(() => draft.value != null && field.value != null && operator.value != null);
|
|
2362
|
+
const showsOperatorGroup = computed(() => operators.value.length > 1 && operator.value != null && operators.value.includes(operator.value));
|
|
2363
|
+
const isEditorDisabled = computed(() => props.isDisabled || props.isReadOnly);
|
|
2364
|
+
const isSaveDisabled = computed(() => isEditorDisabled.value || draft.value?.operator == null || draft.value.value == null);
|
|
2365
|
+
const saveButtonLabel = computed(() => props.saveLabel ?? (draft.value?.mode === "edit" ? props.messages.editor.apply : sheet.value.addFilter));
|
|
2366
|
+
const editorKey = computed(() => draft.value ? `${draft.value.generation}-${draft.value.field}-${draft.value.operator}` : "");
|
|
2367
|
+
/** 覆盖整个编辑区的编辑器:调用方按类型给的,或 `nested` 条件的内置编辑器。 */
|
|
2368
|
+
const editorOverride = computed(() => {
|
|
2369
|
+
const type = operator.value?.value.type;
|
|
2370
|
+
if (type == null) return void 0;
|
|
2371
|
+
return props.components?.[type]?.editor ?? (type === "nested" ? _sfc_main$5 : void 0);
|
|
2372
|
+
});
|
|
2373
|
+
const choiceItems = computed(() => {
|
|
2374
|
+
const value = operator.value?.value;
|
|
2375
|
+
if (value?.type === "enum" || value?.type === "enum_list") return value.values;
|
|
2376
|
+
if (value?.type === "date_relative") return buildRelativeDateOptions(value, sheet.value);
|
|
2377
|
+
return null;
|
|
2378
|
+
});
|
|
2379
|
+
const selectedValues = computed(() => {
|
|
2380
|
+
const value = draft.value?.value;
|
|
2381
|
+
if (value?.type === "enum" || value?.type === "date_relative") return [value.value];
|
|
2382
|
+
if (value?.type === "enum_list") return value.value;
|
|
2383
|
+
return [];
|
|
2384
|
+
});
|
|
2385
|
+
function onChoices(values) {
|
|
2386
|
+
const type = operator.value?.value.type;
|
|
2387
|
+
if (type === "enum_list") props.flow.setDraftValue({
|
|
2388
|
+
type: "enum_list",
|
|
2389
|
+
value: values
|
|
2390
|
+
});
|
|
2391
|
+
else if (type === "enum" || type === "date_relative") props.flow.setDraftValue({
|
|
2392
|
+
type,
|
|
2393
|
+
value: values[0] ?? ""
|
|
2394
|
+
});
|
|
2395
|
+
}
|
|
2396
|
+
function onOperator(key) {
|
|
2397
|
+
const next = operators.value.find((candidate) => candidate.key === key);
|
|
2398
|
+
if (next != null) props.flow.handleOperatorSelect(next);
|
|
2399
|
+
}
|
|
2400
|
+
function onOverrideSave(saved) {
|
|
2401
|
+
const current = draft.value;
|
|
2402
|
+
if (current == null) return;
|
|
2403
|
+
if (saved == null) props.flow.handleRemove();
|
|
2404
|
+
else props.flow.commitSavedFilter(current, saved);
|
|
2405
|
+
}
|
|
2406
|
+
return (_ctx, _cache) => {
|
|
2407
|
+
return openBlock(), createElementBlock("div", _hoisted_1$2, [
|
|
2408
|
+
createElementVNode("div", _hoisted_2$2, [createElementVNode("div", _hoisted_3$2, [createVNode(_sfc_main$17, {
|
|
2409
|
+
level: 3,
|
|
2410
|
+
"max-lines": 1,
|
|
2411
|
+
class: "astryx-power-search-sheet__title"
|
|
2412
|
+
}, {
|
|
2413
|
+
default: withCtx(() => [createTextVNode(toDisplayString(__props.title), 1)]),
|
|
2414
|
+
_: 1
|
|
2415
|
+
})])]),
|
|
2416
|
+
createElementVNode("div", _hoisted_4$2, [isRenderable.value && showsOperatorGroup.value ? (openBlock(), createElementBlock("div", _hoisted_5$2, [createVNode(_sfc_main$36, {
|
|
2417
|
+
label: __props.messages.editor.operator,
|
|
2418
|
+
"is-label-hidden": "",
|
|
2419
|
+
"model-value": draft.value.operator ?? "",
|
|
2420
|
+
"is-disabled": isEditorDisabled.value,
|
|
2421
|
+
"onUpdate:modelValue": onOperator
|
|
2422
|
+
}, {
|
|
2423
|
+
default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(operators.value, (candidate) => {
|
|
2424
|
+
return openBlock(), createBlock(_sfc_main$37, {
|
|
2425
|
+
key: candidate.key,
|
|
2426
|
+
value: candidate.key,
|
|
2427
|
+
label: sheet.value.fieldOperator(field.value.label, unref(resolveOperatorLabel)(candidate, __props.messages))
|
|
2428
|
+
}, null, 8, ["value", "label"]);
|
|
2429
|
+
}), 128))]),
|
|
2430
|
+
_: 1
|
|
2431
|
+
}, 8, [
|
|
2432
|
+
"label",
|
|
2433
|
+
"model-value",
|
|
2434
|
+
"is-disabled"
|
|
2435
|
+
])])) : createCommentVNode("v-if", true), isRenderable.value && editorOverride.value ? (openBlock(), createBlock(resolveDynamicComponent(editorOverride.value), {
|
|
2436
|
+
key: editorKey.value,
|
|
2437
|
+
config: __props.config,
|
|
2438
|
+
filter: {
|
|
2439
|
+
field: draft.value.field,
|
|
2440
|
+
operator: draft.value.operator,
|
|
2441
|
+
value: draft.value.value
|
|
2442
|
+
},
|
|
2443
|
+
mode: draft.value.mode,
|
|
2444
|
+
"save-label": saveButtonLabel.value,
|
|
2445
|
+
"read-only": isEditorDisabled.value,
|
|
2446
|
+
"time-zone": __props.timeZone,
|
|
2447
|
+
"max-menu-items": __props.maxOperatorMenuItems,
|
|
2448
|
+
"on-save": onOverrideSave,
|
|
2449
|
+
"on-cancel": __props.flow.returnFromValue
|
|
2450
|
+
}, null, 40, [
|
|
2451
|
+
"config",
|
|
2452
|
+
"filter",
|
|
2453
|
+
"mode",
|
|
2454
|
+
"save-label",
|
|
2455
|
+
"read-only",
|
|
2456
|
+
"time-zone",
|
|
2457
|
+
"max-menu-items",
|
|
2458
|
+
"on-cancel"
|
|
2459
|
+
])) : isRenderable.value && operator.value.value.type !== "empty" ? (openBlock(), createElementBlock("div", {
|
|
2460
|
+
key: 2,
|
|
2461
|
+
class: normalizeClass({ "astryx-power-search-sheet__section": showsOperatorGroup.value })
|
|
2462
|
+
}, [choiceItems.value ? (openBlock(), createBlock(_sfc_main$4, {
|
|
2463
|
+
key: editorKey.value,
|
|
2464
|
+
items: choiceItems.value,
|
|
2465
|
+
selected: selectedValues.value,
|
|
2466
|
+
"is-multiple": operator.value.value.type === "enum_list",
|
|
2467
|
+
"is-disabled": isEditorDisabled.value,
|
|
2468
|
+
label: field.value.label,
|
|
2469
|
+
onChange: onChoices
|
|
2470
|
+
}, null, 8, [
|
|
2471
|
+
"items",
|
|
2472
|
+
"selected",
|
|
2473
|
+
"is-multiple",
|
|
2474
|
+
"is-disabled",
|
|
2475
|
+
"label"
|
|
2476
|
+
])) : (openBlock(), createBlock(_sfc_main$7, {
|
|
2477
|
+
key: editorKey.value,
|
|
2478
|
+
presentation: "bottom-sheet",
|
|
2479
|
+
"field-label": field.value.label,
|
|
2480
|
+
"operator-value": operator.value.value,
|
|
2481
|
+
"filter-value": draft.value.value,
|
|
2482
|
+
messages: __props.messages,
|
|
2483
|
+
disabled: isEditorDisabled.value,
|
|
2484
|
+
"time-zone": __props.timeZone,
|
|
2485
|
+
"max-menu-items": __props.maxOperatorMenuItems,
|
|
2486
|
+
onChange: __props.flow.setDraftValue,
|
|
2487
|
+
onUnstage: __props.flow.unstageDraft
|
|
2488
|
+
}, null, 8, [
|
|
2489
|
+
"field-label",
|
|
2490
|
+
"operator-value",
|
|
2491
|
+
"filter-value",
|
|
2492
|
+
"messages",
|
|
2493
|
+
"disabled",
|
|
2494
|
+
"time-zone",
|
|
2495
|
+
"max-menu-items",
|
|
2496
|
+
"onChange",
|
|
2497
|
+
"onUnstage"
|
|
2498
|
+
]))], 2)) : draft.value && !isRenderable.value ? (openBlock(), createBlock(_sfc_main$18, {
|
|
2499
|
+
key: 3,
|
|
2500
|
+
type: "body",
|
|
2501
|
+
color: "secondary",
|
|
2502
|
+
class: "astryx-power-search-sheet__unavailable"
|
|
2503
|
+
}, {
|
|
2504
|
+
default: withCtx(() => [createTextVNode(toDisplayString(sheet.value.filterUnavailable), 1)]),
|
|
2505
|
+
_: 1
|
|
2506
|
+
})) : createCommentVNode("v-if", true)]),
|
|
2507
|
+
!(isRenderable.value && editorOverride.value) ? (openBlock(), createElementBlock("div", _hoisted_6$1, [createVNode(_sfc_main$14, {
|
|
2508
|
+
"data-sheet-cancel": "",
|
|
2509
|
+
class: "astryx-power-search-sheet__footer-action",
|
|
2510
|
+
label: __props.messages.editor.cancel,
|
|
2511
|
+
variant: "secondary",
|
|
2512
|
+
size: "lg",
|
|
2513
|
+
width: __props.isReadOnly ? "100%" : void 0,
|
|
2514
|
+
onClick: __props.flow.returnFromValue
|
|
2515
|
+
}, null, 8, [
|
|
2516
|
+
"label",
|
|
2517
|
+
"width",
|
|
2518
|
+
"onClick"
|
|
2519
|
+
]), !__props.isReadOnly && isRenderable.value ? (openBlock(), createBlock(_sfc_main$14, {
|
|
2520
|
+
key: 0,
|
|
2521
|
+
"data-sheet-save": "",
|
|
2522
|
+
class: "astryx-power-search-sheet__footer-action",
|
|
2523
|
+
label: saveButtonLabel.value,
|
|
2524
|
+
variant: "primary",
|
|
2525
|
+
size: "lg",
|
|
2526
|
+
"is-disabled": isSaveDisabled.value,
|
|
2527
|
+
onClick: __props.flow.handleSave
|
|
2528
|
+
}, null, 8, [
|
|
2529
|
+
"label",
|
|
2530
|
+
"is-disabled",
|
|
2531
|
+
"onClick"
|
|
2532
|
+
])) : createCommentVNode("v-if", true)])) : createCommentVNode("v-if", true)
|
|
2533
|
+
]);
|
|
2534
|
+
};
|
|
2535
|
+
}
|
|
2536
|
+
});
|
|
2537
|
+
//#endregion
|
|
2538
|
+
//#region src/PowerSearch/sheetDraftEdits.ts
|
|
2539
|
+
/** 两份条件列表按签名比,条件相同、顺序也相同。 */
|
|
2540
|
+
function hasSameFilters(a, b) {
|
|
2541
|
+
return a.length === b.length && a.every((filter, index) => b[index] != null && filterSignature(filter) === filterSignature(b[index]));
|
|
2542
|
+
}
|
|
2543
|
+
/** `before` 有而 `after` 没有的条件(按签名当多重集合比),保持 `before` 里的顺序。 */
|
|
2544
|
+
function removedFilters(before, after) {
|
|
2545
|
+
const remaining = /* @__PURE__ */ new Map();
|
|
2546
|
+
for (const filter of after) {
|
|
2547
|
+
const signature = filterSignature(filter);
|
|
2548
|
+
remaining.set(signature, (remaining.get(signature) ?? 0) + 1);
|
|
2549
|
+
}
|
|
2550
|
+
return before.filter((filter) => {
|
|
2551
|
+
const signature = filterSignature(filter);
|
|
2552
|
+
const count = remaining.get(signature) ?? 0;
|
|
2553
|
+
if (count > 0) {
|
|
2554
|
+
remaining.set(signature, count - 1);
|
|
2555
|
+
return false;
|
|
2556
|
+
}
|
|
2557
|
+
return true;
|
|
2558
|
+
});
|
|
2559
|
+
}
|
|
2560
|
+
/**
|
|
2561
|
+
* 把草稿里的改动重放到 `base`(字段最新的条件)上,每一步都用改完的列表调一次 `report`。
|
|
2562
|
+
* 新增追加到末尾;修改替换第一个和原条件签名相同的条件;删除按签名去掉删掉的那些。
|
|
2563
|
+
* 修改或删除的目标已经不在 `base` 里(父组件在这期间删了它)时跳过。
|
|
2564
|
+
*/
|
|
2565
|
+
function replayDraftEdits(base, edits, report) {
|
|
2566
|
+
let current = [...base];
|
|
2567
|
+
for (const edit of edits) if (edit.changeType === "add") {
|
|
2568
|
+
const added = edit.after[edit.index];
|
|
2569
|
+
if (added == null) continue;
|
|
2570
|
+
current = [...current, added];
|
|
2571
|
+
report(current, "add", current.length - 1);
|
|
2572
|
+
} else if (edit.changeType === "edit") {
|
|
2573
|
+
const original = edit.before[edit.index];
|
|
2574
|
+
const updated = edit.after[edit.index];
|
|
2575
|
+
if (original == null || updated == null) continue;
|
|
2576
|
+
const signature = filterSignature(original);
|
|
2577
|
+
const index = current.findIndex((filter) => filterSignature(filter) === signature);
|
|
2578
|
+
if (index === -1) continue;
|
|
2579
|
+
current = current.map((filter, i) => i === index ? updated : filter);
|
|
2580
|
+
report(current, "edit", index);
|
|
2581
|
+
} else {
|
|
2582
|
+
const indexes = [];
|
|
2583
|
+
for (const signature of removedFilters(edit.before, edit.after).map(filterSignature)) {
|
|
2584
|
+
const index = current.findIndex((filter, i) => !indexes.includes(i) && filterSignature(filter) === signature);
|
|
2585
|
+
if (index !== -1) indexes.push(index);
|
|
2586
|
+
}
|
|
2587
|
+
if (indexes.length === 0) continue;
|
|
2588
|
+
current = current.filter((_, i) => !indexes.includes(i));
|
|
2589
|
+
report(current, "remove", Math.min(...indexes));
|
|
2590
|
+
}
|
|
2591
|
+
return current;
|
|
2592
|
+
}
|
|
2593
|
+
//#endregion
|
|
2594
|
+
//#region src/PowerSearch/usePowerSearchSheetFlow.ts
|
|
2595
|
+
function resolveDraftFilterIndex(filters, draft) {
|
|
2596
|
+
if (draft.mode !== "edit" || draft.filterIndex == null || draft.sourceFilter == null || draft.sourceSignature == null) return null;
|
|
2597
|
+
return resolveFilterIdentityIndex(filters, draft.sourceFilter, draft.sourceSignature, draft.filterIndex);
|
|
2598
|
+
}
|
|
2599
|
+
function filterFocus(filter, preferredIndex, part) {
|
|
2600
|
+
return {
|
|
2601
|
+
type: "manager-filter",
|
|
2602
|
+
sourceFilter: filter,
|
|
2603
|
+
sourceSignature: filterSignature(filter),
|
|
2604
|
+
preferredIndex,
|
|
2605
|
+
part
|
|
2606
|
+
};
|
|
2607
|
+
}
|
|
2608
|
+
/**
|
|
2609
|
+
* PowerSearch 触屏底部弹层的流程(上游 PowerSearchBottomSheet 的状态部分):「筛选条件」「添加筛选条件」
|
|
2610
|
+
* 和值那一步三张弹层叠着开,每一步开在引出它的那张上面。
|
|
2611
|
+
*
|
|
2612
|
+
* 一次打开编辑一份草稿,草稿从已提交的条件开始,每次改动都记下来;按「完成」把改动按顺序
|
|
2613
|
+
* 重放到字段最新的条件上,字段在这期间变成只读或禁用就什么都不报。草稿改过时关闭先确认。
|
|
2614
|
+
*/
|
|
2615
|
+
function usePowerSearchSheetFlow(options) {
|
|
2616
|
+
const filtersAtOpen = shallowRef([]);
|
|
2617
|
+
const filters = shallowRef([]);
|
|
2618
|
+
let edits = [];
|
|
2619
|
+
const step = ref(null);
|
|
2620
|
+
const fieldPickerOrigin = ref("manage");
|
|
2621
|
+
const draft = shallowRef(null);
|
|
2622
|
+
let generation = 0;
|
|
2623
|
+
const fieldQuery = ref("");
|
|
2624
|
+
const contentQuery = ref("");
|
|
2625
|
+
const isClearConfirmationOpen = ref(false);
|
|
2626
|
+
const isDiscardConfirmationOpen = ref(false);
|
|
2627
|
+
const pendingFocus = shallowRef(null);
|
|
2628
|
+
const isInteractive = computed(options.isInteractive);
|
|
2629
|
+
const isDraftDirty = computed(() => !hasSameFilters(filtersAtOpen.value, filters.value));
|
|
2630
|
+
const isDirectEntry = computed(() => fieldPickerOrigin.value === "trigger");
|
|
2631
|
+
const isManageSheetOpen = computed(() => step.value === "manage" || step.value === "fields" && !isDirectEntry.value || step.value === "value" && (draft.value?.mode === "edit" || !isDirectEntry.value));
|
|
2632
|
+
const isFieldsSheetOpen = computed(() => step.value === "fields" || step.value === "value" && draft.value?.mode === "create");
|
|
2633
|
+
const isValueSheetOpen = computed(() => step.value === "value");
|
|
2634
|
+
watch(options.isOpen, (open) => {
|
|
2635
|
+
if (open) {
|
|
2636
|
+
const committed = options.committed();
|
|
2637
|
+
filtersAtOpen.value = committed;
|
|
2638
|
+
filters.value = committed;
|
|
2639
|
+
edits = [];
|
|
2640
|
+
const startsOnAddFilter = committed.length === 0 && isInteractive.value;
|
|
2641
|
+
fieldQuery.value = "";
|
|
2642
|
+
contentQuery.value = "";
|
|
2643
|
+
pendingFocus.value = null;
|
|
2644
|
+
step.value = startsOnAddFilter ? "fields" : "manage";
|
|
2645
|
+
fieldPickerOrigin.value = startsOnAddFilter ? "trigger" : "manage";
|
|
2646
|
+
} else {
|
|
2647
|
+
step.value = null;
|
|
2648
|
+
isClearConfirmationOpen.value = false;
|
|
2649
|
+
isDiscardConfirmationOpen.value = false;
|
|
2650
|
+
}
|
|
2651
|
+
}, { immediate: true });
|
|
2652
|
+
/** 草稿里的一次改动:记下来,按「完成」时重放。 */
|
|
2653
|
+
function change(next, changeType, index) {
|
|
2654
|
+
edits.push({
|
|
2655
|
+
before: filters.value,
|
|
2656
|
+
after: next,
|
|
2657
|
+
changeType,
|
|
2658
|
+
index
|
|
2659
|
+
});
|
|
2660
|
+
filters.value = next;
|
|
2661
|
+
}
|
|
2662
|
+
function isRowButton(filter) {
|
|
2663
|
+
return !filter.isReadOnly && isInteractive.value;
|
|
2664
|
+
}
|
|
2665
|
+
function isImmediateAddField(field) {
|
|
2666
|
+
const operators = options.lookup().getVisibleOperators(field.key);
|
|
2667
|
+
return operators.length === 1 && operators[0].value.type === "empty";
|
|
2668
|
+
}
|
|
2669
|
+
function goTo(next, focus) {
|
|
2670
|
+
pendingFocus.value = focus;
|
|
2671
|
+
step.value = next;
|
|
2672
|
+
}
|
|
2673
|
+
function closeFlow() {
|
|
2674
|
+
pendingFocus.value = null;
|
|
2675
|
+
step.value = null;
|
|
2676
|
+
options.close();
|
|
2677
|
+
}
|
|
2678
|
+
function commitAndClose() {
|
|
2679
|
+
if (isDraftDirty.value && isInteractive.value) replayDraftEdits(options.committed(), edits, options.commit);
|
|
2680
|
+
edits = [];
|
|
2681
|
+
closeFlow();
|
|
2682
|
+
}
|
|
2683
|
+
function requestDismiss() {
|
|
2684
|
+
if (isDraftDirty.value) isDiscardConfirmationOpen.value = true;
|
|
2685
|
+
else closeFlow();
|
|
2686
|
+
}
|
|
2687
|
+
function discard() {
|
|
2688
|
+
isDiscardConfirmationOpen.value = false;
|
|
2689
|
+
edits = [];
|
|
2690
|
+
closeFlow();
|
|
2691
|
+
}
|
|
2692
|
+
function openFieldList() {
|
|
2693
|
+
if (!isInteractive.value) return;
|
|
2694
|
+
fieldPickerOrigin.value = "manage";
|
|
2695
|
+
fieldQuery.value = "";
|
|
2696
|
+
contentQuery.value = "";
|
|
2697
|
+
goTo("fields", null);
|
|
2698
|
+
}
|
|
2699
|
+
function addAtOnce(filter, label) {
|
|
2700
|
+
const index = filters.value.length;
|
|
2701
|
+
change([...filters.value, filter], "add", index);
|
|
2702
|
+
options.announce(options.added(label));
|
|
2703
|
+
goTo("manage", filterFocus(filter, index));
|
|
2704
|
+
}
|
|
2705
|
+
function openCreateEditor(field, operator, returnFocus = "field") {
|
|
2706
|
+
draft.value = {
|
|
2707
|
+
mode: "create",
|
|
2708
|
+
generation: ++generation,
|
|
2709
|
+
returnFocus,
|
|
2710
|
+
field: field.key,
|
|
2711
|
+
operator: operator.key,
|
|
2712
|
+
value: operator.value.type === "empty" ? { type: "empty" } : void 0
|
|
2713
|
+
};
|
|
2714
|
+
goTo("value", null);
|
|
2715
|
+
}
|
|
2716
|
+
function handleFieldSelect(field) {
|
|
2717
|
+
if (!isInteractive.value) return;
|
|
2718
|
+
const lookup = options.lookup();
|
|
2719
|
+
if (isImmediateAddField(field)) {
|
|
2720
|
+
const operator = lookup.getVisibleOperators(field.key)[0];
|
|
2721
|
+
const filter = {
|
|
2722
|
+
field: field.key,
|
|
2723
|
+
operator: operator.key,
|
|
2724
|
+
value: { type: "empty" }
|
|
2725
|
+
};
|
|
2726
|
+
addAtOnce(filter, options.describe(filter));
|
|
2727
|
+
return;
|
|
2728
|
+
}
|
|
2729
|
+
const operator = lookup.getDefaultOperator(field.key) ?? field.operators[0];
|
|
2730
|
+
if (operator != null) openCreateEditor(field, operator);
|
|
2731
|
+
}
|
|
2732
|
+
function handleContentSuggestionSelect(item) {
|
|
2733
|
+
const aux = item?.auxiliaryData;
|
|
2734
|
+
if (!isInteractive.value || item == null || aux == null) return;
|
|
2735
|
+
const lookup = options.lookup();
|
|
2736
|
+
const field = lookup.getField(aux.fieldKey);
|
|
2737
|
+
const operator = aux.operatorKey == null ? lookup.getDefaultOperator(aux.fieldKey) : lookup.getOperator(aux.fieldKey, aux.operatorKey);
|
|
2738
|
+
if (field == null || operator == null) return;
|
|
2739
|
+
contentQuery.value = "";
|
|
2740
|
+
if (aux.filterValue != null) {
|
|
2741
|
+
addAtOnce({
|
|
2742
|
+
field: field.key,
|
|
2743
|
+
operator: operator.key,
|
|
2744
|
+
value: aux.filterValue
|
|
2745
|
+
}, item.label);
|
|
2746
|
+
return;
|
|
2747
|
+
}
|
|
2748
|
+
openCreateEditor(field, operator, "content-search");
|
|
2749
|
+
}
|
|
2750
|
+
function handleFilterEdit(index) {
|
|
2751
|
+
const filter = filters.value[index];
|
|
2752
|
+
if (!isInteractive.value || filter == null || filter.isReadOnly) return;
|
|
2753
|
+
draft.value = {
|
|
2754
|
+
mode: "edit",
|
|
2755
|
+
generation: ++generation,
|
|
2756
|
+
filterIndex: index,
|
|
2757
|
+
sourceFilter: filter,
|
|
2758
|
+
sourceSignature: filterSignature(filter),
|
|
2759
|
+
field: filter.field,
|
|
2760
|
+
operator: filter.operator,
|
|
2761
|
+
value: filter.value
|
|
2762
|
+
};
|
|
2763
|
+
goTo("value", null);
|
|
2764
|
+
}
|
|
2765
|
+
function handleRemoveFilter(index) {
|
|
2766
|
+
const filter = filters.value[index];
|
|
2767
|
+
if (!isInteractive.value || filter == null || filter.isReadOnly) return;
|
|
2768
|
+
const next = filters.value.filter((_, i) => i !== index);
|
|
2769
|
+
const nextIndex = nearestEditableIndex(next, index, isRowButton);
|
|
2770
|
+
pendingFocus.value = nextIndex == null ? { type: "manager-add" } : filterFocus(next[nextIndex], nextIndex, "remove");
|
|
2771
|
+
change(next, "remove", index);
|
|
2772
|
+
options.announce(options.removed(options.describe(filter)));
|
|
2773
|
+
}
|
|
2774
|
+
function closeClearConfirmation(confirmed) {
|
|
2775
|
+
const kept = filters.value.filter((filter) => filter.isReadOnly);
|
|
2776
|
+
const firstRemovedIndex = filters.value.findIndex((filter) => !filter.isReadOnly);
|
|
2777
|
+
isClearConfirmationOpen.value = false;
|
|
2778
|
+
if (!confirmed || !isInteractive.value || firstRemovedIndex < 0) return;
|
|
2779
|
+
change(kept, "remove", firstRemovedIndex);
|
|
2780
|
+
pendingFocus.value = { type: "manager-add" };
|
|
2781
|
+
options.announce(options.cleared(kept.length > 0));
|
|
2782
|
+
}
|
|
2783
|
+
function updateDraft(patch) {
|
|
2784
|
+
if (draft.value != null) draft.value = {
|
|
2785
|
+
...draft.value,
|
|
2786
|
+
...patch
|
|
2787
|
+
};
|
|
2788
|
+
}
|
|
2789
|
+
/** 换运算符:值的类型一样才留着;`empty` 运算符直接带上空值。 */
|
|
2790
|
+
function handleOperatorSelect(operator) {
|
|
2791
|
+
const current = draft.value;
|
|
2792
|
+
if (current == null) return;
|
|
2793
|
+
const keepsValue = current.value != null && current.value.type === operator.value.type;
|
|
2794
|
+
updateDraft({
|
|
2795
|
+
operator: operator.key,
|
|
2796
|
+
value: operator.value.type === "empty" ? { type: "empty" } : keepsValue ? current.value : void 0
|
|
2797
|
+
});
|
|
2798
|
+
}
|
|
2799
|
+
/** 值那一步交回一个条件(保存或自定义编辑器的 onSave):写进草稿,回到「筛选条件」。 */
|
|
2800
|
+
function commitSavedFilter(current, filter) {
|
|
2801
|
+
if (!isInteractive.value) {
|
|
2802
|
+
goTo("manage", { type: "manager-add" });
|
|
2803
|
+
return;
|
|
2804
|
+
}
|
|
2805
|
+
if (current.mode === "create") {
|
|
2806
|
+
change([...filters.value, filter], "add", filters.value.length);
|
|
2807
|
+
goTo("manage", { type: "manager-add" });
|
|
2808
|
+
return;
|
|
2809
|
+
}
|
|
2810
|
+
const index = resolveDraftFilterIndex(filters.value, current);
|
|
2811
|
+
if (index == null || filters.value[index]?.isReadOnly) {
|
|
2812
|
+
goTo("manage", current.sourceFilter != null && current.filterIndex != null ? filterFocus(current.sourceFilter, current.filterIndex) : { type: "manager-add" });
|
|
2813
|
+
return;
|
|
2814
|
+
}
|
|
2815
|
+
change(filters.value.map((existing, i) => i === index ? filter : existing), "edit", index);
|
|
2816
|
+
goTo("manage", filterFocus(filter, index));
|
|
2817
|
+
}
|
|
2818
|
+
function handleSave() {
|
|
2819
|
+
const current = draft.value;
|
|
2820
|
+
if (current?.value == null || current.operator == null) return;
|
|
2821
|
+
commitSavedFilter(current, {
|
|
2822
|
+
field: current.field,
|
|
2823
|
+
operator: current.operator,
|
|
2824
|
+
value: current.value
|
|
2825
|
+
});
|
|
2826
|
+
}
|
|
2827
|
+
function returnFromValue() {
|
|
2828
|
+
const current = draft.value;
|
|
2829
|
+
if (current == null) {
|
|
2830
|
+
goTo("manage", { type: "manager-add" });
|
|
2831
|
+
return;
|
|
2832
|
+
}
|
|
2833
|
+
if (current.mode === "edit" && current.sourceFilter != null && current.filterIndex != null) {
|
|
2834
|
+
goTo("manage", filterFocus(current.sourceFilter, resolveDraftFilterIndex(filters.value, current) ?? current.filterIndex));
|
|
2835
|
+
return;
|
|
2836
|
+
}
|
|
2837
|
+
if (current.returnFocus === "content-search") goTo("fields", { type: "content-search" });
|
|
2838
|
+
else goTo("fields", {
|
|
2839
|
+
type: "field",
|
|
2840
|
+
fieldKey: current.field
|
|
2841
|
+
});
|
|
2842
|
+
}
|
|
2843
|
+
/** 自定义编辑器交回 null:编辑中就删掉这个条件,新建时什么都不加。 */
|
|
2844
|
+
function handleRemove() {
|
|
2845
|
+
const current = draft.value;
|
|
2846
|
+
if (current?.mode !== "edit") {
|
|
2847
|
+
goTo("manage", { type: "manager-add" });
|
|
2848
|
+
return;
|
|
2849
|
+
}
|
|
2850
|
+
const index = resolveDraftFilterIndex(filters.value, current);
|
|
2851
|
+
step.value = "manage";
|
|
2852
|
+
if (index == null || filters.value[index]?.isReadOnly) pendingFocus.value = { type: "manager-add" };
|
|
2853
|
+
else handleRemoveFilter(index);
|
|
2854
|
+
}
|
|
2855
|
+
function onManageOpenChange(open) {
|
|
2856
|
+
if (!open && step.value === "manage") requestDismiss();
|
|
2857
|
+
}
|
|
2858
|
+
function onFieldsOpenChange(open) {
|
|
2859
|
+
if (open || step.value !== "fields") return;
|
|
2860
|
+
if (isDirectEntry.value) requestDismiss();
|
|
2861
|
+
else goTo("manage", { type: "manager-add" });
|
|
2862
|
+
}
|
|
2863
|
+
function onValueOpenChange(open) {
|
|
2864
|
+
if (!open && step.value === "value") returnFromValue();
|
|
2865
|
+
}
|
|
2866
|
+
return {
|
|
2867
|
+
step,
|
|
2868
|
+
filters,
|
|
2869
|
+
draft,
|
|
2870
|
+
pendingFocus,
|
|
2871
|
+
fieldQuery,
|
|
2872
|
+
contentQuery,
|
|
2873
|
+
isClearConfirmationOpen,
|
|
2874
|
+
isDiscardConfirmationOpen,
|
|
2875
|
+
isInteractive,
|
|
2876
|
+
isDraftDirty,
|
|
2877
|
+
isDirectEntry,
|
|
2878
|
+
isManageSheetOpen,
|
|
2879
|
+
isFieldsSheetOpen,
|
|
2880
|
+
isValueSheetOpen,
|
|
2881
|
+
isRowButton,
|
|
2882
|
+
isImmediateAddField,
|
|
2883
|
+
commitAndClose,
|
|
2884
|
+
requestDismiss,
|
|
2885
|
+
discard,
|
|
2886
|
+
openFieldList,
|
|
2887
|
+
handleFieldSelect,
|
|
2888
|
+
handleContentSuggestionSelect,
|
|
2889
|
+
handleFilterEdit,
|
|
2890
|
+
handleRemoveFilter,
|
|
2891
|
+
setFieldQuery: (query) => {
|
|
2892
|
+
fieldQuery.value = query;
|
|
2893
|
+
},
|
|
2894
|
+
setContentQuery: (query) => {
|
|
2895
|
+
contentQuery.value = query;
|
|
2896
|
+
},
|
|
2897
|
+
openClearConfirmation: () => {
|
|
2898
|
+
isClearConfirmationOpen.value = true;
|
|
2899
|
+
},
|
|
2900
|
+
closeClearConfirmation,
|
|
2901
|
+
handleOperatorSelect,
|
|
2902
|
+
setDraftValue: (value) => updateDraft({ value }),
|
|
2903
|
+
unstageDraft: () => updateDraft({ value: void 0 }),
|
|
2904
|
+
handleSave,
|
|
2905
|
+
commitSavedFilter,
|
|
2906
|
+
returnFromValue,
|
|
2907
|
+
handleRemove,
|
|
2908
|
+
onManageOpenChange,
|
|
2909
|
+
onFieldsOpenChange,
|
|
2910
|
+
onValueOpenChange
|
|
2911
|
+
};
|
|
2912
|
+
}
|
|
2913
|
+
//#endregion
|
|
2914
|
+
//#region src/PowerSearch/PowerSearchBottomSheet.vue
|
|
2915
|
+
const _sfc_main$2 = /*@__PURE__*/ defineComponent({
|
|
2916
|
+
name: "AstryxPowerSearchBottomSheet",
|
|
2917
|
+
__name: "PowerSearchBottomSheet",
|
|
2918
|
+
props: {
|
|
2919
|
+
isOpen: { type: Boolean },
|
|
2920
|
+
finalFocus: {},
|
|
2921
|
+
config: {},
|
|
2922
|
+
lookup: {},
|
|
2923
|
+
filters: {},
|
|
2924
|
+
search: { type: Function },
|
|
2925
|
+
placeholder: {},
|
|
2926
|
+
isReadOnly: { type: Boolean },
|
|
2927
|
+
isDisabled: { type: Boolean },
|
|
2928
|
+
hasClear: { type: Boolean },
|
|
2929
|
+
maxOperatorMenuItems: {},
|
|
2930
|
+
timeZone: {},
|
|
2931
|
+
saveLabel: {},
|
|
2932
|
+
components: {}
|
|
2933
|
+
},
|
|
2934
|
+
emits: [
|
|
2935
|
+
"close",
|
|
2936
|
+
"commit",
|
|
2937
|
+
"motionComplete"
|
|
2938
|
+
],
|
|
2939
|
+
setup(__props, { emit: __emit }) {
|
|
2940
|
+
/**
|
|
2941
|
+
* PowerSearch 触屏呈现的弹层流程(上游 PowerSearchBottomSheet.tsx):「筛选条件」「添加筛选条件」和值那一步
|
|
2942
|
+
* 是三张独立的底部弹层,叠着开。状态和规则在 usePowerSearchSheetFlow 里,这里摆放弹层、确认框,
|
|
2943
|
+
* 并在换步骤后把焦点放到该去的控件上。
|
|
2944
|
+
*/
|
|
2945
|
+
const props = __props;
|
|
2946
|
+
const emit = __emit;
|
|
2947
|
+
const messages = useComponentMessages({
|
|
2948
|
+
powerSearch: powerSearchMessages,
|
|
2949
|
+
powerSearchSheet: powerSearchSheetMessages,
|
|
2950
|
+
tokenizer: tokenizerMessages
|
|
2951
|
+
});
|
|
2952
|
+
const locale = useAstryxLocale();
|
|
2953
|
+
const calendar = useCalendarSystem(void 0, "PowerSearch");
|
|
2954
|
+
const announce = useAnnounce();
|
|
2955
|
+
const textContext = computed(() => ({
|
|
2956
|
+
lookup: props.lookup,
|
|
2957
|
+
messages: messages.value.powerSearch,
|
|
2958
|
+
sheet: messages.value.powerSearchSheet,
|
|
2959
|
+
locale: locale.value,
|
|
2960
|
+
timeZone: props.timeZone,
|
|
2961
|
+
calendar: calendar.value
|
|
2962
|
+
}));
|
|
2963
|
+
const flow = usePowerSearchSheetFlow({
|
|
2964
|
+
isOpen: () => props.isOpen,
|
|
2965
|
+
committed: () => props.filters,
|
|
2966
|
+
lookup: () => props.lookup,
|
|
2967
|
+
isInteractive: () => !props.isDisabled && !props.isReadOnly,
|
|
2968
|
+
commit: (filters, changeType, index) => emit("commit", filters, changeType, index),
|
|
2969
|
+
close: () => emit("close"),
|
|
2970
|
+
describe: (filter) => describeSheetFilter(filter, textContext.value),
|
|
2971
|
+
announce: (message) => void nextTick(() => announce(message)),
|
|
2972
|
+
added: (label) => messages.value.tokenizer.added(label),
|
|
2973
|
+
removed: (label) => messages.value.tokenizer.removed(label),
|
|
2974
|
+
cleared: (keptReadOnly) => keptReadOnly ? messages.value.powerSearch.editableFiltersRemoved : messages.value.powerSearch.allFiltersRemoved
|
|
2975
|
+
});
|
|
2976
|
+
const editorTitle = computed(() => sheetEditorTitle(flow.draft.value, textContext.value));
|
|
2977
|
+
const sheetText = computed(() => messages.value.powerSearchSheet);
|
|
2978
|
+
const panels = reactive({
|
|
2979
|
+
manage: null,
|
|
2980
|
+
fields: null,
|
|
2981
|
+
value: null
|
|
2982
|
+
});
|
|
2983
|
+
/** 关上的步骤弹层退场后把焦点还给这里;没有就还给触发器。 */
|
|
2984
|
+
const stepReturnTarget = ref(null);
|
|
2985
|
+
const stepFinalFocus = computed(() => stepReturnTarget.value ?? props.finalFocus);
|
|
2986
|
+
function setPanel(step, element) {
|
|
2987
|
+
panels[step] = element instanceof HTMLElement ? element : null;
|
|
2988
|
+
}
|
|
2989
|
+
function resolveFocusTarget(target) {
|
|
2990
|
+
if (target.type === "manager-add") return panels.manage?.querySelector("[data-sheet-add]");
|
|
2991
|
+
if (target.type === "content-search") return panels.fields?.querySelector("[data-sheet-content-search] input, input[data-sheet-content-search]");
|
|
2992
|
+
if (target.type === "field") return panels.fields?.querySelector(`[data-sheet-field="${CSS.escape(target.fieldKey)}"] button`);
|
|
2993
|
+
const index = resolveFilterIdentityIndex(flow.filters.value, target.sourceFilter, target.sourceSignature, target.preferredIndex);
|
|
2994
|
+
const row = index == null ? null : panels.manage?.querySelector(`[data-sheet-filter="${index}"]`);
|
|
2995
|
+
return (target.part === "remove" ? row?.querySelector("[data-sheet-remove]") : row?.querySelector("button")) ?? panels.manage?.querySelector("[data-sheet-add]");
|
|
2996
|
+
}
|
|
2997
|
+
function placePendingFocus() {
|
|
2998
|
+
const target = flow.pendingFocus.value;
|
|
2999
|
+
if (target == null) return;
|
|
3000
|
+
const element = resolveFocusTarget(target);
|
|
3001
|
+
if (element == null) return;
|
|
3002
|
+
flow.pendingFocus.value = null;
|
|
3003
|
+
stepReturnTarget.value = element;
|
|
3004
|
+
element.focus({ preventScroll: true });
|
|
3005
|
+
}
|
|
3006
|
+
watch([
|
|
3007
|
+
flow.step,
|
|
3008
|
+
flow.pendingFocus,
|
|
3009
|
+
() => flow.filters.value
|
|
3010
|
+
], () => {
|
|
3011
|
+
nextTick(placePendingFocus);
|
|
3012
|
+
}, { flush: "post" });
|
|
3013
|
+
/** 打开过、还没退场播完的弹层。 */
|
|
3014
|
+
const shownSheets = /* @__PURE__ */ new Set();
|
|
3015
|
+
watch([
|
|
3016
|
+
flow.isManageSheetOpen,
|
|
3017
|
+
flow.isFieldsSheetOpen,
|
|
3018
|
+
flow.isValueSheetOpen
|
|
3019
|
+
], ([manage, fields, value]) => {
|
|
3020
|
+
if (manage) shownSheets.add("manage");
|
|
3021
|
+
if (fields) shownSheets.add("fields");
|
|
3022
|
+
if (value) shownSheets.add("value");
|
|
3023
|
+
}, { immediate: true });
|
|
3024
|
+
function onMotionComplete(sheet, motion) {
|
|
3025
|
+
if (motion === "entering") {
|
|
3026
|
+
placePendingFocus();
|
|
3027
|
+
emit("motionComplete", "entering");
|
|
3028
|
+
return;
|
|
3029
|
+
}
|
|
3030
|
+
shownSheets.delete(sheet);
|
|
3031
|
+
if (!props.isOpen && shownSheets.size === 0) emit("motionComplete", "exiting");
|
|
3032
|
+
}
|
|
3033
|
+
function closeDiscardConfirmation() {
|
|
3034
|
+
flow.isDiscardConfirmationOpen.value = false;
|
|
3035
|
+
nextTick(() => {
|
|
3036
|
+
const panel = flow.step.value === "manage" ? panels.manage : panels.fields;
|
|
3037
|
+
(panel?.querySelector("[data-sheet-add]") ?? panel?.closest("[tabindex=\"-1\"]"))?.focus({ preventScroll: true });
|
|
3038
|
+
});
|
|
3039
|
+
}
|
|
3040
|
+
function closeClearConfirmation(confirmed) {
|
|
3041
|
+
flow.closeClearConfirmation(confirmed);
|
|
3042
|
+
if (!confirmed) nextTick(() => panels.manage?.querySelector("[data-sheet-clear]")?.focus());
|
|
3043
|
+
}
|
|
3044
|
+
return (_ctx, _cache) => {
|
|
3045
|
+
return openBlock(), createElementBlock(Fragment, null, [
|
|
3046
|
+
createVNode(unref(LazyBottomSheet), {
|
|
3047
|
+
"is-open": unref(flow).isManageSheetOpen.value,
|
|
3048
|
+
label: sheetText.value.filtersTitle,
|
|
3049
|
+
height: "tall",
|
|
3050
|
+
padding: 0,
|
|
3051
|
+
"final-focus-ref": __props.finalFocus,
|
|
3052
|
+
"onUpdate:isOpen": _cache[0] || (_cache[0] = (open) => unref(flow).onManageOpenChange(Boolean(open))),
|
|
3053
|
+
onMotionComplete: _cache[1] || (_cache[1] = ($event) => onMotionComplete("manage", $event))
|
|
3054
|
+
}, {
|
|
3055
|
+
default: withCtx(() => [createVNode(_sfc_main$8, {
|
|
3056
|
+
ref: (element) => setPanel("manage", element?.$el),
|
|
3057
|
+
flow: unref(flow),
|
|
3058
|
+
lookup: __props.lookup,
|
|
3059
|
+
"has-clear": __props.hasClear,
|
|
3060
|
+
"describe-parts": (filter) => unref(describeSheetFilterParts)(filter, textContext.value)
|
|
3061
|
+
}, null, 8, [
|
|
3062
|
+
"flow",
|
|
3063
|
+
"lookup",
|
|
3064
|
+
"has-clear",
|
|
3065
|
+
"describe-parts"
|
|
3066
|
+
])]),
|
|
3067
|
+
_: 1
|
|
3068
|
+
}, 8, [
|
|
3069
|
+
"is-open",
|
|
3070
|
+
"label",
|
|
3071
|
+
"final-focus-ref"
|
|
3072
|
+
]),
|
|
3073
|
+
createVNode(unref(LazyBottomSheet), {
|
|
3074
|
+
"is-open": unref(flow).isFieldsSheetOpen.value,
|
|
3075
|
+
label: sheetText.value.addFilter,
|
|
3076
|
+
height: "tall",
|
|
3077
|
+
padding: 0,
|
|
3078
|
+
"final-focus-ref": stepFinalFocus.value,
|
|
3079
|
+
"onUpdate:isOpen": _cache[2] || (_cache[2] = (open) => unref(flow).onFieldsOpenChange(Boolean(open))),
|
|
3080
|
+
onMotionComplete: _cache[3] || (_cache[3] = ($event) => onMotionComplete("fields", $event))
|
|
3081
|
+
}, {
|
|
3082
|
+
default: withCtx(() => [createVNode(_sfc_main$9, {
|
|
3083
|
+
ref: (element) => setPanel("fields", element?.$el),
|
|
3084
|
+
flow: unref(flow),
|
|
3085
|
+
lookup: __props.lookup,
|
|
3086
|
+
placeholder: __props.placeholder,
|
|
3087
|
+
search: __props.search
|
|
3088
|
+
}, null, 8, [
|
|
3089
|
+
"flow",
|
|
3090
|
+
"lookup",
|
|
3091
|
+
"placeholder",
|
|
3092
|
+
"search"
|
|
3093
|
+
])]),
|
|
3094
|
+
_: 1
|
|
3095
|
+
}, 8, [
|
|
3096
|
+
"is-open",
|
|
3097
|
+
"label",
|
|
3098
|
+
"final-focus-ref"
|
|
3099
|
+
]),
|
|
3100
|
+
createVNode(unref(LazyBottomSheet), {
|
|
3101
|
+
"is-open": unref(flow).isValueSheetOpen.value,
|
|
3102
|
+
label: editorTitle.value,
|
|
3103
|
+
height: "tall",
|
|
3104
|
+
padding: 0,
|
|
3105
|
+
purpose: "info",
|
|
3106
|
+
"final-focus-ref": stepFinalFocus.value,
|
|
3107
|
+
"onUpdate:isOpen": _cache[4] || (_cache[4] = (open) => unref(flow).onValueOpenChange(Boolean(open))),
|
|
3108
|
+
onMotionComplete: _cache[5] || (_cache[5] = ($event) => onMotionComplete("value", $event))
|
|
3109
|
+
}, {
|
|
3110
|
+
default: withCtx(() => [createVNode(_sfc_main$3, {
|
|
3111
|
+
ref: (element) => setPanel("value", element?.$el),
|
|
3112
|
+
flow: unref(flow),
|
|
3113
|
+
lookup: __props.lookup,
|
|
3114
|
+
config: __props.config,
|
|
3115
|
+
title: editorTitle.value,
|
|
3116
|
+
messages: unref(messages).powerSearch,
|
|
3117
|
+
components: __props.components,
|
|
3118
|
+
"save-label": __props.saveLabel,
|
|
3119
|
+
"is-read-only": __props.isReadOnly,
|
|
3120
|
+
"is-disabled": __props.isDisabled,
|
|
3121
|
+
"time-zone": __props.timeZone,
|
|
3122
|
+
"max-operator-menu-items": __props.maxOperatorMenuItems
|
|
3123
|
+
}, null, 8, [
|
|
3124
|
+
"flow",
|
|
3125
|
+
"lookup",
|
|
3126
|
+
"config",
|
|
3127
|
+
"title",
|
|
3128
|
+
"messages",
|
|
3129
|
+
"components",
|
|
3130
|
+
"save-label",
|
|
3131
|
+
"is-read-only",
|
|
3132
|
+
"is-disabled",
|
|
3133
|
+
"time-zone",
|
|
3134
|
+
"max-operator-menu-items"
|
|
3135
|
+
])]),
|
|
3136
|
+
_: 1
|
|
3137
|
+
}, 8, [
|
|
3138
|
+
"is-open",
|
|
3139
|
+
"label",
|
|
3140
|
+
"final-focus-ref"
|
|
3141
|
+
]),
|
|
3142
|
+
unref(flow).isClearConfirmationOpen.value ? (openBlock(), createBlock(_sfc_main$34, {
|
|
3143
|
+
key: 0,
|
|
3144
|
+
"is-open": "",
|
|
3145
|
+
title: sheetText.value.clearAllTitle,
|
|
3146
|
+
description: sheetText.value.clearAllDescription,
|
|
3147
|
+
"cancel-label": sheetText.value.clearAllCancel,
|
|
3148
|
+
"action-label": sheetText.value.clearAllConfirm,
|
|
3149
|
+
onOpenChange: _cache[6] || (_cache[6] = ($event) => $event || closeClearConfirmation(false)),
|
|
3150
|
+
onAction: _cache[7] || (_cache[7] = ($event) => closeClearConfirmation(true))
|
|
3151
|
+
}, null, 8, [
|
|
3152
|
+
"title",
|
|
3153
|
+
"description",
|
|
3154
|
+
"cancel-label",
|
|
3155
|
+
"action-label"
|
|
3156
|
+
])) : createCommentVNode("v-if", true),
|
|
3157
|
+
unref(flow).isDiscardConfirmationOpen.value ? (openBlock(), createBlock(_sfc_main$34, {
|
|
3158
|
+
key: 1,
|
|
3159
|
+
"is-open": "",
|
|
3160
|
+
title: sheetText.value.discardTitle,
|
|
3161
|
+
description: sheetText.value.discardDescription,
|
|
3162
|
+
"cancel-label": sheetText.value.keepEditing,
|
|
3163
|
+
"action-label": sheetText.value.discardConfirm,
|
|
3164
|
+
onOpenChange: _cache[8] || (_cache[8] = ($event) => $event || closeDiscardConfirmation()),
|
|
3165
|
+
onAction: unref(flow).discard
|
|
3166
|
+
}, null, 8, [
|
|
3167
|
+
"title",
|
|
3168
|
+
"description",
|
|
3169
|
+
"cancel-label",
|
|
3170
|
+
"action-label",
|
|
3171
|
+
"onAction"
|
|
3172
|
+
])) : createCommentVNode("v-if", true)
|
|
3173
|
+
], 64);
|
|
3174
|
+
};
|
|
3175
|
+
}
|
|
3176
|
+
});
|
|
3177
|
+
//#endregion
|
|
3178
|
+
//#region src/PowerSearch/PowerSearchSheetField.vue
|
|
3179
|
+
const _hoisted_1$1 = ["aria-disabled"];
|
|
3180
|
+
const _hoisted_2$1 = {
|
|
3181
|
+
key: 0,
|
|
3182
|
+
class: "astryx-power-search-icon",
|
|
3183
|
+
"aria-hidden": "true"
|
|
3184
|
+
};
|
|
3185
|
+
const _hoisted_3$1 = [
|
|
3186
|
+
"id",
|
|
3187
|
+
"aria-expanded",
|
|
3188
|
+
"disabled",
|
|
3189
|
+
"aria-disabled",
|
|
3190
|
+
"aria-labelledby",
|
|
3191
|
+
"aria-describedby"
|
|
3192
|
+
];
|
|
3193
|
+
const _hoisted_4$1 = {
|
|
3194
|
+
key: 0,
|
|
3195
|
+
class: "astryx-power-search-sheet-trigger__placeholder"
|
|
3196
|
+
};
|
|
3197
|
+
const _hoisted_5$1 = {
|
|
3198
|
+
key: 0,
|
|
3199
|
+
class: "astryx-power-search-count"
|
|
3200
|
+
};
|
|
3201
|
+
const _sfc_main$1 = /*@__PURE__*/ defineComponent({
|
|
3202
|
+
name: "AstryxPowerSearchSheetField",
|
|
3203
|
+
inheritAttrs: false,
|
|
3204
|
+
__name: "PowerSearchSheetField",
|
|
3205
|
+
props: /*@__PURE__*/ mergeModels({
|
|
3206
|
+
config: {},
|
|
3207
|
+
lookup: {},
|
|
3208
|
+
filters: {},
|
|
3209
|
+
inputId: {},
|
|
3210
|
+
labelId: {},
|
|
3211
|
+
describedBy: {},
|
|
3212
|
+
placeholder: {},
|
|
3213
|
+
size: {},
|
|
3214
|
+
isDisabled: { type: Boolean },
|
|
3215
|
+
isFocusableWhenDisabled: { type: Boolean },
|
|
3216
|
+
isReadOnly: { type: Boolean },
|
|
3217
|
+
hasClear: { type: Boolean },
|
|
3218
|
+
controlClass: {},
|
|
3219
|
+
controlStyle: {},
|
|
3220
|
+
statusIcon: {},
|
|
3221
|
+
statusIconProps: {},
|
|
3222
|
+
displayCount: {},
|
|
3223
|
+
messages: {},
|
|
3224
|
+
locale: {},
|
|
3225
|
+
timeZone: {},
|
|
3226
|
+
maxTokenLength: {},
|
|
3227
|
+
maxOperatorMenuItems: {},
|
|
3228
|
+
saveLabel: {},
|
|
3229
|
+
components: {},
|
|
3230
|
+
search: { type: Function },
|
|
3231
|
+
tokenComponent: { type: Function }
|
|
3232
|
+
}, {
|
|
3233
|
+
"isOpen": {
|
|
3234
|
+
type: Boolean,
|
|
3235
|
+
required: true
|
|
3236
|
+
},
|
|
3237
|
+
"isOpenModifiers": {}
|
|
3238
|
+
}),
|
|
3239
|
+
emits: /*@__PURE__*/ mergeModels([
|
|
3240
|
+
"commit",
|
|
3241
|
+
"motionComplete",
|
|
3242
|
+
"focus",
|
|
3243
|
+
"blur"
|
|
3244
|
+
], ["update:isOpen"]),
|
|
3245
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
3246
|
+
/**
|
|
3247
|
+
* PowerSearch 底部弹层呈现里的字段:沿用行内字段的框和主题挂点,里面是只展示的筛选标签和一个触发器,
|
|
3248
|
+
* 触发器是字段里唯一的 Tab 停靠点(上游 PowerSearch 的 sheet trigger)。
|
|
3249
|
+
*
|
|
3250
|
+
* 点框里任何地方(末尾内容里的控件除外,纯展示的状态图标照样算)都打开弹层流程。触发器的名字是
|
|
3251
|
+
* 标签加上框里看得到的一切:占位文字,或者各个筛选标签。没有条件时占位文字太长会以省略号收尾。
|
|
3252
|
+
* 弹层流程从按下挂到退场播完、焦点回到触发器。
|
|
3253
|
+
*/
|
|
3254
|
+
const props = __props;
|
|
3255
|
+
const emit = __emit;
|
|
3256
|
+
const isOpen = useModel(__props, "isOpen");
|
|
3257
|
+
const boxRef = useTemplateRef("boxRef");
|
|
3258
|
+
const triggerRef = useTemplateRef("triggerRef");
|
|
3259
|
+
const laneRef = useTemplateRef("laneRef");
|
|
3260
|
+
const statusIconRef = useTemplateRef("statusIconRef");
|
|
3261
|
+
const contentId = `${props.inputId}-content`;
|
|
3262
|
+
/** 弹层流程从按下挂到退场播完;平时字段只有触发器,没有关着的对话框和行。 */
|
|
3263
|
+
const isSheetMounted = ref(false);
|
|
3264
|
+
watch(isOpen, (open) => {
|
|
3265
|
+
if (open) isSheetMounted.value = true;
|
|
3266
|
+
}, { immediate: true });
|
|
3267
|
+
watch(() => props.isDisabled, (disabled) => {
|
|
3268
|
+
if (disabled && isOpen.value) isOpen.value = false;
|
|
3269
|
+
});
|
|
3270
|
+
function open() {
|
|
3271
|
+
if (props.isDisabled) return;
|
|
3272
|
+
triggerRef.value?.focus({ preventScroll: true });
|
|
3273
|
+
isOpen.value = true;
|
|
3274
|
+
}
|
|
3275
|
+
function onMotionComplete(motion) {
|
|
3276
|
+
if (motion === "exiting" && !isOpen.value) isSheetMounted.value = false;
|
|
3277
|
+
emit("motionComplete", motion);
|
|
3278
|
+
}
|
|
3279
|
+
function onBoxClick(event) {
|
|
3280
|
+
const target = event.target;
|
|
3281
|
+
if (!(target instanceof Element)) return;
|
|
3282
|
+
const box = boxRef.value;
|
|
3283
|
+
const interactive = target.closest("button, a, input, select, textarea, [tabindex]");
|
|
3284
|
+
const isOnPlainStatusIcon = statusIconRef.value?.contains(target) === true && (interactive == null || !box?.contains(interactive));
|
|
3285
|
+
if (triggerRef.value?.contains(target) || laneRef.value?.contains(target) && !isOnPlainStatusIcon) return;
|
|
3286
|
+
open();
|
|
3287
|
+
}
|
|
3288
|
+
function isOutside(event) {
|
|
3289
|
+
const related = event.relatedTarget;
|
|
3290
|
+
return !(related instanceof Node) || boxRef.value?.contains(related) !== true;
|
|
3291
|
+
}
|
|
3292
|
+
function onFocusIn(event) {
|
|
3293
|
+
if (isOutside(event) && !isSheetMounted.value) emit("focus", event);
|
|
3294
|
+
}
|
|
3295
|
+
function onFocusOut(event) {
|
|
3296
|
+
if (isOutside(event) && !isOpen.value) emit("blur", event);
|
|
3297
|
+
}
|
|
3298
|
+
__expose({
|
|
3299
|
+
element: boxRef,
|
|
3300
|
+
focus: (options) => triggerRef.value?.focus(options),
|
|
3301
|
+
blur: () => triggerRef.value?.blur()
|
|
3302
|
+
});
|
|
3303
|
+
return (_ctx, _cache) => {
|
|
3304
|
+
return openBlock(), createElementBlock(Fragment, null, [
|
|
3305
|
+
createCommentVNode(" eslint-disable-next-line vue-a11y/click-events-have-key-events, vue-a11y/no-static-element-interactions -- 点空白处和标签只是转给触发器;键盘直接操作触发器。 "),
|
|
3306
|
+
createElementVNode("div", {
|
|
3307
|
+
ref_key: "boxRef",
|
|
3308
|
+
ref: boxRef,
|
|
3309
|
+
class: normalizeClass(["astryx-power-search-control astryx-power-search-sheet-field", [__props.controlClass, {
|
|
3310
|
+
"is-disabled": __props.isDisabled,
|
|
3311
|
+
"has-tokens": __props.filters.length > 0,
|
|
3312
|
+
"is-open": isOpen.value
|
|
3313
|
+
}]]),
|
|
3314
|
+
style: normalizeStyle(__props.controlStyle),
|
|
3315
|
+
"aria-disabled": __props.isDisabled || void 0,
|
|
3316
|
+
onClick: onBoxClick,
|
|
3317
|
+
onFocusin: onFocusIn,
|
|
3318
|
+
onFocusout: onFocusOut
|
|
3319
|
+
}, [createElementVNode("div", {
|
|
3320
|
+
id: contentId,
|
|
3321
|
+
class: "astryx-power-search-sheet-field__content"
|
|
3322
|
+
}, [
|
|
3323
|
+
_ctx.$slots.icon ? (openBlock(), createElementBlock("span", _hoisted_2$1, [renderSlot(_ctx.$slots, "icon")])) : createCommentVNode("v-if", true),
|
|
3324
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(__props.filters, (filter, index) => {
|
|
3325
|
+
return openBlock(), createElementBlock("span", {
|
|
3326
|
+
key: `${filter.field}-${filter.operator}-${index}`,
|
|
3327
|
+
class: "astryx-power-search-token"
|
|
3328
|
+
}, [createVNode(_sfc_main$11, {
|
|
3329
|
+
config: __props.config,
|
|
3330
|
+
lookup: __props.lookup,
|
|
3331
|
+
filter,
|
|
3332
|
+
"max-length": __props.maxTokenLength,
|
|
3333
|
+
messages: __props.messages,
|
|
3334
|
+
locale: __props.locale,
|
|
3335
|
+
"time-zone": __props.timeZone,
|
|
3336
|
+
size: __props.size,
|
|
3337
|
+
disabled: __props.isDisabled,
|
|
3338
|
+
custom: __props.tokenComponent(filter),
|
|
3339
|
+
"display-only": ""
|
|
3340
|
+
}, createSlots({ _: 2 }, [_ctx.$slots.token ? {
|
|
3341
|
+
name: "token",
|
|
3342
|
+
fn: withCtx((tokenProps) => [renderSlot(_ctx.$slots, "token", mergeProps({ ref_for: true }, tokenProps))]),
|
|
3343
|
+
key: "0"
|
|
3344
|
+
} : void 0]), 1032, [
|
|
3345
|
+
"config",
|
|
3346
|
+
"lookup",
|
|
3347
|
+
"filter",
|
|
3348
|
+
"max-length",
|
|
3349
|
+
"messages",
|
|
3350
|
+
"locale",
|
|
3351
|
+
"time-zone",
|
|
3352
|
+
"size",
|
|
3353
|
+
"disabled",
|
|
3354
|
+
"custom"
|
|
3355
|
+
])]);
|
|
3356
|
+
}), 128)),
|
|
3357
|
+
createElementVNode("button", mergeProps(_ctx.$attrs, {
|
|
3358
|
+
id: __props.inputId,
|
|
3359
|
+
ref_key: "triggerRef",
|
|
3360
|
+
ref: triggerRef,
|
|
3361
|
+
type: "button",
|
|
3362
|
+
class: ["astryx-power-search-sheet-trigger", { "has-tokens": __props.filters.length > 0 }],
|
|
3363
|
+
"aria-haspopup": "dialog",
|
|
3364
|
+
"aria-expanded": isOpen.value,
|
|
3365
|
+
disabled: __props.isDisabled && !__props.isFocusableWhenDisabled,
|
|
3366
|
+
"aria-disabled": __props.isDisabled || void 0,
|
|
3367
|
+
"aria-labelledby": `${__props.labelId} ${contentId}`,
|
|
3368
|
+
"aria-describedby": __props.describedBy,
|
|
3369
|
+
onClick: open
|
|
3370
|
+
}), [__props.filters.length === 0 ? (openBlock(), createElementBlock("span", _hoisted_4$1, toDisplayString(__props.placeholder), 1)) : createCommentVNode("v-if", true)], 16, _hoisted_3$1)
|
|
3371
|
+
]), __props.displayCount || _ctx.$slots.end || __props.statusIcon ? (openBlock(), createElementBlock("span", {
|
|
3372
|
+
key: 0,
|
|
3373
|
+
ref_key: "laneRef",
|
|
3374
|
+
ref: laneRef,
|
|
3375
|
+
class: "astryx-power-search-end astryx-power-search-sheet-field__end"
|
|
3376
|
+
}, [
|
|
3377
|
+
__props.displayCount ? (openBlock(), createElementBlock("span", _hoisted_5$1, toDisplayString(__props.displayCount), 1)) : createCommentVNode("v-if", true),
|
|
3378
|
+
renderSlot(_ctx.$slots, "end"),
|
|
3379
|
+
createElementVNode("span", {
|
|
3380
|
+
ref_key: "statusIconRef",
|
|
3381
|
+
ref: statusIconRef,
|
|
3382
|
+
class: "astryx-power-search-sheet-field__status"
|
|
3383
|
+
}, [__props.statusIcon ? (openBlock(), createBlock(resolveDynamicComponent(__props.statusIcon), normalizeProps(mergeProps({ key: 0 }, __props.statusIconProps)), null, 16)) : createCommentVNode("v-if", true)], 512)
|
|
3384
|
+
], 512)) : createCommentVNode("v-if", true)], 46, _hoisted_1$1),
|
|
3385
|
+
isSheetMounted.value ? (openBlock(), createBlock(_sfc_main$2, {
|
|
3386
|
+
key: 0,
|
|
3387
|
+
"is-open": isOpen.value,
|
|
3388
|
+
"final-focus": triggerRef.value,
|
|
3389
|
+
config: __props.config,
|
|
3390
|
+
lookup: __props.lookup,
|
|
3391
|
+
filters: __props.filters,
|
|
3392
|
+
search: __props.search,
|
|
3393
|
+
placeholder: __props.placeholder,
|
|
3394
|
+
"is-read-only": __props.isReadOnly,
|
|
3395
|
+
"is-disabled": __props.isDisabled,
|
|
3396
|
+
"has-clear": __props.hasClear,
|
|
3397
|
+
"max-operator-menu-items": __props.maxOperatorMenuItems,
|
|
3398
|
+
"time-zone": __props.timeZone,
|
|
3399
|
+
"save-label": __props.saveLabel,
|
|
3400
|
+
components: __props.components,
|
|
3401
|
+
onClose: _cache[0] || (_cache[0] = ($event) => isOpen.value = false),
|
|
3402
|
+
onCommit: _cache[1] || (_cache[1] = (filters, changeType, index) => emit("commit", filters, changeType, index)),
|
|
3403
|
+
onMotionComplete
|
|
3404
|
+
}, null, 8, [
|
|
3405
|
+
"is-open",
|
|
3406
|
+
"final-focus",
|
|
3407
|
+
"config",
|
|
3408
|
+
"lookup",
|
|
3409
|
+
"filters",
|
|
3410
|
+
"search",
|
|
3411
|
+
"placeholder",
|
|
3412
|
+
"is-read-only",
|
|
3413
|
+
"is-disabled",
|
|
3414
|
+
"has-clear",
|
|
3415
|
+
"max-operator-menu-items",
|
|
3416
|
+
"time-zone",
|
|
3417
|
+
"save-label",
|
|
3418
|
+
"components"
|
|
3419
|
+
])) : createCommentVNode("v-if", true)
|
|
3420
|
+
], 64);
|
|
3421
|
+
};
|
|
3422
|
+
}
|
|
3423
|
+
});
|
|
3424
|
+
//#endregion
|
|
3425
|
+
//#region src/PowerSearch/source.ts
|
|
3426
|
+
const MAX_BROWSE_ITEMS = 1e3;
|
|
3427
|
+
function resolveValueMatches(operator, rawValue) {
|
|
3428
|
+
const kind = operator.value.type;
|
|
3429
|
+
if (kind === "string") return [{
|
|
3430
|
+
displayValue: rawValue,
|
|
3431
|
+
filterValue: {
|
|
3432
|
+
type: "string",
|
|
3433
|
+
value: rawValue
|
|
3434
|
+
},
|
|
3435
|
+
quoted: true
|
|
3436
|
+
}];
|
|
3437
|
+
if (kind === "string_list") return [{
|
|
3438
|
+
displayValue: rawValue,
|
|
3439
|
+
filterValue: {
|
|
3440
|
+
type: "string_list",
|
|
3441
|
+
value: [rawValue]
|
|
3442
|
+
},
|
|
3443
|
+
quoted: true
|
|
3444
|
+
}];
|
|
3445
|
+
if (kind === "enum" || kind === "enum_list") {
|
|
3446
|
+
const lower = rawValue.toLowerCase();
|
|
3447
|
+
return operator.value.values.filter((item) => item.label.toLowerCase().includes(lower)).map((item) => ({
|
|
3448
|
+
displayValue: item.label,
|
|
3449
|
+
filterValue: kind === "enum" ? {
|
|
3450
|
+
type: "enum",
|
|
3451
|
+
value: item.value
|
|
3452
|
+
} : {
|
|
3453
|
+
type: "enum_list",
|
|
3454
|
+
value: [item.value]
|
|
3455
|
+
},
|
|
3456
|
+
quoted: false
|
|
3457
|
+
}));
|
|
3458
|
+
}
|
|
3459
|
+
return [];
|
|
3460
|
+
}
|
|
3461
|
+
function browseItems(lookup) {
|
|
3462
|
+
const grouped = /* @__PURE__ */ new Map();
|
|
3463
|
+
const ungrouped = [];
|
|
3464
|
+
for (const field of lookup.getVisibleFields()) {
|
|
3465
|
+
const operator = lookup.getDefaultOperator(field.key);
|
|
3466
|
+
const item = {
|
|
3467
|
+
id: field.key,
|
|
3468
|
+
label: field.label,
|
|
3469
|
+
description: field.description,
|
|
3470
|
+
auxiliaryData: {
|
|
3471
|
+
fieldKey: field.key,
|
|
3472
|
+
operatorKey: operator?.key,
|
|
3473
|
+
group: field.group
|
|
3474
|
+
}
|
|
3475
|
+
};
|
|
3476
|
+
if (field.group) {
|
|
3477
|
+
const bucket = grouped.get(field.group) ?? [];
|
|
3478
|
+
bucket.push(item);
|
|
3479
|
+
grouped.set(field.group, bucket);
|
|
3480
|
+
} else ungrouped.push(item);
|
|
3481
|
+
}
|
|
3482
|
+
const ordered = [...ungrouped];
|
|
3483
|
+
for (const items of grouped.values()) ordered.push(...items);
|
|
3484
|
+
return ordered.slice(0, MAX_BROWSE_ITEMS);
|
|
3485
|
+
}
|
|
3486
|
+
function searchPowerSearchFields(lookup, query, messages, maxTypedResults) {
|
|
3487
|
+
const trimmed = query.trim();
|
|
3488
|
+
if (trimmed === "") return browseItems(lookup);
|
|
3489
|
+
const lower = trimmed.toLowerCase();
|
|
3490
|
+
const results = [];
|
|
3491
|
+
const seen = /* @__PURE__ */ new Set();
|
|
3492
|
+
const labelOf = (operator) => resolveOperatorLabel(operator, messages);
|
|
3493
|
+
for (const field of lookup.getVisibleFields()) {
|
|
3494
|
+
if (field.typeaheadMinQueryLength != null && lower.length < field.typeaheadMinQueryLength) continue;
|
|
3495
|
+
if ((field.label.toLowerCase().includes(lower) || field.typeaheadAliases?.some((alias) => alias.toLowerCase().includes(lower)) === true) && !seen.has(field.key)) {
|
|
3496
|
+
seen.add(field.key);
|
|
3497
|
+
const operator = lookup.getDefaultOperator(field.key);
|
|
3498
|
+
results.push({
|
|
3499
|
+
id: field.key,
|
|
3500
|
+
label: field.label,
|
|
3501
|
+
description: field.description,
|
|
3502
|
+
auxiliaryData: {
|
|
3503
|
+
fieldKey: field.key,
|
|
3504
|
+
operatorKey: operator?.key,
|
|
3505
|
+
group: field.group
|
|
3506
|
+
}
|
|
3507
|
+
});
|
|
3508
|
+
}
|
|
3509
|
+
for (const operator of field.operators) {
|
|
3510
|
+
const combined = `${field.label} ${labelOf(operator)}`.toLowerCase();
|
|
3511
|
+
const id = `${field.key}:${operator.key}`;
|
|
3512
|
+
if (combined.includes(lower) && !seen.has(id)) {
|
|
3513
|
+
seen.add(id);
|
|
3514
|
+
results.push({
|
|
3515
|
+
id,
|
|
3516
|
+
label: `${field.label} ${labelOf(operator)}`,
|
|
3517
|
+
description: field.description,
|
|
3518
|
+
auxiliaryData: {
|
|
3519
|
+
fieldKey: field.key,
|
|
3520
|
+
operatorKey: operator.key,
|
|
3521
|
+
group: field.group
|
|
3522
|
+
}
|
|
3523
|
+
});
|
|
3524
|
+
}
|
|
3525
|
+
}
|
|
3526
|
+
}
|
|
3527
|
+
for (const field of lookup.getVisibleFields()) {
|
|
3528
|
+
if (field.isValueMatchAllowed === false) continue;
|
|
3529
|
+
const fieldLabel = field.label.toLowerCase();
|
|
3530
|
+
let exactOperator = false;
|
|
3531
|
+
for (const operator of field.operators) {
|
|
3532
|
+
const prefix = `${fieldLabel} ${labelOf(operator).toLowerCase()} `;
|
|
3533
|
+
if (!lower.startsWith(prefix) || lower.length <= prefix.length) continue;
|
|
3534
|
+
const matches = resolveValueMatches(operator, trimmed.slice(prefix.length));
|
|
3535
|
+
if (matches.length > 0) exactOperator = true;
|
|
3536
|
+
for (const match of matches) {
|
|
3537
|
+
const id = `${field.key}:${operator.key}:value:${match.displayValue}`;
|
|
3538
|
+
if (seen.has(id)) continue;
|
|
3539
|
+
seen.add(id);
|
|
3540
|
+
const shown = match.quoted ? `"${match.displayValue}"` : match.displayValue;
|
|
3541
|
+
results.push({
|
|
3542
|
+
id,
|
|
3543
|
+
label: `${field.label} ${labelOf(operator)} ${shown}`,
|
|
3544
|
+
auxiliaryData: {
|
|
3545
|
+
fieldKey: field.key,
|
|
3546
|
+
operatorKey: operator.key,
|
|
3547
|
+
filterValue: match.filterValue
|
|
3548
|
+
}
|
|
3549
|
+
});
|
|
3550
|
+
}
|
|
3551
|
+
}
|
|
3552
|
+
const fieldPrefix = `${fieldLabel} `;
|
|
3553
|
+
if (!exactOperator && lower.startsWith(fieldPrefix) && lower.length > fieldPrefix.length) {
|
|
3554
|
+
const remainder = lower.slice(fieldPrefix.length);
|
|
3555
|
+
if (!field.operators.some((operator) => labelOf(operator).toLowerCase().startsWith(remainder))) {
|
|
3556
|
+
const rawValue = trimmed.slice(fieldPrefix.length);
|
|
3557
|
+
for (const operator of field.operators) for (const match of resolveValueMatches(operator, rawValue)) {
|
|
3558
|
+
const id = `${field.key}:${operator.key}:value:${match.displayValue}`;
|
|
3559
|
+
if (seen.has(id)) continue;
|
|
3560
|
+
seen.add(id);
|
|
3561
|
+
const shown = match.quoted ? `"${match.displayValue}"` : match.displayValue;
|
|
3562
|
+
results.push({
|
|
3563
|
+
id,
|
|
3564
|
+
label: `${field.label} ${labelOf(operator)} ${shown}`,
|
|
3565
|
+
auxiliaryData: {
|
|
3566
|
+
fieldKey: field.key,
|
|
3567
|
+
operatorKey: operator.key,
|
|
3568
|
+
filterValue: match.filterValue
|
|
3569
|
+
}
|
|
3570
|
+
});
|
|
3571
|
+
}
|
|
3572
|
+
}
|
|
3573
|
+
}
|
|
3574
|
+
}
|
|
3575
|
+
const contentKey = lookup.config.contentSearchFieldKey;
|
|
3576
|
+
const exact = lookup.getVisibleFields().some((field) => field.label.toLowerCase() === lower || field.operators.some((operator) => `${field.label} ${labelOf(operator)}`.toLowerCase() === lower));
|
|
3577
|
+
if (contentKey && !exact) {
|
|
3578
|
+
const field = lookup.getField(contentKey);
|
|
3579
|
+
const operator = lookup.getDefaultOperator(contentKey);
|
|
3580
|
+
if (field && operator) results.unshift({
|
|
3581
|
+
id: `__content_search__:${trimmed}`,
|
|
3582
|
+
label: `"${trimmed}"`,
|
|
3583
|
+
auxiliaryData: {
|
|
3584
|
+
fieldKey: contentKey,
|
|
3585
|
+
operatorKey: operator.key,
|
|
3586
|
+
filterValue: {
|
|
3587
|
+
type: "string",
|
|
3588
|
+
value: trimmed
|
|
3589
|
+
}
|
|
3590
|
+
}
|
|
3591
|
+
});
|
|
3592
|
+
}
|
|
3593
|
+
return results.slice(0, maxTypedResults);
|
|
3594
|
+
}
|
|
3595
|
+
//#endregion
|
|
3596
|
+
//#region src/PowerSearch/useFilterTokenNaming.ts
|
|
3597
|
+
/**
|
|
3598
|
+
* 内置筛选标签的弹层状态和编辑器名称。
|
|
3599
|
+
*
|
|
3600
|
+
* 标签按钮带 `aria-haspopup="dialog"` 和 `aria-expanded`,编辑器是一个以标签全部可见文字
|
|
3601
|
+
* 命名的非模态对话框。换掉了标签的调用方自己命名,编辑器保持普通浮层。
|
|
3602
|
+
*/
|
|
3603
|
+
function useFilterTokenNaming(options) {
|
|
3604
|
+
function nameId(index) {
|
|
3605
|
+
return `${options.idPrefix()}-token-${index}-name`;
|
|
3606
|
+
}
|
|
3607
|
+
function tokenProps(filter, index) {
|
|
3608
|
+
const session = options.session.value;
|
|
3609
|
+
return {
|
|
3610
|
+
nameId: nameId(index),
|
|
3611
|
+
opensEditor: options.opensEditor(filter),
|
|
3612
|
+
expanded: session?.mode === "edit" && session.index === index
|
|
3613
|
+
};
|
|
3614
|
+
}
|
|
3615
|
+
return {
|
|
3616
|
+
tokenProps,
|
|
3617
|
+
editorAttrs: computed(() => {
|
|
3618
|
+
const session = options.session.value;
|
|
3619
|
+
const filter = session?.mode === "edit" ? options.filters.value[session.index] : void 0;
|
|
3620
|
+
if (session == null || filter == null || !options.isBuiltIn(filter)) return {};
|
|
3621
|
+
return {
|
|
3622
|
+
"role": "dialog",
|
|
3623
|
+
"aria-labelledby": nameId(session.index)
|
|
3624
|
+
};
|
|
3625
|
+
})
|
|
3626
|
+
};
|
|
3627
|
+
}
|
|
3628
|
+
//#endregion
|
|
3629
|
+
//#region src/PowerSearch/usePowerSearchActions.ts
|
|
3630
|
+
function usePowerSearchActions(options) {
|
|
3631
|
+
const { props, emit, menu, lookup, text, announce } = options;
|
|
3632
|
+
const removeTap = useTokenRemoveTap({
|
|
3633
|
+
root: options.anchorRef,
|
|
3634
|
+
input: options.inputRef,
|
|
3635
|
+
tokenSelector: ".astryx-power-search-token"
|
|
3636
|
+
});
|
|
3637
|
+
const gutter = useLayerGutter();
|
|
3638
|
+
const internal = ref([]);
|
|
3639
|
+
const filters = computed(() => props.filters ?? internal.value);
|
|
3640
|
+
const session = ref(null);
|
|
3641
|
+
const openingControl = ref(null);
|
|
3642
|
+
const editorOpen = computed(() => session.value != null);
|
|
3643
|
+
const tokenEls = /* @__PURE__ */ new Map();
|
|
3644
|
+
const editorStyle = computed(() => {
|
|
3645
|
+
const place = session.value?.placement;
|
|
3646
|
+
if (place == null) return void 0;
|
|
3647
|
+
return {
|
|
3648
|
+
top: `${place.top}px`,
|
|
3649
|
+
left: `${place.left}px`,
|
|
3650
|
+
width: `${place.width}px`
|
|
3651
|
+
};
|
|
3652
|
+
});
|
|
3653
|
+
const editorComponent = computed(() => {
|
|
3654
|
+
const filter = session.value?.filter;
|
|
3655
|
+
if (filter?.operator == null) return _sfc_main$5;
|
|
3656
|
+
const type = lookup.value.getOperator(filter.field, filter.operator)?.value.type;
|
|
3657
|
+
return (type ? props.components?.[type]?.editor : void 0) ?? _sfc_main$5;
|
|
3658
|
+
});
|
|
3659
|
+
function commit(next, changeType, index) {
|
|
3660
|
+
internal.value = next;
|
|
3661
|
+
emit("update:filters", next);
|
|
3662
|
+
emit("change", next, changeType, index);
|
|
3663
|
+
}
|
|
3664
|
+
function operatorFor(filter) {
|
|
3665
|
+
return lookup.value.getOperator(filter.field, filter.operator);
|
|
3666
|
+
}
|
|
3667
|
+
function fieldFor(filter) {
|
|
3668
|
+
return lookup.value.getField(filter.field);
|
|
3669
|
+
}
|
|
3670
|
+
function emptyEditorOverridden(components) {
|
|
3671
|
+
return Boolean(components?.empty?.editor || options.hasCustomEditor());
|
|
3672
|
+
}
|
|
3673
|
+
function canEdit(filter) {
|
|
3674
|
+
if (props.disabled || props.readOnly || filter.isReadOnly) return false;
|
|
3675
|
+
const operator = operatorFor(filter);
|
|
3676
|
+
if (operator == null) return false;
|
|
3677
|
+
if (operator.value.type !== "empty") return true;
|
|
3678
|
+
return emptyEditorOverridden(props.components);
|
|
3679
|
+
}
|
|
3680
|
+
function canRemove(filter) {
|
|
3681
|
+
return !props.disabled && !props.readOnly && filter.isReadOnly !== true;
|
|
3682
|
+
}
|
|
3683
|
+
function tokenComponent(filter) {
|
|
3684
|
+
const type = operatorFor(filter)?.value.type;
|
|
3685
|
+
return type ? props.components?.[type]?.token : void 0;
|
|
3686
|
+
}
|
|
3687
|
+
function measure(control) {
|
|
3688
|
+
const outer = options.anchorRef.value;
|
|
3689
|
+
if (outer == null) return null;
|
|
3690
|
+
const target = control ?? outer;
|
|
3691
|
+
const outerRect = outer.getBoundingClientRect();
|
|
3692
|
+
const controlRect = target.getBoundingClientRect();
|
|
3693
|
+
const edges = gutter.value;
|
|
3694
|
+
return resolveEditorPlacement({
|
|
3695
|
+
outer: {
|
|
3696
|
+
left: outerRect.left,
|
|
3697
|
+
right: outerRect.right,
|
|
3698
|
+
width: outerRect.width
|
|
3699
|
+
},
|
|
3700
|
+
control: {
|
|
3701
|
+
left: controlRect.left,
|
|
3702
|
+
right: controlRect.right,
|
|
3703
|
+
width: controlRect.width
|
|
3704
|
+
},
|
|
3705
|
+
viewportWidth: window.innerWidth,
|
|
3706
|
+
viewportHeight: window.innerHeight,
|
|
3707
|
+
inlineStart: edges.inlineStart,
|
|
3708
|
+
inlineEnd: edges.inlineEnd,
|
|
3709
|
+
blockInset: edges.blockStart,
|
|
3710
|
+
direction: getComputedStyle(outer).direction === "rtl" ? "rtl" : "ltr",
|
|
3711
|
+
anchorTop: controlRect.top,
|
|
3712
|
+
anchorBottom: controlRect.bottom
|
|
3713
|
+
});
|
|
3714
|
+
}
|
|
3715
|
+
function openEditor(mode, filter, index, control) {
|
|
3716
|
+
const placement = measure(control);
|
|
3717
|
+
if (placement == null) return;
|
|
3718
|
+
menu.close();
|
|
3719
|
+
openingControl.value = control;
|
|
3720
|
+
session.value = {
|
|
3721
|
+
mode,
|
|
3722
|
+
index,
|
|
3723
|
+
filter,
|
|
3724
|
+
placement,
|
|
3725
|
+
ready: false,
|
|
3726
|
+
control
|
|
3727
|
+
};
|
|
3728
|
+
nextTick(() => {
|
|
3729
|
+
requestAnimationFrame(() => {
|
|
3730
|
+
if (session.value) session.value = {
|
|
3731
|
+
...session.value,
|
|
3732
|
+
ready: true
|
|
3733
|
+
};
|
|
3734
|
+
});
|
|
3735
|
+
});
|
|
3736
|
+
}
|
|
3737
|
+
function closeEditor(restore) {
|
|
3738
|
+
const control = session.value?.control;
|
|
3739
|
+
session.value = null;
|
|
3740
|
+
openingControl.value = null;
|
|
3741
|
+
if (!restore) return;
|
|
3742
|
+
nextTick(() => {
|
|
3743
|
+
if (control instanceof HTMLElement) control.focus();
|
|
3744
|
+
else options.inputRef.value?.focus();
|
|
3745
|
+
});
|
|
3746
|
+
}
|
|
3747
|
+
function focusInput() {
|
|
3748
|
+
nextTick(() => options.inputRef.value?.focus());
|
|
3749
|
+
}
|
|
3750
|
+
function pick(item) {
|
|
3751
|
+
const data = item.auxiliaryData;
|
|
3752
|
+
if (data == null) return;
|
|
3753
|
+
const field = lookup.value.getField(data.fieldKey);
|
|
3754
|
+
const operator = (data.operatorKey ? lookup.value.getOperator(data.fieldKey, data.operatorKey) : void 0) ?? lookup.value.getDefaultOperator(data.fieldKey);
|
|
3755
|
+
if (field == null || operator == null) return;
|
|
3756
|
+
menu.setQuery("");
|
|
3757
|
+
menu.close();
|
|
3758
|
+
if (data.filterValue != null || operator.value.type === "empty") {
|
|
3759
|
+
const value = data.filterValue ?? { type: "empty" };
|
|
3760
|
+
const next = [...filters.value, {
|
|
3761
|
+
field: field.key,
|
|
3762
|
+
operator: operator.key,
|
|
3763
|
+
value
|
|
3764
|
+
}];
|
|
3765
|
+
commit(next, "add", next.length - 1);
|
|
3766
|
+
announce(`${field.label}: ${operator.key}`);
|
|
3767
|
+
focusInput();
|
|
3768
|
+
return;
|
|
3769
|
+
}
|
|
3770
|
+
openEditor("create", {
|
|
3771
|
+
field: field.key,
|
|
3772
|
+
operator: operator.key
|
|
3773
|
+
}, filters.value.length, options.inputRef.value);
|
|
3774
|
+
}
|
|
3775
|
+
function onEditorSave(filter) {
|
|
3776
|
+
const current = session.value;
|
|
3777
|
+
if (current == null) return;
|
|
3778
|
+
if (filter == null) {
|
|
3779
|
+
if (current.mode === "edit") {
|
|
3780
|
+
const dropped = filters.value[current.index];
|
|
3781
|
+
commit(filters.value.filter((_, index) => index !== current.index), "remove", current.index);
|
|
3782
|
+
announce(text.value.removeFilter(dropped ? fieldFor(dropped)?.label ?? dropped.field : ""));
|
|
3783
|
+
}
|
|
3784
|
+
closeEditor(false);
|
|
3785
|
+
focusInput();
|
|
3786
|
+
return;
|
|
3787
|
+
}
|
|
3788
|
+
if (current.mode === "edit") commit(filters.value.map((item, index) => index === current.index ? filter : item), "edit", current.index);
|
|
3789
|
+
else {
|
|
3790
|
+
const next = [...filters.value, filter];
|
|
3791
|
+
commit(next, "add", next.length - 1);
|
|
3792
|
+
}
|
|
3793
|
+
const field = lookup.value.getField(filter.field);
|
|
3794
|
+
announce(field?.label ?? filter.field);
|
|
3795
|
+
closeEditor(false);
|
|
3796
|
+
focusInput();
|
|
3797
|
+
}
|
|
3798
|
+
function removeAt(index) {
|
|
3799
|
+
const filter = filters.value[index];
|
|
3800
|
+
if (filter == null || !canRemove(filter)) return;
|
|
3801
|
+
commit(filters.value.filter((_, itemIndex) => itemIndex !== index), "remove", index);
|
|
3802
|
+
announce(text.value.removeFilter(fieldFor(filter)?.label ?? filter.field));
|
|
3803
|
+
if (removeTap.shouldFocusInputAfterRemove()) focusInput();
|
|
3804
|
+
}
|
|
3805
|
+
function clearAll(event) {
|
|
3806
|
+
event?.stopPropagation();
|
|
3807
|
+
if (props.disabled || props.readOnly) return;
|
|
3808
|
+
const firstRemoved = filters.value.findIndex((filter) => filter.isReadOnly !== true);
|
|
3809
|
+
if (firstRemoved < 0) return;
|
|
3810
|
+
const kept = filters.value.filter((filter) => filter.isReadOnly === true);
|
|
3811
|
+
commit(kept, "remove", firstRemoved);
|
|
3812
|
+
announce(kept.length > 0 ? text.value.editableFiltersRemoved : text.value.allFiltersRemoved);
|
|
3813
|
+
menu.close();
|
|
3814
|
+
options.inputRef.value?.focus();
|
|
3815
|
+
}
|
|
3816
|
+
function activate(index) {
|
|
3817
|
+
const filter = filters.value[index];
|
|
3818
|
+
if (filter == null || props.disabled || props.readOnly || filter.isReadOnly) return;
|
|
3819
|
+
if (operatorFor(filter)?.value.type === "empty" && !emptyEditorOverridden(props.components)) {
|
|
3820
|
+
commit(filters.value.map((item, itemIndex) => itemIndex === index ? {
|
|
3821
|
+
field: item.field,
|
|
3822
|
+
operator: item.operator,
|
|
3823
|
+
value: { type: "empty" },
|
|
3824
|
+
isReadOnly: item.isReadOnly
|
|
3825
|
+
} : item), "edit", index);
|
|
3826
|
+
return;
|
|
3827
|
+
}
|
|
3828
|
+
if (!canEdit(filter)) return;
|
|
3829
|
+
openEditor("edit", filter, index, tokenEls.get(index) ?? null);
|
|
3830
|
+
}
|
|
3831
|
+
function setTokenEl(index, element) {
|
|
3832
|
+
if (element instanceof HTMLElement) tokenEls.set(index, element);
|
|
3833
|
+
else tokenEls.delete(index);
|
|
3834
|
+
}
|
|
3835
|
+
function focusToken(index) {
|
|
3836
|
+
nextTick(() => tokenEls.get(index)?.focus());
|
|
3837
|
+
}
|
|
3838
|
+
function onInput(event) {
|
|
3839
|
+
if (props.disabled || props.readOnly) return;
|
|
3840
|
+
menu.setQuery(event.target.value);
|
|
3841
|
+
}
|
|
3842
|
+
function onInputKeyDown(event) {
|
|
3843
|
+
if (session.value != null) return;
|
|
3844
|
+
const input = options.inputRef.value;
|
|
3845
|
+
if (event.key === "Backspace" && menu.query.value === "" && filters.value.length > 0 && canRemove(filters.value[filters.value.length - 1])) {
|
|
3846
|
+
event.preventDefault();
|
|
3847
|
+
removeAt(filters.value.length - 1);
|
|
3848
|
+
return;
|
|
3849
|
+
}
|
|
3850
|
+
if (event.key === "ArrowLeft" && input && input.selectionStart === 0 && input.selectionEnd === 0 && filters.value.length > 0) {
|
|
3851
|
+
event.preventDefault();
|
|
3852
|
+
focusToken(Math.min(options.visibleCount(), filters.value.length) - 1);
|
|
3853
|
+
return;
|
|
3854
|
+
}
|
|
3855
|
+
if (event.key === "ArrowRight" && input && menu.query.value === "" && input.selectionStart === 0) return;
|
|
3856
|
+
menu.onKeyDown(event);
|
|
3857
|
+
}
|
|
3858
|
+
function onTokenKeyDown(event, index) {
|
|
3859
|
+
const shown = options.visibleCount();
|
|
3860
|
+
if (event.key === "ArrowLeft" && index > 0) {
|
|
3861
|
+
event.preventDefault();
|
|
3862
|
+
focusToken(index - 1);
|
|
3863
|
+
} else if (event.key === "ArrowRight") {
|
|
3864
|
+
event.preventDefault();
|
|
3865
|
+
if (index < shown - 1) focusToken(index + 1);
|
|
3866
|
+
else options.inputRef.value?.focus();
|
|
3867
|
+
} else if (event.key === "Escape") options.inputRef.value?.focus();
|
|
3868
|
+
else if ((event.key === "Backspace" || event.key === "Delete") && canRemove(filters.value[index])) {
|
|
3869
|
+
event.preventDefault();
|
|
3870
|
+
removeAt(index);
|
|
3871
|
+
if (index > 0) focusToken(index - 1);
|
|
3872
|
+
} else if (event.key === "Enter") {
|
|
3873
|
+
event.preventDefault();
|
|
3874
|
+
activate(index);
|
|
3875
|
+
}
|
|
3876
|
+
}
|
|
3877
|
+
return {
|
|
3878
|
+
activate,
|
|
3879
|
+
canEdit,
|
|
3880
|
+
canRemove,
|
|
3881
|
+
clearAll,
|
|
3882
|
+
closeEditor,
|
|
3883
|
+
commit,
|
|
3884
|
+
editorComponent,
|
|
3885
|
+
editorOpen,
|
|
3886
|
+
editorStyle,
|
|
3887
|
+
fieldFor,
|
|
3888
|
+
filters,
|
|
3889
|
+
onEditorSave,
|
|
3890
|
+
onInput,
|
|
3891
|
+
onInputKeyDown,
|
|
3892
|
+
onTokenKeyDown,
|
|
3893
|
+
openingControl,
|
|
3894
|
+
operatorFor,
|
|
3895
|
+
pick,
|
|
3896
|
+
removeAt,
|
|
3897
|
+
session,
|
|
3898
|
+
setTokenEl,
|
|
3899
|
+
tokenComponent
|
|
3900
|
+
};
|
|
3901
|
+
}
|
|
3902
|
+
//#endregion
|
|
3903
|
+
//#region src/PowerSearch/usePowerSearchPresentation.ts
|
|
3904
|
+
/**
|
|
3905
|
+
* PowerSearch 的呈现:行内字段加浮层菜单,还是触屏底部弹层流程。底部弹层呈现里没有浮层菜单和
|
|
3906
|
+
* 浮层编辑器,换过去时把开着的都收起;`menuWidth` 和 `overflow` 只描述行内字段,在那里不生效。
|
|
3907
|
+
*/
|
|
3908
|
+
function usePowerSearchPresentation(options) {
|
|
3909
|
+
const { props } = options;
|
|
3910
|
+
const state = useSheetPresentation({
|
|
3911
|
+
component: "PowerSearch",
|
|
3912
|
+
presentation: () => props.presentation ?? "adaptive",
|
|
3913
|
+
root: options.root,
|
|
3914
|
+
focusControl: () => control()?.focus(),
|
|
3915
|
+
inertProps: () => [props.menuWidth != null ? "menuWidth" : "", props.overflow != null && props.overflow !== "none" ? "overflow" : ""].filter(Boolean)
|
|
3916
|
+
});
|
|
3917
|
+
function control() {
|
|
3918
|
+
return state.isSheet.value ? options.sheetTrigger() : options.input();
|
|
3919
|
+
}
|
|
3920
|
+
watch(state.isSheet, (isSheet) => {
|
|
3921
|
+
if (isSheet) options.onEnterSheet();
|
|
3922
|
+
});
|
|
3923
|
+
return {
|
|
3924
|
+
...state,
|
|
3925
|
+
focusControl: (focusOptions) => control()?.focus(focusOptions),
|
|
3926
|
+
blurControl: () => control()?.blur()
|
|
3927
|
+
};
|
|
3928
|
+
}
|
|
3929
|
+
//#endregion
|
|
3930
|
+
//#region src/PowerSearch/useResultCountAnnouncement.ts
|
|
3931
|
+
/**
|
|
3932
|
+
* 结果数变化时给读屏的播报文字。挂载时已经有的数不念,只念之后的变化:
|
|
3933
|
+
* 数字交给 `format` 写成句子,字符串原样念。
|
|
3934
|
+
*/
|
|
3935
|
+
function useResultCountAnnouncement(count, format) {
|
|
3936
|
+
const liveText = ref("");
|
|
3937
|
+
let sawCount = false;
|
|
3938
|
+
watch(count, (value) => {
|
|
3939
|
+
if (!sawCount) {
|
|
3940
|
+
sawCount = true;
|
|
3941
|
+
return;
|
|
3942
|
+
}
|
|
3943
|
+
if (typeof value === "number") liveText.value = format(value);
|
|
3944
|
+
else if (typeof value === "string") liveText.value = value;
|
|
3945
|
+
}, { immediate: true });
|
|
3946
|
+
return liveText;
|
|
3947
|
+
}
|
|
3948
|
+
//#endregion
|
|
3949
|
+
//#region src/PowerSearch/PowerSearch.vue
|
|
3950
|
+
const _hoisted_1 = {
|
|
3951
|
+
key: 0,
|
|
3952
|
+
class: "astryx-power-search-icon",
|
|
3953
|
+
"aria-hidden": "true"
|
|
3954
|
+
};
|
|
3955
|
+
const _hoisted_2 = ["onKeydown"];
|
|
3956
|
+
const _hoisted_3 = {
|
|
3957
|
+
key: 0,
|
|
3958
|
+
class: "astryx-power-search-more"
|
|
3959
|
+
};
|
|
3960
|
+
const _hoisted_4 = {
|
|
3961
|
+
"data-overflow-indicator": "",
|
|
3962
|
+
class: "astryx-power-search-more"
|
|
3963
|
+
};
|
|
3964
|
+
const _hoisted_5 = [
|
|
3965
|
+
"id",
|
|
3966
|
+
"placeholder",
|
|
3967
|
+
"value",
|
|
3968
|
+
"disabled",
|
|
3969
|
+
"readonly",
|
|
3970
|
+
"aria-disabled",
|
|
3971
|
+
"aria-expanded",
|
|
3972
|
+
"aria-controls",
|
|
3973
|
+
"aria-activedescendant",
|
|
3974
|
+
"aria-describedby"
|
|
3975
|
+
];
|
|
3976
|
+
const _hoisted_6 = {
|
|
3977
|
+
key: 1,
|
|
3978
|
+
class: "astryx-power-search-end"
|
|
3979
|
+
};
|
|
3980
|
+
const _hoisted_7 = {
|
|
3981
|
+
key: 0,
|
|
3982
|
+
class: "astryx-power-search-count"
|
|
3983
|
+
};
|
|
3984
|
+
const _hoisted_8 = ["aria-label"];
|
|
3985
|
+
const _hoisted_9 = ["id"];
|
|
3986
|
+
const _hoisted_10 = {
|
|
3987
|
+
class: "astryx-visually-hidden",
|
|
3988
|
+
"aria-live": "polite"
|
|
3989
|
+
};
|
|
3990
|
+
const _hoisted_11 = ["data-ready"];
|
|
3991
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
3992
|
+
name: "AstryxPowerSearch",
|
|
3993
|
+
inheritAttrs: false,
|
|
3994
|
+
__name: "PowerSearch",
|
|
3995
|
+
props: {
|
|
3996
|
+
config: {},
|
|
3997
|
+
filters: {},
|
|
3998
|
+
label: {},
|
|
3999
|
+
isLabelHidden: { type: Boolean },
|
|
4000
|
+
labelHidden: {
|
|
4001
|
+
type: Boolean,
|
|
4002
|
+
default: true
|
|
4003
|
+
},
|
|
4004
|
+
placeholder: {},
|
|
4005
|
+
autofocus: { type: Boolean },
|
|
4006
|
+
hasClear: {
|
|
4007
|
+
type: Boolean,
|
|
4008
|
+
default: true
|
|
4009
|
+
},
|
|
4010
|
+
clearable: {
|
|
4011
|
+
type: Boolean,
|
|
4012
|
+
default: true
|
|
4013
|
+
},
|
|
4014
|
+
readOnly: {
|
|
4015
|
+
type: Boolean,
|
|
4016
|
+
default: false
|
|
4017
|
+
},
|
|
4018
|
+
disabled: {
|
|
4019
|
+
type: Boolean,
|
|
4020
|
+
default: false
|
|
4021
|
+
},
|
|
4022
|
+
disabledMessage: {},
|
|
4023
|
+
disabledReason: {},
|
|
4024
|
+
status: { default: "default" },
|
|
4025
|
+
statusMessage: {},
|
|
4026
|
+
statusVariant: { default: "attached" },
|
|
4027
|
+
maxTokenLength: { default: 40 },
|
|
4028
|
+
maxOperatorMenuItems: {},
|
|
4029
|
+
maxSearchResults: { default: 10 },
|
|
4030
|
+
menuWidth: {},
|
|
4031
|
+
popoverSaveButtonLabel: {},
|
|
4032
|
+
saveLabel: {},
|
|
4033
|
+
timezoneID: {},
|
|
4034
|
+
timeZone: {},
|
|
4035
|
+
overflow: { default: "none" },
|
|
4036
|
+
resultCount: {},
|
|
4037
|
+
size: {},
|
|
4038
|
+
components: {},
|
|
4039
|
+
presentation: { default: "adaptive" },
|
|
4040
|
+
containerClass: { type: [
|
|
4041
|
+
Boolean,
|
|
4042
|
+
null,
|
|
4043
|
+
String,
|
|
4044
|
+
Object,
|
|
4045
|
+
Array
|
|
4046
|
+
] },
|
|
4047
|
+
containerStyle: { type: [
|
|
4048
|
+
Boolean,
|
|
4049
|
+
null,
|
|
4050
|
+
String,
|
|
4051
|
+
Object,
|
|
4052
|
+
Array
|
|
4053
|
+
] },
|
|
4054
|
+
controlClass: { type: [
|
|
4055
|
+
Boolean,
|
|
4056
|
+
null,
|
|
4057
|
+
String,
|
|
4058
|
+
Object,
|
|
4059
|
+
Array
|
|
4060
|
+
] },
|
|
4061
|
+
controlStyle: { type: [
|
|
4062
|
+
Boolean,
|
|
4063
|
+
null,
|
|
4064
|
+
String,
|
|
4065
|
+
Object,
|
|
4066
|
+
Array
|
|
4067
|
+
] }
|
|
4068
|
+
},
|
|
4069
|
+
emits: [
|
|
4070
|
+
"update:filters",
|
|
4071
|
+
"change",
|
|
4072
|
+
"focus",
|
|
4073
|
+
"blur"
|
|
4074
|
+
],
|
|
4075
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
4076
|
+
const props = __props;
|
|
4077
|
+
const emit = __emit;
|
|
4078
|
+
const slots = useSlots();
|
|
4079
|
+
if (isDevBuild() && props.config == null) throw devPropError("PowerSearch", "config", "is required: the fields people can filter by, for example :config=\"{ fields: [...] }\".");
|
|
4080
|
+
const size = useSize(() => props.size, "md");
|
|
4081
|
+
const attrs = useAttrs();
|
|
4082
|
+
const parts = useFieldPartStyling({
|
|
4083
|
+
component: "PowerSearch",
|
|
4084
|
+
props,
|
|
4085
|
+
attrs,
|
|
4086
|
+
reservedAttrs: [
|
|
4087
|
+
"id",
|
|
4088
|
+
"type",
|
|
4089
|
+
"role",
|
|
4090
|
+
"value",
|
|
4091
|
+
"disabled",
|
|
4092
|
+
"readonly",
|
|
4093
|
+
"placeholder",
|
|
4094
|
+
"autocomplete",
|
|
4095
|
+
"aria-expanded",
|
|
4096
|
+
"aria-controls",
|
|
4097
|
+
"aria-autocomplete",
|
|
4098
|
+
"aria-activedescendant",
|
|
4099
|
+
"aria-describedby",
|
|
4100
|
+
"aria-disabled"
|
|
4101
|
+
]
|
|
4102
|
+
});
|
|
4103
|
+
const hideLabel = useResolvedLabelHidden(() => props.isLabelHidden, () => props.labelHidden, true);
|
|
4104
|
+
const messages = useComponentMessages({ powerSearch: powerSearchMessages });
|
|
4105
|
+
const locale = useAstryxLocale();
|
|
4106
|
+
const announce = useAnnounce();
|
|
4107
|
+
const generatedId = `astryx-power-search-${useId()}`;
|
|
4108
|
+
const passedId = computed(() => typeof attrs.id === "string" && attrs.id !== "" ? attrs.id : void 0);
|
|
4109
|
+
const inputId = computed(() => passedId.value ?? generatedId);
|
|
4110
|
+
const listboxId = computed(() => `${inputId.value}-listbox`);
|
|
4111
|
+
const disabledId = computed(() => `${inputId.value}-disabled`);
|
|
4112
|
+
const focused = ref(false);
|
|
4113
|
+
const placeholderHeight = ref(0);
|
|
4114
|
+
const queryMirror = ref("");
|
|
4115
|
+
const anchorRef = useTemplateRef("anchorRef");
|
|
4116
|
+
const listboxRef = useTemplateRef("listboxRef");
|
|
4117
|
+
const listboxElement = computed(() => listboxRef.value?.element ?? null);
|
|
4118
|
+
const sheetFieldRef = useTemplateRef("sheetFieldRef");
|
|
4119
|
+
const inputRef = useTemplateRef("inputRef");
|
|
4120
|
+
const editorRef = useTemplateRef("editorRef");
|
|
4121
|
+
const visibleCountOf = { current: () => 0 };
|
|
4122
|
+
const text = computed(() => messages.value.powerSearch);
|
|
4123
|
+
const liveText = useResultCountAnnouncement(() => props.resultCount, (count) => text.value.resultCount(count));
|
|
4124
|
+
const label = computed(() => props.label ?? text.value.label);
|
|
4125
|
+
const placeholder = computed(() => props.placeholder ?? text.value.placeholder);
|
|
4126
|
+
const disabledMessage = computed(() => (props.disabledMessage ?? props.disabledReason)?.trim() || void 0);
|
|
4127
|
+
const focusableDisabled = computed(() => props.disabled && disabledMessage.value != null);
|
|
4128
|
+
const showsClear = computed(() => props.hasClear && props.clearable);
|
|
4129
|
+
const resolvedSaveLabel = computed(() => props.popoverSaveButtonLabel ?? props.saveLabel);
|
|
4130
|
+
const resolvedTimeZone = computed(() => props.timezoneID ?? props.timeZone);
|
|
4131
|
+
const lookup = computed(() => createPowerSearchLookup(props.config));
|
|
4132
|
+
const fieldStatus = computed(() => !props.statusMessage || props.status === "default" ? void 0 : {
|
|
4133
|
+
type: props.status,
|
|
4134
|
+
message: props.statusMessage
|
|
4135
|
+
});
|
|
4136
|
+
const { statusIcon, statusIconProps } = useInputStatusIcon({
|
|
4137
|
+
status: () => fieldStatus.value,
|
|
4138
|
+
statusVariant: () => props.statusVariant
|
|
4139
|
+
});
|
|
4140
|
+
const externalDescribedBy = computed(() => typeof attrs["aria-describedby"] === "string" ? attrs["aria-describedby"] : void 0);
|
|
4141
|
+
const describedBy = computed(() => [
|
|
4142
|
+
externalDescribedBy.value,
|
|
4143
|
+
focusableDisabled.value ? disabledId.value : void 0,
|
|
4144
|
+
props.statusMessage ? `${inputId.value}-status` : void 0
|
|
4145
|
+
].filter(Boolean).join(" ") || void 0);
|
|
4146
|
+
const source = computed(() => ({ search(query) {
|
|
4147
|
+
const limit = query.trim() === "" ? 1e3 : props.maxSearchResults;
|
|
4148
|
+
return searchPowerSearchFields(lookup.value, query, text.value, limit);
|
|
4149
|
+
} }));
|
|
4150
|
+
const bridge = {
|
|
4151
|
+
pick: (_item) => {},
|
|
4152
|
+
sessionOpen: () => false,
|
|
4153
|
+
closeEditor: (_restore) => {}
|
|
4154
|
+
};
|
|
4155
|
+
const menu = useTypeaheadMenu({
|
|
4156
|
+
source: () => source.value,
|
|
4157
|
+
debounceMs: 0,
|
|
4158
|
+
showOnFocus: () => !props.readOnly,
|
|
4159
|
+
maxItems: () => queryMirror.value.trim() === "" ? 1e3 : props.maxSearchResults,
|
|
4160
|
+
disabled: () => props.disabled || props.readOnly || bridge.sessionOpen(),
|
|
4161
|
+
onSelect: (entry) => bridge.pick(entry.item),
|
|
4162
|
+
onQueryChange: (query) => {
|
|
4163
|
+
queryMirror.value = query;
|
|
4164
|
+
}
|
|
4165
|
+
});
|
|
4166
|
+
const anchored = useAnchoredListbox({
|
|
4167
|
+
anchor: anchorRef,
|
|
4168
|
+
layer: listboxElement,
|
|
4169
|
+
isOpen: menu.combobox.isOpen,
|
|
4170
|
+
onDismiss: () => menu.close()
|
|
4171
|
+
});
|
|
4172
|
+
const { activate, canEdit, canRemove, clearAll, closeEditor, commit, editorComponent, editorOpen, editorStyle, fieldFor, filters, onEditorSave, onInput, onInputKeyDown, onTokenKeyDown, openingControl, operatorFor, pick, removeAt, session, setTokenEl, tokenComponent } = usePowerSearchActions({
|
|
4173
|
+
props,
|
|
4174
|
+
emit,
|
|
4175
|
+
hasCustomEditor: () => slots.editor != null,
|
|
4176
|
+
menu: {
|
|
4177
|
+
query: menu.query,
|
|
4178
|
+
close: () => menu.close(),
|
|
4179
|
+
setQuery: (value) => {
|
|
4180
|
+
menu.query.value = value;
|
|
4181
|
+
},
|
|
4182
|
+
onKeyDown: (event) => menu.onKeyDown(event)
|
|
4183
|
+
},
|
|
4184
|
+
anchorRef,
|
|
4185
|
+
inputRef,
|
|
4186
|
+
lookup,
|
|
4187
|
+
text,
|
|
4188
|
+
announce,
|
|
4189
|
+
visibleCount: () => visibleCountOf.current()
|
|
4190
|
+
});
|
|
4191
|
+
const naming = useFilterTokenNaming({
|
|
4192
|
+
idPrefix: () => inputId.value,
|
|
4193
|
+
session,
|
|
4194
|
+
filters,
|
|
4195
|
+
opensEditor: canEdit,
|
|
4196
|
+
isBuiltIn: (filter) => !slots.token && !tokenComponent(filter)
|
|
4197
|
+
});
|
|
4198
|
+
bridge.pick = pick;
|
|
4199
|
+
bridge.sessionOpen = () => session.value != null;
|
|
4200
|
+
bridge.closeEditor = closeEditor;
|
|
4201
|
+
const sheet = usePowerSearchPresentation({
|
|
4202
|
+
props,
|
|
4203
|
+
root: () => anchorRef.value ?? sheetFieldRef.value?.element,
|
|
4204
|
+
input: () => inputRef.value,
|
|
4205
|
+
sheetTrigger: () => sheetFieldRef.value,
|
|
4206
|
+
onEnterSheet: () => {
|
|
4207
|
+
menu.close();
|
|
4208
|
+
closeEditor(false);
|
|
4209
|
+
}
|
|
4210
|
+
});
|
|
4211
|
+
const collapsed = computed(() => props.overflow !== "none" && !focused.value && !sheet.isSheet.value);
|
|
4212
|
+
const floating = computed(() => props.overflow === "unfocused-layer" && focused.value && !sheet.isSheet.value);
|
|
4213
|
+
useDismiss({
|
|
4214
|
+
container: editorRef,
|
|
4215
|
+
trigger: openingControl,
|
|
4216
|
+
isEnabled: editorOpen,
|
|
4217
|
+
dismissOnEscape: "ignore",
|
|
4218
|
+
onDismiss: () => closeEditor(true)
|
|
4219
|
+
});
|
|
4220
|
+
const tokenCount = computed(() => filters.value.length);
|
|
4221
|
+
const overflowState = useOverflow(tokenCount, { gap: 4 });
|
|
4222
|
+
const visibleCount = computed(() => collapsed.value ? overflowState.visibleCount.value : tokenCount.value);
|
|
4223
|
+
visibleCountOf.current = () => visibleCount.value;
|
|
4224
|
+
const hiddenCount = computed(() => Math.max(0, tokenCount.value - visibleCount.value));
|
|
4225
|
+
watch(collapsed, () => {
|
|
4226
|
+
nextTick(() => overflowState.remeasure());
|
|
4227
|
+
});
|
|
4228
|
+
const visibleFilters = computed(() => filters.value.slice(0, visibleCount.value));
|
|
4229
|
+
const hasClearButton = computed(() => showsClear.value && filters.value.some((filter) => filter.isReadOnly !== true) && !props.disabled && !props.readOnly);
|
|
4230
|
+
const displayCount = computed(() => resultCountText(props.resultCount, text.value.resultCount));
|
|
4231
|
+
const menuStyle = computed(() => menuStyleWithWidth(anchored.style.value, props.menuWidth));
|
|
4232
|
+
function onInputFocus(event) {
|
|
4233
|
+
if (sheet.isHandingOffFocus()) return;
|
|
4234
|
+
emit("focus", event);
|
|
4235
|
+
if (!props.disabled && !props.readOnly && session.value == null) menu.open();
|
|
4236
|
+
}
|
|
4237
|
+
function onFocusIn() {
|
|
4238
|
+
if (!focused.value && props.overflow === "unfocused-layer") placeholderHeight.value = anchorRef.value?.offsetHeight ?? 0;
|
|
4239
|
+
focused.value = true;
|
|
4240
|
+
}
|
|
4241
|
+
function onFocusOut(event) {
|
|
4242
|
+
const next = event.relatedTarget;
|
|
4243
|
+
if (next instanceof Node && (anchorRef.value?.contains(next) || listboxElement.value?.contains(next) || editorRef.value?.contains(next))) return;
|
|
4244
|
+
focused.value = false;
|
|
4245
|
+
if (session.value == null) menu.close();
|
|
4246
|
+
}
|
|
4247
|
+
function onFieldClick(event) {
|
|
4248
|
+
if (props.disabled && !focusableDisabled.value) return;
|
|
4249
|
+
const target = event.target;
|
|
4250
|
+
if (target instanceof Element && target.closest("button, a")) return;
|
|
4251
|
+
inputRef.value?.focus();
|
|
4252
|
+
}
|
|
4253
|
+
onMounted(() => {
|
|
4254
|
+
if (props.autofocus) sheet.focusControl();
|
|
4255
|
+
});
|
|
4256
|
+
__expose({
|
|
4257
|
+
focusTypeahead: () => sheet.focusControl(),
|
|
4258
|
+
blurTypeahead: () => sheet.blurControl()
|
|
4259
|
+
});
|
|
4260
|
+
return (_ctx, _cache) => {
|
|
4261
|
+
return openBlock(), createElementBlock(Fragment, null, [
|
|
4262
|
+
createVNode(_sfc_main$20, {
|
|
4263
|
+
class: normalizeClass(["astryx-power-search", [
|
|
4264
|
+
unref(parts).containerClass.value,
|
|
4265
|
+
`size-${unref(size)}`,
|
|
4266
|
+
{ "is-floating": floating.value }
|
|
4267
|
+
]]),
|
|
4268
|
+
style: normalizeStyle(unref(parts).containerStyle.value),
|
|
4269
|
+
label: label.value,
|
|
4270
|
+
"input-id": inputId.value,
|
|
4271
|
+
"is-label-hidden": unref(hideLabel),
|
|
4272
|
+
"is-disabled": __props.disabled && !focusableDisabled.value,
|
|
4273
|
+
status: fieldStatus.value,
|
|
4274
|
+
"status-variant": __props.statusVariant
|
|
4275
|
+
}, {
|
|
4276
|
+
default: withCtx(() => [
|
|
4277
|
+
floating.value ? (openBlock(), createElementBlock("div", {
|
|
4278
|
+
key: 0,
|
|
4279
|
+
class: "astryx-power-search-placeholder",
|
|
4280
|
+
style: normalizeStyle({ height: `${placeholderHeight.value}px` })
|
|
4281
|
+
}, null, 4)) : createCommentVNode("v-if", true),
|
|
4282
|
+
createVNode(_sfc_main$16, {
|
|
4283
|
+
content: disabledMessage.value,
|
|
4284
|
+
"is-enabled": focusableDisabled.value
|
|
4285
|
+
}, {
|
|
4286
|
+
default: withCtx(() => [unref(sheet).isSheet.value ? (openBlock(), createBlock(_sfc_main$1, mergeProps({
|
|
4287
|
+
key: 0,
|
|
4288
|
+
ref_key: "sheetFieldRef",
|
|
4289
|
+
ref: sheetFieldRef
|
|
4290
|
+
}, unref(parts).forwardedAttrs(), {
|
|
4291
|
+
"is-open": unref(sheet).sheetOpen.value,
|
|
4292
|
+
"onUpdate:isOpen": _cache[0] || (_cache[0] = ($event) => unref(sheet).sheetOpen.value = $event),
|
|
4293
|
+
config: __props.config,
|
|
4294
|
+
lookup: lookup.value,
|
|
4295
|
+
filters: unref(filters),
|
|
4296
|
+
"input-id": inputId.value,
|
|
4297
|
+
"label-id": `${inputId.value}-label`,
|
|
4298
|
+
"described-by": describedBy.value,
|
|
4299
|
+
placeholder: placeholder.value,
|
|
4300
|
+
size: unref(size),
|
|
4301
|
+
"is-disabled": __props.disabled,
|
|
4302
|
+
"is-focusable-when-disabled": focusableDisabled.value,
|
|
4303
|
+
"is-read-only": __props.readOnly,
|
|
4304
|
+
"has-clear": showsClear.value,
|
|
4305
|
+
"control-class": [unref(parts).controlClass(), `status-${__props.status}`],
|
|
4306
|
+
"control-style": unref(parts).controlStyle(),
|
|
4307
|
+
"status-icon": unref(statusIcon),
|
|
4308
|
+
"status-icon-props": unref(statusIconProps),
|
|
4309
|
+
"display-count": displayCount.value,
|
|
4310
|
+
messages: text.value,
|
|
4311
|
+
locale: unref(locale),
|
|
4312
|
+
"time-zone": resolvedTimeZone.value,
|
|
4313
|
+
"max-token-length": __props.maxTokenLength,
|
|
4314
|
+
"max-operator-menu-items": __props.maxOperatorMenuItems,
|
|
4315
|
+
"save-label": resolvedSaveLabel.value,
|
|
4316
|
+
components: __props.components,
|
|
4317
|
+
search: (query) => source.value.search(query),
|
|
4318
|
+
"token-component": unref(tokenComponent),
|
|
4319
|
+
onCommit: unref(commit),
|
|
4320
|
+
onMotionComplete: unref(sheet).onSheetMotionComplete,
|
|
4321
|
+
onFocus: _cache[1] || (_cache[1] = ($event) => unref(sheet).isHandingOffFocus() || emit("focus", $event)),
|
|
4322
|
+
onBlur: _cache[2] || (_cache[2] = ($event) => emit("blur", $event))
|
|
4323
|
+
}), createSlots({ _: 2 }, [
|
|
4324
|
+
slots.icon ? {
|
|
4325
|
+
name: "icon",
|
|
4326
|
+
fn: withCtx(() => [renderSlot(_ctx.$slots, "icon")]),
|
|
4327
|
+
key: "0"
|
|
4328
|
+
} : void 0,
|
|
4329
|
+
slots.endContent || slots.end ? {
|
|
4330
|
+
name: "end",
|
|
4331
|
+
fn: withCtx(() => [slots.endContent ? renderSlot(_ctx.$slots, "endContent", {}, void 0, void 0, 0) : renderSlot(_ctx.$slots, "end", {}, void 0, void 0, 1)]),
|
|
4332
|
+
key: "1"
|
|
4333
|
+
} : void 0,
|
|
4334
|
+
slots.token ? {
|
|
4335
|
+
name: "token",
|
|
4336
|
+
fn: withCtx((tokenProps) => [renderSlot(_ctx.$slots, "token", normalizeProps(guardReactiveProps(tokenProps)))]),
|
|
4337
|
+
key: "2"
|
|
4338
|
+
} : void 0
|
|
4339
|
+
]), 1040, [
|
|
4340
|
+
"is-open",
|
|
4341
|
+
"config",
|
|
4342
|
+
"lookup",
|
|
4343
|
+
"filters",
|
|
4344
|
+
"input-id",
|
|
4345
|
+
"label-id",
|
|
4346
|
+
"described-by",
|
|
4347
|
+
"placeholder",
|
|
4348
|
+
"size",
|
|
4349
|
+
"is-disabled",
|
|
4350
|
+
"is-focusable-when-disabled",
|
|
4351
|
+
"is-read-only",
|
|
4352
|
+
"has-clear",
|
|
4353
|
+
"control-class",
|
|
4354
|
+
"control-style",
|
|
4355
|
+
"status-icon",
|
|
4356
|
+
"status-icon-props",
|
|
4357
|
+
"display-count",
|
|
4358
|
+
"messages",
|
|
4359
|
+
"locale",
|
|
4360
|
+
"time-zone",
|
|
4361
|
+
"max-token-length",
|
|
4362
|
+
"max-operator-menu-items",
|
|
4363
|
+
"save-label",
|
|
4364
|
+
"components",
|
|
4365
|
+
"search",
|
|
4366
|
+
"token-component",
|
|
4367
|
+
"onCommit",
|
|
4368
|
+
"onMotionComplete"
|
|
4369
|
+
])) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [createCommentVNode(" eslint-disable-next-line vue-a11y/click-events-have-key-events, vue-a11y/no-static-element-interactions -- 点空白处把焦点交给输入框。 "), createElementVNode("div", {
|
|
4370
|
+
ref_key: "anchorRef",
|
|
4371
|
+
ref: anchorRef,
|
|
4372
|
+
class: normalizeClass(["astryx-power-search-control", [
|
|
4373
|
+
unref(parts).controlClass(),
|
|
4374
|
+
`status-${__props.status}`,
|
|
4375
|
+
{
|
|
4376
|
+
"is-open": unref(menu).combobox.isOpen.value,
|
|
4377
|
+
"is-disabled": __props.disabled,
|
|
4378
|
+
"is-floating": floating.value
|
|
4379
|
+
}
|
|
4380
|
+
]]),
|
|
4381
|
+
style: normalizeStyle(unref(parts).controlStyle()),
|
|
4382
|
+
onClick: onFieldClick,
|
|
4383
|
+
onFocusin: onFocusIn,
|
|
4384
|
+
onFocusout: onFocusOut
|
|
4385
|
+
}, [
|
|
4386
|
+
slots.icon ? (openBlock(), createElementBlock("span", _hoisted_1, [renderSlot(_ctx.$slots, "icon")])) : createCommentVNode("v-if", true),
|
|
4387
|
+
createElementVNode("span", {
|
|
4388
|
+
ref: unref(overflowState).containerRef,
|
|
4389
|
+
class: normalizeClass(["astryx-power-search-tokens", { "is-collapsed": collapsed.value }])
|
|
4390
|
+
}, [
|
|
4391
|
+
createCommentVNode(" eslint-disable-next-line vue-a11y/no-static-element-interactions -- 方向键在条件之间移动焦点。 "),
|
|
4392
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(visibleFilters.value, (filter, index) => {
|
|
4393
|
+
return openBlock(), createElementBlock("span", {
|
|
4394
|
+
key: `${filter.field}-${filter.operator}-${index}`,
|
|
4395
|
+
ref_for: true,
|
|
4396
|
+
ref: (element) => unref(setTokenEl)(index, element),
|
|
4397
|
+
class: "astryx-power-search-token",
|
|
4398
|
+
tabindex: "-1",
|
|
4399
|
+
onKeydown: ($event) => unref(onTokenKeyDown)($event, index)
|
|
4400
|
+
}, [createVNode(_sfc_main$11, mergeProps({ ref_for: true }, unref(naming).tokenProps(filter, index), {
|
|
4401
|
+
config: __props.config,
|
|
4402
|
+
lookup: lookup.value,
|
|
4403
|
+
filter,
|
|
4404
|
+
"max-length": __props.maxTokenLength,
|
|
4405
|
+
messages: text.value,
|
|
4406
|
+
locale: unref(locale),
|
|
4407
|
+
"time-zone": resolvedTimeZone.value,
|
|
4408
|
+
size: unref(size),
|
|
4409
|
+
disabled: __props.disabled,
|
|
4410
|
+
removable: unref(canRemove)(filter),
|
|
4411
|
+
custom: unref(tokenComponent)(filter),
|
|
4412
|
+
onActivate: ($event) => unref(activate)(index),
|
|
4413
|
+
onRemove: ($event) => unref(removeAt)(index)
|
|
4414
|
+
}), createSlots({ _: 2 }, [slots.token ? {
|
|
4415
|
+
name: "token",
|
|
4416
|
+
fn: withCtx((tokenProps) => [renderSlot(_ctx.$slots, "token", mergeProps({ ref_for: true }, tokenProps))]),
|
|
4417
|
+
key: "0"
|
|
4418
|
+
} : void 0]), 1040, [
|
|
4419
|
+
"config",
|
|
4420
|
+
"lookup",
|
|
4421
|
+
"filter",
|
|
4422
|
+
"max-length",
|
|
4423
|
+
"messages",
|
|
4424
|
+
"locale",
|
|
4425
|
+
"time-zone",
|
|
4426
|
+
"size",
|
|
4427
|
+
"disabled",
|
|
4428
|
+
"removable",
|
|
4429
|
+
"custom",
|
|
4430
|
+
"onActivate",
|
|
4431
|
+
"onRemove"
|
|
4432
|
+
])], 40, _hoisted_2);
|
|
4433
|
+
}), 128)),
|
|
4434
|
+
collapsed.value && hiddenCount.value > 0 ? (openBlock(), createElementBlock("span", _hoisted_3, toDisplayString(text.value.more(hiddenCount.value)), 1)) : createCommentVNode("v-if", true)
|
|
4435
|
+
], 2),
|
|
4436
|
+
createElementVNode("span", {
|
|
4437
|
+
ref: unref(overflowState).measureRef,
|
|
4438
|
+
class: "astryx-power-search-measure",
|
|
4439
|
+
"aria-hidden": "true"
|
|
4440
|
+
}, [(openBlock(true), createElementBlock(Fragment, null, renderList(unref(filters), (filter, index) => {
|
|
4441
|
+
return openBlock(), createElementBlock("span", {
|
|
4442
|
+
key: `${filter.field}-${index}`,
|
|
4443
|
+
class: "astryx-power-search-token"
|
|
4444
|
+
}, [unref(fieldFor)(filter) && unref(operatorFor)(filter) ? (openBlock(), createBlock(_sfc_main$12, {
|
|
4445
|
+
key: 0,
|
|
4446
|
+
"field-label": unref(fieldFor)(filter).label,
|
|
4447
|
+
operator: unref(operatorFor)(filter),
|
|
4448
|
+
filter,
|
|
4449
|
+
"max-length": __props.maxTokenLength,
|
|
4450
|
+
messages: text.value,
|
|
4451
|
+
locale: unref(locale),
|
|
4452
|
+
size: unref(size),
|
|
4453
|
+
removable: ""
|
|
4454
|
+
}, null, 8, [
|
|
4455
|
+
"field-label",
|
|
4456
|
+
"operator",
|
|
4457
|
+
"filter",
|
|
4458
|
+
"max-length",
|
|
4459
|
+
"messages",
|
|
4460
|
+
"locale",
|
|
4461
|
+
"size"
|
|
4462
|
+
])) : createCommentVNode("v-if", true)]);
|
|
4463
|
+
}), 128)), createElementVNode("span", _hoisted_4, toDisplayString(text.value.more(Math.max(hiddenCount.value, 1))), 1)], 512),
|
|
4464
|
+
createElementVNode("input", mergeProps(unref(parts).forwardedAttrs(), {
|
|
4465
|
+
id: inputId.value,
|
|
4466
|
+
ref_key: "inputRef",
|
|
4467
|
+
ref: inputRef,
|
|
4468
|
+
class: "astryx-power-search-input",
|
|
4469
|
+
type: "text",
|
|
4470
|
+
role: "combobox",
|
|
4471
|
+
autocomplete: "off",
|
|
4472
|
+
autocapitalize: "off",
|
|
4473
|
+
autocorrect: "off",
|
|
4474
|
+
enterkeyhint: "search",
|
|
4475
|
+
placeholder: unref(filters).length === 0 ? placeholder.value : void 0,
|
|
4476
|
+
value: unref(menu).query.value,
|
|
4477
|
+
disabled: __props.disabled && !focusableDisabled.value,
|
|
4478
|
+
readonly: __props.readOnly || focusableDisabled.value || void 0,
|
|
4479
|
+
"aria-disabled": __props.disabled ? "true" : void 0,
|
|
4480
|
+
"aria-expanded": unref(menu).combobox.isOpen.value,
|
|
4481
|
+
"aria-controls": listboxId.value,
|
|
4482
|
+
"aria-autocomplete": "list",
|
|
4483
|
+
"aria-activedescendant": unref(menu).activeId.value ? `${listboxId.value}-option-${unref(menu).combobox.activeIndex.value}` : void 0,
|
|
4484
|
+
"aria-describedby": describedBy.value,
|
|
4485
|
+
onInput: _cache[3] || (_cache[3] = (...args) => unref(onInput) && unref(onInput)(...args)),
|
|
4486
|
+
onKeydown: _cache[4] || (_cache[4] = (...args) => unref(onInputKeyDown) && unref(onInputKeyDown)(...args)),
|
|
4487
|
+
onFocus: onInputFocus,
|
|
4488
|
+
onBlur: _cache[5] || (_cache[5] = ($event) => emit("blur", $event))
|
|
4489
|
+
}), null, 16, _hoisted_5),
|
|
4490
|
+
createCommentVNode(" 同上游 Tokenizer 的 endSection:计数、endContent、清除按钮并成一组,距边框 8px、间距 8px。 "),
|
|
4491
|
+
displayCount.value || slots.endContent || slots.end || hasClearButton.value || unref(statusIcon) ? (openBlock(), createElementBlock("span", _hoisted_6, [
|
|
4492
|
+
displayCount.value ? (openBlock(), createElementBlock("span", _hoisted_7, toDisplayString(displayCount.value), 1)) : createCommentVNode("v-if", true),
|
|
4493
|
+
slots.endContent ? renderSlot(_ctx.$slots, "endContent", {}, void 0, void 0, 1) : renderSlot(_ctx.$slots, "end", {}, void 0, void 0, 2),
|
|
4494
|
+
hasClearButton.value ? (openBlock(), createElementBlock("button", {
|
|
4495
|
+
key: 3,
|
|
4496
|
+
type: "button",
|
|
4497
|
+
class: "astryx-power-search-clear",
|
|
4498
|
+
"aria-label": text.value.clear,
|
|
4499
|
+
onClick: _cache[6] || (_cache[6] = (...args) => unref(clearAll) && unref(clearAll)(...args))
|
|
4500
|
+
}, [createVNode(_sfc_main$13, {
|
|
4501
|
+
icon: "close",
|
|
4502
|
+
size: "sm"
|
|
4503
|
+
})], 8, _hoisted_8)) : createCommentVNode("v-if", true),
|
|
4504
|
+
unref(statusIcon) ? (openBlock(), createBlock(resolveDynamicComponent(unref(statusIcon)), normalizeProps(mergeProps({ key: 4 }, unref(statusIconProps))), null, 16)) : createCommentVNode("v-if", true)
|
|
4505
|
+
])) : createCommentVNode("v-if", true)
|
|
4506
|
+
], 38)], 2112))]),
|
|
4507
|
+
_: 3
|
|
4508
|
+
}, 8, ["content", "is-enabled"]),
|
|
4509
|
+
focusableDisabled.value ? (openBlock(), createElementBlock("span", {
|
|
4510
|
+
key: 1,
|
|
4511
|
+
id: disabledId.value,
|
|
4512
|
+
class: "astryx-visually-hidden"
|
|
4513
|
+
}, toDisplayString(disabledMessage.value), 9, _hoisted_9)) : createCommentVNode("v-if", true),
|
|
4514
|
+
createElementVNode("span", _hoisted_10, toDisplayString(unref(liveText)), 1)
|
|
4515
|
+
]),
|
|
4516
|
+
_: 3
|
|
4517
|
+
}, 8, [
|
|
4518
|
+
"class",
|
|
4519
|
+
"style",
|
|
4520
|
+
"label",
|
|
4521
|
+
"input-id",
|
|
4522
|
+
"is-label-hidden",
|
|
4523
|
+
"is-disabled",
|
|
4524
|
+
"status",
|
|
4525
|
+
"status-variant"
|
|
4526
|
+
]),
|
|
4527
|
+
!unref(sheet).isSheet.value ? (openBlock(), createBlock(_sfc_main$10, {
|
|
4528
|
+
key: 0,
|
|
4529
|
+
id: listboxId.value,
|
|
4530
|
+
ref_key: "listboxRef",
|
|
4531
|
+
ref: listboxRef,
|
|
4532
|
+
"is-open": unref(menu).combobox.isOpen.value,
|
|
4533
|
+
entries: unref(menu).entries.value,
|
|
4534
|
+
"active-index": unref(menu).combobox.activeIndex.value,
|
|
4535
|
+
label: text.value.results,
|
|
4536
|
+
"empty-text": text.value.empty,
|
|
4537
|
+
placement: unref(anchored).position.value.placement,
|
|
4538
|
+
"menu-style": menuStyle.value,
|
|
4539
|
+
lookup: lookup.value,
|
|
4540
|
+
onHighlight: _cache[7] || (_cache[7] = ($event) => unref(menu).combobox.activeIndex.value = $event),
|
|
4541
|
+
onPick: unref(pick)
|
|
4542
|
+
}, null, 8, [
|
|
4543
|
+
"id",
|
|
4544
|
+
"is-open",
|
|
4545
|
+
"entries",
|
|
4546
|
+
"active-index",
|
|
4547
|
+
"label",
|
|
4548
|
+
"empty-text",
|
|
4549
|
+
"placement",
|
|
4550
|
+
"menu-style",
|
|
4551
|
+
"lookup",
|
|
4552
|
+
"onPick"
|
|
4553
|
+
])) : createCommentVNode("v-if", true),
|
|
4554
|
+
(openBlock(), createBlock(Teleport, { to: "body" }, [unref(session) ? (openBlock(), createElementBlock("div", mergeProps({
|
|
4555
|
+
key: 0,
|
|
4556
|
+
ref_key: "editorRef",
|
|
4557
|
+
ref: editorRef
|
|
4558
|
+
}, unref(naming).editorAttrs.value, {
|
|
4559
|
+
class: "astryx-power-search-editor astryx-layer",
|
|
4560
|
+
"data-ready": unref(session).ready ? "true" : "false",
|
|
4561
|
+
style: unref(editorStyle)
|
|
4562
|
+
}), [renderSlot(_ctx.$slots, "editor", {
|
|
4563
|
+
config: __props.config,
|
|
4564
|
+
filter: unref(session).filter,
|
|
4565
|
+
mode: unref(session).mode,
|
|
4566
|
+
saveLabel: resolvedSaveLabel.value,
|
|
4567
|
+
readOnly: __props.readOnly,
|
|
4568
|
+
timeZone: resolvedTimeZone.value,
|
|
4569
|
+
maxMenuItems: __props.maxOperatorMenuItems,
|
|
4570
|
+
onSave: unref(onEditorSave),
|
|
4571
|
+
onCancel: () => unref(closeEditor)(true)
|
|
4572
|
+
}, () => [(openBlock(), createBlock(resolveDynamicComponent(unref(editorComponent)), {
|
|
4573
|
+
config: __props.config,
|
|
4574
|
+
filter: unref(session).filter,
|
|
4575
|
+
mode: unref(session).mode,
|
|
4576
|
+
"save-label": resolvedSaveLabel.value,
|
|
4577
|
+
"read-only": __props.readOnly,
|
|
4578
|
+
"time-zone": resolvedTimeZone.value,
|
|
4579
|
+
"max-menu-items": __props.maxOperatorMenuItems,
|
|
4580
|
+
"on-save": unref(onEditorSave),
|
|
4581
|
+
"on-cancel": () => unref(closeEditor)(true)
|
|
4582
|
+
}, null, 40, [
|
|
4583
|
+
"config",
|
|
4584
|
+
"filter",
|
|
4585
|
+
"mode",
|
|
4586
|
+
"save-label",
|
|
4587
|
+
"read-only",
|
|
4588
|
+
"time-zone",
|
|
4589
|
+
"max-menu-items",
|
|
4590
|
+
"on-save",
|
|
4591
|
+
"on-cancel"
|
|
4592
|
+
]))])], 16, _hoisted_11)) : createCommentVNode("v-if", true)]))
|
|
4593
|
+
], 64);
|
|
4594
|
+
};
|
|
4595
|
+
}
|
|
4596
|
+
});
|
|
4597
|
+
//#endregion
|
|
4598
|
+
//#region src/PowerSearch/fieldBuilders.ts
|
|
4599
|
+
function i18n(key, message, value) {
|
|
4600
|
+
return {
|
|
4601
|
+
key,
|
|
4602
|
+
i18nKey: `@astryx.powersearch.operator.${message}`,
|
|
4603
|
+
value
|
|
4604
|
+
};
|
|
4605
|
+
}
|
|
4606
|
+
function stringField(key, label) {
|
|
4607
|
+
return {
|
|
4608
|
+
key,
|
|
4609
|
+
label,
|
|
4610
|
+
defaultOperator: "contains",
|
|
4611
|
+
operators: [
|
|
4612
|
+
i18n("contains", "contains", { type: "string" }),
|
|
4613
|
+
i18n("not_contains", "notContains", { type: "string" }),
|
|
4614
|
+
i18n("starts_with", "startsWith", { type: "string" }),
|
|
4615
|
+
i18n("not_starts_with", "notStartsWith", { type: "string" }),
|
|
4616
|
+
i18n("ends_with", "endsWith", { type: "string" }),
|
|
4617
|
+
i18n("not_ends_with", "notEndsWith", { type: "string" }),
|
|
4618
|
+
i18n("is", "is", { type: "string" }),
|
|
4619
|
+
i18n("is_not", "isNot", { type: "string" })
|
|
4620
|
+
]
|
|
4621
|
+
};
|
|
4622
|
+
}
|
|
4623
|
+
function numberField(key, label) {
|
|
4624
|
+
const value = { type: "float" };
|
|
4625
|
+
return {
|
|
4626
|
+
key,
|
|
4627
|
+
label,
|
|
4628
|
+
defaultOperator: "equals",
|
|
4629
|
+
operators: [
|
|
4630
|
+
i18n("equals", "equals", value),
|
|
4631
|
+
i18n("not_equals", "notEquals", value),
|
|
4632
|
+
i18n("greater_than", "greaterThan", value),
|
|
4633
|
+
i18n("less_than", "lessThan", value),
|
|
4634
|
+
i18n("greater_than_or_equal", "greaterThanOrEqual", value),
|
|
4635
|
+
i18n("less_than_or_equal", "lessThanOrEqual", value)
|
|
4636
|
+
]
|
|
4637
|
+
};
|
|
4638
|
+
}
|
|
4639
|
+
function dateField(key, label) {
|
|
4640
|
+
return {
|
|
4641
|
+
key,
|
|
4642
|
+
label,
|
|
4643
|
+
defaultOperator: "after",
|
|
4644
|
+
operators: [
|
|
4645
|
+
i18n("before", "before", { type: "date_absolute" }),
|
|
4646
|
+
i18n("after", "after", { type: "date_absolute" }),
|
|
4647
|
+
i18n("between", "between", { type: "date_range" })
|
|
4648
|
+
]
|
|
4649
|
+
};
|
|
4650
|
+
}
|
|
4651
|
+
function booleanField(key, label) {
|
|
4652
|
+
return {
|
|
4653
|
+
key,
|
|
4654
|
+
label,
|
|
4655
|
+
defaultOperator: "is_true",
|
|
4656
|
+
operators: [i18n("is_true", "isTrue", { type: "empty" }), i18n("is_false", "isFalse", { type: "empty" })]
|
|
4657
|
+
};
|
|
4658
|
+
}
|
|
4659
|
+
function enumField(key, label, values) {
|
|
4660
|
+
return {
|
|
4661
|
+
key,
|
|
4662
|
+
label,
|
|
4663
|
+
defaultOperator: "is",
|
|
4664
|
+
operators: [
|
|
4665
|
+
i18n("is", "is", {
|
|
4666
|
+
type: "enum",
|
|
4667
|
+
values
|
|
4668
|
+
}),
|
|
4669
|
+
i18n("is_not", "isNot", {
|
|
4670
|
+
type: "enum",
|
|
4671
|
+
values
|
|
4672
|
+
}),
|
|
4673
|
+
i18n("is_any_of", "isAnyOf", {
|
|
4674
|
+
type: "enum_list",
|
|
4675
|
+
values
|
|
4676
|
+
}),
|
|
4677
|
+
i18n("is_none_of", "isNoneOf", {
|
|
4678
|
+
type: "enum_list",
|
|
4679
|
+
values
|
|
4680
|
+
})
|
|
4681
|
+
]
|
|
4682
|
+
};
|
|
4683
|
+
}
|
|
4684
|
+
function enumListField(key, label, values) {
|
|
4685
|
+
return {
|
|
4686
|
+
key,
|
|
4687
|
+
label,
|
|
4688
|
+
defaultOperator: "is_any_of",
|
|
4689
|
+
operators: [i18n("is_any_of", "isAnyOf", {
|
|
4690
|
+
type: "enum_list",
|
|
4691
|
+
values
|
|
4692
|
+
}), i18n("is_none_of", "isNoneOf", {
|
|
4693
|
+
type: "enum_list",
|
|
4694
|
+
values
|
|
4695
|
+
})]
|
|
4696
|
+
};
|
|
4697
|
+
}
|
|
4698
|
+
function stringListField(key, label) {
|
|
4699
|
+
return {
|
|
4700
|
+
key,
|
|
4701
|
+
label,
|
|
4702
|
+
defaultOperator: "is_any_of",
|
|
4703
|
+
operators: [i18n("is_any_of", "isAnyOf", { type: "string_list" }), i18n("is_none_of", "isNoneOf", { type: "string_list" })]
|
|
4704
|
+
};
|
|
4705
|
+
}
|
|
4706
|
+
function buildPowerSearchField(definition) {
|
|
4707
|
+
const label = definition.label ?? definition.key;
|
|
4708
|
+
switch (definition.type) {
|
|
4709
|
+
case "string": return stringField(definition.key, label);
|
|
4710
|
+
case "number": return numberField(definition.key, label);
|
|
4711
|
+
case "date": return dateField(definition.key, label);
|
|
4712
|
+
case "boolean": return booleanField(definition.key, label);
|
|
4713
|
+
case "enum": return enumField(definition.key, label, definition.enumValues ?? []);
|
|
4714
|
+
case "enum_list": return enumListField(definition.key, label, definition.enumValues ?? []);
|
|
4715
|
+
case "string_list": return stringListField(definition.key, label);
|
|
4716
|
+
}
|
|
4717
|
+
}
|
|
4718
|
+
//#endregion
|
|
4719
|
+
//#region src/PowerSearch/query.ts
|
|
4720
|
+
const stringHandlers = {
|
|
4721
|
+
contains: (value, target) => value.includes(target),
|
|
4722
|
+
not_contains: (value, target) => !value.includes(target),
|
|
4723
|
+
starts_with: (value, target) => value.startsWith(target),
|
|
4724
|
+
not_starts_with: (value, target) => !value.startsWith(target),
|
|
4725
|
+
ends_with: (value, target) => value.endsWith(target),
|
|
4726
|
+
not_ends_with: (value, target) => !value.endsWith(target),
|
|
4727
|
+
is: (value, target) => value === target,
|
|
4728
|
+
is_not: (value, target) => value !== target
|
|
4729
|
+
};
|
|
4730
|
+
const numberHandlers = {
|
|
4731
|
+
equals: (value, target) => value === target,
|
|
4732
|
+
not_equals: (value, target) => value !== target,
|
|
4733
|
+
greater_than: (value, target) => value > target,
|
|
4734
|
+
less_than: (value, target) => value < target,
|
|
4735
|
+
greater_than_or_equal: (value, target) => value >= target,
|
|
4736
|
+
less_than_or_equal: (value, target) => value <= target
|
|
4737
|
+
};
|
|
4738
|
+
function toUnixSeconds(value) {
|
|
4739
|
+
return value instanceof Date ? Math.floor(value.getTime() / 1e3) : value;
|
|
4740
|
+
}
|
|
4741
|
+
function toStringValues(value) {
|
|
4742
|
+
if (typeof value === "string") return [value];
|
|
4743
|
+
if (Array.isArray(value) && value.every((item) => typeof item === "string")) return value;
|
|
4744
|
+
return null;
|
|
4745
|
+
}
|
|
4746
|
+
function isAnyOperator(operator) {
|
|
4747
|
+
return operator === "or" || operator === "any" || operator === "any_of" || operator.includes("any");
|
|
4748
|
+
}
|
|
4749
|
+
function matchesNested(row, value, operator) {
|
|
4750
|
+
if (value.type !== "nested") return true;
|
|
4751
|
+
const checks = value.value.map((filter) => matchesPowerSearchFilter(row, filter));
|
|
4752
|
+
if (checks.length === 0) return true;
|
|
4753
|
+
return isAnyOperator(operator) ? checks.some(Boolean) : checks.every(Boolean);
|
|
4754
|
+
}
|
|
4755
|
+
function matchesPowerSearchFilter(row, filter) {
|
|
4756
|
+
const fieldValue = row[filter.field];
|
|
4757
|
+
const { operator, value } = filter;
|
|
4758
|
+
switch (value.type) {
|
|
4759
|
+
case "empty":
|
|
4760
|
+
if (operator === "is_true") return Boolean(fieldValue) === true;
|
|
4761
|
+
if (operator === "is_false") return Boolean(fieldValue) === false;
|
|
4762
|
+
return true;
|
|
4763
|
+
case "string": {
|
|
4764
|
+
if (typeof fieldValue !== "string") return false;
|
|
4765
|
+
const handler = stringHandlers[operator];
|
|
4766
|
+
return handler ? handler(fieldValue.toLowerCase(), value.value.toLowerCase()) : true;
|
|
4767
|
+
}
|
|
4768
|
+
case "integer":
|
|
4769
|
+
case "float": {
|
|
4770
|
+
if (typeof fieldValue !== "number") return false;
|
|
4771
|
+
const handler = numberHandlers[operator];
|
|
4772
|
+
return handler ? handler(fieldValue, value.value) : true;
|
|
4773
|
+
}
|
|
4774
|
+
case "date_absolute": {
|
|
4775
|
+
if (!(fieldValue instanceof Date) && typeof fieldValue !== "number") return false;
|
|
4776
|
+
const stamp = toUnixSeconds(fieldValue);
|
|
4777
|
+
if (operator === "before") return stamp < value.unixSeconds;
|
|
4778
|
+
if (operator === "after") return stamp > value.unixSeconds;
|
|
4779
|
+
return true;
|
|
4780
|
+
}
|
|
4781
|
+
case "date_range": {
|
|
4782
|
+
if (!(fieldValue instanceof Date) && typeof fieldValue !== "number") return false;
|
|
4783
|
+
if (operator !== "between") return true;
|
|
4784
|
+
const now = Date.now() / 1e3;
|
|
4785
|
+
const stamp = toUnixSeconds(fieldValue);
|
|
4786
|
+
const start = resolveDateTimeRangePart(value.value.start, now);
|
|
4787
|
+
const end = resolveDateTimeRangePart(value.value.end, now);
|
|
4788
|
+
return stamp >= start && stamp <= end;
|
|
4789
|
+
}
|
|
4790
|
+
case "enum":
|
|
4791
|
+
if (typeof fieldValue !== "string") return false;
|
|
4792
|
+
if (operator === "is") return fieldValue === value.value;
|
|
4793
|
+
if (operator === "is_not") return fieldValue !== value.value;
|
|
4794
|
+
return true;
|
|
4795
|
+
case "enum_list":
|
|
4796
|
+
case "string_list": {
|
|
4797
|
+
const values = toStringValues(fieldValue);
|
|
4798
|
+
if (values == null) return false;
|
|
4799
|
+
if (operator === "is_any_of") return values.some((item) => value.value.includes(item));
|
|
4800
|
+
if (operator === "is_none_of") return values.every((item) => !value.value.includes(item));
|
|
4801
|
+
return true;
|
|
4802
|
+
}
|
|
4803
|
+
case "nested": return matchesNested(row, value, operator);
|
|
4804
|
+
case "time":
|
|
4805
|
+
case "date_relative":
|
|
4806
|
+
case "entity_list":
|
|
4807
|
+
case "custom": return true;
|
|
4808
|
+
}
|
|
4809
|
+
}
|
|
4810
|
+
function applyPowerSearchFilters(filters, data) {
|
|
4811
|
+
if (filters.length === 0) return [...data];
|
|
4812
|
+
return data.filter((row) => filters.every((filter) => matchesPowerSearchFilter(row, filter)));
|
|
4813
|
+
}
|
|
4814
|
+
function createPowerSearchConfig(definitions, configName) {
|
|
4815
|
+
return {
|
|
4816
|
+
config: {
|
|
4817
|
+
name: configName ?? "PowerSearchConfig",
|
|
4818
|
+
fields: definitions.map((definition) => buildPowerSearchField(definition))
|
|
4819
|
+
},
|
|
4820
|
+
applyFilters(filters, data) {
|
|
4821
|
+
return applyPowerSearchFilters(filters, data);
|
|
4822
|
+
}
|
|
4823
|
+
};
|
|
4824
|
+
}
|
|
4825
|
+
function usePowerSearchConfig(definitions, configName) {
|
|
4826
|
+
return createPowerSearchConfig(definitions, configName);
|
|
4827
|
+
}
|
|
4828
|
+
//#endregion
|
|
4829
|
+
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 };
|