@mittwald/flow-remote-vue-components 1.6.0-next.5 → 1.6.0-next.50

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.
Files changed (56) hide show
  1. package/README.md +2 -2
  2. package/dist/js/components-base/src/index.mjs +5 -2
  3. package/dist/js/components-base/src/list/filter/ListDateRangeFilter.mjs +1 -0
  4. package/dist/js/components-base/src/list/filter/ListDateRangeFilter.mjs.map +1 -1
  5. package/dist/js/components-base/src/list/filter/ListFilter.mjs +4 -1
  6. package/dist/js/components-base/src/list/filter/ListFilter.mjs.map +1 -1
  7. package/dist/js/components-base/src/list/filter/dateRange.mjs +37 -13
  8. package/dist/js/components-base/src/list/filter/dateRange.mjs.map +1 -1
  9. package/dist/js/components-base/src/list/filter/dateTimeRangeFields.mjs +53 -0
  10. package/dist/js/components-base/src/list/filter/dateTimeRangeFields.mjs.map +1 -0
  11. package/dist/js/components-base/src/list/filter/formatDateRange.mjs +25 -0
  12. package/dist/js/components-base/src/list/filter/formatDateRange.mjs.map +1 -0
  13. package/dist/js/components-base/src/list/loading/ListLoaderState.mjs +10 -5
  14. package/dist/js/components-base/src/list/loading/ListLoaderState.mjs.map +1 -1
  15. package/dist/js/components-base/src/overlay/OverlayState.mjs +194 -0
  16. package/dist/js/components-base/src/overlay/OverlayState.mjs.map +1 -0
  17. package/dist/js/index.mjs +2 -1
  18. package/dist/js/remote-vue-components/src/components/Action.mjs +1 -1
  19. package/dist/js/remote-vue-components/src/components/DeprecationWarningProvider.mjs +15 -9
  20. package/dist/js/remote-vue-components/src/components/DeprecationWarningProvider.mjs.map +1 -1
  21. package/dist/js/remote-vue-components/src/list/ActiveFilters.mjs +5 -2
  22. package/dist/js/remote-vue-components/src/list/ActiveFilters.mjs.map +1 -1
  23. package/dist/js/remote-vue-components/src/list/AllFiltersModal.mjs +3 -2
  24. package/dist/js/remote-vue-components/src/list/AllFiltersModal.mjs.map +1 -1
  25. package/dist/js/remote-vue-components/src/list/DateTimeRangeFields.mjs +100 -0
  26. package/dist/js/remote-vue-components/src/list/DateTimeRangeFields.mjs.map +1 -0
  27. package/dist/js/remote-vue-components/src/list/Header.mjs +12 -7
  28. package/dist/js/remote-vue-components/src/list/Header.mjs.map +1 -1
  29. package/dist/js/remote-vue-components/src/list/dateRangeFilter.mjs +14 -6
  30. package/dist/js/remote-vue-components/src/list/dateRangeFilter.mjs.map +1 -1
  31. package/dist/js/remote-vue-components/src/list/locales.mjs +14 -0
  32. package/dist/js/remote-vue-components/src/list/locales.mjs.map +1 -1
  33. package/dist/js/remote-vue-components/src/list/styles.mjs +7 -1
  34. package/dist/js/remote-vue-components/src/list/styles.mjs.map +1 -1
  35. package/dist/js/remote-vue-components/src/overlays/Modal.mjs +14 -18
  36. package/dist/js/remote-vue-components/src/overlays/Modal.mjs.map +1 -1
  37. package/dist/js/remote-vue-components/src/overlays/overlayController.mjs +57 -63
  38. package/dist/js/remote-vue-components/src/overlays/overlayController.mjs.map +1 -1
  39. package/dist/js/remote-vue-components/src/version.mjs +1 -1
  40. package/dist/types/_bundled/flow-components-base/index.d.ts +4 -1
  41. package/dist/types/_bundled/flow-components-base/list/filter/ListFilter.d.ts +2 -0
  42. package/dist/types/_bundled/flow-components-base/list/filter/dateRange.d.ts +24 -1
  43. package/dist/types/_bundled/flow-components-base/list/filter/dateTimeRangeFields.d.ts +34 -0
  44. package/dist/types/_bundled/flow-components-base/list/filter/formatDateRange.d.ts +7 -0
  45. package/dist/types/_bundled/flow-components-base/list/loading/ListLoaderState.d.ts +5 -0
  46. package/dist/types/_bundled/flow-components-base/overlay/OverlayState.d.ts +94 -0
  47. package/dist/types/components/DeprecationWarningProvider.d.ts +2 -4
  48. package/dist/types/list/DateTimeRangeFields.d.ts +43 -0
  49. package/dist/types/list/dateRangeFilter.d.ts +6 -6
  50. package/dist/types/list/index.d.ts +1 -0
  51. package/dist/types/list/locales.d.ts +14 -0
  52. package/dist/types/list/styles.d.ts +6 -0
  53. package/dist/types/list/types.d.ts +8 -2
  54. package/dist/types/overlays/Modal.d.ts +2 -2
  55. package/dist/types/overlays/overlayController.d.ts +28 -18
  56. package/package.json +14 -14
