@mittwald/flow-remote-vue-components 1.6.0-next.4 → 1.6.0-next.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/js/components-base/src/index.mjs +5 -2
- package/dist/js/components-base/src/list/filter/ListDateRangeFilter.mjs +1 -0
- package/dist/js/components-base/src/list/filter/ListDateRangeFilter.mjs.map +1 -1
- package/dist/js/components-base/src/list/filter/ListFilter.mjs +4 -1
- package/dist/js/components-base/src/list/filter/ListFilter.mjs.map +1 -1
- package/dist/js/components-base/src/list/filter/dateRange.mjs +37 -13
- package/dist/js/components-base/src/list/filter/dateRange.mjs.map +1 -1
- package/dist/js/components-base/src/list/filter/dateTimeRangeFields.mjs +53 -0
- package/dist/js/components-base/src/list/filter/dateTimeRangeFields.mjs.map +1 -0
- package/dist/js/components-base/src/list/filter/formatDateRange.mjs +25 -0
- package/dist/js/components-base/src/list/filter/formatDateRange.mjs.map +1 -0
- package/dist/js/components-base/src/overlay/OverlayState.mjs +194 -0
- package/dist/js/components-base/src/overlay/OverlayState.mjs.map +1 -0
- package/dist/js/index.mjs +2 -1
- package/dist/js/remote-vue-components/src/components/Action.mjs +1 -1
- package/dist/js/remote-vue-components/src/components/DeprecationWarningProvider.mjs +15 -9
- package/dist/js/remote-vue-components/src/components/DeprecationWarningProvider.mjs.map +1 -1
- package/dist/js/remote-vue-components/src/list/ActiveFilters.mjs +5 -2
- package/dist/js/remote-vue-components/src/list/ActiveFilters.mjs.map +1 -1
- package/dist/js/remote-vue-components/src/list/AllFiltersModal.mjs +3 -2
- package/dist/js/remote-vue-components/src/list/AllFiltersModal.mjs.map +1 -1
- package/dist/js/remote-vue-components/src/list/DateTimeRangeFields.mjs +100 -0
- package/dist/js/remote-vue-components/src/list/DateTimeRangeFields.mjs.map +1 -0
- package/dist/js/remote-vue-components/src/list/Header.mjs +12 -7
- package/dist/js/remote-vue-components/src/list/Header.mjs.map +1 -1
- package/dist/js/remote-vue-components/src/list/dateRangeFilter.mjs +14 -6
- package/dist/js/remote-vue-components/src/list/dateRangeFilter.mjs.map +1 -1
- package/dist/js/remote-vue-components/src/list/locales.mjs +14 -0
- package/dist/js/remote-vue-components/src/list/locales.mjs.map +1 -1
- package/dist/js/remote-vue-components/src/list/styles.mjs +7 -1
- package/dist/js/remote-vue-components/src/list/styles.mjs.map +1 -1
- package/dist/js/remote-vue-components/src/overlays/Modal.mjs +14 -18
- package/dist/js/remote-vue-components/src/overlays/Modal.mjs.map +1 -1
- package/dist/js/remote-vue-components/src/overlays/overlayController.mjs +57 -63
- package/dist/js/remote-vue-components/src/overlays/overlayController.mjs.map +1 -1
- package/dist/js/remote-vue-components/src/version.mjs +1 -1
- package/dist/types/_bundled/flow-components-base/index.d.ts +4 -1
- package/dist/types/_bundled/flow-components-base/list/filter/ListFilter.d.ts +2 -0
- package/dist/types/_bundled/flow-components-base/list/filter/dateRange.d.ts +24 -1
- package/dist/types/_bundled/flow-components-base/list/filter/dateTimeRangeFields.d.ts +34 -0
- package/dist/types/_bundled/flow-components-base/list/filter/formatDateRange.d.ts +7 -0
- package/dist/types/_bundled/flow-components-base/overlay/OverlayState.d.ts +94 -0
- package/dist/types/components/DeprecationWarningProvider.d.ts +2 -4
- package/dist/types/list/DateTimeRangeFields.d.ts +43 -0
- package/dist/types/list/dateRangeFilter.d.ts +6 -6
- package/dist/types/list/index.d.ts +1 -0
- package/dist/types/list/locales.d.ts +14 -0
- package/dist/types/list/styles.d.ts +6 -0
- package/dist/types/list/types.d.ts +8 -2
- package/dist/types/overlays/Modal.d.ts +2 -2
- package/dist/types/overlays/overlayController.d.ts +28 -18
- package/package.json +14 -14
package/dist/js/index.mjs
CHANGED
|
@@ -273,6 +273,7 @@ import { IconSucceeded } from "./remote-vue-components/src/icons/components/Icon
|
|
|
273
273
|
import { IconSuccess } from "./remote-vue-components/src/icons/components/IconSuccess.mjs";
|
|
274
274
|
import { IconUnavailable } from "./remote-vue-components/src/icons/components/IconUnavailable.mjs";
|
|
275
275
|
import { IconWarning } from "./remote-vue-components/src/icons/components/IconWarning.mjs";
|
|
276
|
+
import { resolveListDateRange } from "./components-base/src/list/filter/dateRange.mjs";
|
|
276
277
|
import { createOverlayController, injectOverlayController, useModalController, useOverlayController } from "./remote-vue-components/src/overlays/overlayController.mjs";
|
|
277
278
|
import { Action } from "./remote-vue-components/src/components/Action.mjs";
|
|
278
279
|
import { ActionBatch } from "./remote-vue-components/src/components/ActionBatch.mjs";
|
|
@@ -298,4 +299,4 @@ import { Wrap } from "./remote-vue-components/src/components/Wrap.mjs";
|
|
|
298
299
|
import { LightBox } from "./remote-vue-components/src/overlays/LightBox.mjs";
|
|
299
300
|
import { useIsMounted } from "./remote-vue-components/src/composables/useIsMounted.mjs";
|
|
300
301
|
import { useOnChange } from "./remote-vue-components/src/composables/useOnChange.mjs";
|
|
301
|
-
export { AccentBox, Accordion, AccordionGroup, Action, ActionBatch, ActionGroup, Alert, AlertBadge, AlertIcon, AlertText, Align, Area, Autocomplete, Avatar, AvatarStack, Badge, Bar, BigNumber, Breadcrumb, BrowserOnly, Button, CartesianChart, CartesianGrid, ChartGrid, ChartLegend, ChartTooltip, Chat, Checkbox, CheckboxButton, CheckboxGroup, ClearPropsContext, CoachMark, CodeBlock, CodeEditor, Color, ColumnLayout, Combine, ComboBox, ComponentPropsContextProvider, Content, ContextMenu, ContextMenuContent, ContextMenuSection, ContextMenuTrigger, ContextualHelp, ContextualHelpTrigger, CopyButton, CounterBadge, CountryOptions, DatePicker, DateRangePicker, DeprecationWarningProvider, DialogTrigger, Div, DonutChart, FieldDescription, FieldError, FileCard, FileCardList, FileDropZone, FileField, Flex, Form, Header, HeaderNavigation, Heading, Icon, IconAI, IconAIHosting, IconAnalytics, IconApp, IconAscending, IconAttachment, IconAutoresponder, IconBackLink, IconBackup, IconBold, IconCamera, IconCertificate, IconChangelog, IconCheck, IconCheckboxChecked, IconCheckboxEmpty, IconCheckboxIndeterminate, IconChevronDown, IconChevronLeft, IconChevronRight, IconChevronUp, IconClose, IconCode, IconContainer, IconContextMenu, IconContextMenuVertical, IconContract, IconContractPartner, IconContributor, IconCopy, IconCronjob, IconCustomer, IconDanger, IconDashboard, IconDatabase, IconDate, IconDelete, IconDeliveryBox, IconDescending, IconDesktop, IconDirectory, IconDnsSubZone, IconDnsZone, IconDomain, IconDownload, IconEdit, IconEmail, IconEmailArchive, IconExtension, IconExternalLink, IconFailed, IconFeedback, IconFile, IconFilter, IconForwardAddress, IconForwardLink, IconHide, IconHome, IconImage, IconInfo, IconInvite, IconInvoice, IconItalic, IconKnowledgeHint, IconLanguage, IconLeadFyndr, IconLink, IconLock, IconLockOpen, IconLogout, IconMainUser, IconMarketplace, IconMaximize, IconMember, IconMenu, IconMinimize, IconMinus, IconMittwald, IconMobile, IconMonitoring, IconMove, IconNewsletter, IconNotification, IconNumber, IconOrder, IconOrderedList, IconPassword, IconPath, IconPause, IconPayment, IconPending, IconPicture, IconPlus, IconProject, IconQuote, IconRadioOff, IconRadioOn, IconRedo, IconRefresh, IconRegistry, IconSave, IconSearch, IconSecurity, IconSend, IconServer, IconSetProvider, IconSettings, IconShare, IconShow, IconSorting, IconSsh, IconSshKey, IconSshSftp, IconStack, IconStar, IconStarFilled, IconStart, IconStrikeThrough, IconSubdomain, IconSucceeded, IconSuccess, IconSupport, IconTerminate, IconTicket, IconTime, IconUnavailable, IconUndo, IconUnorderedList, IconUpload, IconUser, IconVhost, IconView, IconVolume, IconWarning, IllustratedMessage, Image, ImageCropper, Initials, InlineCode, ItemsGridList, ItemsGridListItem, Kbd, Label, LabeledValue, LayoutCard, Legend, LightBox, LightBoxGallery, LightBoxGalleryItem, LightBoxTrigger, Line, Link, List, ListEmptyView, ListEmptyViewContainer, ListFilter, ListItem, ListItemView, ListItemViewContent, ListLoaderAsync, ListLoaderComposable, ListModel, ListSearch, ListSorting, ListStaticData, ListSummary, ListTable, ListTableBody, ListTableCell, ListTableColumn, ListTableHeader, ListTableRow, LoadingFallbackTrigger, LoadingIndicator, LoadingSpinner, Markdown, MarkdownEditor, MenuItem, MenuTrigger, Message, MessageSeparator, MessageThread, Modal, ModalTrigger, Navigation, NavigationGroup, Notification, NotificationController, NotificationProvider, NumberField, Option, OverlayContent, PasswordCreationField, Popover, PopoverContent, PopoverTrigger, ProgressBar, Radio, RadioButton, RadioGroup, RangeCalendar, Rating, RatingSegment, RemoteRoot, SearchField, Section, Segment, SegmentedControl, Select, Separator, SettingsProvider, SettingsStore, Skeleton, SkeletonMode, SkeletonText, Slider, Switch, Tab, TabNavigation, TabTitle, Table, TableBody, TableCell, TableColumn, TableFooterRow, TableHeader, TableRow, Tabs, Text, TextArea, TextField, TimeField, Tooltip, TooltipTrigger, TranslationProvider, Truncate, TunnelEntry, Wrap, XAxis, YAxis, communicationVersion, createFlowRemoteComponent, createListSettings, createOverlayController, injectContextIcon, injectListModel, injectOverlayController, injectSettings, packageVersion, svgIcon, tablerIcon, useIsMounted, useLanguage, useListMetadata, useListSettings, useModalController, useNotificationController, useOnChange, useOverlayController, useRemoteConnection, useWarnDeprecation };
|
|
302
|
+
export { AccentBox, Accordion, AccordionGroup, Action, ActionBatch, ActionGroup, Alert, AlertBadge, AlertIcon, AlertText, Align, Area, Autocomplete, Avatar, AvatarStack, Badge, Bar, BigNumber, Breadcrumb, BrowserOnly, Button, CartesianChart, CartesianGrid, ChartGrid, ChartLegend, ChartTooltip, Chat, Checkbox, CheckboxButton, CheckboxGroup, ClearPropsContext, CoachMark, CodeBlock, CodeEditor, Color, ColumnLayout, Combine, ComboBox, ComponentPropsContextProvider, Content, ContextMenu, ContextMenuContent, ContextMenuSection, ContextMenuTrigger, ContextualHelp, ContextualHelpTrigger, CopyButton, CounterBadge, CountryOptions, DatePicker, DateRangePicker, DeprecationWarningProvider, DialogTrigger, Div, DonutChart, FieldDescription, FieldError, FileCard, FileCardList, FileDropZone, FileField, Flex, Form, Header, HeaderNavigation, Heading, Icon, IconAI, IconAIHosting, IconAnalytics, IconApp, IconAscending, IconAttachment, IconAutoresponder, IconBackLink, IconBackup, IconBold, IconCamera, IconCertificate, IconChangelog, IconCheck, IconCheckboxChecked, IconCheckboxEmpty, IconCheckboxIndeterminate, IconChevronDown, IconChevronLeft, IconChevronRight, IconChevronUp, IconClose, IconCode, IconContainer, IconContextMenu, IconContextMenuVertical, IconContract, IconContractPartner, IconContributor, IconCopy, IconCronjob, IconCustomer, IconDanger, IconDashboard, IconDatabase, IconDate, IconDelete, IconDeliveryBox, IconDescending, IconDesktop, IconDirectory, IconDnsSubZone, IconDnsZone, IconDomain, IconDownload, IconEdit, IconEmail, IconEmailArchive, IconExtension, IconExternalLink, IconFailed, IconFeedback, IconFile, IconFilter, IconForwardAddress, IconForwardLink, IconHide, IconHome, IconImage, IconInfo, IconInvite, IconInvoice, IconItalic, IconKnowledgeHint, IconLanguage, IconLeadFyndr, IconLink, IconLock, IconLockOpen, IconLogout, IconMainUser, IconMarketplace, IconMaximize, IconMember, IconMenu, IconMinimize, IconMinus, IconMittwald, IconMobile, IconMonitoring, IconMove, IconNewsletter, IconNotification, IconNumber, IconOrder, IconOrderedList, IconPassword, IconPath, IconPause, IconPayment, IconPending, IconPicture, IconPlus, IconProject, IconQuote, IconRadioOff, IconRadioOn, IconRedo, IconRefresh, IconRegistry, IconSave, IconSearch, IconSecurity, IconSend, IconServer, IconSetProvider, IconSettings, IconShare, IconShow, IconSorting, IconSsh, IconSshKey, IconSshSftp, IconStack, IconStar, IconStarFilled, IconStart, IconStrikeThrough, IconSubdomain, IconSucceeded, IconSuccess, IconSupport, IconTerminate, IconTicket, IconTime, IconUnavailable, IconUndo, IconUnorderedList, IconUpload, IconUser, IconVhost, IconView, IconVolume, IconWarning, IllustratedMessage, Image, ImageCropper, Initials, InlineCode, ItemsGridList, ItemsGridListItem, Kbd, Label, LabeledValue, LayoutCard, Legend, LightBox, LightBoxGallery, LightBoxGalleryItem, LightBoxTrigger, Line, Link, List, ListEmptyView, ListEmptyViewContainer, ListFilter, ListItem, ListItemView, ListItemViewContent, ListLoaderAsync, ListLoaderComposable, ListModel, ListSearch, ListSorting, ListStaticData, ListSummary, ListTable, ListTableBody, ListTableCell, ListTableColumn, ListTableHeader, ListTableRow, LoadingFallbackTrigger, LoadingIndicator, LoadingSpinner, Markdown, MarkdownEditor, MenuItem, MenuTrigger, Message, MessageSeparator, MessageThread, Modal, ModalTrigger, Navigation, NavigationGroup, Notification, NotificationController, NotificationProvider, NumberField, Option, OverlayContent, PasswordCreationField, Popover, PopoverContent, PopoverTrigger, ProgressBar, Radio, RadioButton, RadioGroup, RangeCalendar, Rating, RatingSegment, RemoteRoot, SearchField, Section, Segment, SegmentedControl, Select, Separator, SettingsProvider, SettingsStore, Skeleton, SkeletonMode, SkeletonText, Slider, Switch, Tab, TabNavigation, TabTitle, Table, TableBody, TableCell, TableColumn, TableFooterRow, TableHeader, TableRow, Tabs, Text, TextArea, TextField, TimeField, Tooltip, TooltipTrigger, TranslationProvider, Truncate, TunnelEntry, Wrap, XAxis, YAxis, communicationVersion, createFlowRemoteComponent, createListSettings, createOverlayController, injectContextIcon, injectListModel, injectOverlayController, injectSettings, packageVersion, resolveListDateRange as resolveDateRangeFilterValue, svgIcon, tablerIcon, useIsMounted, useLanguage, useListMetadata, useListSettings, useModalController, useNotificationController, useOnChange, useOverlayController, useRemoteConnection, useWarnDeprecation };
|
|
@@ -5,9 +5,9 @@ import { Link } from "../auto-generated/Link.mjs";
|
|
|
5
5
|
import { MenuItem } from "../auto-generated/MenuItem.mjs";
|
|
6
6
|
import watchMobxValue from "../lib/mobxSelector.mjs";
|
|
7
7
|
import { dynamic, mapChildren } from "../overlays/childProps.mjs";
|
|
8
|
-
import { injectOverlayContext, isOverlayController } from "../overlays/overlayController.mjs";
|
|
9
8
|
import { ActionState } from "../../../components-base/src/action/ActionState.mjs";
|
|
10
9
|
import "../../../components-base/src/index.mjs";
|
|
10
|
+
import { injectOverlayContext, isOverlayController } from "../overlays/overlayController.mjs";
|
|
11
11
|
import { defineComponent, inject, onMounted, provide } from "vue";
|
|
12
12
|
//#region src/components/Action.ts
|
|
13
13
|
var actionProps = {
|
|
@@ -15,23 +15,29 @@ var DeprecationWarningProvider = defineComponent({
|
|
|
15
15
|
default: void 0
|
|
16
16
|
} },
|
|
17
17
|
setup(props, { slots }) {
|
|
18
|
-
|
|
18
|
+
const reported = /* @__PURE__ */ new Set();
|
|
19
|
+
provide(deprecationWarningKey, (message) => {
|
|
20
|
+
const onWarning = props.onWarning;
|
|
21
|
+
if (!onWarning || reported.has(message)) return;
|
|
22
|
+
reported.add(message);
|
|
23
|
+
onWarning(message);
|
|
24
|
+
});
|
|
19
25
|
return () => slots.default?.();
|
|
20
26
|
}
|
|
21
27
|
});
|
|
28
|
+
/** Messages already written to `console.warn`, across all providers. */
|
|
29
|
+
var consoleReported = /* @__PURE__ */ new Set();
|
|
22
30
|
/**
|
|
23
|
-
* Warns once per message, in the console
|
|
24
|
-
*
|
|
25
|
-
* Deduplicated per call site, like Flow's hook: a component that warns on every
|
|
26
|
-
* render must not fill the console.
|
|
31
|
+
* Warns once per message, like Flow's hook: in the console once for the whole
|
|
32
|
+
* app, and once to each provider.
|
|
27
33
|
*/
|
|
28
34
|
var useWarnDeprecation = () => {
|
|
29
35
|
const onWarning = inject(deprecationWarningKey, void 0);
|
|
30
|
-
const reported = /* @__PURE__ */ new Set();
|
|
31
36
|
return (message) => {
|
|
32
|
-
if (
|
|
33
|
-
|
|
34
|
-
|
|
37
|
+
if (!consoleReported.has(message)) {
|
|
38
|
+
consoleReported.add(message);
|
|
39
|
+
console.warn(message);
|
|
40
|
+
}
|
|
35
41
|
onWarning?.(message);
|
|
36
42
|
};
|
|
37
43
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeprecationWarningProvider.mjs","names":[],"sources":["../../../../../src/components/DeprecationWarningProvider.ts"],"sourcesContent":["import {\n defineComponent,\n inject,\n provide,\n type InjectionKey,\n type PropType,\n} from \"vue\";\nimport { composition } from \"@/lib/composition\";\n\nexport type DeprecationWarningHandler = (message: string) => void;\n\nconst deprecationWarningKey: InjectionKey<DeprecationWarningHandler> = Symbol(\n \"flowDeprecationWarning\",\n);\n\n/**\n * Collects the deprecation warnings a remote app triggers.\n *\n * `RemoteRoot` installs one that forwards to the host, which is how mStudio\n * learns which deprecated paths an extension still uses.\n */\nexport const DeprecationWarningProvider = defineComponent({\n name: \"DeprecationWarningProvider\",\n\n props: {\n onWarning: {\n type: Function as PropType<DeprecationWarningHandler>,\n default: undefined,\n },\n },\n\n setup(props, { slots }) {\n provide(deprecationWarningKey, (message: string)
|
|
1
|
+
{"version":3,"file":"DeprecationWarningProvider.mjs","names":[],"sources":["../../../../../src/components/DeprecationWarningProvider.ts"],"sourcesContent":["import {\n defineComponent,\n inject,\n provide,\n type InjectionKey,\n type PropType,\n} from \"vue\";\nimport { composition } from \"@/lib/composition\";\n\nexport type DeprecationWarningHandler = (message: string) => void;\n\nconst deprecationWarningKey: InjectionKey<DeprecationWarningHandler> = Symbol(\n \"flowDeprecationWarning\",\n);\n\n/**\n * Collects the deprecation warnings a remote app triggers.\n *\n * `RemoteRoot` installs one that forwards to the host, which is how mStudio\n * learns which deprecated paths an extension still uses.\n */\nexport const DeprecationWarningProvider = defineComponent({\n name: \"DeprecationWarningProvider\",\n\n props: {\n onWarning: {\n type: Function as PropType<DeprecationWarningHandler>,\n default: undefined,\n },\n },\n\n setup(props, { slots }) {\n const reported = new Set<string>();\n\n provide(deprecationWarningKey, (message: string) => {\n const onWarning = props.onWarning;\n if (!onWarning || reported.has(message)) {\n return;\n }\n reported.add(message);\n onWarning(message);\n });\n\n return () => slots.default?.();\n },\n});\n\n/** Messages already written to `console.warn`, across all providers. */\nconst consoleReported = new Set<string>();\n\n/**\n * Warns once per message, like Flow's hook: in the console once for the whole\n * app, and once to each provider.\n */\nexport const useWarnDeprecation = (): DeprecationWarningHandler => {\n const onWarning = inject(deprecationWarningKey, undefined);\n\n return (message: string) => {\n if (!consoleReported.has(message)) {\n consoleReported.add(message);\n console.warn(message);\n }\n onWarning?.(message);\n };\n};\n\ncomposition(DeprecationWarningProvider);\n\nexport default DeprecationWarningProvider;\n"],"mappings":";;;AAWA,IAAM,wBAAiE,OACrE,wBACF;;;;;;;AAQA,IAAa,6BAA6B,gBAAgB;CACxD,MAAM;CAEN,OAAO,EACL,WAAW;EACT,MAAM;EACN,SAAS,KAAA;CACX,EACF;CAEA,MAAM,OAAO,EAAE,SAAS;EACtB,MAAM,2BAAW,IAAI,IAAY;EAEjC,QAAQ,wBAAwB,YAAoB;GAClD,MAAM,YAAY,MAAM;GACxB,IAAI,CAAC,aAAa,SAAS,IAAI,OAAO,GACpC;GAEF,SAAS,IAAI,OAAO;GACpB,UAAU,OAAO;EACnB,CAAC;EAED,aAAa,MAAM,UAAU;CAC/B;AACF,CAAC;;AAGD,IAAM,kCAAkB,IAAI,IAAY;;;;;AAMxC,IAAa,2BAAsD;CACjE,MAAM,YAAY,OAAO,uBAAuB,KAAA,CAAS;CAEzD,QAAQ,YAAoB;EAC1B,IAAI,CAAC,gBAAgB,IAAI,OAAO,GAAG;GACjC,gBAAgB,IAAI,OAAO;GAC3B,QAAQ,KAAK,OAAO;EACtB;EACA,YAAY,OAAO;CACrB;AACF;AAEA,YAAY,0BAA0B"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useLanguage } from "../composables/remoteContext.mjs";
|
|
1
2
|
import { composition } from "../lib/composition.mjs";
|
|
2
3
|
import { Badge } from "../auto-generated/Badge.mjs";
|
|
3
4
|
import { Button } from "../auto-generated/Button.mjs";
|
|
@@ -10,11 +11,12 @@ import { IconSave } from "../icons/components/IconSave.mjs";
|
|
|
10
11
|
import { IconUndo } from "../icons/components/IconUndo.mjs";
|
|
11
12
|
import watchMobxValue from "../lib/mobxSelector.mjs";
|
|
12
13
|
import { ListFilter } from "../../../components-base/src/list/filter/ListFilter.mjs";
|
|
14
|
+
import { formatListDateRange } from "../../../components-base/src/list/filter/formatDateRange.mjs";
|
|
13
15
|
import "../../../components-base/src/index.mjs";
|
|
14
16
|
import { injectListModel } from "./listContext.mjs";
|
|
15
17
|
import { useListTexts } from "./locales.mjs";
|
|
16
18
|
import { listStyles } from "./styles.mjs";
|
|
17
|
-
import {
|
|
19
|
+
import { isDateRangeFilter } from "./dateRangeFilter.mjs";
|
|
18
20
|
import { defineComponent, h } from "vue";
|
|
19
21
|
//#region src/list/ActiveFilters.ts
|
|
20
22
|
/**
|
|
@@ -33,6 +35,7 @@ var ActiveFilters = defineComponent({
|
|
|
33
35
|
setup(props) {
|
|
34
36
|
const list = injectListModel();
|
|
35
37
|
const texts = useListTexts();
|
|
38
|
+
const language = useLanguage();
|
|
36
39
|
const tableRevision = watchMobxValue(() => list.listTable.revision);
|
|
37
40
|
const iconButton = (label, icon, onPress) => h(TooltipTrigger, { isDisabled: props.isDisabled }, () => [h(Tooltip, null, () => texts.value(label)), h(Button, {
|
|
38
41
|
size: "s",
|
|
@@ -51,7 +54,7 @@ var ActiveFilters = defineComponent({
|
|
|
51
54
|
key: filter.storageKey,
|
|
52
55
|
isDisabled: props.isDisabled,
|
|
53
56
|
onClose: () => filter.clear()
|
|
54
|
-
}, () => h(Text, null, () =>
|
|
57
|
+
}, () => h(Text, null, () => formatListDateRange(range, language.value ?? navigator.language, texts.value)))] : [];
|
|
55
58
|
}
|
|
56
59
|
return filter.values.filter((value) => value.isActive).map((value) => h(Badge, {
|
|
57
60
|
key: value.id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActiveFilters.mjs","names":[],"sources":["../../../../../src/list/ActiveFilters.ts"],"sourcesContent":["import {\n Badge,\n Button,\n Div,\n Text,\n Tooltip,\n TooltipTrigger,\n} from \"@/auto-generated\";\nimport { IconClose, IconSave, IconUndo } from \"@/icons\";\nimport { watchMobxValue } from \"@/lib/mobxSelector\";\nimport {
|
|
1
|
+
{"version":3,"file":"ActiveFilters.mjs","names":[],"sources":["../../../../../src/list/ActiveFilters.ts"],"sourcesContent":["import {\n Badge,\n Button,\n Div,\n Text,\n Tooltip,\n TooltipTrigger,\n} from \"@/auto-generated\";\nimport { IconClose, IconSave, IconUndo } from \"@/icons\";\nimport { watchMobxValue } from \"@/lib/mobxSelector\";\nimport { useLanguage } from \"@/composables/remoteContext\";\nimport {\n formatListDateRange,\n ListFilter,\n} from \"@mittwald/flow-components-base\";\nimport type { ListDateRange } from \"@mittwald/flow-components-base\";\nimport { defineComponent, h, type VNodeChild } from \"vue\";\nimport { isDateRangeFilter } from \"./dateRangeFilter\";\nimport { injectListModel } from \"./listContext\";\nimport { useListTexts, type ListTextKey } from \"./locales\";\nimport { listStyles } from \"./styles\";\nimport type { ListRendered } from \"./types\";\nimport { composition } from \"@/lib/composition\";\n\n/** What the chips need of a filter and its values, and nothing more. */\ninterface ChipDateRangeFilter {\n readonly name?: string;\n getValue(): ListDateRange | null;\n clear(): void;\n}\n\ninterface ChipFilter {\n readonly storageKey: string;\n readonly mode: string;\n readonly values: {\n readonly id: string;\n readonly isActive: boolean;\n deactivate(): void;\n render(): ListRendered;\n }[];\n getArrayValue(): { id: string }[];\n isStoringAvailable(): boolean;\n hasChanges(): boolean;\n}\n\n/**\n * The selected filter values, and what can be done with the set of them.\n *\n * Shown beside the filter menus rather than inside them, so a selection made in\n * one menu stays visible while another is open — and can be taken back one\n * value at a time.\n */\nexport const ActiveFilters = defineComponent({\n name: \"ListActiveFilters\",\n\n props: {\n isDisabled: { type: Boolean, default: false },\n },\n\n setup(props) {\n const list = injectListModel();\n const texts = useListTexts();\n /* As in React's remote root: the host's language, else the browser's. */\n const language = useLanguage();\n\n /* Every read here is of the table's filter state. */\n const tableRevision = watchMobxValue(() => list.listTable.revision);\n\n const iconButton = (\n label: ListTextKey,\n icon: unknown,\n onPress: () => void,\n ): VNodeChild =>\n h(TooltipTrigger, { isDisabled: props.isDisabled }, () => [\n h(Tooltip, null, () => texts.value(label)),\n h(\n Button,\n {\n size: \"s\",\n variant: \"plain\",\n color: \"secondary\",\n \"aria-label\": texts.value(label),\n onPress,\n },\n () => h(icon as never),\n ),\n ]);\n\n return () => {\n void tableRevision.value;\n\n const filters = list.filters as unknown as ChipFilter[];\n\n const chips = filters.flatMap((filter) => {\n /* One chip for the whole range, and closing it clears the range. */\n if (isDateRangeFilter(filter)) {\n const range = (filter as unknown as ChipDateRangeFilter).getValue();\n\n return range\n ? [\n h(\n Badge,\n {\n key: filter.storageKey,\n isDisabled: props.isDisabled,\n onClose: () =>\n (filter as unknown as ChipDateRangeFilter).clear(),\n },\n () =>\n h(Text, null, () =>\n formatListDateRange(\n range,\n language.value ?? navigator.language,\n texts.value,\n ),\n ),\n ),\n ]\n : [];\n }\n\n return filter.values\n .filter((value) => value.isActive)\n .map((value) =>\n h(\n Badge,\n {\n key: value.id,\n isDisabled: props.isDisabled,\n onClose: () => value.deactivate(),\n },\n () => h(Text, null, () => value.render()),\n ),\n );\n });\n\n const hasChanges = filters.some((filter) => filter.hasChanges());\n const storingAvailable = filters.some((filter) =>\n filter.isStoringAvailable(),\n );\n\n const storeButton =\n storingAvailable && hasChanges\n ? iconButton(\"filters.store\", IconSave, () =>\n ListFilter.storeFilters(list, filters, {\n autosave: false,\n manualSave: true,\n }),\n )\n : undefined;\n\n const resetButton = hasChanges\n ? iconButton(\"filters.reset\", IconUndo, () => list.resetFilters())\n : undefined;\n\n const clearButton =\n chips.length > 1\n ? iconButton(\"filters.clear\", IconClose, () =>\n list.filters.forEach((filter) => filter.clear()),\n )\n : undefined;\n\n if (chips.length === 0 && !storeButton && !resetButton) {\n return null;\n }\n\n return h(Div, { class: listStyles.activeFilters }, () => [\n ...chips,\n storeButton,\n resetButton,\n clearButton,\n ]);\n };\n },\n});\n\ncomposition(ActiveFilters);\n\nexport default ActiveFilters;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoDA,IAAa,gBAAgB,gBAAgB;CAC3C,MAAM;CAEN,OAAO,EACL,YAAY;EAAE,MAAM;EAAS,SAAS;CAAM,EAC9C;C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aAAa,CAAC,IAC/D,KAAA;GAEJ,MAAM,cACJ,MAAM,SAAS,IACX,WAAW,iBAAiB,iBAC1B,KAAK,QAAQ,SAAS,WAAW,OAAO,MAAM,CAAC,CACjD,IACA,KAAA;GAEN,IAAI,MAAM,WAAW,KAAK,CAAC,eAAe,CAAC,aACzC,OAAO;GAGT,OAAO,EAAE,KAAK,EAAE,OAAO,WAAW,cAAc,SAAS;IACvD,GAAG;IACH;IACA;IACA;GACF,CAAC;EACH;CACF;AACF,CAAC;AAED,YAAY,aAAa"}
|
|
@@ -23,6 +23,7 @@ import { listStyles } from "./styles.mjs";
|
|
|
23
23
|
import { ModalTrigger } from "../overlays/triggers.mjs";
|
|
24
24
|
import { isDateRangeFilter } from "./dateRangeFilter.mjs";
|
|
25
25
|
import { Modal } from "../overlays/Modal.mjs";
|
|
26
|
+
import { DateTimeRangeFields } from "./DateTimeRangeFields.mjs";
|
|
26
27
|
import { defineComponent, h } from "vue";
|
|
27
28
|
//#region src/list/AllFiltersModal.ts
|
|
28
29
|
var accordion = (key, heading, expanded, content) => h(Accordion, {
|
|
@@ -35,8 +36,8 @@ var renderDateRangeAccordion = (filter, expanded, texts) => {
|
|
|
35
36
|
return accordion(`filter-${name}`, name, expanded, () => h(Flex, {
|
|
36
37
|
direction: "column",
|
|
37
38
|
gap: "m"
|
|
38
|
-
}, () => [h(RangeCalendar, {
|
|
39
|
-
...filter.
|
|
39
|
+
}, () => [filter.granularity === "minute" ? h(DateTimeRangeFields, { filter }) : h(RangeCalendar, {
|
|
40
|
+
...filter.rangeCalendarProps,
|
|
40
41
|
value,
|
|
41
42
|
onChange: (range) => filter.setValue(range)
|
|
42
43
|
}), value ? h(Button, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AllFiltersModal.mjs","names":[],"sources":["../../../../../src/list/AllFiltersModal.ts"],"sourcesContent":["import {\n Accordion,\n AccordionGroup,\n ActionGroup,\n Button,\n Checkbox,\n CheckboxGroup,\n Content,\n Flex,\n Heading,\n Radio,\n RadioGroup,\n RangeCalendar,\n Section,\n SkeletonText,\n Text,\n} from \"@/auto-generated\";\nimport { IconFilter } from \"@/icons\";\nimport { watchMobxValue } from \"@/lib/mobxSelector\";\nimport { Modal } from \"@/overlays/Modal\";\nimport { createOverlayController } from \"@/overlays/overlayController\";\nimport { ModalTrigger } from \"@/overlays/triggers\";\nimport { defineComponent, h, type VNodeChild } from \"vue\";\nimport { isDateRangeFilter } from \"./dateRangeFilter\";\nimport { injectListModel, type AnyListModel } from \"./listContext\";\nimport { useListTexts, type ListTextFormatter } from \"./locales\";\nimport { listStyles } from \"./styles\";\nimport type { ListRendered } from \"./types\";\nimport { composition } from \"@/lib/composition\";\n\n/*\n * What this modal needs of a filter and a sorting. Not the classes: a list of\n * concrete filters is not assignable to a list of generic ones — a row model\n * sits in a contravariant position deep inside `Column`.\n */\ninterface ModalFilterValue {\n readonly id: string;\n readonly isActive: boolean;\n toggle(): void;\n render(): ListRendered;\n}\n\ninterface ModalFilter {\n readonly name?: string;\n readonly property: unknown;\n readonly mode: string;\n readonly priority: \"primary\" | \"secondary\";\n readonly values: ModalFilterValue[];\n readonly isSelectAllAvailable: boolean;\n isActive(): boolean;\n isEveryValueActive(): boolean;\n selectAll(): void;\n deselectAll(): void;\n clear(): void;\n}\n\ninterface ModalSorting {\n readonly id: string;\n readonly name?: string;\n readonly property: unknown;\n readonly directionName?: string;\n isSorted(): boolean;\n enable(): void;\n}\n\nconst accordion = (\n key: string,\n heading: string,\n expanded: boolean,\n content: () => VNodeChild,\n): VNodeChild =>\n h(Accordion, { key, defaultExpanded: expanded }, () => [\n h(Heading, null, () => heading),\n h(Content, null, content),\n ]);\n\ninterface ModalDateRangeFilter {\n readonly name?: string;\n readonly property: unknown;\n readonly dateRangeOptions?: Record<string, unknown>;\n getValue(): unknown;\n setValue(range: unknown): void;\n clear(): void;\n}\n\nconst renderDateRangeAccordion = (\n filter: ModalDateRangeFilter,\n expanded: boolean,\n texts: ListTextFormatter,\n): VNodeChild => {\n const name = filter.name ?? String(filter.property);\n const value = filter.getValue();\n\n return accordion(`filter-${name}`, name, expanded, () =>\n h(Flex, { direction: \"column\", gap: \"m\" }, () => [\n h(RangeCalendar, {\n ...filter.dateRangeOptions,\n value,\n onChange: (range: unknown) => filter.setValue(range),\n } as never),\n value\n ? h(\n Button,\n {\n size: \"s\",\n color: \"secondary\",\n variant: \"soft\",\n onPress: () => filter.clear(),\n },\n () => texts(\"filters.clearSelection\"),\n )\n : null,\n ]),\n );\n};\n\n/*\n * Flow's `FilterAccordionCheckboxGroup`: outside the checkbox group, so it is\n * not one of the values, and indeterminate while only some of them are on.\n */\nconst renderSelectAllCheckbox = (\n filter: ModalFilter,\n texts: ListTextFormatter,\n): VNodeChild => {\n const isEveryValueActive = filter.isEveryValueActive();\n\n return h(\n Checkbox,\n {\n key: \"select-all\",\n class: listStyles.selectAllCheckbox,\n isSelected: isEveryValueActive,\n isIndeterminate: filter.isActive() && !isEveryValueActive,\n onChange: () =>\n isEveryValueActive ? filter.deselectAll() : filter.selectAll(),\n },\n () =>\n texts(isEveryValueActive ? \"filters.deselectAll\" : \"filters.selectAll\"),\n );\n};\n\nconst renderFilterAccordion = (\n filter: ModalFilter,\n expanded: boolean,\n texts: ListTextFormatter,\n): VNodeChild => {\n const name = filter.name ?? String(filter.property);\n const activeIds = filter.values.filter((v) => v.isActive).map((v) => v.id);\n\n const content = (): VNodeChild =>\n filter.mode === \"one\"\n ? h(Flex, { direction: \"column\", gap: \"m\" }, () => [\n h(\n RadioGroup,\n {\n /*\n * Keyed on the selection, like Flow's: the group is controlled\n * and only remounting makes it pick up a value that changed from\n * outside — a chip removed, a reset.\n */\n key: activeIds[0],\n value: activeIds[0],\n m: [1, 1],\n \"aria-label\": name,\n },\n () =>\n filter.values.map((value) =>\n h(\n Radio,\n {\n key: value.id,\n value: value.id,\n onPress: () => {\n if (!value.isActive) {\n value.toggle();\n }\n },\n },\n () => value.render(),\n ),\n ),\n ),\n activeIds.length > 0\n ? h(\n Button,\n {\n size: \"s\",\n color: \"secondary\",\n variant: \"soft\",\n onPress: () => filter.clear(),\n },\n () => texts(\"filters.clearSelection\"),\n )\n : null,\n ])\n : [\n filter.isSelectAllAvailable\n ? renderSelectAllCheckbox(filter, texts)\n : null,\n h(\n CheckboxGroup,\n { value: activeIds, m: [1, 1], \"aria-label\": name },\n () =>\n filter.values.map((value) =>\n h(\n Checkbox,\n {\n key: value.id,\n value: value.id,\n onPress: () => value.toggle(),\n },\n () => value.render(),\n ),\n ),\n ),\n ];\n\n return accordion(`filter-${name}`, name, expanded, content);\n};\n\nconst renderSortingAccordion = (\n sortings: ModalSorting[],\n expanded: boolean,\n texts: ListTextFormatter,\n): VNodeChild => {\n const active = sortings.find((s) => s.isSorted());\n\n return accordion(\"sorting\", texts(\"sorting\"), expanded, () =>\n h(RadioGroup, { value: active?.id, m: [1, 1] }, () =>\n sortings.map((sorting) =>\n h(\n Radio,\n {\n key: sorting.id,\n value: sorting.id,\n onPress: () => sorting.enable(),\n },\n () =>\n `${sorting.name ?? String(sorting.property)} ${sorting.directionName ?? \"\"}`.trim(),\n ),\n ),\n ),\n );\n};\n\nconst renderViewModeAccordion = (\n list: AnyListModel,\n modes: (\"list\" | \"table\" | \"tiles\")[],\n selected: \"list\" | \"table\" | \"tiles\",\n expanded: boolean,\n texts: ListTextFormatter,\n): VNodeChild =>\n accordion(\"viewMode\", texts(\"settings.viewMode\"), expanded, () =>\n h(RadioGroup, { value: selected, m: [1, 1] }, () =>\n modes.map((mode) =>\n h(\n Radio,\n { key: mode, value: mode, onPress: () => list.viewMode.set(mode) },\n () => texts(`settings.viewMode.${mode}`),\n ),\n ),\n ),\n );\n\n/**\n * Every filter, sorting and view mode in one off-canvas modal.\n *\n * The mobile path to what the header shows as separate menus on desktop — and\n * on desktop too, where a list has secondary filters that the header leaves\n * out. It drives the same model objects, so a value ticked here is the same\n * event as one ticked in a menu.\n */\nexport const AllFiltersModal = defineComponent({\n name: \"ListAllFiltersModal\",\n\n props: {\n isDisabled: { type: Boolean, default: false },\n /** The layouts this list can show, from the header. */\n viewModes: {\n type: Array as () => (\"list\" | \"table\" | \"tiles\")[],\n default: () => [],\n },\n },\n\n setup(props) {\n const list = injectListModel();\n const texts = useListTexts();\n const controller = createOverlayController();\n\n const isInitiallyLoading = watchMobxValue(\n () => list.loaderState.isInitiallyLoading,\n );\n const viewMode = watchMobxValue(() => list.viewMode.value);\n const totalItemCount = watchMobxValue(() => {\n void list.listTable.revision;\n return list.batches.getTotalItemsCount();\n });\n /* Every value below is read off the table's filter and sorting state. */\n const tableRevision = watchMobxValue(() => list.listTable.revision);\n\n return () => {\n void tableRevision.value;\n\n const format = texts.value;\n const filters = list.filters as unknown as ModalFilter[];\n const sortings = list.visibleSorting as unknown as ModalSorting[];\n const modes = props.viewModes;\n\n const accordionCount =\n (modes.length > 1 ? 1 : 0) +\n (sortings.length > 0 ? 1 : 0) +\n filters.length;\n\n if (accordionCount === 0) {\n return null;\n }\n\n /* Two or fewer open by default — more than that is a wall of controls. */\n const expanded = accordionCount <= 2;\n\n const accordions: VNodeChild[] = [\n modes.length > 1\n ? renderViewModeAccordion(\n list,\n modes,\n viewMode.value,\n expanded,\n format,\n )\n : null,\n sortings.length > 0\n ? renderSortingAccordion(sortings, expanded, format)\n : null,\n ...filters.map((filter) =>\n isDateRangeFilter(filter)\n ? renderDateRangeAccordion(\n filter as unknown as ModalDateRangeFilter,\n expanded,\n format,\n )\n : renderFilterAccordion(filter, expanded, format),\n ),\n ];\n\n const hasSecondaryFilters = filters.some(\n (filter) => filter.priority === \"secondary\",\n );\n\n const showCount = format(\n totalItemCount.value === 1 ? \"results.show.one\" : \"results.show.other\",\n { totalItemCount: totalItemCount.value },\n );\n\n return h(ModalTrigger, { controller }, () => [\n h(\n Button,\n {\n class: [\n listStyles.hideOnMobile,\n hasSecondaryFilters ? undefined : listStyles.hideOnDesktop,\n ]\n .filter(Boolean)\n .join(\" \"),\n variant: \"outline\",\n color: \"secondary\",\n isDisabled: props.isDisabled,\n },\n () => [h(Text, null, () => format(\"filters.all\")), h(IconFilter)],\n ),\n\n h(\n Button,\n {\n class: listStyles.hideOnDesktop,\n variant: \"outline\",\n color: \"secondary\",\n \"aria-label\": format(\"filters.all\"),\n },\n () => h(IconFilter),\n ),\n\n h(Modal, { offCanvas: true, controller }, () => [\n h(Heading, null, () => format(\"filters.all\")),\n h(Content, null, () =>\n h(Section, null, () => h(AccordionGroup, null, () => accordions)),\n ),\n h(ActionGroup, null, () => [\n h(Button, { onPress: () => controller.close() }, () =>\n h(Text, null, () =>\n isInitiallyLoading.value\n ? h(SkeletonText, { width: \"16ch\" })\n : showCount,\n ),\n ),\n h(\n Button,\n {\n color: \"secondary\",\n variant: \"soft\",\n onPress: () => {\n list.resetFilters();\n controller.close();\n },\n },\n () => format(\"reset\"),\n ),\n ]),\n ]),\n ]);\n };\n },\n});\n\ncomposition(AllFiltersModal);\n\nexport default AllFiltersModal;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAiEA,IAAM,aACJ,KACA,SACA,UACA,YAEA,EAAE,WAAW;CAAE;CAAK,iBAAiB;AAAS,SAAS,CACrD,EAAE,SAAS,YAAY,OAAO,GAC9B,EAAE,SAAS,MAAM,OAAO,CAC1B,CAAC;AAWH,IAAM,4BACJ,QACA,UACA,UACe;CACf,MAAM,OAAO,OAAO,QAAQ,OAAO,OAAO,QAAQ;CAClD,MAAM,QAAQ,OAAO,SAAS;CAE9B,OAAO,UAAU,UAAU,QAAQ,MAAM,gBACvC,EAAE,MAAM;EAAE,WAAW;EAAU,KAAK;CAAI,SAAS,CAC/C,EAAE,eAAe;EACf,GAAG,OAAO;EACV;EACA,WAAW,UAAmB,OAAO,SAAS,KAAK;CACrD,CAAU,GACV,QACI,EACE,QACA;EACE,MAAM;EACN,OAAO;EACP,SAAS;EACT,eAAe,OAAO,MAAM;CAC9B,SACM,MAAM,wBAAwB,CACtC,IACA,IACN,CAAC,CACH;AACF;AAMA,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,aAAa,YAAY,CACzB,EAAE,QAAQ,EAAE,eAAe,WAAW,MAAM,EAAE,SAC5C,EAAE,MAAM,YACN,mBAAmB,QACf,EAAE,cAAc,EAAE,OAAO,OAAO,CAAC,IACjC,SACN,CACF,GACA,EACE,QACA;MACE,OAAO;MACP,SAAS;MACT,eAAe;OACb,KAAK,aAAa;OAClB,WAAW,MAAM;MACnB;KACF,SACM,OAAO,OAAO,CACtB,CACF,CAAC;IACH,CAAC;GACH,CAAC;EACH;CACF;AACF,CAAC;AAED,YAAY,eAAe"}
|
|
1
|
+
{"version":3,"file":"AllFiltersModal.mjs","names":[],"sources":["../../../../../src/list/AllFiltersModal.ts"],"sourcesContent":["import {\n Accordion,\n AccordionGroup,\n ActionGroup,\n Button,\n Checkbox,\n CheckboxGroup,\n Content,\n Flex,\n Heading,\n Radio,\n RadioGroup,\n RangeCalendar,\n Section,\n SkeletonText,\n Text,\n} from \"@/auto-generated\";\nimport { IconFilter } from \"@/icons\";\nimport { watchMobxValue } from \"@/lib/mobxSelector\";\nimport { Modal } from \"@/overlays/Modal\";\nimport { createOverlayController } from \"@/overlays/overlayController\";\nimport { ModalTrigger } from \"@/overlays/triggers\";\nimport { defineComponent, h, type VNodeChild } from \"vue\";\nimport { isDateRangeFilter } from \"./dateRangeFilter\";\nimport {\n DateTimeRangeFields,\n type DateTimeRangeFilter,\n} from \"./DateTimeRangeFields\";\nimport { injectListModel, type AnyListModel } from \"./listContext\";\nimport { useListTexts, type ListTextFormatter } from \"./locales\";\nimport { listStyles } from \"./styles\";\nimport type { ListRendered } from \"./types\";\nimport { composition } from \"@/lib/composition\";\nimport type { ListDateRange } from \"@mittwald/flow-components-base\";\n\n/*\n * What this modal needs of a filter and a sorting. Not the classes: a list of\n * concrete filters is not assignable to a list of generic ones — a row model\n * sits in a contravariant position deep inside `Column`.\n */\ninterface ModalFilterValue {\n readonly id: string;\n readonly isActive: boolean;\n toggle(): void;\n render(): ListRendered;\n}\n\ninterface ModalFilter {\n readonly name?: string;\n readonly property: unknown;\n readonly mode: string;\n readonly priority: \"primary\" | \"secondary\";\n readonly values: ModalFilterValue[];\n readonly isSelectAllAvailable: boolean;\n isActive(): boolean;\n isEveryValueActive(): boolean;\n selectAll(): void;\n deselectAll(): void;\n clear(): void;\n}\n\ninterface ModalSorting {\n readonly id: string;\n readonly name?: string;\n readonly property: unknown;\n readonly directionName?: string;\n isSorted(): boolean;\n enable(): void;\n}\n\nconst accordion = (\n key: string,\n heading: string,\n expanded: boolean,\n content: () => VNodeChild,\n): VNodeChild =>\n h(Accordion, { key, defaultExpanded: expanded }, () => [\n h(Heading, null, () => heading),\n h(Content, null, content),\n ]);\n\ninterface ModalDateRangeFilter extends DateTimeRangeFilter {\n readonly name?: string;\n readonly property: unknown;\n readonly granularity: \"day\" | \"minute\";\n readonly rangeCalendarProps: Record<string, unknown>;\n}\n\nconst renderDateRangeAccordion = (\n filter: ModalDateRangeFilter,\n expanded: boolean,\n texts: ListTextFormatter,\n): VNodeChild => {\n const name = filter.name ?? String(filter.property);\n const value = filter.getValue();\n\n return accordion(`filter-${name}`, name, expanded, () =>\n h(Flex, { direction: \"column\", gap: \"m\" }, () => [\n filter.granularity === \"minute\"\n ? h(DateTimeRangeFields, { filter })\n : h(RangeCalendar, {\n ...filter.rangeCalendarProps,\n value,\n onChange: (range: ListDateRange) => filter.setValue(range),\n } as never),\n value\n ? h(\n Button,\n {\n size: \"s\",\n color: \"secondary\",\n variant: \"soft\",\n onPress: () => filter.clear(),\n },\n () => texts(\"filters.clearSelection\"),\n )\n : null,\n ]),\n );\n};\n\n/*\n * Flow's `FilterAccordionCheckboxGroup`: outside the checkbox group, so it is\n * not one of the values, and indeterminate while only some of them are on.\n */\nconst renderSelectAllCheckbox = (\n filter: ModalFilter,\n texts: ListTextFormatter,\n): VNodeChild => {\n const isEveryValueActive = filter.isEveryValueActive();\n\n return h(\n Checkbox,\n {\n key: \"select-all\",\n class: listStyles.selectAllCheckbox,\n isSelected: isEveryValueActive,\n isIndeterminate: filter.isActive() && !isEveryValueActive,\n onChange: () =>\n isEveryValueActive ? filter.deselectAll() : filter.selectAll(),\n },\n () =>\n texts(isEveryValueActive ? \"filters.deselectAll\" : \"filters.selectAll\"),\n );\n};\n\nconst renderFilterAccordion = (\n filter: ModalFilter,\n expanded: boolean,\n texts: ListTextFormatter,\n): VNodeChild => {\n const name = filter.name ?? String(filter.property);\n const activeIds = filter.values.filter((v) => v.isActive).map((v) => v.id);\n\n const content = (): VNodeChild =>\n filter.mode === \"one\"\n ? h(Flex, { direction: \"column\", gap: \"m\" }, () => [\n h(\n RadioGroup,\n {\n /*\n * Keyed on the selection, like Flow's: the group is controlled\n * and only remounting makes it pick up a value that changed from\n * outside — a chip removed, a reset.\n */\n key: activeIds[0],\n value: activeIds[0],\n m: [1, 1],\n \"aria-label\": name,\n },\n () =>\n filter.values.map((value) =>\n h(\n Radio,\n {\n key: value.id,\n value: value.id,\n onPress: () => {\n if (!value.isActive) {\n value.toggle();\n }\n },\n },\n () => value.render(),\n ),\n ),\n ),\n activeIds.length > 0\n ? h(\n Button,\n {\n size: \"s\",\n color: \"secondary\",\n variant: \"soft\",\n onPress: () => filter.clear(),\n },\n () => texts(\"filters.clearSelection\"),\n )\n : null,\n ])\n : [\n filter.isSelectAllAvailable\n ? renderSelectAllCheckbox(filter, texts)\n : null,\n h(\n CheckboxGroup,\n { value: activeIds, m: [1, 1], \"aria-label\": name },\n () =>\n filter.values.map((value) =>\n h(\n Checkbox,\n {\n key: value.id,\n value: value.id,\n onPress: () => value.toggle(),\n },\n () => value.render(),\n ),\n ),\n ),\n ];\n\n return accordion(`filter-${name}`, name, expanded, content);\n};\n\nconst renderSortingAccordion = (\n sortings: ModalSorting[],\n expanded: boolean,\n texts: ListTextFormatter,\n): VNodeChild => {\n const active = sortings.find((s) => s.isSorted());\n\n return accordion(\"sorting\", texts(\"sorting\"), expanded, () =>\n h(RadioGroup, { value: active?.id, m: [1, 1] }, () =>\n sortings.map((sorting) =>\n h(\n Radio,\n {\n key: sorting.id,\n value: sorting.id,\n onPress: () => sorting.enable(),\n },\n () =>\n `${sorting.name ?? String(sorting.property)} ${sorting.directionName ?? \"\"}`.trim(),\n ),\n ),\n ),\n );\n};\n\nconst renderViewModeAccordion = (\n list: AnyListModel,\n modes: (\"list\" | \"table\" | \"tiles\")[],\n selected: \"list\" | \"table\" | \"tiles\",\n expanded: boolean,\n texts: ListTextFormatter,\n): VNodeChild =>\n accordion(\"viewMode\", texts(\"settings.viewMode\"), expanded, () =>\n h(RadioGroup, { value: selected, m: [1, 1] }, () =>\n modes.map((mode) =>\n h(\n Radio,\n { key: mode, value: mode, onPress: () => list.viewMode.set(mode) },\n () => texts(`settings.viewMode.${mode}`),\n ),\n ),\n ),\n );\n\n/**\n * Every filter, sorting and view mode in one off-canvas modal.\n *\n * The mobile path to what the header shows as separate menus on desktop — and\n * on desktop too, where a list has secondary filters that the header leaves\n * out. It drives the same model objects, so a value ticked here is the same\n * event as one ticked in a menu.\n */\nexport const AllFiltersModal = defineComponent({\n name: \"ListAllFiltersModal\",\n\n props: {\n isDisabled: { type: Boolean, default: false },\n /** The layouts this list can show, from the header. */\n viewModes: {\n type: Array as () => (\"list\" | \"table\" | \"tiles\")[],\n default: () => [],\n },\n },\n\n setup(props) {\n const list = injectListModel();\n const texts = useListTexts();\n const controller = createOverlayController();\n\n const isInitiallyLoading = watchMobxValue(\n () => list.loaderState.isInitiallyLoading,\n );\n const viewMode = watchMobxValue(() => list.viewMode.value);\n const totalItemCount = watchMobxValue(() => {\n void list.listTable.revision;\n return list.batches.getTotalItemsCount();\n });\n /* Every value below is read off the table's filter and sorting state. */\n const tableRevision = watchMobxValue(() => list.listTable.revision);\n\n return () => {\n void tableRevision.value;\n\n const format = texts.value;\n const filters = list.filters as unknown as ModalFilter[];\n const sortings = list.visibleSorting as unknown as ModalSorting[];\n const modes = props.viewModes;\n\n const accordionCount =\n (modes.length > 1 ? 1 : 0) +\n (sortings.length > 0 ? 1 : 0) +\n filters.length;\n\n if (accordionCount === 0) {\n return null;\n }\n\n /* Two or fewer open by default — more than that is a wall of controls. */\n const expanded = accordionCount <= 2;\n\n const accordions: VNodeChild[] = [\n modes.length > 1\n ? renderViewModeAccordion(\n list,\n modes,\n viewMode.value,\n expanded,\n format,\n )\n : null,\n sortings.length > 0\n ? renderSortingAccordion(sortings, expanded, format)\n : null,\n ...filters.map((filter) =>\n isDateRangeFilter(filter)\n ? renderDateRangeAccordion(\n filter as unknown as ModalDateRangeFilter,\n expanded,\n format,\n )\n : renderFilterAccordion(filter, expanded, format),\n ),\n ];\n\n const hasSecondaryFilters = filters.some(\n (filter) => filter.priority === \"secondary\",\n );\n\n const showCount = format(\n totalItemCount.value === 1 ? \"results.show.one\" : \"results.show.other\",\n { totalItemCount: totalItemCount.value },\n );\n\n return h(ModalTrigger, { controller }, () => [\n h(\n Button,\n {\n class: [\n listStyles.hideOnMobile,\n hasSecondaryFilters ? undefined : listStyles.hideOnDesktop,\n ]\n .filter(Boolean)\n .join(\" \"),\n variant: \"outline\",\n color: \"secondary\",\n isDisabled: props.isDisabled,\n },\n () => [h(Text, null, () => format(\"filters.all\")), h(IconFilter)],\n ),\n\n h(\n Button,\n {\n class: listStyles.hideOnDesktop,\n variant: \"outline\",\n color: \"secondary\",\n \"aria-label\": format(\"filters.all\"),\n },\n () => h(IconFilter),\n ),\n\n h(Modal, { offCanvas: true, controller }, () => [\n h(Heading, null, () => format(\"filters.all\")),\n h(Content, null, () =>\n h(Section, null, () => h(AccordionGroup, null, () => accordions)),\n ),\n h(ActionGroup, null, () => [\n h(Button, { onPress: () => controller.close() }, () =>\n h(Text, null, () =>\n isInitiallyLoading.value\n ? h(SkeletonText, { width: \"16ch\" })\n : showCount,\n ),\n ),\n h(\n Button,\n {\n color: \"secondary\",\n variant: \"soft\",\n onPress: () => {\n list.resetFilters();\n controller.close();\n },\n },\n () => format(\"reset\"),\n ),\n ]),\n ]),\n ]);\n };\n },\n});\n\ncomposition(AllFiltersModal);\n\nexport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BAAsB,QAAQ,MACjC,WAAW,OAAO,aAAa,WAClC;GAEA,MAAM,YAAY,OAChB,eAAe,UAAU,IAAI,qBAAqB,sBAClD,EAAE,gBAAgB,eAAe,MAAM,CACzC;GAEA,OAAO,EAAE,cAAc,EAAE,WAAW,SAAS;IAC3C,EACE,QACA;KACE,OAAO,CACL,WAAW,cACX,sBAAsB,KAAA,IAAY,WAAW,aAC/C,CAAC,CACE,OAAO,OAAO,CAAC,CACf,KAAK,GAAG;KACX,SAAS;KACT,OAAO;KACP,YAAY,MAAM;IACpB,SACM,CAAC,EAAE,MAAM,YAAY,OAAO,aAAa,CAAC,GAAG,EAAE,UAAU,CAAC,CAClE;IAEA,EACE,QACA;KACE,OAAO,WAAW;KAClB,SAAS;KACT,OAAO;KACP,cAAc,OAAO,aAAa;IACpC,SACM,EAAE,UAAU,CACpB;IAEA,EAAE,OAAO;KAAE,WAAW;KAAM;IAAW,SAAS;KAC9C,EAAE,SAAS,YAAY,OAAO,aAAa,CAAC;KAC5C,EAAE,SAAS,YACT,EAAE,SAAS,YAAY,EAAE,gBAAgB,YAAY,UAAU,CAAC,CAClE;KACA,EAAE,aAAa,YAAY,CACzB,EAAE,QAAQ,EAAE,eAAe,WAAW,MAAM,EAAE,SAC5C,EAAE,MAAM,YACN,mBAAmB,QACf,EAAE,cAAc,EAAE,OAAO,OAAO,CAAC,IACjC,SACN,CACF,GACA,EACE,QACA;MACE,OAAO;MACP,SAAS;MACT,eAAe;OACb,KAAK,aAAa;OAClB,WAAW,MAAM;MACnB;KACF,SACM,OAAO,OAAO,CACtB,CACF,CAAC;IACH,CAAC;GACH,CAAC;EACH;CACF;AACF,CAAC;AAED,YAAY,eAAe"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { composition } from "../lib/composition.mjs";
|
|
2
|
+
import { DatePicker } from "../auto-generated/DatePicker.mjs";
|
|
3
|
+
import { Div } from "../auto-generated/Div.mjs";
|
|
4
|
+
import { FieldError } from "../auto-generated/FieldError.mjs";
|
|
5
|
+
import { Label } from "../auto-generated/Label.mjs";
|
|
6
|
+
import { TimeField } from "../auto-generated/TimeField.mjs";
|
|
7
|
+
import watchMobxValue from "../lib/mobxSelector.mjs";
|
|
8
|
+
import { getListDateTimeRangeUpdate, isListDateTimeRangeEndBeforeStart, listDateTimeRangeFieldsFromValue, toListCalendarDate, toListTime } from "../../../components-base/src/list/filter/dateTimeRangeFields.mjs";
|
|
9
|
+
import "../../../components-base/src/index.mjs";
|
|
10
|
+
import { injectListModel } from "./listContext.mjs";
|
|
11
|
+
import { useListTexts } from "./locales.mjs";
|
|
12
|
+
import { className, dateTimeRangeStyles } from "./styles.mjs";
|
|
13
|
+
import { defineComponent, h, shallowRef, useId, watch } from "vue";
|
|
14
|
+
//#region src/list/DateTimeRangeFields.ts
|
|
15
|
+
/**
|
|
16
|
+
* Flow's `DateTimeRangeFields`: start and end, each a date and a time, for a
|
|
17
|
+
* filter with `granularity: "minute"`.
|
|
18
|
+
*
|
|
19
|
+
* Which input is valid and when it applies is `components-base`'s
|
|
20
|
+
* (`getListDateTimeRangeUpdate`), so both bindings apply the same ranges. What
|
|
21
|
+
* is held here is the input itself, which may be invalid for a while — a year
|
|
22
|
+
* typed digit by digit, an end before its start — while the filter keeps the
|
|
23
|
+
* last valid range.
|
|
24
|
+
*/
|
|
25
|
+
var DateTimeRangeFields = defineComponent({
|
|
26
|
+
name: "ListDateTimeRangeFields",
|
|
27
|
+
props: {
|
|
28
|
+
filter: {
|
|
29
|
+
type: Object,
|
|
30
|
+
required: true
|
|
31
|
+
},
|
|
32
|
+
class: {
|
|
33
|
+
type: String,
|
|
34
|
+
default: void 0
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
setup(props) {
|
|
38
|
+
const list = injectListModel();
|
|
39
|
+
const texts = useListTexts();
|
|
40
|
+
const rangeErrorId = useId();
|
|
41
|
+
const tableRevision = watchMobxValue(() => list.listTable.revision);
|
|
42
|
+
let appliedValue = props.filter.getValue();
|
|
43
|
+
const fields = shallowRef(listDateTimeRangeFieldsFromValue(appliedValue));
|
|
44
|
+
watch(tableRevision, () => {
|
|
45
|
+
const value = props.filter.getValue();
|
|
46
|
+
if (value !== appliedValue) {
|
|
47
|
+
appliedValue = value;
|
|
48
|
+
fields.value = listDateTimeRangeFieldsFromValue(value);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
const update = (change) => {
|
|
52
|
+
const next = {
|
|
53
|
+
...fields.value,
|
|
54
|
+
...change
|
|
55
|
+
};
|
|
56
|
+
fields.value = next;
|
|
57
|
+
const newValue = getListDateTimeRangeUpdate(next, appliedValue, props.filter.dateTimeRangeLimits);
|
|
58
|
+
if (newValue === void 0) return;
|
|
59
|
+
appliedValue = newValue;
|
|
60
|
+
if (newValue) props.filter.setValue(newValue);
|
|
61
|
+
else props.filter.clear();
|
|
62
|
+
};
|
|
63
|
+
const label = (key) => () => h(Label, { optional: false }, () => texts.value(key));
|
|
64
|
+
return () => {
|
|
65
|
+
const limits = props.filter.dateTimeRangeLimits;
|
|
66
|
+
const minValue = toListCalendarDate(limits?.minValue);
|
|
67
|
+
const maxValue = toListCalendarDate(limits?.maxValue);
|
|
68
|
+
const hasRangeError = isListDateTimeRangeEndBeforeStart(fields.value);
|
|
69
|
+
const describedBy = hasRangeError ? rangeErrorId : void 0;
|
|
70
|
+
const datePicker = (side, labelKey) => h(DatePicker, {
|
|
71
|
+
value: fields.value[side],
|
|
72
|
+
onChange: (date) => update({ [side]: toListCalendarDate(date) }),
|
|
73
|
+
minValue,
|
|
74
|
+
maxValue,
|
|
75
|
+
"aria-describedby": describedBy,
|
|
76
|
+
isDateUnavailable: limits?.isDateUnavailable
|
|
77
|
+
}, () => [label(labelKey)(), h(FieldError)]);
|
|
78
|
+
const timeField = (side, labelKey) => h(TimeField, {
|
|
79
|
+
value: fields.value[side],
|
|
80
|
+
onChange: (time) => update({ [side]: toListTime(time) }),
|
|
81
|
+
"aria-describedby": describedBy
|
|
82
|
+
}, label(labelKey));
|
|
83
|
+
return h(Div, { class: className(dateTimeRangeStyles.fields, props.class) }, () => [
|
|
84
|
+
datePicker("startDate", "dateRange.startDate"),
|
|
85
|
+
timeField("startTime", "dateRange.startTime"),
|
|
86
|
+
datePicker("endDate", "dateRange.endDate"),
|
|
87
|
+
timeField("endTime", "dateRange.endTime"),
|
|
88
|
+
hasRangeError ? h(FieldError, {
|
|
89
|
+
id: rangeErrorId,
|
|
90
|
+
class: dateTimeRangeStyles.rangeError
|
|
91
|
+
}, () => texts.value("dateRange.endBeforeStart")) : null
|
|
92
|
+
]);
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
composition(DateTimeRangeFields);
|
|
97
|
+
//#endregion
|
|
98
|
+
export { DateTimeRangeFields, DateTimeRangeFields as default };
|
|
99
|
+
|
|
100
|
+
//# sourceMappingURL=DateTimeRangeFields.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DateTimeRangeFields.mjs","names":[],"sources":["../../../../../src/list/DateTimeRangeFields.ts"],"sourcesContent":["import {\n DatePicker,\n Div,\n FieldError,\n Label,\n TimeField,\n} from \"@/auto-generated\";\nimport { watchMobxValue } from \"@/lib/mobxSelector\";\nimport {\n getListDateTimeRangeUpdate,\n isListDateTimeRangeEndBeforeStart,\n listDateTimeRangeFieldsFromValue,\n toListCalendarDate,\n toListTime,\n type ListDateRange,\n type ListDateTimeRangeFields,\n type ListDateTimeRangeLimits,\n} from \"@mittwald/flow-components-base\";\nimport {\n defineComponent,\n h,\n shallowRef,\n useId,\n watch,\n type PropType,\n} from \"vue\";\nimport { composition } from \"@/lib/composition\";\nimport { injectListModel } from \"./listContext\";\nimport { useListTexts, type ListTextKey } from \"./locales\";\nimport { className, dateTimeRangeStyles } from \"./styles\";\n\n/** What the fields need of a date-range filter, and nothing more. */\nexport interface DateTimeRangeFilter {\n readonly dateTimeRangeLimits?: ListDateTimeRangeLimits;\n getValue(): ListDateRange | null;\n setValue(range: ListDateRange): void;\n clear(): void;\n}\n\n/**\n * Flow's `DateTimeRangeFields`: start and end, each a date and a time, for a\n * filter with `granularity: \"minute\"`.\n *\n * Which input is valid and when it applies is `components-base`'s\n * (`getListDateTimeRangeUpdate`), so both bindings apply the same ranges. What\n * is held here is the input itself, which may be invalid for a while — a year\n * typed digit by digit, an end before its start — while the filter keeps the\n * last valid range.\n */\nexport const DateTimeRangeFields = defineComponent({\n name: \"ListDateTimeRangeFields\",\n\n props: {\n filter: {\n type: Object as PropType<DateTimeRangeFilter>,\n required: true,\n },\n class: { type: String, default: undefined },\n },\n\n setup(props) {\n const list = injectListModel();\n const texts = useListTexts();\n const rangeErrorId = useId();\n\n /* The filter's value is table state, read through the table's revision. */\n const tableRevision = watchMobxValue(() => list.listTable.revision);\n\n let appliedValue = props.filter.getValue();\n const fields = shallowRef(listDateTimeRangeFieldsFromValue(appliedValue));\n\n /* A range set elsewhere — the chip, \"Reset filters\" — replaces the input. */\n watch(tableRevision, () => {\n const value = props.filter.getValue();\n if (value !== appliedValue) {\n appliedValue = value;\n fields.value = listDateTimeRangeFieldsFromValue(value);\n }\n });\n\n const update = (change: Partial<ListDateTimeRangeFields>) => {\n const next = { ...fields.value, ...change };\n fields.value = next;\n\n const newValue = getListDateTimeRangeUpdate(\n next,\n appliedValue,\n props.filter.dateTimeRangeLimits,\n );\n if (newValue === undefined) {\n return;\n }\n\n appliedValue = newValue;\n\n if (newValue) {\n props.filter.setValue(newValue);\n } else {\n props.filter.clear();\n }\n };\n\n const label = (key: ListTextKey) => () =>\n h(Label, { optional: false }, () => texts.value(key));\n\n return () => {\n const limits = props.filter.dateTimeRangeLimits;\n const minValue = toListCalendarDate(limits?.minValue);\n const maxValue = toListCalendarDate(limits?.maxValue);\n const hasRangeError = isListDateTimeRangeEndBeforeStart(fields.value);\n const describedBy = hasRangeError ? rangeErrorId : undefined;\n\n const datePicker = (\n side: \"startDate\" | \"endDate\",\n labelKey: ListTextKey,\n ) =>\n h(\n DatePicker,\n {\n value: fields.value[side],\n onChange: (date: Parameters<typeof toListCalendarDate>[0]) =>\n update({ [side]: toListCalendarDate(date) }),\n minValue,\n maxValue,\n \"aria-describedby\": describedBy,\n isDateUnavailable: limits?.isDateUnavailable,\n } as never,\n () => [label(labelKey)(), h(FieldError)],\n );\n\n const timeField = (\n side: \"startTime\" | \"endTime\",\n labelKey: ListTextKey,\n ) =>\n h(\n TimeField,\n {\n value: fields.value[side],\n onChange: (time: Parameters<typeof toListTime>[0]) =>\n update({ [side]: toListTime(time) }),\n \"aria-describedby\": describedBy,\n } as never,\n label(labelKey),\n );\n\n return h(\n Div,\n { class: className(dateTimeRangeStyles.fields, props.class) },\n () => [\n datePicker(\"startDate\", \"dateRange.startDate\"),\n timeField(\"startTime\", \"dateRange.startTime\"),\n datePicker(\"endDate\", \"dateRange.endDate\"),\n timeField(\"endTime\", \"dateRange.endTime\"),\n hasRangeError\n ? h(\n FieldError,\n { id: rangeErrorId, class: dateTimeRangeStyles.rangeError },\n () => texts.value(\"dateRange.endBeforeStart\"),\n )\n : null,\n ],\n );\n };\n },\n});\n\ncomposition(DateTimeRangeFields);\n\nexport default DateTimeRangeFields;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAiDA,IAAa,sBAAsB,gBAAgB;CACjD,MAAM;CAEN,OAAO;EACL,QAAQ;GACN,MAAM;GACN,UAAU;EACZ;EACA,OAAO;GAAE,MAAM;GAAQ,SAAS,KAAA;EAAU;CAC5C;CAEA,MAAM,OAAO;EACX,MAAM,OAAO,gBAAgB;EAC7B,MAAM,QAAQ,aAAa;EAC3B,MAAM,eAAe,MAAM;EAG3B,MAAM,gBAAgB,qBAAqB,KAAK,UAAU,QAAQ;EAElE,IAAI,eAAe,MAAM,OAAO,SAAS;EACzC,MAAM,SAAS,WAAW,iCAAiC,YAAY,CAAC;EAGxE,MAAM,qBAAqB;GACzB,MAAM,QAAQ,MAAM,OAAO,SAAS;GACpC,IAAI,UAAU,cAAc;IAC1B,eAAe;IACf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Ac,OAAO,oBAAoB;IAAW,SACpD,MAAM,MAAM,0BAA0B,CAC9C,IACA;GACN,CACF;EACF;CACF;AACF,CAAC;AAED,YAAY,mBAAmB"}
|
|
@@ -16,16 +16,16 @@ import watchMobxValue from "../lib/mobxSelector.mjs";
|
|
|
16
16
|
import { createOverlayController } from "../overlays/overlayController.mjs";
|
|
17
17
|
import { injectListModel } from "./listContext.mjs";
|
|
18
18
|
import { useListTexts } from "./locales.mjs";
|
|
19
|
-
import { listStyles } from "./styles.mjs";
|
|
19
|
+
import { dateTimeRangeStyles, listStyles } from "./styles.mjs";
|
|
20
20
|
import { Popover } from "../overlays/Popover.mjs";
|
|
21
21
|
import { PopoverTrigger } from "../overlays/triggers.mjs";
|
|
22
22
|
import { isDateRangeFilter } from "./dateRangeFilter.mjs";
|
|
23
23
|
import { ActiveFilters } from "./ActiveFilters.mjs";
|
|
24
|
+
import { DateTimeRangeFields } from "./DateTimeRangeFields.mjs";
|
|
24
25
|
import { AllFiltersModal } from "./AllFiltersModal.mjs";
|
|
25
26
|
import { defineComponent, h, onBeforeUnmount, ref, watch } from "vue";
|
|
26
27
|
//#region src/list/Header.ts
|
|
27
28
|
var autoSubmitTimeout = 500;
|
|
28
|
-
var dateRangeCalendarClass = "flow--list--header--filter-context-menu--calendar";
|
|
29
29
|
var availableViewModes = (shape) => {
|
|
30
30
|
const modes = [];
|
|
31
31
|
if (shape.itemView?.showList) modes.push("list");
|
|
@@ -67,11 +67,12 @@ var renderSortingMenu = (list, texts, isDisabled) => {
|
|
|
67
67
|
}, () => `${sorting.name ?? String(sorting.property)} ${sorting.directionName ?? ""}`.trim())))]);
|
|
68
68
|
};
|
|
69
69
|
/**
|
|
70
|
-
* A date-range filter is a calendar in a popover, not a menu of values
|
|
70
|
+
* A date-range filter is a calendar in a popover, not a menu of values — or,
|
|
71
|
+
* with `granularity: "minute"`, date and time fields.
|
|
71
72
|
*
|
|
72
73
|
* The same shape Flow's React list gives it — the calendar closes the popover
|
|
73
74
|
* when a range is picked, because a range is complete the moment its second end
|
|
74
|
-
* is.
|
|
75
|
+
* is. The fields leave it open: they apply as they are typed.
|
|
75
76
|
*/
|
|
76
77
|
var renderDateRangeFilter = (filter, isDisabled, calendarLabel, controller) => h(PopoverTrigger, {
|
|
77
78
|
key: filter.storageKey,
|
|
@@ -80,9 +81,12 @@ var renderDateRangeFilter = (filter, isDisabled, calendarLabel, controller) => h
|
|
|
80
81
|
placement: "bottom end",
|
|
81
82
|
isDialogContent: true,
|
|
82
83
|
"aria-label": calendarLabel
|
|
83
|
-
}, () => h(
|
|
84
|
-
|
|
85
|
-
class:
|
|
84
|
+
}, () => filter.granularity === "minute" ? h(DateTimeRangeFields, {
|
|
85
|
+
filter,
|
|
86
|
+
class: dateTimeRangeStyles.popover
|
|
87
|
+
}) : h(RangeCalendar, {
|
|
88
|
+
...filter.rangeCalendarProps,
|
|
89
|
+
class: dateTimeRangeStyles.calendar,
|
|
86
90
|
value: filter.getValue(),
|
|
87
91
|
onChange: (range) => {
|
|
88
92
|
filter.setValue(range);
|
|
@@ -185,6 +189,7 @@ var Header = defineComponent({
|
|
|
185
189
|
viewModes: modes
|
|
186
190
|
}),
|
|
187
191
|
list.search ? h(SearchField, {
|
|
192
|
+
key: isDisabled ? "disabled" : "enabled",
|
|
188
193
|
class: listStyles.searchField,
|
|
189
194
|
isDisabled,
|
|
190
195
|
autoFocus: searchShape?.autoFocus,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Header.mjs","names":[],"sources":["../../../../../src/list/Header.ts"],"sourcesContent":["import {\n Button,\n ContextMenu,\n ContextMenuTrigger,\n Div,\n MenuItem,\n RangeCalendar,\n SearchField,\n Text,\n} from \"@/auto-generated\";\nimport { Popover } from \"@/overlays/Popover\";\nimport { PopoverTrigger } from \"@/overlays/triggers\";\nimport {\n IconAscending,\n IconDescending,\n IconFilter,\n IconSorting,\n IconView,\n} from \"@/icons\";\nimport { watchMobxValue } from \"@/lib/mobxSelector\";\nimport {\n createOverlayController,\n type OverlayController,\n} from \"@/overlays/overlayController\";\nimport {\n defineComponent,\n h,\n onBeforeUnmount,\n ref,\n watch,\n type VNodeChild,\n} from \"vue\";\nimport { ActiveFilters } from \"./ActiveFilters\";\nimport { AllFiltersModal } from \"./AllFiltersModal\";\nimport { isDateRangeFilter } from \"./dateRangeFilter\";\nimport { injectListModel, type AnyListModel } from \"./listContext\";\nimport { useListTexts, type ListTextFormatter } from \"./locales\";\nimport type { ListRenderShape } from \"./model\";\nimport { listStyles } from \"./styles\";\nimport type { ListRendered } from \"./types\";\nimport { composition } from \"@/lib/composition\";\n\nconst autoSubmitTimeout = 500;\n\n/* `FilterContextMenus.module.scss`'s `.calendar`. */\nconst dateRangeCalendarClass =\n \"flow--list--header--filter-context-menu--calendar\";\n\n/*\n * What the header needs of a sorting and of a filter, and nothing more.\n *\n * Not the classes themselves: a list of concrete filters is not assignable to\n * a list of generic ones, because a row model sits in a contravariant position\n * deep inside `Column`, so `Table<any>` and `Table<never>` never meet. Reading\n * only the members it renders keeps the header out of that entirely.\n */\ninterface HeaderSorting {\n readonly id: string;\n readonly name?: string;\n readonly property: unknown;\n readonly direction: \"asc\" | \"desc\";\n readonly directionName?: string;\n isSorted(): boolean;\n enable(): void;\n}\n\ninterface HeaderFilterValue {\n readonly id: string;\n readonly isActive: boolean;\n toggle(): void;\n render(): ListRendered;\n}\n\ninterface HeaderDateRangeFilter {\n readonly storageKey: string;\n readonly name?: string;\n readonly property: unknown;\n readonly dateRangeOptions?: Record<string, unknown>;\n getValue(): unknown;\n setValue(range: unknown): void;\n}\n\ninterface HeaderFilter {\n readonly storageKey: string;\n readonly mode: string;\n readonly priority: \"primary\" | \"secondary\";\n readonly name?: string;\n readonly property: unknown;\n readonly values: HeaderFilterValue[];\n readonly isSelectAllAvailable: boolean;\n selectAll(): void;\n setActiveValueIds(ids: Iterable<unknown>): void;\n}\n\n/** Which layouts this list can actually show. */\ntype ViewMode = \"list\" | \"table\" | \"tiles\";\n\nconst availableViewModes = (shape: ListRenderShape<never>): ViewMode[] => {\n const modes: ViewMode[] = [];\n if (shape.itemView?.showList) {\n modes.push(\"list\");\n }\n if (shape.table) {\n modes.push(\"table\");\n }\n if (shape.itemView?.showTiles) {\n modes.push(\"tiles\");\n }\n return modes;\n};\n\nconst outlineButton = (isDisabled: boolean) => ({\n variant: \"outline\" as const,\n color: \"secondary\" as const,\n class: listStyles.hideOnMobile,\n isDisabled,\n});\n\nconst renderViewModeMenu = (\n list: AnyListModel,\n modes: ViewMode[],\n texts: ListTextFormatter,\n isDisabled: boolean,\n selected: ViewMode,\n): VNodeChild => {\n if (modes.length <= 1) {\n return null;\n }\n\n return h(ContextMenuTrigger, null, () => [\n h(\n Button,\n { ...outlineButton(isDisabled), \"aria-label\": texts(\"settings\") },\n () => [\n h(Text, null, () => texts(`settings.viewMode.${selected}`)),\n h(IconView),\n ],\n ),\n h(ContextMenu, { selectionMode: \"single\", selectedKeys: [selected] }, () =>\n modes.map((mode) =>\n h(\n MenuItem,\n { key: mode, id: mode, onAction: () => list.viewMode.set(mode) },\n () => texts(`settings.viewMode.${mode}`),\n ),\n ),\n ),\n ]);\n};\n\nconst renderSortingMenu = (\n list: AnyListModel,\n texts: ListTextFormatter,\n isDisabled: boolean,\n): VNodeChild => {\n const sortings = list.visibleSorting as HeaderSorting[];\n\n if (sortings.length === 0) {\n return null;\n }\n\n const active = sortings.find((s) => s.isSorted());\n\n return h(ContextMenuTrigger, null, () => [\n h(Button, outlineButton(isDisabled), () => [\n h(Text, null, () =>\n active ? (active.name ?? String(active.property)) : texts(\"sorting\"),\n ),\n h(\n active\n ? active.direction === \"asc\"\n ? IconAscending\n : IconDescending\n : IconSorting,\n ),\n ]),\n h(\n ContextMenu,\n {\n selectionMode: \"single\",\n selectedKeys: active ? [active.id] : [],\n },\n () =>\n sortings.map((sorting) =>\n h(\n MenuItem,\n {\n key: sorting.id,\n id: sorting.id,\n onAction: () => sorting.enable(),\n },\n () =>\n `${sorting.name ?? String(sorting.property)} ${sorting.directionName ?? \"\"}`.trim(),\n ),\n ),\n ),\n ]);\n};\n\n/**\n * A date-range filter is a calendar in a popover, not a menu of values.\n *\n * The same shape Flow's React list gives it — the calendar closes the popover\n * when a range is picked, because a range is complete the moment its second end\n * is.\n */\nconst renderDateRangeFilter = (\n filter: HeaderDateRangeFilter,\n isDisabled: boolean,\n calendarLabel: string,\n controller: OverlayController,\n): VNodeChild =>\n h(PopoverTrigger, { key: filter.storageKey, controller }, () => [\n h(Button, outlineButton(isDisabled), () => [\n h(Text, null, () => filter.name ?? String(filter.property)),\n h(IconFilter),\n ]),\n h(\n Popover,\n {\n placement: \"bottom end\",\n isDialogContent: true,\n \"aria-label\": calendarLabel,\n },\n () =>\n /*\n * Cast at the call, because the options are whatever the consumer\n * handed the filter: an open record does not match a typed component's\n * props, and TypeScript then resolves `h` to its instance overload.\n */\n h(RangeCalendar, {\n ...filter.dateRangeOptions,\n class: dateRangeCalendarClass,\n value: filter.getValue(),\n onChange: (range: unknown) => {\n filter.setValue(range);\n controller.close();\n },\n } as never),\n ),\n ]);\n\nconst renderFilterMenu = (\n filter: HeaderFilter,\n isDisabled: boolean,\n): VNodeChild => {\n const selectionMode = filter.mode === \"one\" ? \"single\" : \"multiple\";\n const values = filter.values;\n\n return h(ContextMenuTrigger, { key: filter.storageKey }, () => [\n h(Button, outlineButton(isDisabled), () => [\n h(Text, null, () => filter.name ?? String(filter.property)),\n h(IconFilter),\n ]),\n h(\n ContextMenu,\n {\n selectionMode,\n selectedKeys: values.filter((v) => v.isActive).map((v) => v.id),\n /*\n * Flow's: a multiple-choice menu reports its whole selection, and the\n * \"Select all\" entry the host adds reports it as `\"all\"`.\n */\n onSelectionChange:\n selectionMode === \"multiple\"\n ? (keys: unknown) =>\n keys === \"all\"\n ? filter.selectAll()\n : filter.setActiveValueIds(keys as Iterable<unknown>)\n : undefined,\n showSelectAll: filter.isSelectAllAvailable,\n },\n () =>\n values.map((value) =>\n h(\n MenuItem,\n {\n key: value.id,\n id: value.id,\n /* A multiple choice goes through `onSelectionChange`. */\n onAction: () => {\n if (selectionMode === \"single\" && !value.isActive) {\n value.toggle();\n }\n },\n },\n () => value.render(),\n ),\n ),\n ),\n ]);\n};\n\n/**\n * The list's controls: layout, sorting, filters, search — plus the app's own\n * `ActionGroup`, which the `List` hands over as the `actions` slot.\n *\n * Each one is a remote element the host materialises — a context menu trigger\n * with a button and a menu — and what they act on is the shared model, so a\n * filter behaves here exactly as it does in React.\n */\nexport const Header = defineComponent({\n name: \"ListHeader\",\n\n setup(_props, { slots }) {\n const list = injectListModel();\n const texts = useListTexts();\n\n const isEmpty = watchMobxValue(() => list.isEmpty);\n const isInitiallyLoading = watchMobxValue(\n () => list.loaderState.isInitiallyLoading,\n );\n const emptyViewType = watchMobxValue(() => list.getEmptyViewType());\n const viewMode = watchMobxValue(() => list.viewMode.value);\n /* Filters and sortings read the table, so they follow its revision. */\n const tableRevision = watchMobxValue(() => list.listTable.revision);\n const renderShape = watchMobxValue(() => list.renderShape);\n\n /*\n * One controller per date filter, kept for as long as the header is.\n * Created in the render it would be a new one every time — and a range\n * takes two clicks, so the popover would forget the first between them.\n */\n const dateControllers = new Map<string, OverlayController>();\n const dateController = (key: string): OverlayController => {\n const existing = dateControllers.get(key);\n if (existing) {\n return existing;\n }\n const created = createOverlayController();\n dateControllers.set(key, created);\n return created;\n };\n\n /*\n * Flow's `DefaultSearchFieldRender`: the field holds what is typed, and a\n * search is submitted after a pause — or, with `autoSubmit={false}`, on\n * Enter. Escape and the clear button clear at once.\n */\n const searchShape = list.shape.search;\n const autoSubmit = searchShape?.autoSubmit !== false;\n const searchInput = ref(list.search?.value ?? \"\");\n let previousSearch = \"\";\n let submitTimeout: ReturnType<typeof setTimeout> | undefined;\n\n const submitSearch = () => {\n if (searchInput.value.trim() === \"\") {\n list.search?.setValue(undefined);\n } else if (previousSearch !== searchInput.value) {\n previousSearch = searchInput.value;\n list.search?.setValue(searchInput.value);\n }\n };\n\n const clearSearch = () => {\n clearTimeout(submitTimeout);\n list.search?.setValue(undefined);\n searchInput.value = \"\";\n };\n\n watch(searchInput, () => {\n clearTimeout(submitTimeout);\n if (autoSubmit) {\n submitTimeout = setTimeout(submitSearch, autoSubmitTimeout);\n }\n });\n\n /* A search set from outside the field — a reset — shows in it. */\n const searchValue = watchMobxValue(() => {\n void list.listTable.revision;\n return list.search?.value;\n });\n watch(searchValue, (value) => {\n searchInput.value = value ?? \"\";\n });\n\n const onSearchKeyUp = (event: { key?: string } | undefined) => {\n if (event?.key === \"Enter\" && !autoSubmit) {\n submitSearch();\n } else if (event?.key === \"Escape\") {\n clearSearch();\n }\n };\n\n onBeforeUnmount(() => clearTimeout(submitTimeout));\n\n return () => {\n void tableRevision.value;\n\n const noItemsAvailable = isEmpty.value && emptyViewType.value === \"list\";\n const isDisabled = isInitiallyLoading.value || noItemsAvailable;\n const modes = availableViewModes(renderShape.value);\n\n const actions = slots.actions?.();\n\n /*\n * The header is rendered even with nothing in it, because Flow's is: it\n * holds the app's own `ActionGroup`, and a list that gained one would\n * otherwise change the DOM around it.\n *\n * Asked of the model rather than of what the options rendered — the\n * all-filters modal decides for itself whether it has anything to show.\n */\n const hasOptions =\n list.filters.length > 0 ||\n list.visibleSorting.length > 0 ||\n !!list.search ||\n modes.length > 1;\n\n /*\n * Nothing to show yet and nothing to configure it with: Flow hides the\n * header rather than dropping it, so what an app put in it keeps its\n * state across the switch to and from the empty view.\n */\n if (noItemsAvailable) {\n return h(\n Div,\n { class: listStyles.hideVisuallyActions, \"aria-hidden\": true },\n /*\n * Same nesting and same classes as the branch below, which is what\n * Flow's comment on this branch asks for — the tunnel's content has\n * to survive the switch. React arrives at the inner class by reusing\n * the element rather than by setting it: a `className` that goes from\n * set to undefined never reaches the host, so the previous one stays.\n *\n * `[actions, null]`, not `actions`: Vue wraps a nested array in a\n * fragment, so only the same array shape keeps the actions at the\n * same position in the same fragment — anything else remounts them,\n * and a modal open from the header closes.\n */\n () =>\n h(Div, { class: listStyles.headerContent }, () => [actions, null]),\n );\n }\n\n const options: VNodeChild[] = [\n renderViewModeMenu(\n list,\n modes,\n texts.value,\n isDisabled,\n viewMode.value,\n ),\n renderSortingMenu(list, texts.value, isDisabled),\n /*\n * Primary only. A secondary filter is reachable through the\n * all-filters modal, which is the whole reason that modal shows on\n * desktop at all.\n */\n ...(list.filters as HeaderFilter[])\n .filter((filter) => filter.priority === \"primary\")\n .map((filter) =>\n isDateRangeFilter(filter)\n ? renderDateRangeFilter(\n filter as unknown as HeaderDateRangeFilter,\n isDisabled,\n texts.value(\"dateRange\"),\n dateController(filter.storageKey),\n )\n : renderFilterMenu(filter, isDisabled),\n ),\n h(AllFiltersModal, { isDisabled, viewModes: modes }),\n list.search\n ? h(SearchField, {\n class: listStyles.searchField,\n isDisabled,\n autoFocus: searchShape?.autoFocus,\n value: searchInput.value,\n onChange: (value: string) => {\n searchInput.value = value;\n },\n onKeyUp: onSearchKeyUp,\n onClear: clearSearch,\n })\n : null,\n ];\n\n return h(\n Div,\n {\n class: [\n listStyles.header,\n list.search ? listStyles.headerWithSearch : undefined,\n ]\n .filter(Boolean)\n .join(\" \"),\n },\n () => [\n h(Div, { class: listStyles.headerContent }, () => [\n actions,\n hasOptions\n ? h(Div, { class: listStyles.headerOptions }, () => options)\n : null,\n ]),\n h(ActiveFilters, { isDisabled }),\n ],\n );\n };\n },\n});\n\ncomposition(Header);\n\nexport default Header;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,IAAM,oBAAoB;AAG1B,IAAM,yBACJ;AAmDF,IAAM,sBAAsB,UAA8C;CACxE,MAAM,QAAoB,CAAC;CAC3B,IAAI,MAAM,UAAU,UAClB,MAAM,KAAK,MAAM;CAEnB,IAAI,MAAM,OACR,MAAM,KAAK,OAAO;CAEpB,IAAI,MAAM,UAAU,WAClB,MAAM,KAAK,OAAO;CAEpB,OAAO;AACT;AAEA,IAAM,iBAAiB,gBAAyB;CAC9C,SAAS;CACT,OAAO;CACP,OA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ACI,EAAE,KAAK,EAAE,OAAO,WAAW,cAAc,SAAS,OAAO,IACzD,IACN,CAAC,GACD,EAAE,eAAe,EAAE,WAAW,CAAC,CACjC,CACF;EACF;CACF;AACF,CAAC;AAED,YAAY,MAAM"}
|
|
1
|
+
{"version":3,"file":"Header.mjs","names":[],"sources":["../../../../../src/list/Header.ts"],"sourcesContent":["import {\n Button,\n ContextMenu,\n ContextMenuTrigger,\n Div,\n MenuItem,\n RangeCalendar,\n SearchField,\n Text,\n} from \"@/auto-generated\";\nimport { Popover } from \"@/overlays/Popover\";\nimport { PopoverTrigger } from \"@/overlays/triggers\";\nimport {\n IconAscending,\n IconDescending,\n IconFilter,\n IconSorting,\n IconView,\n} from \"@/icons\";\nimport { watchMobxValue } from \"@/lib/mobxSelector\";\nimport {\n createOverlayController,\n type OverlayController,\n} from \"@/overlays/overlayController\";\nimport {\n defineComponent,\n h,\n onBeforeUnmount,\n ref,\n watch,\n type VNodeChild,\n} from \"vue\";\nimport { ActiveFilters } from \"./ActiveFilters\";\nimport { AllFiltersModal } from \"./AllFiltersModal\";\nimport { isDateRangeFilter } from \"./dateRangeFilter\";\nimport {\n DateTimeRangeFields,\n type DateTimeRangeFilter,\n} from \"./DateTimeRangeFields\";\nimport { injectListModel, type AnyListModel } from \"./listContext\";\nimport { useListTexts, type ListTextFormatter } from \"./locales\";\nimport type { ListRenderShape } from \"./model\";\nimport { dateTimeRangeStyles, listStyles } from \"./styles\";\nimport type { ListRendered } from \"./types\";\nimport { composition } from \"@/lib/composition\";\nimport type { ListDateRange } from \"@mittwald/flow-components-base\";\n\nconst autoSubmitTimeout = 500;\n\n/*\n * What the header needs of a sorting and of a filter, and nothing more.\n *\n * Not the classes themselves: a list of concrete filters is not assignable to\n * a list of generic ones, because a row model sits in a contravariant position\n * deep inside `Column`, so `Table<any>` and `Table<never>` never meet. Reading\n * only the members it renders keeps the header out of that entirely.\n */\ninterface HeaderSorting {\n readonly id: string;\n readonly name?: string;\n readonly property: unknown;\n readonly direction: \"asc\" | \"desc\";\n readonly directionName?: string;\n isSorted(): boolean;\n enable(): void;\n}\n\ninterface HeaderFilterValue {\n readonly id: string;\n readonly isActive: boolean;\n toggle(): void;\n render(): ListRendered;\n}\n\ninterface HeaderDateRangeFilter extends DateTimeRangeFilter {\n readonly storageKey: string;\n readonly name?: string;\n readonly property: unknown;\n readonly granularity: \"day\" | \"minute\";\n readonly rangeCalendarProps: Record<string, unknown>;\n}\n\ninterface HeaderFilter {\n readonly storageKey: string;\n readonly mode: string;\n readonly priority: \"primary\" | \"secondary\";\n readonly name?: string;\n readonly property: unknown;\n readonly values: HeaderFilterValue[];\n readonly isSelectAllAvailable: boolean;\n selectAll(): void;\n setActiveValueIds(ids: Iterable<unknown>): void;\n}\n\n/** Which layouts this list can actually show. */\ntype ViewMode = \"list\" | \"table\" | \"tiles\";\n\nconst availableViewModes = (shape: ListRenderShape<never>): ViewMode[] => {\n const modes: ViewMode[] = [];\n if (shape.itemView?.showList) {\n modes.push(\"list\");\n }\n if (shape.table) {\n modes.push(\"table\");\n }\n if (shape.itemView?.showTiles) {\n modes.push(\"tiles\");\n }\n return modes;\n};\n\nconst outlineButton = (isDisabled: boolean) => ({\n variant: \"outline\" as const,\n color: \"secondary\" as const,\n class: listStyles.hideOnMobile,\n isDisabled,\n});\n\nconst renderViewModeMenu = (\n list: AnyListModel,\n modes: ViewMode[],\n texts: ListTextFormatter,\n isDisabled: boolean,\n selected: ViewMode,\n): VNodeChild => {\n if (modes.length <= 1) {\n return null;\n }\n\n return h(ContextMenuTrigger, null, () => [\n h(\n Button,\n { ...outlineButton(isDisabled), \"aria-label\": texts(\"settings\") },\n () => [\n h(Text, null, () => texts(`settings.viewMode.${selected}`)),\n h(IconView),\n ],\n ),\n h(ContextMenu, { selectionMode: \"single\", selectedKeys: [selected] }, () =>\n modes.map((mode) =>\n h(\n MenuItem,\n { key: mode, id: mode, onAction: () => list.viewMode.set(mode) },\n () => texts(`settings.viewMode.${mode}`),\n ),\n ),\n ),\n ]);\n};\n\nconst renderSortingMenu = (\n list: AnyListModel,\n texts: ListTextFormatter,\n isDisabled: boolean,\n): VNodeChild => {\n const sortings = list.visibleSorting as HeaderSorting[];\n\n if (sortings.length === 0) {\n return null;\n }\n\n const active = sortings.find((s) => s.isSorted());\n\n return h(ContextMenuTrigger, null, () => [\n h(Button, outlineButton(isDisabled), () => [\n h(Text, null, () =>\n active ? (active.name ?? String(active.property)) : texts(\"sorting\"),\n ),\n h(\n active\n ? active.direction === \"asc\"\n ? IconAscending\n : IconDescending\n : IconSorting,\n ),\n ]),\n h(\n ContextMenu,\n {\n selectionMode: \"single\",\n selectedKeys: active ? [active.id] : [],\n },\n () =>\n sortings.map((sorting) =>\n h(\n MenuItem,\n {\n key: sorting.id,\n id: sorting.id,\n onAction: () => sorting.enable(),\n },\n () =>\n `${sorting.name ?? String(sorting.property)} ${sorting.directionName ?? \"\"}`.trim(),\n ),\n ),\n ),\n ]);\n};\n\n/**\n * A date-range filter is a calendar in a popover, not a menu of values — or,\n * with `granularity: \"minute\"`, date and time fields.\n *\n * The same shape Flow's React list gives it — the calendar closes the popover\n * when a range is picked, because a range is complete the moment its second end\n * is. The fields leave it open: they apply as they are typed.\n */\nconst renderDateRangeFilter = (\n filter: HeaderDateRangeFilter,\n isDisabled: boolean,\n calendarLabel: string,\n controller: OverlayController,\n): VNodeChild =>\n h(PopoverTrigger, { key: filter.storageKey, controller }, () => [\n h(Button, outlineButton(isDisabled), () => [\n h(Text, null, () => filter.name ?? String(filter.property)),\n h(IconFilter),\n ]),\n h(\n Popover,\n {\n placement: \"bottom end\",\n isDialogContent: true,\n \"aria-label\": calendarLabel,\n },\n () =>\n filter.granularity === \"minute\"\n ? h(DateTimeRangeFields, {\n filter,\n class: dateTimeRangeStyles.popover,\n })\n : /*\n * Cast at the call, because the options are whatever the consumer\n * handed the filter: an open record does not match a typed\n * component's props, and TypeScript then resolves `h` to its\n * instance overload.\n */\n h(RangeCalendar, {\n ...filter.rangeCalendarProps,\n class: dateTimeRangeStyles.calendar,\n value: filter.getValue(),\n onChange: (range: ListDateRange) => {\n filter.setValue(range);\n controller.close();\n },\n } as never),\n ),\n ]);\n\nconst renderFilterMenu = (\n filter: HeaderFilter,\n isDisabled: boolean,\n): VNodeChild => {\n const selectionMode = filter.mode === \"one\" ? \"single\" : \"multiple\";\n const values = filter.values;\n\n return h(ContextMenuTrigger, { key: filter.storageKey }, () => [\n h(Button, outlineButton(isDisabled), () => [\n h(Text, null, () => filter.name ?? String(filter.property)),\n h(IconFilter),\n ]),\n h(\n ContextMenu,\n {\n selectionMode,\n selectedKeys: values.filter((v) => v.isActive).map((v) => v.id),\n /*\n * Flow's: a multiple-choice menu reports its whole selection, and the\n * \"Select all\" entry the host adds reports it as `\"all\"`.\n */\n onSelectionChange:\n selectionMode === \"multiple\"\n ? (keys: unknown) =>\n keys === \"all\"\n ? filter.selectAll()\n : filter.setActiveValueIds(keys as Iterable<unknown>)\n : undefined,\n showSelectAll: filter.isSelectAllAvailable,\n },\n () =>\n values.map((value) =>\n h(\n MenuItem,\n {\n key: value.id,\n id: value.id,\n /* A multiple choice goes through `onSelectionChange`. */\n onAction: () => {\n if (selectionMode === \"single\" && !value.isActive) {\n value.toggle();\n }\n },\n },\n () => value.render(),\n ),\n ),\n ),\n ]);\n};\n\n/**\n * The list's controls: layout, sorting, filters, search — plus the app's own\n * `ActionGroup`, which the `List` hands over as the `actions` slot.\n *\n * Each one is a remote element the host materialises — a context menu trigger\n * with a button and a menu — and what they act on is the shared model, so a\n * filter behaves here exactly as it does in React.\n */\nexport const Header = defineComponent({\n name: \"ListHeader\",\n\n setup(_props, { slots }) {\n const list = injectListModel();\n const texts = useListTexts();\n\n const isEmpty = watchMobxValue(() => list.isEmpty);\n const isInitiallyLoading = watchMobxValue(\n () => list.loaderState.isInitiallyLoading,\n );\n const emptyViewType = watchMobxValue(() => list.getEmptyViewType());\n const viewMode = watchMobxValue(() => list.viewMode.value);\n /* Filters and sortings read the table, so they follow its revision. */\n const tableRevision = watchMobxValue(() => list.listTable.revision);\n const renderShape = watchMobxValue(() => list.renderShape);\n\n /*\n * One controller per date filter, kept for as long as the header is.\n * Created in the render it would be a new one every time — and a range\n * takes two clicks, so the popover would forget the first between them.\n */\n const dateControllers = new Map<string, OverlayController>();\n const dateController = (key: string): OverlayController => {\n const existing = dateControllers.get(key);\n if (existing) {\n return existing;\n }\n const created = createOverlayController();\n dateControllers.set(key, created);\n return created;\n };\n\n /*\n * Flow's `DefaultSearchFieldRender`: the field holds what is typed, and a\n * search is submitted after a pause — or, with `autoSubmit={false}`, on\n * Enter. Escape and the clear button clear at once.\n */\n const searchShape = list.shape.search;\n const autoSubmit = searchShape?.autoSubmit !== false;\n const searchInput = ref(list.search?.value ?? \"\");\n let previousSearch = \"\";\n let submitTimeout: ReturnType<typeof setTimeout> | undefined;\n\n const submitSearch = () => {\n if (searchInput.value.trim() === \"\") {\n list.search?.setValue(undefined);\n } else if (previousSearch !== searchInput.value) {\n previousSearch = searchInput.value;\n list.search?.setValue(searchInput.value);\n }\n };\n\n const clearSearch = () => {\n clearTimeout(submitTimeout);\n list.search?.setValue(undefined);\n searchInput.value = \"\";\n };\n\n watch(searchInput, () => {\n clearTimeout(submitTimeout);\n if (autoSubmit) {\n submitTimeout = setTimeout(submitSearch, autoSubmitTimeout);\n }\n });\n\n /* A search set from outside the field — a reset — shows in it. */\n const searchValue = watchMobxValue(() => {\n void list.listTable.revision;\n return list.search?.value;\n });\n watch(searchValue, (value) => {\n searchInput.value = value ?? \"\";\n });\n\n const onSearchKeyUp = (event: { key?: string } | undefined) => {\n if (event?.key === \"Enter\" && !autoSubmit) {\n submitSearch();\n } else if (event?.key === \"Escape\") {\n clearSearch();\n }\n };\n\n onBeforeUnmount(() => clearTimeout(submitTimeout));\n\n return () => {\n void tableRevision.value;\n\n const noItemsAvailable = isEmpty.value && emptyViewType.value === \"list\";\n const isDisabled = isInitiallyLoading.value || noItemsAvailable;\n const modes = availableViewModes(renderShape.value);\n\n const actions = slots.actions?.();\n\n /*\n * The header is rendered even with nothing in it, because Flow's is: it\n * holds the app's own `ActionGroup`, and a list that gained one would\n * otherwise change the DOM around it.\n *\n * Asked of the model rather than of what the options rendered — the\n * all-filters modal decides for itself whether it has anything to show.\n */\n const hasOptions =\n list.filters.length > 0 ||\n list.visibleSorting.length > 0 ||\n !!list.search ||\n modes.length > 1;\n\n /*\n * Nothing to show yet and nothing to configure it with: Flow hides the\n * header rather than dropping it, so what an app put in it keeps its\n * state across the switch to and from the empty view.\n */\n if (noItemsAvailable) {\n return h(\n Div,\n { class: listStyles.hideVisuallyActions, \"aria-hidden\": true },\n /*\n * Same nesting and same classes as the branch below, which is what\n * Flow's comment on this branch asks for — the tunnel's content has\n * to survive the switch. React arrives at the inner class by reusing\n * the element rather than by setting it: a `className` that goes from\n * set to undefined never reaches the host, so the previous one stays.\n *\n * `[actions, null]`, not `actions`: Vue wraps a nested array in a\n * fragment, so only the same array shape keeps the actions at the\n * same position in the same fragment — anything else remounts them,\n * and a modal open from the header closes.\n */\n () =>\n h(Div, { class: listStyles.headerContent }, () => [actions, null]),\n );\n }\n\n const options: VNodeChild[] = [\n renderViewModeMenu(\n list,\n modes,\n texts.value,\n isDisabled,\n viewMode.value,\n ),\n renderSortingMenu(list, texts.value, isDisabled),\n /*\n * Primary only. A secondary filter is reachable through the\n * all-filters modal, which is the whole reason that modal shows on\n * desktop at all.\n */\n ...(list.filters as HeaderFilter[])\n .filter((filter) => filter.priority === \"primary\")\n .map((filter) =>\n isDateRangeFilter(filter)\n ? renderDateRangeFilter(\n filter as unknown as HeaderDateRangeFilter,\n isDisabled,\n texts.value(\"dateRange\"),\n dateController(filter.storageKey),\n )\n : renderFilterMenu(filter, isDisabled),\n ),\n h(AllFiltersModal, { isDisabled, viewModes: modes }),\n list.search\n ? h(SearchField, {\n /* autoFocus acts on mount only — remount once enabled. */\n key: isDisabled ? \"disabled\" : \"enabled\",\n class: listStyles.searchField,\n isDisabled,\n autoFocus: searchShape?.autoFocus,\n value: searchInput.value,\n onChange: (value: string) => {\n searchInput.value = value;\n },\n onKeyUp: onSearchKeyUp,\n onClear: clearSearch,\n })\n : null,\n ];\n\n return h(\n Div,\n {\n class: [\n listStyles.header,\n list.search ? listStyles.headerWithSearch : undefined,\n ]\n .filter(Boolean)\n .join(\" \"),\n },\n () => [\n h(Div, { class: listStyles.headerContent }, () => [\n actions,\n hasOptions\n ? h(Div, { class: listStyles.headerOptions }, () => options)\n : null,\n ]),\n h(ActiveFilters, { isDisabled }),\n ],\n );\n };\n },\n});\n\ncomposition(Header);\n\nexport default Header;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CA,IAAM,oBAAoB;AAkD1B,IAAM,sBAAsB,UAA8C;CACxE,MAAM,QAAoB,CAAC;CAC3B,IAAI,MAAM,UAAU,UAClB,MAAM,KAAK,MAAM;CAEnB,IAAI,MAAM,OACR,MAAM,KAAK,OAAO;CAEpB,IAAI,MAAM,UAAU,WAClB,MAAM,KAAK,OAAO;CAEpB,OAAO;AACT;AAEA,IAAM,iBAAiB,gBAAyB;CAC9C,SAAS;CACT,OAAO;CACP,OAAO,WAAW;CAClB;AACF;AAEA,IAAM,sBACJ,MACA,OACA,OACA,YACA,aACe;CACf,IAAI,MAAM,UAAU,GAClB,OAAO;CAGT,OAAO,EAAE,oBAAoB,YAAY,CACvC,EACE,QACA;EAAE,GAAG,cAAc,UAAU;EAAG,cAAc,MAAM,UAAU;CAAE,SAC1D,CACJ,EAAE,MAAM,YAAY,MAAM,qBAAqB,UAAU,CAAC,GAC1D,EAAE,QAAQ,CACZ,CACF,GACA,EAAE,aAAa;EAAE,eAAe;EAAU,cAAc,CAAC,QAAQ;CAAE,SACjE,MAAM,KAAK,SACT,EACE,UACA;EAAE,KAAK;EAAM,IAAI;EAAM,gBAAgB,KAAK,SAAS,IAAI,IAAI;CAAE,SACzD,MAAM,qBAAqB,MAAM,CACzC,CACF,CACF,CACF,CAAC;AACH;AAEA,IAAM,qBAC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AAE,KAAK,EAAE,OAAO,WAAW,cAAc,SAAS,CAAC,SAAS,IAAI,CAAC,CACrE;GAGF,MAAM,UAAwB;IAC5B,mBACE,MACA,OACA,MAAM,OACN,YACA,SAAS,KACX;IACA,kBAAkB,MAAM,MAAM,OAAO,UAAU;IAM/C,GAAI,KAAK,QACN,QAAQ,WAAW,OAAO,aAAa,SAAS,CAAC,CACjD,KAAK,WACJ,kBAAkB,MAAM,IACpB,sBACE,QACA,YACA,MAAM,MAAM,WAAW,GACvB,eAAe,OAAO,UAAU,CAClC,IACA,iBAAiB,QAAQ,UAAU,CACzC;IACF,EAAE,iBAAiB;KAAE;KAAY,WAAW;IAAM,CAAC;IACnD,KAAK,SACD,EAAE,aAAa;KAEb,KAAK,aAAa,aAAa;KAC/B,OAAO,WAAW;KAClB;KACA,WAAW,aAAa;KACxB,OAAO,YAAY;KACnB,WAAW,UAAkB;MAC3B,YAAY,QAAQ;KACtB;KACA,SAAS;KACT,SAAS;IACX,CAAC,IACD;GACN;GAEA,OAAO,EACL,KACA,EACE,OAAO,CACL,WAAW,QACX,KAAK,SAAS,WAAW,mBAAmB,KAAA,CAC9C,CAAC,CACE,OAAO,OAAO,CAAC,CACf,KAAK,GAAG,EACb,SACM,CACJ,EAAE,KAAK,EAAE,OAAO,WAAW,cAAc,SAAS,CAChD,SACA,aACI,EAAE,KAAK,EAAE,OAAO,WAAW,cAAc,SAAS,OAAO,IACzD,IACN,CAAC,GACD,EAAE,eAAe,EAAE,WAAW,CAAC,CACjC,CACF;EACF;CACF;AACF,CAAC;AAED,YAAY,MAAM"}
|
|
@@ -2,11 +2,11 @@ import { ListDateRangeFilter } from "../../../components-base/src/list/filter/Li
|
|
|
2
2
|
import "../../../components-base/src/index.mjs";
|
|
3
3
|
//#region src/list/dateRangeFilter.ts
|
|
4
4
|
/**
|
|
5
|
-
* A date-range filter, with the options its
|
|
5
|
+
* A date-range filter, with the options its fields take.
|
|
6
6
|
*
|
|
7
7
|
* The column, the comparison and the stored value are the shared
|
|
8
8
|
* `ListDateRangeFilter`, so a Vue list and a React list filter the same dates
|
|
9
|
-
* the same way. What a binding adds is only what its
|
|
9
|
+
* the same way. What a binding adds is only what its fields accept.
|
|
10
10
|
*/
|
|
11
11
|
var DateRangeFilter = class extends ListDateRangeFilter {
|
|
12
12
|
/** Handed to the `RangeCalendar` — a minimum date, unavailable days, … */
|
|
@@ -15,13 +15,21 @@ var DateRangeFilter = class extends ListDateRangeFilter {
|
|
|
15
15
|
super(context, shape);
|
|
16
16
|
this.dateRangeOptions = shape.dateRangeOptions;
|
|
17
17
|
}
|
|
18
|
+
get granularity() {
|
|
19
|
+
return this.dateRangeOptions?.granularity === "minute" ? "minute" : "day";
|
|
20
|
+
}
|
|
21
|
+
get rangeCalendarProps() {
|
|
22
|
+
if (this.granularity === "minute") return {};
|
|
23
|
+
const { granularity, ...props } = this.dateRangeOptions ?? {};
|
|
24
|
+
return props;
|
|
25
|
+
}
|
|
26
|
+
get dateTimeRangeLimits() {
|
|
27
|
+
return this.granularity === "minute" ? this.dateRangeOptions : void 0;
|
|
28
|
+
}
|
|
18
29
|
};
|
|
19
30
|
/** Whether a filter is one of these, without reaching for the class. */
|
|
20
31
|
var isDateRangeFilter = (filter) => filter.mode === "dateRange";
|
|
21
|
-
/** `01/03/2024`, the way `Intl` writes it for the host's locale. */
|
|
22
|
-
var formatDate = (date) => new Date(date.year, date.month - 1, date.day).toLocaleDateString();
|
|
23
|
-
var formatDateRange = (range) => [range.start, range.end].map((date) => date ? formatDate(date) : "").join(" - ");
|
|
24
32
|
//#endregion
|
|
25
|
-
export { DateRangeFilter,
|
|
33
|
+
export { DateRangeFilter, isDateRangeFilter };
|
|
26
34
|
|
|
27
35
|
//# sourceMappingURL=dateRangeFilter.mjs.map
|