@@ -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(RangeCalendar, {
84
- ...filter.dateRangeOptions,
85
- class: dateRangeCalendarClass,
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,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,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F,OAAO,EACL,KACA;IAAE,OAAO,WAAW;IAAqB,eAAe;GAAK,SAc3D,EAAE,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;KACb,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"}
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"],"m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F,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 calendar takes.
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 calendar accepts.
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, formatDate, formatDateRange, isDateRangeFilter };
33
+ export { DateRangeFilter, isDateRangeFilter };
26
34
 
27
35
  //# sourceMappingURL=dateRangeFilter.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"dateRangeFilter.mjs","names":[],"sources":["../../../../../src/list/dateRangeFilter.ts"],"sourcesContent":["import { ListDateRangeFilter } from \"@mittwald/flow-components-base\";\nimport type {\n ListDateParts,\n ListDateRange,\n ListModelContext,\n} from \"@mittwald/flow-components-base\";\nimport type { ListRendered, VueListFilterShape } from \"./types\";\n\n/**\n * A date-range filter, with the options its calendar takes.\n *\n * The column, the comparison and the stored value are the shared\n * `ListDateRangeFilter`, so a Vue list and a React list filter the same dates\n * the same way. What a binding adds is only what its calendar accepts.\n */\nexport class DateRangeFilter<T = never> extends ListDateRangeFilter<\n T,\n never,\n ListRendered\n> {\n /** Handed to the `RangeCalendar` — a minimum date, unavailable days, … */\n public readonly dateRangeOptions?: Record<string, unknown>;\n\n public constructor(\n context: ListModelContext<T>,\n shape: VueListFilterShape<T>,\n ) {\n super(context, shape as never);\n this.dateRangeOptions = (\n shape as { dateRangeOptions?: Record<string, unknown> }\n ).dateRangeOptions;\n }\n}\n\n/** Whether a filter is one of these, without reaching for the class. */\nexport const isDateRangeFilter = (filter: {\n readonly mode: string;\n}): filter is DateRangeFilter<never> => filter.mode === \"dateRange\";\n\n/** `01/03/2024`, the way `Intl` writes it for the host's locale. */\nexport const formatDate = (date: ListDateParts): string =>\n new Date(date.year, date.month - 1, date.day).toLocaleDateString();\n\nexport const formatDateRange = (range: ListDateRange): string =>\n [range.start, range.end]\n .map((date) => (date ? formatDate(date) : \"\"))\n .join(\" - \");\n"],"mappings":";;;;;;;;;;AAeA,IAAa,kBAAb,cAAgD,oBAI9C;;CAEA;CAEA,YACE,SACA,OACA;EACA,MAAM,SAAS,KAAc;EAC7B,KAAK,mBACH,MACA;CACJ;AACF;;AAGA,IAAa,qBAAqB,WAEM,OAAO,SAAS;;AAGxD,IAAa,cAAc,SACzB,IAAI,KAAK,KAAK,MAAM,KAAK,QAAQ,GAAG,KAAK,GAAG,CAAC,CAAC,mBAAmB;AAEnE,IAAa,mBAAmB,UAC9B,CAAC,MAAM,OAAO,MAAM,GAAG,CAAC,CACrB,KAAK,SAAU,OAAO,WAAW,IAAI,IAAI,EAAG,CAAC,CAC7C,KAAK,KAAK"}
1
+ {"version":3,"file":"dateRangeFilter.mjs","names":[],"sources":["../../../../../src/list/dateRangeFilter.ts"],"sourcesContent":["import { ListDateRangeFilter } from \"@mittwald/flow-components-base\";\nimport type {\n ListDateTimeRangeLimits,\n ListModelContext,\n} from \"@mittwald/flow-components-base\";\nimport type { ListRendered, VueListFilterShape } from \"./types\";\n\n/**\n * A date-range filter, with the options its fields take.\n *\n * The column, the comparison and the stored value are the shared\n * `ListDateRangeFilter`, so a Vue list and a React list filter the same dates\n * the same way. What a binding adds is only what its fields accept.\n */\nexport class DateRangeFilter<T = never> extends ListDateRangeFilter<\n T,\n never,\n ListRendered\n> {\n /** Handed to the `RangeCalendar` — a minimum date, unavailable days, … */\n public readonly dateRangeOptions?: Record<string, unknown>;\n\n public constructor(\n context: ListModelContext<T>,\n shape: VueListFilterShape<T>,\n ) {\n super(context, shape as never);\n this.dateRangeOptions = (\n shape as { dateRangeOptions?: Record<string, unknown> }\n ).dateRangeOptions;\n }\n\n public get granularity(): \"day\" | \"minute\" {\n return this.dateRangeOptions?.granularity === \"minute\" ? \"minute\" : \"day\";\n }\n\n public get rangeCalendarProps(): Record<string, unknown> {\n if (this.granularity === \"minute\") {\n return {};\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { granularity, ...props } = this.dateRangeOptions ?? {};\n return props;\n }\n\n public get dateTimeRangeLimits(): ListDateTimeRangeLimits | undefined {\n return this.granularity === \"minute\"\n ? (this.dateRangeOptions as ListDateTimeRangeLimits)\n : undefined;\n }\n}\n\n/** Whether a filter is one of these, without reaching for the class. */\nexport const isDateRangeFilter = (filter: {\n readonly mode: string;\n}): filter is DateRangeFilter<never> => filter.mode === \"dateRange\";\n"],"mappings":";;;;;;;;;;AAcA,IAAa,kBAAb,cAAgD,oBAI9C;;CAEA;CAEA,YACE,SACA,OACA;EACA,MAAM,SAAS,KAAc;EAC7B,KAAK,mBACH,MACA;CACJ;CAEA,IAAW,cAAgC;EACzC,OAAO,KAAK,kBAAkB,gBAAgB,WAAW,WAAW;CACtE;CAEA,IAAW,qBAA8C;EACvD,IAAI,KAAK,gBAAgB,UACvB,OAAO,CAAC;EAGV,MAAM,EAAE,aAAa,GAAG,UAAU,KAAK,oBAAoB,CAAC;EAC5D,OAAO;CACT;CAEA,IAAW,sBAA2D;EACpE,OAAO,KAAK,gBAAgB,WACvB,KAAK,mBACN,KAAA;CACN;AACF;;AAGA,IAAa,qBAAqB,WAEM,OAAO,SAAS"}
@@ -4,6 +4,13 @@ import { computed } from "vue";
4
4
  var texts = {
5
5
  "en-US": {
6
6
  dateRange: "Date range",
7
+ "dateRange.endBeforeStart": "The end must not be before the start.",
8
+ "dateRange.endDate": "End date",
9
+ "dateRange.endTime": "End time",
10
+ "dateRange.from": "from {date}",
11
+ "dateRange.startDate": "Start date",
12
+ "dateRange.startTime": "Start time",
13
+ "dateRange.until": "until {date}",
7
14
  filters: "Filters",
8
15
  "filters.all": "All filters",
9
16
  "filters.clear": "Clear filters",
@@ -34,6 +41,13 @@ var texts = {
34
41
  },
35
42
  "de-DE": {
36
43
  dateRange: "Zeitraum",
44
+ "dateRange.endBeforeStart": "Das Ende darf nicht vor dem Start liegen.",
45
+ "dateRange.endDate": "Enddatum",
46
+ "dateRange.endTime": "Endzeit",
47
+ "dateRange.from": "ab {date}",
48
+ "dateRange.startDate": "Startdatum",
49
+ "dateRange.startTime": "Startzeit",
50
+ "dateRange.until": "bis {date}",
37
51
  filters: "Filter",
38
52
  "filters.all": "Alle Filter",
39
53
  "filters.clear": "Filter entfernen",
@@ -1 +1 @@
1
- {"version":3,"file":"locales.mjs","names":[],"sources":["../../../../../src/list/locales.ts"],"sourcesContent":["import { useLanguage } from \"@/composables/remoteContext\";\nimport { computed, type ComputedRef } from \"vue\";\n\n/*\n * Copied from `packages/components/src/components/List/locales/*.locale.json`.\n *\n * Flow's strings are compiled into the React bundle by a locale plugin and are\n * not importable from a published package, so a Vue binding has to carry its\n * own — the same trade as the overlays' strings (`src/overlays/locales.ts`), at\n * a larger count. A rewording on the Flow side fails\n * `src/tests/CopiedTexts.test.ts`.\n */\nexport const texts = {\n \"en-US\": {\n dateRange: \"Date range\",\n filters: \"Filters\",\n \"filters.all\": \"All filters\",\n \"filters.clear\": \"Clear filters\",\n \"filters.clearSelection\": \"Clear selection\",\n \"filters.deselectAll\": \"Deselect all\",\n \"filters.reset\": \"Reset filters\",\n \"filters.selectAll\": \"Select all\",\n \"filters.store\": \"Store filters\",\n loadingMore: \"Loading more items\",\n \"noItems.heading\": \"No items available\",\n \"noItems.text\":\n \"Once there are items available, they will be displayed here.\",\n \"noResult.heading\": \"No search results found\",\n \"noResult.text\":\n \"Your search did not return any results. Please adjust the search query or your filters.\",\n options: \"Options\",\n paginationInfo: \"Showing {visibleItemsCount} of {totalItemsCount}\",\n reset: \"Reset\",\n /*\n * One key per branch, because Flow's is ICU (`{n, select, 1 {…} other {…}}`)\n * and this binding carries a `{name}` formatter rather than an ICU parser.\n * The two branches are picked in code — see `AllFiltersModal`.\n */\n \"results.show.one\": \"Show {totalItemCount} result\",\n \"results.show.other\": \"Show {totalItemCount} Results\",\n settings: \"Settings\",\n \"settings.viewMode\": \"View\",\n \"settings.viewMode.list\": \"List\",\n \"settings.viewMode.table\": \"Table\",\n \"settings.viewMode.tiles\": \"Tiles\",\n showMore: \"Show more\",\n sorting: \"Sorting\",\n \"toggleExpandButton.collapse\": \"Show less\",\n \"toggleExpandButton.expand\": \"Show more\",\n },\n \"de-DE\": {\n dateRange: \"Zeitraum\",\n filters: \"Filter\",\n \"filters.all\": \"Alle Filter\",\n \"filters.clear\": \"Filter entfernen\",\n \"filters.clearSelection\": \"Auswahl aufheben\",\n \"filters.deselectAll\": \"Alle abwählen\",\n \"filters.reset\": \"Filter zurücksetzen\",\n \"filters.selectAll\": \"Alle auswählen\",\n \"filters.store\": \"Filter speichern\",\n loadingMore: \"Weitere Einträge werden geladen\",\n \"noItems.heading\": \"Keine Einträge vorhanden\",\n \"noItems.text\":\n \"Sobald Einträge vorhanden sind, werden sie hier angezeigt.\",\n \"noResult.heading\": \"Keine Suchergebnisse gefunden\",\n \"noResult.text\":\n \"Deine Suche ergab keine Ergebnisse. Bitte passe die Suchanfrage oder deine Filter an.\",\n options: \"Optionen\",\n paginationInfo:\n \"{visibleItemsCount} von insgesamt {totalItemsCount} angezeigt\",\n reset: \"Zurücksetzen\",\n \"results.show.one\": \"{totalItemCount} Ergebnis anzeigen\",\n \"results.show.other\": \"{totalItemCount} Ergebnisse anzeigen\",\n settings: \"Einstellungen\",\n \"settings.viewMode\": \"Ansicht\",\n \"settings.viewMode.list\": \"Liste\",\n \"settings.viewMode.table\": \"Tabelle\",\n \"settings.viewMode.tiles\": \"Raster\",\n showMore: \"Mehr anzeigen\",\n sorting: \"Sortierung\",\n \"toggleExpandButton.collapse\": \"Weniger anzeigen\",\n \"toggleExpandButton.expand\": \"Mehr anzeigen\",\n },\n} as const;\n\nexport type ListTextKey = keyof (typeof texts)[\"en-US\"];\n\nexport type ListTextFormatter = (\n key: ListTextKey,\n values?: Record<string, string | number>,\n) => string;\n\n/**\n * The list's texts in the host's language.\n *\n * Only `{name}` placeholders, not ICU: the two strings that interpolate count\n * items, and neither pluralizes. A string that needed a plural rule would need\n * a formatter, and the honest fix then is `@flr-generate` on the List rather\n * than an ICU parser in a binding.\n */\nexport const useListTexts = (): ComputedRef<ListTextFormatter> => {\n const language = useLanguage();\n\n return computed(() => {\n const table = language.value?.startsWith(\"de\")\n ? texts[\"de-DE\"]\n : texts[\"en-US\"];\n\n return (key, values = {}) =>\n table[key].replace(/\\{(\\w+)\\}/g, (placeholder, name: string) =>\n name in values ? String(values[name]) : placeholder,\n );\n });\n};\n"],"mappings":";;;AAYA,IAAa,QAAQ;CACnB,SAAS;EACP,WAAW;EACX,SAAS;EACT,eAAe;EACf,iBAAiB;EACjB,0BAA0B;EAC1B,uBAAuB;EACvB,iBAAiB;EACjB,qBAAqB;EACrB,iBAAiB;EACjB,aAAa;EACb,mBAAmB;EACnB,gBACE;EACF,oBAAoB;EACpB,iBACE;EACF,SAAS;EACT,gBAAgB;EAChB,OAAO;EAMP,oBAAoB;EACpB,sBAAsB;EACtB,UAAU;EACV,qBAAqB;EACrB,0BAA0B;EAC1B,2BAA2B;EAC3B,2BAA2B;EAC3B,UAAU;EACV,SAAS;EACT,+BAA+B;EAC/B,6BAA6B;CAC/B;CACA,SAAS;EACP,WAAW;EACX,SAAS;EACT,eAAe;EACf,iBAAiB;EACjB,0BAA0B;EAC1B,uBAAuB;EACvB,iBAAiB;EACjB,qBAAqB;EACrB,iBAAiB;EACjB,aAAa;EACb,mBAAmB;EACnB,gBACE;EACF,oBAAoB;EACpB,iBACE;EACF,SAAS;EACT,gBACE;EACF,OAAO;EACP,oBAAoB;EACpB,sBAAsB;EACtB,UAAU;EACV,qBAAqB;EACrB,0BAA0B;EAC1B,2BAA2B;EAC3B,2BAA2B;EAC3B,UAAU;EACV,SAAS;EACT,+BAA+B;EAC/B,6BAA6B;CAC/B;AACF;;;;;;;;;AAiBA,IAAa,qBAAqD;CAChE,MAAM,WAAW,YAAY;CAE7B,OAAO,eAAe;EACpB,MAAM,QAAQ,SAAS,OAAO,WAAW,IAAI,IACzC,MAAM,WACN,MAAM;EAEV,QAAQ,KAAK,SAAS,CAAC,MACrB,MAAM,IAAI,CAAC,QAAQ,eAAe,aAAa,SAC7C,QAAQ,SAAS,OAAO,OAAO,KAAK,IAAI,WAC1C;CACJ,CAAC;AACH"}
1
+ {"version":3,"file":"locales.mjs","names":[],"sources":["../../../../../src/list/locales.ts"],"sourcesContent":["import { useLanguage } from \"@/composables/remoteContext\";\nimport { computed, type ComputedRef } from \"vue\";\n\n/*\n * Copied from `packages/components/src/components/List/locales/*.locale.json`.\n *\n * Flow's strings are compiled into the React bundle by a locale plugin and are\n * not importable from a published package, so a Vue binding has to carry its\n * own — the same trade as the overlays' strings (`src/overlays/locales.ts`), at\n * a larger count. A rewording on the Flow side fails\n * `src/tests/CopiedTexts.test.ts`.\n */\nexport const texts = {\n \"en-US\": {\n dateRange: \"Date range\",\n \"dateRange.endBeforeStart\": \"The end must not be before the start.\",\n \"dateRange.endDate\": \"End date\",\n \"dateRange.endTime\": \"End time\",\n \"dateRange.from\": \"from {date}\",\n \"dateRange.startDate\": \"Start date\",\n \"dateRange.startTime\": \"Start time\",\n \"dateRange.until\": \"until {date}\",\n filters: \"Filters\",\n \"filters.all\": \"All filters\",\n \"filters.clear\": \"Clear filters\",\n \"filters.clearSelection\": \"Clear selection\",\n \"filters.deselectAll\": \"Deselect all\",\n \"filters.reset\": \"Reset filters\",\n \"filters.selectAll\": \"Select all\",\n \"filters.store\": \"Store filters\",\n loadingMore: \"Loading more items\",\n \"noItems.heading\": \"No items available\",\n \"noItems.text\":\n \"Once there are items available, they will be displayed here.\",\n \"noResult.heading\": \"No search results found\",\n \"noResult.text\":\n \"Your search did not return any results. Please adjust the search query or your filters.\",\n options: \"Options\",\n paginationInfo: \"Showing {visibleItemsCount} of {totalItemsCount}\",\n reset: \"Reset\",\n /*\n * One key per branch, because Flow's is ICU (`{n, select, 1 {…} other {…}}`)\n * and this binding carries a `{name}` formatter rather than an ICU parser.\n * The two branches are picked in code — see `AllFiltersModal`.\n */\n \"results.show.one\": \"Show {totalItemCount} result\",\n \"results.show.other\": \"Show {totalItemCount} Results\",\n settings: \"Settings\",\n \"settings.viewMode\": \"View\",\n \"settings.viewMode.list\": \"List\",\n \"settings.viewMode.table\": \"Table\",\n \"settings.viewMode.tiles\": \"Tiles\",\n showMore: \"Show more\",\n sorting: \"Sorting\",\n \"toggleExpandButton.collapse\": \"Show less\",\n \"toggleExpandButton.expand\": \"Show more\",\n },\n \"de-DE\": {\n dateRange: \"Zeitraum\",\n \"dateRange.endBeforeStart\": \"Das Ende darf nicht vor dem Start liegen.\",\n \"dateRange.endDate\": \"Enddatum\",\n \"dateRange.endTime\": \"Endzeit\",\n \"dateRange.from\": \"ab {date}\",\n \"dateRange.startDate\": \"Startdatum\",\n \"dateRange.startTime\": \"Startzeit\",\n \"dateRange.until\": \"bis {date}\",\n filters: \"Filter\",\n \"filters.all\": \"Alle Filter\",\n \"filters.clear\": \"Filter entfernen\",\n \"filters.clearSelection\": \"Auswahl aufheben\",\n \"filters.deselectAll\": \"Alle abwählen\",\n \"filters.reset\": \"Filter zurücksetzen\",\n \"filters.selectAll\": \"Alle auswählen\",\n \"filters.store\": \"Filter speichern\",\n loadingMore: \"Weitere Einträge werden geladen\",\n \"noItems.heading\": \"Keine Einträge vorhanden\",\n \"noItems.text\":\n \"Sobald Einträge vorhanden sind, werden sie hier angezeigt.\",\n \"noResult.heading\": \"Keine Suchergebnisse gefunden\",\n \"noResult.text\":\n \"Deine Suche ergab keine Ergebnisse. Bitte passe die Suchanfrage oder deine Filter an.\",\n options: \"Optionen\",\n paginationInfo:\n \"{visibleItemsCount} von insgesamt {totalItemsCount} angezeigt\",\n reset: \"Zurücksetzen\",\n \"results.show.one\": \"{totalItemCount} Ergebnis anzeigen\",\n \"results.show.other\": \"{totalItemCount} Ergebnisse anzeigen\",\n settings: \"Einstellungen\",\n \"settings.viewMode\": \"Ansicht\",\n \"settings.viewMode.list\": \"Liste\",\n \"settings.viewMode.table\": \"Tabelle\",\n \"settings.viewMode.tiles\": \"Raster\",\n showMore: \"Mehr anzeigen\",\n sorting: \"Sortierung\",\n \"toggleExpandButton.collapse\": \"Weniger anzeigen\",\n \"toggleExpandButton.expand\": \"Mehr anzeigen\",\n },\n} as const;\n\nexport type ListTextKey = keyof (typeof texts)[\"en-US\"];\n\nexport type ListTextFormatter = (\n key: ListTextKey,\n values?: Record<string, string | number>,\n) => string;\n\n/**\n * The list's texts in the host's language.\n *\n * Only `{name}` placeholders, not ICU: the two strings that interpolate count\n * items, and neither pluralizes. A string that needed a plural rule would need\n * a formatter, and the honest fix then is `@flr-generate` on the List rather\n * than an ICU parser in a binding.\n */\nexport const useListTexts = (): ComputedRef<ListTextFormatter> => {\n const language = useLanguage();\n\n return computed(() => {\n const table = language.value?.startsWith(\"de\")\n ? texts[\"de-DE\"]\n : texts[\"en-US\"];\n\n return (key, values = {}) =>\n table[key].replace(/\\{(\\w+)\\}/g, (placeholder, name: string) =>\n name in values ? String(values[name]) : placeholder,\n );\n });\n};\n"],"mappings":";;;AAYA,IAAa,QAAQ;CACnB,SAAS;EACP,WAAW;EACX,4BAA4B;EAC5B,qBAAqB;EACrB,qBAAqB;EACrB,kBAAkB;EAClB,uBAAuB;EACvB,uBAAuB;EACvB,mBAAmB;EACnB,SAAS;EACT,eAAe;EACf,iBAAiB;EACjB,0BAA0B;EAC1B,uBAAuB;EACvB,iBAAiB;EACjB,qBAAqB;EACrB,iBAAiB;EACjB,aAAa;EACb,mBAAmB;EACnB,gBACE;EACF,oBAAoB;EACpB,iBACE;EACF,SAAS;EACT,gBAAgB;EAChB,OAAO;EAMP,oBAAoB;EACpB,sBAAsB;EACtB,UAAU;EACV,qBAAqB;EACrB,0BAA0B;EAC1B,2BAA2B;EAC3B,2BAA2B;EAC3B,UAAU;EACV,SAAS;EACT,+BAA+B;EAC/B,6BAA6B;CAC/B;CACA,SAAS;EACP,WAAW;EACX,4BAA4B;EAC5B,qBAAqB;EACrB,qBAAqB;EACrB,kBAAkB;EAClB,uBAAuB;EACvB,uBAAuB;EACvB,mBAAmB;EACnB,SAAS;EACT,eAAe;EACf,iBAAiB;EACjB,0BAA0B;EAC1B,uBAAuB;EACvB,iBAAiB;EACjB,qBAAqB;EACrB,iBAAiB;EACjB,aAAa;EACb,mBAAmB;EACnB,gBACE;EACF,oBAAoB;EACpB,iBACE;EACF,SAAS;EACT,gBACE;EACF,OAAO;EACP,oBAAoB;EACpB,sBAAsB;EACtB,UAAU;EACV,qBAAqB;EACrB,0BAA0B;EAC1B,2BAA2B;EAC3B,2BAA2B;EAC3B,UAAU;EACV,SAAS;EACT,+BAA+B;EAC/B,6BAA6B;CAC/B;AACF;;;;;;;;;AAiBA,IAAa,qBAAqD;CAChE,MAAM,WAAW,YAAY;CAE7B,OAAO,eAAe;EACpB,MAAM,QAAQ,SAAS,OAAO,WAAW,IAAI,IACzC,MAAM,WACN,MAAM;EAEV,QAAQ,KAAK,SAAS,CAAC,MACrB,MAAM,IAAI,CAAC,QAAQ,eAAe,aAAa,SAC7C,QAAQ,SAAS,OAAO,OAAO,KAAK,IAAI,WAC1C;CACJ,CAAC;AACH"}
@@ -20,6 +20,12 @@ var listStyles = {
20
20
  hideVisuallyActions: "flow--list--header--hide-visually-actions",
21
21
  selectAllCheckbox: "flow--list--header--all-filters-modal--select-all-checkbox"
22
22
  };
23
+ var dateTimeRangeStyles = {
24
+ calendar: "flow--list--header--filter-context-menu--calendar",
25
+ popover: "flow--list--header--filter-context-menu--date-time-range",
26
+ fields: "flow--list--header--date-time-range-fields",
27
+ rangeError: "flow--list--header--date-time-range-fields--range-error"
28
+ };
23
29
  /** The list item view's own classes, from `ListItemView.module.scss`. */
24
30
  var itemViewStyles = { action: "flow--list--list-item-view--action" };
25
31
  var className = (...parts) => {
@@ -27,6 +33,6 @@ var className = (...parts) => {
27
33
  return used.length > 0 ? used.join(" ") : void 0;
28
34
  };
29
35
  //#endregion
30
- export { className, itemViewStyles, listStyles };
36
+ export { className, dateTimeRangeStyles, itemViewStyles, listStyles };
31
37
 
32
38
  //# sourceMappingURL=styles.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"styles.mjs","names":[],"sources":["../../../../../src/list/styles.ts"],"sourcesContent":["/*\n * Flow's own class names, from the List's CSS modules.\n *\n * Generated from each file's path (`flow--list--header--options` is\n * `Header.module.scss`'s `.options`), shipped in `@mittwald/flow-stylesheet`,\n * and not importable from a published package — so a Vue rebuild of a React\n * composition has to name them. The same trade `Modal` makes, and the same\n * argument for marking `List` `@flr-generate` instead.\n */\nexport const listStyles = {\n list: \"flow--list\",\n listWrapper: \"flow--list--list-wrapper\",\n hideVisuallyEmptyView: \"flow--list--hide-visually-empty-view\",\n items: \"flow--list--items\",\n itemsLoading: \"flow--list--items--is-loading\",\n itemsTiles: \"flow--list--items--tiles\",\n footer: \"flow--list--footer\",\n header: \"flow--list--header\",\n headerContent: \"flow--list--header--header-content\",\n headerOptions: \"flow--list--header--options\",\n headerWithSearch: \"flow--list--header--with-search\",\n headerActions: \"flow--list--header--actions\",\n headerAction: \"flow--list--header--action\",\n hideOnMobile: \"flow--list--header--hide-on-mobile\",\n hideOnDesktop: \"flow--list--header--hide-on-desktop\",\n activeFilters: \"flow--list--header--active-filters\",\n searchField: \"flow--list--header--search-field\",\n hideVisuallyActions: \"flow--list--header--hide-visually-actions\",\n selectAllCheckbox:\n \"flow--list--header--all-filters-modal--select-all-checkbox\",\n} as const;\n\n/** The list item view's own classes, from `ListItemView.module.scss`. */\nexport const itemViewStyles = {\n action: \"flow--list--list-item-view--action\",\n} as const;\n\nexport const className = (\n ...parts: (string | false | undefined)[]\n): string | undefined => {\n const used = parts.filter((p): p is string => !!p);\n return used.length > 0 ? used.join(\" \") : undefined;\n};\n"],"mappings":";AASA,IAAa,aAAa;CACxB,MAAM;CACN,aAAa;CACb,uBAAuB;CACvB,OAAO;CACP,cAAc;CACd,YAAY;CACZ,QAAQ;CACR,QAAQ;CACR,eAAe;CACf,eAAe;CACf,kBAAkB;CAClB,eAAe;CACf,cAAc;CACd,cAAc;CACd,eAAe;CACf,eAAe;CACf,aAAa;CACb,qBAAqB;CACrB,mBACE;AACJ;;AAGA,IAAa,iBAAiB,EAC5B,QAAQ,qCACV;AAEA,IAAa,aACX,GAAG,UACoB;CACvB,MAAM,OAAO,MAAM,QAAQ,MAAmB,CAAC,CAAC,CAAC;CACjD,OAAO,KAAK,SAAS,IAAI,KAAK,KAAK,GAAG,IAAI,KAAA;AAC5C"}
1
+ {"version":3,"file":"styles.mjs","names":[],"sources":["../../../../../src/list/styles.ts"],"sourcesContent":["/*\n * Flow's own class names, from the List's CSS modules.\n *\n * Generated from each file's path (`flow--list--header--options` is\n * `Header.module.scss`'s `.options`), shipped in `@mittwald/flow-stylesheet`,\n * and not importable from a published package — so a Vue rebuild of a React\n * composition has to name them. The same trade `Modal` makes, and the same\n * argument for marking `List` `@flr-generate` instead.\n */\nexport const listStyles = {\n list: \"flow--list\",\n listWrapper: \"flow--list--list-wrapper\",\n hideVisuallyEmptyView: \"flow--list--hide-visually-empty-view\",\n items: \"flow--list--items\",\n itemsLoading: \"flow--list--items--is-loading\",\n itemsTiles: \"flow--list--items--tiles\",\n footer: \"flow--list--footer\",\n header: \"flow--list--header\",\n headerContent: \"flow--list--header--header-content\",\n headerOptions: \"flow--list--header--options\",\n headerWithSearch: \"flow--list--header--with-search\",\n headerActions: \"flow--list--header--actions\",\n headerAction: \"flow--list--header--action\",\n hideOnMobile: \"flow--list--header--hide-on-mobile\",\n hideOnDesktop: \"flow--list--header--hide-on-desktop\",\n activeFilters: \"flow--list--header--active-filters\",\n searchField: \"flow--list--header--search-field\",\n hideVisuallyActions: \"flow--list--header--hide-visually-actions\",\n selectAllCheckbox:\n \"flow--list--header--all-filters-modal--select-all-checkbox\",\n} as const;\n\n/*\n * The date-range filter's classes, from `FilterContextMenus.module.scss` and\n * `DateTimeRangeFields.module.scss`.\n */\nexport const dateTimeRangeStyles = {\n calendar: \"flow--list--header--filter-context-menu--calendar\",\n popover: \"flow--list--header--filter-context-menu--date-time-range\",\n fields: \"flow--list--header--date-time-range-fields\",\n rangeError: \"flow--list--header--date-time-range-fields--range-error\",\n} as const;\n\n/** The list item view's own classes, from `ListItemView.module.scss`. */\nexport const itemViewStyles = {\n action: \"flow--list--list-item-view--action\",\n} as const;\n\nexport const className = (\n ...parts: (string | false | undefined)[]\n): string | undefined => {\n const used = parts.filter((p): p is string => !!p);\n return used.length > 0 ? used.join(\" \") : undefined;\n};\n"],"mappings":";AASA,IAAa,aAAa;CACxB,MAAM;CACN,aAAa;CACb,uBAAuB;CACvB,OAAO;CACP,cAAc;CACd,YAAY;CACZ,QAAQ;CACR,QAAQ;CACR,eAAe;CACf,eAAe;CACf,kBAAkB;CAClB,eAAe;CACf,cAAc;CACd,cAAc;CACd,eAAe;CACf,eAAe;CACf,aAAa;CACb,qBAAqB;CACrB,mBACE;AACJ;AAMA,IAAa,sBAAsB;CACjC,UAAU;CACV,SAAS;CACT,QAAQ;CACR,YAAY;AACd;;AAGA,IAAa,iBAAiB,EAC5B,QAAQ,qCACV;AAEA,IAAa,aACX,GAAG,UACoB;CACvB,MAAM,OAAO,MAAM,QAAQ,MAAmB,CAAC,CAAC,CAAC;CACjD,OAAO,KAAK,SAAS,IAAI,KAAK,KAAK,GAAG,IAAI,KAAA;AAC5C"}
@@ -16,10 +16,10 @@ import { Section } from "../auto-generated/Section.mjs";
16
16
  import { Text } from "../auto-generated/Text.mjs";
17
17
  import { IconClose } from "../icons/components/IconClose.mjs";
18
18
  import { applyChildRules, dynamic, withSlotContent } from "./childProps.mjs";
19
- import { createOverlayControllerFor, isOverlayController, provideOverlayContext, useOverlayHandlers, useOwnController } from "./overlayController.mjs";
19
+ import { createOverlayController, isOverlayController, provideOverlayContext, useConfirmOnCloseSource, useOverlayHandlers, useOwnController } from "./overlayController.mjs";
20
20
  import { Action } from "../components/Action.mjs";
21
21
  import { confirmCloseTexts } from "./locales.mjs";
22
- import { defineComponent, h, onBeforeUnmount, onMounted, useId, watch, watchEffect } from "vue";
22
+ import { defineComponent, h, onMounted, useId, watch } from "vue";
23
23
  //#region src/overlays/Modal.ts
24
24
  var styles = {
25
25
  overlay: "flow--overlay",
@@ -83,11 +83,11 @@ var nestedHeadingRules = (child) => child.type === Heading ? { props: { level: 3
83
83
  children: (grandChild) => grandChild.type === Header ? { children: headingLevel3 } : headingLevel3(grandChild)
84
84
  } : child.type === Header ? { children: headingLevel3 } : void 0;
85
85
  /**
86
- * Asks before a `<Modal confirm-on-close>` closes.
86
+ * Asks before a modal that requires confirmation closes.
87
87
  *
88
- * Bound to the parent's `isConfirmingClose` rather than holding state of its
89
- * own: a dismiss of this modal is then the same event as answering "keep
90
- * editing", and there is one place that decides whether the parent closes.
88
+ * Flow's `useCloseOverlayConfirmationController`: a controller of its own,
89
+ * opened while the parent asks. A dismiss of this modal answers "keep editing",
90
+ * and an answer from anywhere closes it again.
91
91
  *
92
92
  * Annotated rather than inferred — it renders a `Modal` and the `Modal` renders
93
93
  * it, and without an annotation TypeScript cannot break that cycle (TS7022).
@@ -100,7 +100,11 @@ var ConfirmCloseModal = defineComponent({
100
100
  } },
101
101
  setup(props) {
102
102
  const language = useLanguage();
103
- const controller = createOverlayControllerFor(props.parent.isConfirmingClose);
103
+ const controller = createOverlayController();
104
+ watch(() => props.parent.isConfirmingClose.value, (isConfirming) => isConfirming ? controller.open() : controller.close(), { immediate: true });
105
+ controller.addOnClose(() => {
106
+ if (props.parent.isConfirmingClose.value) props.parent.cancelConfirmation();
107
+ });
104
108
  return () => {
105
109
  const texts = language.value?.startsWith("de") ? confirmCloseTexts["de-DE"] : confirmCloseTexts["en-US"];
106
110
  return h(Modal, { controller }, () => [
@@ -152,7 +156,7 @@ var Modal = defineComponent({
152
156
  */
153
157
  confirmOnClose: {
154
158
  type: Boolean,
155
- default: false
159
+ default: void 0
156
160
  },
157
161
  /** A controller to open and close the modal from anywhere. */
158
162
  controller: {
@@ -202,15 +206,7 @@ var Modal = defineComponent({
202
206
  onClose: () => props.onClose,
203
207
  onOpenChange: () => props.onOpenChange
204
208
  });
205
- watchEffect(() => {
206
- controller.value.confirmOnClose.value = props.confirmOnClose;
207
- });
208
- const release = (released) => {
209
- released.confirmOnClose.value = false;
210
- released.isConfirmingClose.value = false;
211
- };
212
- watch(controller, (next, previous) => release(previous));
213
- onBeforeUnmount(() => release(controller.value));
209
+ useConfirmOnCloseSource(() => controller.value, () => props.confirmOnClose);
214
210
  const childRules = (child) => {
215
211
  if (child.type === Heading) return { props: {
216
212
  class: styles.header,
@@ -253,7 +249,7 @@ var Modal = defineComponent({
253
249
  ].filter(Boolean).join(" ");
254
250
  const texts = language.value?.startsWith("de") ? confirmCloseTexts["de-DE"] : confirmCloseTexts["en-US"];
255
251
  const children = applyChildRules(slots.default?.(), childRules).map((child) => child.type === Heading ? withHeaderChrome(child, texts.close, props.showCloseButton) : child);
256
- if (props.confirmOnClose) children.push(h(ConfirmCloseModal, { parent: controller.value }));
252
+ if (controller.value.confirmOnClose.value) children.push(h(ConfirmCloseModal, { parent: controller.value }));
257
253
  return h(ClearPropsContext, null, () => h(OverlayContent, {
258
254
  class: className,
259
255
  isOpen: props.isOpen ?? controller.value.isOpen.value,
@@ -1 +1 @@
1
- {"version":3,"file":"Modal.mjs","names":[],"sources":["../../../../../src/overlays/Modal.ts"],"sourcesContent":["import {\n AccentBox,\n ActionGroup,\n Button,\n ClearPropsContext,\n ColumnLayout,\n Content,\n Div,\n Header,\n Heading,\n OverlayContent,\n Section,\n Text,\n} from \"@/auto-generated\";\nimport { IconClose } from \"@/icons\";\nimport Action from \"@/components/Action\";\nimport { useLanguage } from \"@/composables/remoteContext\";\nimport { confirmCloseTexts } from \"@/overlays/locales\";\nimport {\n applyChildRules,\n dynamic,\n withSlotContent,\n type ChildRules,\n} from \"@/overlays/childProps\";\nimport { readProp } from \"@/lib/propKeys\";\nimport {\n createOverlayControllerFor,\n isOverlayController,\n provideOverlayContext,\n useOwnController,\n useOverlayHandlers,\n type OverlayCloseHandler,\n type OverlayController,\n type OverlayOpenHandler,\n type OverlayOpenStateHandler,\n} from \"@/overlays/overlayController\";\nimport type { AnyRecord } from \"@/lib/types\";\nimport {\n defineComponent,\n h,\n onBeforeUnmount,\n onMounted,\n useId,\n watch,\n watchEffect,\n type Component,\n type PropType,\n type VNode,\n} from \"vue\";\nimport { composition } from \"@/lib/composition\";\nimport { useComponentUsage } from \"@/composables/useComponentUsage\";\n\nexport type ModalSize = \"s\" | \"m\" | \"l\";\n\n/*\n * Flow's `Modal` is a React composition, not a remote element: it renders an\n * `OverlayContent` and configures the components inside it through a props\n * context — the header, the content padding, the footer spacing. Both halves\n * are rebuilt here, so a Vue app writes `Modal` and not the overlay plumbing.\n *\n * The class names are Flow's own, taken from `Modal.module.scss` by way of the\n * generated `flow--…` names. They are internal, and repeating them is the price\n * of a composition that lives in React: the alternative — marking `Modal`\n * `@flr-generate`, so the host materialises the whole thing from one element —\n * would make this file unnecessary.\n */\nconst styles = {\n overlay: \"flow--overlay\",\n modal: \"flow--modal\",\n offCanvas: \"flow--modal--off-canvas\",\n left: \"flow--modal--left\",\n size: (size: ModalSize) => `flow--modal--size-${size}`,\n header: \"flow--modal--header\",\n headerTitle: \"flow--modal--header-title\",\n closeButton: \"flow--modal--close-button\",\n alwaysVisible: \"flow--modal--always-visible\",\n alwaysHidden: \"flow--modal--always-hidden\",\n content: \"flow--modal--content\",\n columnLayout: \"flow--modal--column-layout\",\n accentBox: \"flow--modal--accent-box\",\n actionGroup: \"flow--modal--action-group\",\n};\n\n/**\n * The chrome Flow puts around a modal's heading: the title in its own\n * container, and the close button beside it.\n *\n * Not props on the heading but a rebuild of what it was handed — the reason\n * `withSlotContent` exists. The close button clears the props context around\n * it, the way Flow's does, so the modal's own rules for `Button` do not reach\n * it, and it closes without asking again: this button _is_ the deliberate way\n * out.\n */\nconst withHeaderChrome = (\n heading: VNode,\n closeLabel: string,\n showCloseButton: boolean | undefined,\n): VNode =>\n withSlotContent(heading, (title) => [\n h(Div, { class: styles.headerTitle }, () => title),\n h(ClearPropsContext, null, () =>\n h(Action, { closeModal: { bypassConfirmation: true } }, () =>\n h(\n Button,\n {\n variant: \"plain\",\n color: \"secondary\",\n \"aria-label\": closeLabel,\n class: [\n styles.closeButton,\n showCloseButton === true\n ? styles.alwaysVisible\n : showCloseButton === false\n ? styles.alwaysHidden\n : undefined,\n ]\n .filter(Boolean)\n .join(\" \"),\n },\n () => h(IconClose),\n ),\n ),\n ),\n ]);\n\n/**\n * Lets an `Action` in the modal's footer close without asking again.\n *\n * Only where the action already closes something: Flow's props context rewrites\n * an existing `closeModal`/`closeOverlay` and adds none, and an `Action` that\n * merely runs something must not be turned into a close button. An explicit\n * `bypassConfirmation` in the object form wins, as in Flow.\n */\nconst withBypassedConfirmation = (child: VNode): AnyRecord | undefined => {\n if (child.type !== Action) {\n return undefined;\n }\n\n const bypassed: AnyRecord = {};\n\n for (const name of [\"closeModal\", \"closeOverlay\"]) {\n const value = readProp(child.props, name);\n\n if (value === undefined || value === null || value === false) {\n continue;\n }\n\n /*\n * A controller names the overlay, like a type name does — spread, it\n * would lose its identity and the action would close the modal instead.\n */\n bypassed[name] = dynamic(\n isOverlayController(value) || (typeof value === \"string\" && value !== \"\")\n ? { bypassConfirmation: true, overlay: value }\n : typeof value === \"object\"\n ? { bypassConfirmation: true, ...value }\n : { bypassConfirmation: true },\n );\n }\n\n return Object.keys(bypassed).length > 0 ? bypassed : undefined;\n};\n\n/*\n * Flow's `nestedHeadingProps`: inside the content, headings are one level\n * down, and a section drops its separator.\n */\nconst headingLevel3: ChildRules = (child) =>\n child.type === Heading ? { props: { level: 3 } } : undefined;\n\nconst nestedHeadingRules: ChildRules = (child) =>\n child.type === Heading\n ? { props: { level: 3 } }\n : child.type === Section\n ? {\n props: { hideSeparator: true },\n children: (grandChild) =>\n grandChild.type === Header\n ? { children: headingLevel3 }\n : headingLevel3(grandChild),\n }\n : child.type === Header\n ? { children: headingLevel3 }\n : undefined;\n\n/**\n * Asks before a `<Modal confirm-on-close>` closes.\n *\n * Bound to the parent's `isConfirmingClose` rather than holding state of its\n * own: a dismiss of this modal is then the same event as answering \"keep\n * editing\", and there is one place that decides whether the parent closes.\n *\n * Annotated rather than inferred — it renders a `Modal` and the `Modal` renders\n * it, and without an annotation TypeScript cannot break that cycle (TS7022).\n */\nconst ConfirmCloseModal: Component = defineComponent({\n name: \"ConfirmCloseModal\",\n\n props: {\n parent: {\n type: Object as PropType<OverlayController>,\n required: true,\n },\n },\n\n setup(props) {\n const language = useLanguage();\n const controller = createOverlayControllerFor(\n props.parent.isConfirmingClose,\n );\n\n return () => {\n const texts = language.value?.startsWith(\"de\")\n ? confirmCloseTexts[\"de-DE\"]\n : confirmCloseTexts[\"en-US\"];\n\n return h(Modal, { controller }, () => [\n h(Heading, null, () => texts.heading),\n h(Content, null, () => h(Text, null, () => texts.text)),\n h(ActionGroup, null, () => [\n h(Action, { onAction: props.parent.confirmClose }, () =>\n h(Button, { color: \"danger\" }, () => texts.close),\n ),\n h(Action, { onAction: props.parent.cancelClose }, () =>\n h(\n Button,\n { color: \"secondary\", variant: \"soft\" },\n () => texts.keepOpen,\n ),\n ),\n ]),\n ]);\n };\n },\n});\n\nexport const Modal = defineComponent({\n name: \"Modal\",\n\n /* Like Flow's, a modal passes on only the props it knows. */\n inheritAttrs: false,\n\n props: {\n /** The size of the modal. @default \"s\" */\n size: { type: String as PropType<ModalSize>, default: \"s\" },\n /** Whether the modal is displayed as an off canvas. */\n offCanvas: { type: Boolean, default: false },\n /** Which side the off canvas comes from. @default \"right\" */\n offCanvasOrientation: {\n type: String as PropType<\"left\" | \"right\">,\n default: \"right\",\n },\n /** Whether a click outside closes the modal. @default true */\n isDismissable: { type: Boolean, default: true },\n /**\n * Whether the close button is always visible (`true`) or always hidden\n * (`false`). By default Flow decides by screen size.\n */\n showCloseButton: { type: Boolean, default: undefined },\n /**\n * Whether closing the modal has to be confirmed — use it to protect unsaved\n * changes.\n */\n confirmOnClose: { type: Boolean, default: false },\n /** A controller to open and close the modal from anywhere. */\n controller: {\n type: Object as PropType<OverlayController>,\n default: undefined,\n },\n /** Whether the modal is open. Use it to control the modal state. */\n isOpen: { type: Boolean, default: undefined },\n /**\n * Whether the modal is open initially, when it has a controller of its own\n * — not one from a trigger or the `controller` prop. @default false\n */\n isDefaultOpen: { type: Boolean, default: undefined },\n /** Called when the modal opens. Returning `false` keeps it closed. */\n onOpen: {\n type: Function as PropType<OverlayOpenHandler>,\n default: undefined,\n },\n /** Called when the modal closes. Returning `false` keeps it open. */\n onClose: {\n type: Function as PropType<OverlayCloseHandler>,\n default: undefined,\n },\n /**\n * Called with the new state whenever the modal opens or closes. Returning\n * `false` aborts the change.\n */\n onOpenChange: {\n type: Function as PropType<OverlayOpenStateHandler>,\n default: undefined,\n },\n },\n\n setup(props, { slots, attrs }) {\n /* Flow's React `Modal` is a `flowComponent` and reports itself. */\n onMounted(useComponentUsage(\"Modal\"));\n\n const language = useLanguage();\n /*\n * The dialog is labelled by its own heading, so the two need an id they\n * agree on. Flow generates one with `useId`; `useId` exists in Vue too,\n * and both sides end up with an id the host rewrites anyway — what has to\n * match is that the heading carries one at all.\n */\n const headingId = useId();\n /*\n * Three ways to own the state, in Flow's order of precedence: a\n * controller the app passes, the controller of a surrounding trigger, or\n * one of its own.\n */\n const controller = useOwnController(\n () => props.controller,\n \"Modal\",\n () => ({ isDefaultOpen: props.isDefaultOpen }),\n );\n\n // So an `Action` inside finds it.\n provideOverlayContext(\"Modal\", () => controller.value);\n\n useOverlayHandlers(() => controller.value, {\n onOpen: () => props.onOpen,\n onClose: () => props.onClose,\n onOpenChange: () => props.onOpenChange,\n });\n\n /*\n * The requirement lives on the controller, not on this component: what\n * asks for the confirmation is a close, and a close arrives at the\n * controller — from an `Action` inside, from the host's dismiss, or from\n * an app holding the controller itself.\n */\n watchEffect(() => {\n controller.value.confirmOnClose.value = props.confirmOnClose;\n });\n\n /*\n * Taken back, because the controller usually outlives the modal: a\n * trigger keeps it, and the next modal it opens would inherit a\n * requirement it never asked for. The same goes for a controller the\n * app swapped for another.\n */\n const release = (released: OverlayController) => {\n released.confirmOnClose.value = false;\n released.isConfirmingClose.value = false;\n };\n watch(controller, (next, previous) => release(previous));\n onBeforeUnmount(() => release(controller.value));\n\n /* Flow's props context for the modal's children, rule for rule. */\n const childRules: ChildRules = (child) => {\n if (child.type === Heading) {\n return { props: { class: styles.header, level: 2, id: headingId } };\n }\n if (child.type === Content) {\n return {\n props: { class: styles.content },\n children: nestedHeadingRules,\n };\n }\n if (child.type === ColumnLayout) {\n return {\n props: { class: styles.columnLayout, l: [2, 1], m: [1] },\n children: (grandChild) =>\n grandChild.type === AccentBox\n ? {\n props: {\n class: styles.accentBox,\n backgroundColor: \"neutral\",\n },\n }\n : nestedHeadingRules(grandChild),\n };\n }\n if (child.type === ActionGroup) {\n /*\n * The footer is the deliberate way out, so its actions close\n * without asking again — the rule Flow's `Modal` writes for\n * `ActionGroup > Action`. An `Action` anywhere else in the modal is\n * an incidental close and is confirmed.\n */\n return {\n props: { class: styles.actionGroup, spacing: \"m\" },\n children: (grandChild) => {\n const props = withBypassedConfirmation(grandChild);\n return props ? { props } : undefined;\n },\n };\n }\n return undefined;\n };\n\n return () => {\n const className = [\n styles.overlay,\n props.offCanvas ? styles.offCanvas : styles.modal,\n styles.size(props.size),\n props.offCanvas && props.offCanvasOrientation === \"left\"\n ? styles.left\n : undefined,\n attrs.class,\n ]\n .filter(Boolean)\n .join(\" \");\n\n const texts = language.value?.startsWith(\"de\")\n ? confirmCloseTexts[\"de-DE\"]\n : confirmCloseTexts[\"en-US\"];\n\n const children: VNode[] = applyChildRules(\n slots.default?.(),\n childRules,\n ).map((child) =>\n child.type === Heading\n ? withHeaderChrome(child, texts.close, props.showCloseButton)\n : child,\n );\n\n if (props.confirmOnClose) {\n children.push(h(ConfirmCloseModal, { parent: controller.value }));\n }\n\n /* A UI component: Flow clears the host's props context around it. */\n return h(ClearPropsContext, null, () =>\n h(\n OverlayContent,\n {\n class: className,\n isOpen: props.isOpen ?? controller.value.isOpen.value,\n isDismissable: props.isDismissable,\n \"aria-labelledby\": headingId,\n onOpenChange: controller.value.setOpen,\n },\n () => children,\n ),\n );\n };\n },\n});\n\ncomposition(ConfirmCloseModal);\ncomposition(Modal);\n\nexport default Modal;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAkEA,IAAM,SAAS;CACb,SAAS;CACT,OAAO;CACP,WAAW;CACX,MAAM;CACN,OAAO,SAAoB,qBAAqB;CAChD,QAAQ;CACR,aAAa;CACb,aAAa;CACb,eAAe;CACf,cAAc;CACd,SAAS;CACT,cAAc;CACd,WAAW;CACX,aAAa;AACf;;;;;;;;;;;AAYA,IAAM,oBACJ,SACA,YACA,oBAEA,gBAAgB,UAAU,UAAU,CAClC,EAAE,KAAK,EAAE,OAAO,OAAO,YAAY,SAAS,KAAK,GACjD,EAAE,mBAAmB,YACnB,EAAE,QAAQ,EAAE,YAAY,EAAE,oBAAoB,KAAK,EAAE,SACnD,EACE,QACA;CACE,SAAS;CACT,OAAO;CACP,cAAc;CACd,OAAO,CACL,OAAO,aACP,oBAAoB,OAChB,OAAO,gBACP,oBAAoB,QAClB,OAAO,eACP,KAAA,CACR,CAAC,CACE,OAAO,OAAO,CAAC,CACf,KAAK,GAAG;AACb,SACM,EAAE,SAAS,CACnB,CACF,CACF,CACF,CAAC;;;;;;;;;AAUH,IAAM,4BAA4B,UAAwC;CACxE,IAAI,MAAM,SAAS,QACjB;CAGF,MAAM,WAAsB,CAAC;CAE7B,KAAK,MAAM,QAAQ,CAAC,cAAc,cAAc,GAAG;EACjD,MAAM,QAAQ,SAAS,MAAM,OAAO,IAAI;EAExC,IAAI,UAAU,KAAA,KAAa,UAAU,QAAQ,UAAU,OACrD;EAOF,SAAS,QAAQ,QACf,oBAAoB,KAAK,KAAM,OAAO,UAAU,YAAY,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AAmB,YAC1B,EACE,gBACA;IACE,OAAO;IACP,QAAQ,MAAM,UAAU,WAAW,MAAM,OAAO;IAChD,eAAe,MAAM;IACrB,mBAAmB;IACnB,cAAc,WAAW,MAAM;GACjC,SACM,QACR,CACF;EACF;CACF;AACF,CAAC;AAED,YAAY,iBAAiB;AAC7B,YAAY,KAAK"}
1
+ {"version":3,"file":"Modal.mjs","names":[],"sources":["../../../../../src/overlays/Modal.ts"],"sourcesContent":["import {\n AccentBox,\n ActionGroup,\n Button,\n ClearPropsContext,\n ColumnLayout,\n Content,\n Div,\n Header,\n Heading,\n OverlayContent,\n Section,\n Text,\n} from \"@/auto-generated\";\nimport { IconClose } from \"@/icons\";\nimport Action from \"@/components/Action\";\nimport { useLanguage } from \"@/composables/remoteContext\";\nimport { confirmCloseTexts } from \"@/overlays/locales\";\nimport {\n applyChildRules,\n dynamic,\n withSlotContent,\n type ChildRules,\n} from \"@/overlays/childProps\";\nimport { readProp } from \"@/lib/propKeys\";\nimport {\n createOverlayController,\n isOverlayController,\n provideOverlayContext,\n useConfirmOnCloseSource,\n useOwnController,\n useOverlayHandlers,\n type OverlayCloseHandler,\n type OverlayController,\n type OverlayOpenHandler,\n type OverlayOpenStateHandler,\n} from \"@/overlays/overlayController\";\nimport type { AnyRecord } from \"@/lib/types\";\nimport {\n defineComponent,\n h,\n onMounted,\n useId,\n watch,\n type Component,\n type PropType,\n type VNode,\n} from \"vue\";\nimport { composition } from \"@/lib/composition\";\nimport { useComponentUsage } from \"@/composables/useComponentUsage\";\n\nexport type ModalSize = \"s\" | \"m\" | \"l\";\n\n/*\n * Flow's `Modal` is a React composition, not a remote element: it renders an\n * `OverlayContent` and configures the components inside it through a props\n * context — the header, the content padding, the footer spacing. Both halves\n * are rebuilt here, so a Vue app writes `Modal` and not the overlay plumbing.\n *\n * The class names are Flow's own, taken from `Modal.module.scss` by way of the\n * generated `flow--…` names. They are internal, and repeating them is the price\n * of a composition that lives in React: the alternative — marking `Modal`\n * `@flr-generate`, so the host materialises the whole thing from one element —\n * would make this file unnecessary.\n */\nconst styles = {\n overlay: \"flow--overlay\",\n modal: \"flow--modal\",\n offCanvas: \"flow--modal--off-canvas\",\n left: \"flow--modal--left\",\n size: (size: ModalSize) => `flow--modal--size-${size}`,\n header: \"flow--modal--header\",\n headerTitle: \"flow--modal--header-title\",\n closeButton: \"flow--modal--close-button\",\n alwaysVisible: \"flow--modal--always-visible\",\n alwaysHidden: \"flow--modal--always-hidden\",\n content: \"flow--modal--content\",\n columnLayout: \"flow--modal--column-layout\",\n accentBox: \"flow--modal--accent-box\",\n actionGroup: \"flow--modal--action-group\",\n};\n\n/**\n * The chrome Flow puts around a modal's heading: the title in its own\n * container, and the close button beside it.\n *\n * Not props on the heading but a rebuild of what it was handed — the reason\n * `withSlotContent` exists. The close button clears the props context around\n * it, the way Flow's does, so the modal's own rules for `Button` do not reach\n * it, and it closes without asking again: this button _is_ the deliberate way\n * out.\n */\nconst withHeaderChrome = (\n heading: VNode,\n closeLabel: string,\n showCloseButton: boolean | undefined,\n): VNode =>\n withSlotContent(heading, (title) => [\n h(Div, { class: styles.headerTitle }, () => title),\n h(ClearPropsContext, null, () =>\n h(Action, { closeModal: { bypassConfirmation: true } }, () =>\n h(\n Button,\n {\n variant: \"plain\",\n color: \"secondary\",\n \"aria-label\": closeLabel,\n class: [\n styles.closeButton,\n showCloseButton === true\n ? styles.alwaysVisible\n : showCloseButton === false\n ? styles.alwaysHidden\n : undefined,\n ]\n .filter(Boolean)\n .join(\" \"),\n },\n () => h(IconClose),\n ),\n ),\n ),\n ]);\n\n/**\n * Lets an `Action` in the modal's footer close without asking again.\n *\n * Only where the action already closes something: Flow's props context rewrites\n * an existing `closeModal`/`closeOverlay` and adds none, and an `Action` that\n * merely runs something must not be turned into a close button. An explicit\n * `bypassConfirmation` in the object form wins, as in Flow.\n */\nconst withBypassedConfirmation = (child: VNode): AnyRecord | undefined => {\n if (child.type !== Action) {\n return undefined;\n }\n\n const bypassed: AnyRecord = {};\n\n for (const name of [\"closeModal\", \"closeOverlay\"]) {\n const value = readProp(child.props, name);\n\n if (value === undefined || value === null || value === false) {\n continue;\n }\n\n /*\n * A controller names the overlay, like a type name does — spread, it\n * would lose its identity and the action would close the modal instead.\n */\n bypassed[name] = dynamic(\n isOverlayController(value) || (typeof value === \"string\" && value !== \"\")\n ? { bypassConfirmation: true, overlay: value }\n : typeof value === \"object\"\n ? { bypassConfirmation: true, ...value }\n : { bypassConfirmation: true },\n );\n }\n\n return Object.keys(bypassed).length > 0 ? bypassed : undefined;\n};\n\n/*\n * Flow's `nestedHeadingProps`: inside the content, headings are one level\n * down, and a section drops its separator.\n */\nconst headingLevel3: ChildRules = (child) =>\n child.type === Heading ? { props: { level: 3 } } : undefined;\n\nconst nestedHeadingRules: ChildRules = (child) =>\n child.type === Heading\n ? { props: { level: 3 } }\n : child.type === Section\n ? {\n props: { hideSeparator: true },\n children: (grandChild) =>\n grandChild.type === Header\n ? { children: headingLevel3 }\n : headingLevel3(grandChild),\n }\n : child.type === Header\n ? { children: headingLevel3 }\n : undefined;\n\n/**\n * Asks before a modal that requires confirmation closes.\n *\n * Flow's `useCloseOverlayConfirmationController`: a controller of its own,\n * opened while the parent asks. A dismiss of this modal answers \"keep editing\",\n * and an answer from anywhere closes it again.\n *\n * Annotated rather than inferred — it renders a `Modal` and the `Modal` renders\n * it, and without an annotation TypeScript cannot break that cycle (TS7022).\n */\nconst ConfirmCloseModal: Component = defineComponent({\n name: \"ConfirmCloseModal\",\n\n props: {\n parent: {\n type: Object as PropType<OverlayController>,\n required: true,\n },\n },\n\n setup(props) {\n const language = useLanguage();\n const controller = createOverlayController();\n\n watch(\n () => props.parent.isConfirmingClose.value,\n (isConfirming) => (isConfirming ? controller.open() : controller.close()),\n { immediate: true },\n );\n\n controller.addOnClose(() => {\n if (props.parent.isConfirmingClose.value) {\n props.parent.cancelConfirmation();\n }\n });\n\n return () => {\n const texts = language.value?.startsWith(\"de\")\n ? confirmCloseTexts[\"de-DE\"]\n : confirmCloseTexts[\"en-US\"];\n\n return h(Modal, { controller }, () => [\n h(Heading, null, () => texts.heading),\n h(Content, null, () => h(Text, null, () => texts.text)),\n h(ActionGroup, null, () => [\n h(Action, { onAction: props.parent.confirmClose }, () =>\n h(Button, { color: \"danger\" }, () => texts.close),\n ),\n h(Action, { onAction: props.parent.cancelClose }, () =>\n h(\n Button,\n { color: \"secondary\", variant: \"soft\" },\n () => texts.keepOpen,\n ),\n ),\n ]),\n ]);\n };\n },\n});\n\nexport const Modal = defineComponent({\n name: \"Modal\",\n\n /* Like Flow's, a modal passes on only the props it knows. */\n inheritAttrs: false,\n\n props: {\n /** The size of the modal. @default \"s\" */\n size: { type: String as PropType<ModalSize>, default: \"s\" },\n /** Whether the modal is displayed as an off canvas. */\n offCanvas: { type: Boolean, default: false },\n /** Which side the off canvas comes from. @default \"right\" */\n offCanvasOrientation: {\n type: String as PropType<\"left\" | \"right\">,\n default: \"right\",\n },\n /** Whether a click outside closes the modal. @default true */\n isDismissable: { type: Boolean, default: true },\n /**\n * Whether the close button is always visible (`true`) or always hidden\n * (`false`). By default Flow decides by screen size.\n */\n showCloseButton: { type: Boolean, default: undefined },\n /**\n * Whether closing the modal has to be confirmed — use it to protect unsaved\n * changes.\n */\n confirmOnClose: { type: Boolean, default: undefined },\n /** A controller to open and close the modal from anywhere. */\n controller: {\n type: Object as PropType<OverlayController>,\n default: undefined,\n },\n /** Whether the modal is open. Use it to control the modal state. */\n isOpen: { type: Boolean, default: undefined },\n /**\n * Whether the modal is open initially, when it has a controller of its own\n * — not one from a trigger or the `controller` prop. @default false\n */\n isDefaultOpen: { type: Boolean, default: undefined },\n /** Called when the modal opens. Returning `false` keeps it closed. */\n onOpen: {\n type: Function as PropType<OverlayOpenHandler>,\n default: undefined,\n },\n /** Called when the modal closes. Returning `false` keeps it open. */\n onClose: {\n type: Function as PropType<OverlayCloseHandler>,\n default: undefined,\n },\n /**\n * Called with the new state whenever the modal opens or closes. Returning\n * `false` aborts the change.\n */\n onOpenChange: {\n type: Function as PropType<OverlayOpenStateHandler>,\n default: undefined,\n },\n },\n\n setup(props, { slots, attrs }) {\n /* Flow's React `Modal` is a `flowComponent` and reports itself. */\n onMounted(useComponentUsage(\"Modal\"));\n\n const language = useLanguage();\n /*\n * The dialog is labelled by its own heading, so the two need an id they\n * agree on. Flow generates one with `useId`; `useId` exists in Vue too,\n * and both sides end up with an id the host rewrites anyway — what has to\n * match is that the heading carries one at all.\n */\n const headingId = useId();\n /*\n * Three ways to own the state, in Flow's order of precedence: a\n * controller the app passes, the controller of a surrounding trigger, or\n * one of its own.\n */\n const controller = useOwnController(\n () => props.controller,\n \"Modal\",\n () => ({ isDefaultOpen: props.isDefaultOpen }),\n );\n\n // So an `Action` inside finds it.\n provideOverlayContext(\"Modal\", () => controller.value);\n\n useOverlayHandlers(() => controller.value, {\n onOpen: () => props.onOpen,\n onClose: () => props.onClose,\n onOpenChange: () => props.onOpenChange,\n });\n\n /*\n * The requirement lives on the controller, not on this component: what\n * asks for the confirmation is a close, and a close arrives at the\n * controller — from an `Action` inside, from the host's dismiss, or from\n * an app holding the controller itself. It is one source among others,\n * withdrawn when the modal unmounts or its controller changes, because\n * the controller usually outlives the modal.\n */\n useConfirmOnCloseSource(\n () => controller.value,\n () => props.confirmOnClose,\n );\n\n /* Flow's props context for the modal's children, rule for rule. */\n const childRules: ChildRules = (child) => {\n if (child.type === Heading) {\n return { props: { class: styles.header, level: 2, id: headingId } };\n }\n if (child.type === Content) {\n return {\n props: { class: styles.content },\n children: nestedHeadingRules,\n };\n }\n if (child.type === ColumnLayout) {\n return {\n props: { class: styles.columnLayout, l: [2, 1], m: [1] },\n children: (grandChild) =>\n grandChild.type === AccentBox\n ? {\n props: {\n class: styles.accentBox,\n backgroundColor: \"neutral\",\n },\n }\n : nestedHeadingRules(grandChild),\n };\n }\n if (child.type === ActionGroup) {\n /*\n * The footer is the deliberate way out, so its actions close\n * without asking again — the rule Flow's `Modal` writes for\n * `ActionGroup > Action`. An `Action` anywhere else in the modal is\n * an incidental close and is confirmed.\n */\n return {\n props: { class: styles.actionGroup, spacing: \"m\" },\n children: (grandChild) => {\n const props = withBypassedConfirmation(grandChild);\n return props ? { props } : undefined;\n },\n };\n }\n return undefined;\n };\n\n return () => {\n const className = [\n styles.overlay,\n props.offCanvas ? styles.offCanvas : styles.modal,\n styles.size(props.size),\n props.offCanvas && props.offCanvasOrientation === \"left\"\n ? styles.left\n : undefined,\n attrs.class,\n ]\n .filter(Boolean)\n .join(\" \");\n\n const texts = language.value?.startsWith(\"de\")\n ? confirmCloseTexts[\"de-DE\"]\n : confirmCloseTexts[\"en-US\"];\n\n const children: VNode[] = applyChildRules(\n slots.default?.(),\n childRules,\n ).map((child) =>\n child.type === Heading\n ? withHeaderChrome(child, texts.close, props.showCloseButton)\n : child,\n );\n\n if (controller.value.confirmOnClose.value) {\n children.push(h(ConfirmCloseModal, { parent: controller.value }));\n }\n\n /* A UI component: Flow clears the host's props context around it. */\n return h(ClearPropsContext, null, () =>\n h(\n OverlayContent,\n {\n class: className,\n isOpen: props.isOpen ?? controller.value.isOpen.value,\n isDismissable: props.isDismissable,\n \"aria-labelledby\": headingId,\n onOpenChange: controller.value.setOpen,\n },\n () => children,\n ),\n );\n };\n },\n});\n\ncomposition(ConfirmCloseModal);\ncomposition(Modal);\n\nexport default Modal;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAiEA,IAAM,SAAS;CACb,SAAS;CACT,OAAO;CACP,WAAW;CACX,MAAM;CACN,OAAO,SAAoB,qBAAqB;CAChD,QAAQ;CACR,aAAa;CACb,aAAa;CACb,eAAe;CACf,cAAc;CACd,SAAS;CACT,cAAc;CACd,WAAW;CACX,aAAa;AACf;;;;;;;;;;;AAYA,IAAM,oBACJ,SACA,YACA,oBAEA,gBAAgB,UAAU,UAAU,CAClC,EAAE,KAAK,EAAE,OAAO,OAAO,YAAY,SAAS,KAAK,GACjD,EAAE,mBAAmB,YACnB,EAAE,QAAQ,EAAE,YA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