@mittwald/flow-remote-vue-components 1.6.0-next.3 → 1.6.0-next.31

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 (42) hide show
  1. package/dist/js/components-base/src/index.mjs +4 -2
  2. package/dist/js/components-base/src/list/filter/ListDateRangeFilter.mjs +1 -0
  3. package/dist/js/components-base/src/list/filter/ListDateRangeFilter.mjs.map +1 -1
  4. package/dist/js/components-base/src/list/filter/ListFilter.mjs +4 -1
  5. package/dist/js/components-base/src/list/filter/ListFilter.mjs.map +1 -1
  6. package/dist/js/components-base/src/list/filter/dateRange.mjs +37 -13
  7. package/dist/js/components-base/src/list/filter/dateRange.mjs.map +1 -1
  8. package/dist/js/components-base/src/list/filter/dateTimeRangeFields.mjs +53 -0
  9. package/dist/js/components-base/src/list/filter/dateTimeRangeFields.mjs.map +1 -0
  10. package/dist/js/components-base/src/list/filter/formatDateRange.mjs +25 -0
  11. package/dist/js/components-base/src/list/filter/formatDateRange.mjs.map +1 -0
  12. package/dist/js/index.mjs +2 -1
  13. package/dist/js/remote-vue-components/src/components/DeprecationWarningProvider.mjs +15 -9
  14. package/dist/js/remote-vue-components/src/components/DeprecationWarningProvider.mjs.map +1 -1
  15. package/dist/js/remote-vue-components/src/list/ActiveFilters.mjs +8 -5
  16. package/dist/js/remote-vue-components/src/list/ActiveFilters.mjs.map +1 -1
  17. package/dist/js/remote-vue-components/src/list/AllFiltersModal.mjs +3 -2
  18. package/dist/js/remote-vue-components/src/list/AllFiltersModal.mjs.map +1 -1
  19. package/dist/js/remote-vue-components/src/list/DateTimeRangeFields.mjs +100 -0
  20. package/dist/js/remote-vue-components/src/list/DateTimeRangeFields.mjs.map +1 -0
  21. package/dist/js/remote-vue-components/src/list/Header.mjs +11 -7
  22. package/dist/js/remote-vue-components/src/list/Header.mjs.map +1 -1
  23. package/dist/js/remote-vue-components/src/list/dateRangeFilter.mjs +14 -6
  24. package/dist/js/remote-vue-components/src/list/dateRangeFilter.mjs.map +1 -1
  25. package/dist/js/remote-vue-components/src/list/locales.mjs +14 -0
  26. package/dist/js/remote-vue-components/src/list/locales.mjs.map +1 -1
  27. package/dist/js/remote-vue-components/src/list/styles.mjs +7 -1
  28. package/dist/js/remote-vue-components/src/list/styles.mjs.map +1 -1
  29. package/dist/js/remote-vue-components/src/version.mjs +1 -1
  30. package/dist/types/_bundled/flow-components-base/index.d.ts +3 -1
  31. package/dist/types/_bundled/flow-components-base/list/filter/ListFilter.d.ts +2 -0
  32. package/dist/types/_bundled/flow-components-base/list/filter/dateRange.d.ts +24 -1
  33. package/dist/types/_bundled/flow-components-base/list/filter/dateTimeRangeFields.d.ts +34 -0
  34. package/dist/types/_bundled/flow-components-base/list/filter/formatDateRange.d.ts +7 -0
  35. package/dist/types/components/DeprecationWarningProvider.d.ts +2 -4
  36. package/dist/types/list/DateTimeRangeFields.d.ts +43 -0
  37. package/dist/types/list/dateRangeFilter.d.ts +6 -6
  38. package/dist/types/list/index.d.ts +1 -0
  39. package/dist/types/list/locales.d.ts +14 -0
  40. package/dist/types/list/styles.d.ts +6 -0
  41. package/dist/types/list/types.d.ts +8 -2
  42. package/package.json +14 -14
@@ -3,8 +3,10 @@ import "./lib/array.mjs";
3
3
  import "./list/ListModelContext.mjs";
4
4
  import "./list/filter/ListFilterValue.mjs";
5
5
  import { ListFilter } from "./list/filter/ListFilter.mjs";
6
- import "./list/filter/dateRange.mjs";
6
+ import { resolveListDateRange } from "./list/filter/dateRange.mjs";
7
7
  import { ListDateRangeFilter } from "./list/filter/ListDateRangeFilter.mjs";
8
+ import { formatListDateRange } from "./list/filter/formatDateRange.mjs";
9
+ import { getListDateTimeRangeUpdate, isListDateTimeRangeEndBeforeStart, listDateTimeRangeFieldsFromValue, toListCalendarDate, toListTime } from "./list/filter/dateTimeRangeFields.mjs";
8
10
  import "./list/item/ListItem.mjs";
9
11
  import { ListItemCollection } from "./list/item/ListItemCollection.mjs";
10
12
  import { ListLoaderState } from "./list/loading/ListLoaderState.mjs";
@@ -14,4 +16,4 @@ import { ListSearch } from "./list/search/ListSearch.mjs";
14
16
  import { ListSorting, mergeHiddenSorting } from "./list/sorting/ListSorting.mjs";
15
17
  import { ListTable } from "./list/table/ListTable.mjs";
16
18
  import { ListViewMode } from "./list/viewMode/ListViewMode.mjs";
17
- export { ActionState, ListBatchesController, ListDateRangeFilter, ListFilter, ListItemCollection, ListLoaderState, ListSearch, ListSorting, ListTable, ListViewMode, getListDataLoaderOptions, mergeHiddenSorting };
19
+ export { ActionState, ListBatchesController, ListDateRangeFilter, ListFilter, ListItemCollection, ListLoaderState, ListSearch, ListSorting, ListTable, ListViewMode, formatListDateRange, getListDataLoaderOptions, getListDateTimeRangeUpdate, isListDateTimeRangeEndBeforeStart, listDateTimeRangeFieldsFromValue, mergeHiddenSorting, resolveListDateRange, toListCalendarDate, toListTime };
@@ -19,6 +19,7 @@ var ListDateRangeFilter = class extends ListFilter {
19
19
  }
20
20
  setValue(range) {
21
21
  this.getTableColumn().setFilterValue(range);
22
+ this.notifyFilterUpdated(range ? [range] : []);
22
23
  }
23
24
  };
24
25
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"ListDateRangeFilter.mjs","names":[],"sources":["../../../../../../../components-base/src/list/filter/ListDateRangeFilter.ts"],"sourcesContent":["import { ListFilter } from \"./ListFilter\";\nimport {\n applyDateRangeColumnDef,\n isListDateRange,\n type ListDateRange,\n} from \"./dateRange\";\nimport type { PropertyName } from \"../types\";\nimport type { ColumnDef } from \"@tanstack/table-core\";\n\n/**\n * A filter over a span of days rather than over a set of values.\n *\n * Everything except the control that picks the range: the table column, the\n * comparison and the stored value are the same in every binding, and what a\n * calendar looks like is not. A binding subclasses this to add its own calendar\n * options.\n */\nexport class ListDateRangeFilter<\n T = never,\n TProp extends PropertyName<T> = never,\n TRendered = unknown,\n> extends ListFilter<T, TProp, never, TRendered> {\n public override updateTableColumnDef(def: ColumnDef<T>): void {\n applyDateRangeColumnDef(def);\n }\n\n public override getValue(): ListDateRange | null {\n const value = super.getValue();\n return isListDateRange(value) ? value : null;\n }\n\n public setValue(range: ListDateRange | null): void {\n this.getTableColumn().setFilterValue(range);\n }\n}\n\nexport default ListDateRangeFilter;\n"],"mappings":";;;;;;;;;;;AAiBA,IAAa,sBAAb,cAIU,WAAuC;CAC/C,qBAAqC,KAAyB;EAC5D,wBAAwB,GAAG;CAC7B;CAEA,WAAiD;EAC/C,MAAM,QAAQ,MAAM,SAAS;EAC7B,OAAO,gBAAgB,KAAK,IAAI,QAAQ;CAC1C;CAEA,SAAgB,OAAmC;EACjD,KAAK,eAAe,CAAC,CAAC,eAAe,KAAK;CAC5C;AACF"}
1
+ {"version":3,"file":"ListDateRangeFilter.mjs","names":[],"sources":["../../../../../../../components-base/src/list/filter/ListDateRangeFilter.ts"],"sourcesContent":["import { ListFilter } from \"./ListFilter\";\nimport {\n applyDateRangeColumnDef,\n isListDateRange,\n type ListDateRange,\n} from \"./dateRange\";\nimport type { PropertyName } from \"../types\";\nimport type { ColumnDef } from \"@tanstack/table-core\";\n\n/**\n * A filter over a span of days rather than over a set of values.\n *\n * Everything except the control that picks the range: the table column, the\n * comparison and the stored value are the same in every binding, and what a\n * calendar looks like is not. A binding subclasses this to add its own calendar\n * options.\n */\nexport class ListDateRangeFilter<\n T = never,\n TProp extends PropertyName<T> = never,\n TRendered = unknown,\n> extends ListFilter<T, TProp, never, TRendered> {\n public override updateTableColumnDef(def: ColumnDef<T>): void {\n applyDateRangeColumnDef(def);\n }\n\n public override getValue(): ListDateRange | null {\n const value = super.getValue();\n return isListDateRange(value) ? value : null;\n }\n\n public setValue(range: ListDateRange | null): void {\n this.getTableColumn().setFilterValue(range);\n this.notifyFilterUpdated(range ? [range] : []);\n }\n}\n\nexport default ListDateRangeFilter;\n"],"mappings":";;;;;;;;;;;AAiBA,IAAa,sBAAb,cAIU,WAAuC;CAC/C,qBAAqC,KAAyB;EAC5D,wBAAwB,GAAG;CAC7B;CAEA,WAAiD;EAC/C,MAAM,QAAQ,MAAM,SAAS;EAC7B,OAAO,gBAAgB,KAAK,IAAI,QAAQ;CAC1C;CAEA,SAAgB,OAAmC;EACjD,KAAK,eAAe,CAAC,CAAC,eAAe,KAAK;EAC1C,KAAK,oBAAoB,QAAQ,CAAC,KAAK,IAAI,CAAC,CAAC;CAC/C;AACF"}
@@ -164,7 +164,10 @@ var ListFilter = class {
164
164
  this.callOnChangedHandlers(updatedValue);
165
165
  }
166
166
  callOnChangedHandlers(newValue) {
167
- const values = toArray(newValue).map((v) => v?.value);
167
+ this.notifyFilterUpdated(toArray(newValue).map((v) => v?.value));
168
+ }
169
+ /** Tells the listeners — the list resetting its batches among them. */
170
+ notifyFilterUpdated(values) {
168
171
  this.onFilterChangeCallbacks.forEach((cb) => cb(values));
169
172
  }
170
173
  hasChanges() {
@@ -1 +1 @@
1
- {"version":3,"file":"ListFilter.mjs","names":[],"sources":["../../../../../../../components-base/src/list/filter/ListFilter.ts"],"sourcesContent":["import { toArray } from \"../../lib/array\";\nimport { getListColumn, type ListModelContext } from \"../ListModelContext\";\nimport type { ListSettingsOperationOptions } from \"../settings/types\";\nimport { customPropertyPrefix } from \"../types\";\nimport type { PropertyName, PropertyValueRenderMethod } from \"../types\";\nimport { ListFilterValue } from \"./ListFilterValue\";\nimport type {\n FilterMatcher,\n FilterMode,\n FilterUpdatedCallback,\n ListFilterShape,\n} from \"./types\";\nimport type {\n Column,\n ColumnDef,\n ColumnFilter,\n InitialTableState,\n} from \"@tanstack/table-core\";\nimport { getProperty } from \"dot-prop\";\nimport { difference, unique } from \"remeda\";\n\nconst equalsPropertyMatcher: FilterMatcher<unknown, never, never> = (\n filterValue,\n propertyValue,\n) => filterValue === propertyValue;\n\n/** From how many values on a multiple-choice filter offers \"Select all\". */\nconst selectAllMinValueCount = 6;\n\nconst stringCastRenderMethod: PropertyValueRenderMethod<unknown, never> = (\n value,\n) => String(value) as never;\n\n/** What `storeFilters` needs of a filter, and nothing more. */\ninterface StorableFilter {\n readonly storageKey: string;\n getArrayValue(): { id: string }[];\n}\n\n/**\n * One filter of a list: its values, which of them are on, and how that is\n * persisted.\n *\n * Framework-free apart from one thing, which is why `TRendered` exists: a\n * filter value has to be _shown_, and what \"shown\" is belongs to the binding.\n * React's `Filter` fills it with `ReactNode`; the default is `unknown`, so the\n * core can be read without deciding.\n *\n * The selected values live in the TanStack table's column filter, not here.\n * This translates: ids to values, values to a predicate, a toggle to a new\n * column filter.\n */\nexport class ListFilter<\n T = never,\n TProp extends PropertyName<T> = never,\n TMatchValue = never,\n TRendered = unknown,\n> {\n private _values?: ListFilterValue<TRendered>[] | undefined;\n private valuesFromTableState?: {\n facets: Map<unknown, number>;\n values: ListFilterValue<TRendered>[];\n };\n public readonly context: ListModelContext<T>;\n public readonly property: TProp;\n public readonly mode: FilterMode;\n public readonly matcher: FilterMatcher<T, never, never>;\n public readonly renderItem: PropertyValueRenderMethod<TMatchValue, TRendered>;\n public readonly name?: string;\n public readonly autosave: boolean;\n public readonly manualSave: boolean;\n private readonly onFilterChangeCallbacks = new Set<FilterUpdatedCallback>();\n private readonly defaultSelectedValues?: ListFilterValue<TRendered>[];\n public readonly priority: \"primary\" | \"secondary\";\n public readonly storageKey: string;\n\n public constructor(\n context: ListModelContext<T>,\n shape: ListFilterShape<T, TProp, TMatchValue, TRendered>,\n ) {\n const {\n autosave = context.settingsDefaults?.filters?.autosave ?? false,\n manualSave = context.settingsDefaults?.filters?.manualSave ?? true,\n property,\n mode = \"some\",\n values,\n matcher = equalsPropertyMatcher,\n renderItem = stringCastRenderMethod as PropertyValueRenderMethod<\n TMatchValue,\n TRendered\n >,\n priority = \"primary\",\n name,\n defaultSelected,\n onChange,\n } = shape;\n\n this.context = context;\n this.autosave = autosave;\n this.manualSave = manualSave;\n this.property = property;\n this.storageKey = String(property);\n this.mode = mode;\n this._values = values?.map((v) => ListFilterValue.create(this, v));\n this.matcher = matcher;\n this.renderItem = renderItem;\n this.name = name;\n this.priority = priority;\n this.defaultSelectedValues = defaultSelected?.map((v) =>\n ListFilterValue.create(this, v),\n );\n if (onChange) {\n this.onFilterChangeCallbacks.add(onChange);\n }\n }\n\n public updateInitialState(initialState: InitialTableState): void {\n const initialIds = this.getInitialSelectedIds();\n\n if (initialIds?.length) {\n initialState.columnFilters = [\n ...(initialState.columnFilters ?? []),\n {\n id: this.property as string,\n value: initialIds,\n },\n ];\n }\n }\n\n private getInitialSelectedIds(): string[] | undefined {\n return (\n this.getStoredSelectedIds({\n autosave: this.autosave,\n manualSave: this.manualSave,\n }) ?? this.defaultSelectedValues?.map((v) => v.id)\n );\n }\n\n private getStoredSelectedIds(\n options: ListSettingsOperationOptions,\n ): string[] | undefined {\n return this.context.settings?.get(\"activeFilters\", options)?.[\n this.storageKey\n ];\n }\n\n private getStoredSelectedValues(\n options: ListSettingsOperationOptions,\n ): ListFilterValue<TRendered>[] | undefined {\n return this.getStoredSelectedIds(options)\n ?.map((id) => this.values.find((v) => v.id === id))\n .filter((v): v is ListFilterValue<TRendered> => v !== undefined);\n }\n\n /**\n * Writes every filter's selection in one go — they share a settings key.\n *\n * Takes the two members it reads rather than a `ListFilter<any, …>`: a\n * `Table<never>` is not assignable to a `Table<any>` (a row model sits in a\n * contravariant position deep inside), so a list of concrete filters would\n * not go in.\n */\n public static storeFilters<T>(\n context: ListModelContext<T>,\n filters: StorableFilter[],\n options: ListSettingsOperationOptions,\n ): void {\n const data = Object.fromEntries(\n filters.map((filter) => [\n filter.storageKey,\n filter.getArrayValue().map((v) => v.id),\n ]),\n );\n\n context.settings?.store(\"activeFilters\", data, options);\n }\n\n public updateTableColumnDef(def: ColumnDef<T>): void {\n def.enableColumnFilter = true;\n def.filterFn = this.getTableFilterFn();\n }\n\n private getTableFilterFn(): ColumnDef<T>[\"filterFn\"] {\n return (row, _, filterValue) => {\n const propertyAsString = this.property as string;\n\n /*\n * A custom property is not on the item, so the matcher gets the item\n * itself and decides.\n */\n const filterBy = propertyAsString.startsWith(customPropertyPrefix)\n ? row.original\n : getProperty(row.original as object, propertyAsString);\n\n return this.checkFilterMatches(filterBy, filterValue);\n };\n }\n\n private checkFilterMatches(\n property: unknown,\n filterValueInput: unknown,\n ): boolean {\n if (filterValueInput === null) {\n return true;\n }\n\n const predicate = (filterValue: ListFilterValue<TRendered>) =>\n this.matcher(filterValue.value as never, property as never);\n\n const toFilterValue = (something: unknown) =>\n ListFilterValue.create(this, something);\n\n if (this.mode === \"all\") {\n return toArray(filterValueInput).map(toFilterValue).every(predicate);\n } else if (this.mode === \"some\") {\n const filterArr = toArray(filterValueInput);\n return (\n filterArr.length === 0 || filterArr.map(toFilterValue).some(predicate)\n );\n } else if (this.mode === \"one\") {\n const oneValue = Array.isArray(filterValueInput)\n ? filterValueInput[0]\n : filterValueInput;\n return predicate(toFilterValue(oneValue));\n }\n\n throw new Error(`Unknown filter mode '${this.mode}'`);\n }\n\n protected getTableColumnFilter(): ColumnFilter | undefined {\n return this.context.dataTable\n .getState()\n .columnFilters.find((f) => f.id === this.property);\n }\n\n protected getTableColumn(): Column<T> {\n return getListColumn(this.context.dataTable, this.property);\n }\n\n public getValue(): unknown {\n return this.getTableColumnFilter()?.value ?? null;\n }\n\n /*\n * Rebuilt only when TanStack hands out a new map: it memoizes the faceted\n * values and replaces the map when the data changes. Without this, every\n * row the filter function checks re-hashes every value — `getArrayValue()`\n * resolves each stored id through `values`.\n */\n private getValuesFromTableState(): ListFilterValue<TRendered>[] {\n const facets = this.getTableColumn().getFacetedUniqueValues();\n\n if (this.valuesFromTableState?.facets !== facets) {\n this.valuesFromTableState = {\n facets,\n values: unique(\n Array.from(facets.keys())\n .flatMap((v) => v)\n .filter((v) => v !== undefined && v !== null),\n ).map((v) => ListFilterValue.create(this, v)),\n };\n }\n\n return this.valuesFromTableState.values;\n }\n\n private checkIfValueIsUnknown(value: ListFilterValue<TRendered>): boolean {\n return !this.values.some((v) => v.id === value.id);\n }\n\n /**\n * Drops a selection the data no longer offers — a stored filter value whose\n * item is gone would otherwise filter everything away with no way to undo\n * it.\n */\n public deleteUnknownFilterValues(): void {\n /* Values the data offers are by definition known. */\n if (this._values === undefined) {\n return;\n }\n\n for (const currentValues of this.getArrayValue()) {\n if (this.checkIfValueIsUnknown(currentValues)) {\n this.deactivateValue(currentValues);\n }\n }\n }\n\n /**\n * The values the filter offers — the ones it was given, or the ones the data\n * has.\n *\n * Follows the table, not a snapshot. A binding that keeps one filter instance\n * for the list's lifetime would otherwise hold the answer from before the\n * first batch arrived: an async loader gives the header an empty menu and\n * never fills it. The values are cached per faceted-values map, which\n * TanStack replaces when the data changes.\n */\n public get values(): ListFilterValue<TRendered>[] {\n return this._values ?? this.getValuesFromTableState();\n }\n\n public getArrayValue(): ListFilterValue<TRendered>[] {\n const value = this.getValue();\n return value === null\n ? []\n : toArray(value).map((v) => ListFilterValue.create(this, v));\n }\n\n public isValueActive(value: ListFilterValue<TRendered>): boolean {\n return this.getArrayValue().some((v) => v.equals(value));\n }\n\n public isActive(): boolean {\n return this.getArrayValue().length > 0;\n }\n\n public deactivateValue(value: ListFilterValue<TRendered>): void {\n const currentValueAsArray = this.getArrayValue();\n\n const updatedValue =\n this.mode === \"all\" || this.mode === \"some\"\n ? currentValueAsArray.filter((v) => !v.equals(value))\n : null;\n\n this.getTableColumn().setFilterValue(updatedValue);\n this.callOnChangedHandlers(updatedValue);\n }\n\n private callOnChangedHandlers(\n newValue: ListFilterValue<TRendered>[] | ListFilterValue<TRendered> | null,\n ): void {\n const values = toArray(newValue).map((v) => v?.value);\n this.onFilterChangeCallbacks.forEach((cb) => cb(values));\n }\n\n public hasChanges(): boolean {\n const currentIds = this.getArrayValue().map((v) => v.id);\n\n const defaultIds =\n this.getStoredSelectedIds({ autosave: false }) ??\n this.defaultSelectedValues?.map((v) => v.id) ??\n [];\n\n return (\n currentIds.length !== defaultIds.length ||\n difference(currentIds, defaultIds).length > 0\n );\n }\n\n public isStoringAvailable(): boolean {\n return !!this.context.settings && this.manualSave;\n }\n\n public resetValues(): void {\n const storedValues =\n this.getStoredSelectedValues({ autosave: false }) ??\n this.defaultSelectedValues;\n\n const resetTo =\n storedValues ?? (this.mode === \"all\" || this.mode === \"some\" ? [] : null);\n\n this.getTableColumn().setFilterValue(resetTo);\n this.callOnChangedHandlers(resetTo);\n }\n\n public clear(): void {\n this.getTableColumn().setFilterValue(null);\n this.callOnChangedHandlers(null);\n }\n\n public toggleValue(newValue: ListFilterValue<TRendered>): void {\n const currentValueAsArray = this.getArrayValue();\n\n let updatedValue:\n ListFilterValue<TRendered>[] | ListFilterValue<TRendered> | null;\n\n if (this.mode === \"all\" || this.mode === \"some\") {\n updatedValue = newValue.isActive\n ? currentValueAsArray.filter((v) => !v.equals(newValue))\n : [...currentValueAsArray, newValue];\n } else {\n updatedValue = newValue.isActive ? null : newValue;\n }\n\n this.getTableColumn().setFilterValue(updatedValue);\n this.callOnChangedHandlers(updatedValue);\n }\n\n /**\n * Whether the filter offers \"Select all\" — a `some` filter with enough\n * values.\n */\n public get isSelectAllAvailable(): boolean {\n return this.mode === \"some\" && this.values.length >= selectAllMinValueCount;\n }\n\n public isEveryValueActive(): boolean {\n return this.values.every((v) => v.isActive);\n }\n\n public selectAll(): void {\n this.setArrayValue(this.values);\n }\n\n /** Makes exactly these values active — what a multiple-selection menu reports. */\n public setActiveValueIds(ids: Iterable<unknown>): void {\n const idSet = new Set(ids);\n this.setArrayValue(this.values.filter((v) => idSet.has(v.id)));\n }\n\n public deselectAll(): void {\n this.setArrayValue([]);\n }\n\n private setArrayValue(value: ListFilterValue<TRendered>[]): void {\n this.getTableColumn().setFilterValue(value);\n this.callOnChangedHandlers(value);\n }\n\n public onFilterUpdated(cb: () => unknown): void {\n this.onFilterChangeCallbacks.add(cb);\n }\n}\n\nexport default ListFilter;\n"],"mappings":";;;;;;AAqBA,IAAM,yBACJ,aACA,kBACG,gBAAgB;;AAGrB,IAAM,yBAAyB;AAE/B,IAAM,0BACJ,UACG,OAAO,KAAK;;;;;;;;;;;;;;AAqBjB,IAAa,aAAb,MAKE;CACA;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e,YAAY;EACjD,KAAK,sBAAsB,YAAY;CACzC;;;;;CAMA,IAAW,uBAAgC;EACzC,OAAO,KAAK,SAAS,UAAU,KAAK,OAAO,UAAU;CACvD;CAEA,qBAAqC;EACnC,OAAO,KAAK,OAAO,OAAO,MAAM,EAAE,QAAQ;CAC5C;CAEA,YAAyB;EACvB,KAAK,cAAc,KAAK,MAAM;CAChC;;CAGA,kBAAyB,KAA8B;EACrD,MAAM,QAAQ,IAAI,IAAI,GAAG;EACzB,KAAK,cAAc,KAAK,OAAO,QAAQ,MAAM,MAAM,IAAI,EAAE,EAAE,CAAC,CAAC;CAC/D;CAEA,cAA2B;EACzB,KAAK,cAAc,CAAC,CAAC;CACvB;CAEA,cAAsB,OAA2C;EAC/D,KAAK,eAAe,CAAC,CAAC,eAAe,KAAK;EAC1C,KAAK,sBAAsB,KAAK;CAClC;CAEA,gBAAuB,IAAyB;EAC9C,KAAK,wBAAwB,IAAI,EAAE;CACrC;AACF"}
1
+ {"version":3,"file":"ListFilter.mjs","names":[],"sources":["../../../../../../../components-base/src/list/filter/ListFilter.ts"],"sourcesContent":["import { toArray } from \"../../lib/array\";\nimport { getListColumn, type ListModelContext } from \"../ListModelContext\";\nimport type { ListSettingsOperationOptions } from \"../settings/types\";\nimport { customPropertyPrefix } from \"../types\";\nimport type { PropertyName, PropertyValueRenderMethod } from \"../types\";\nimport { ListFilterValue } from \"./ListFilterValue\";\nimport type {\n FilterMatcher,\n FilterMode,\n FilterUpdatedCallback,\n ListFilterShape,\n} from \"./types\";\nimport type {\n Column,\n ColumnDef,\n ColumnFilter,\n InitialTableState,\n} from \"@tanstack/table-core\";\nimport { getProperty } from \"dot-prop\";\nimport { difference, unique } from \"remeda\";\n\nconst equalsPropertyMatcher: FilterMatcher<unknown, never, never> = (\n filterValue,\n propertyValue,\n) => filterValue === propertyValue;\n\n/** From how many values on a multiple-choice filter offers \"Select all\". */\nconst selectAllMinValueCount = 6;\n\nconst stringCastRenderMethod: PropertyValueRenderMethod<unknown, never> = (\n value,\n) => String(value) as never;\n\n/** What `storeFilters` needs of a filter, and nothing more. */\ninterface StorableFilter {\n readonly storageKey: string;\n getArrayValue(): { id: string }[];\n}\n\n/**\n * One filter of a list: its values, which of them are on, and how that is\n * persisted.\n *\n * Framework-free apart from one thing, which is why `TRendered` exists: a\n * filter value has to be _shown_, and what \"shown\" is belongs to the binding.\n * React's `Filter` fills it with `ReactNode`; the default is `unknown`, so the\n * core can be read without deciding.\n *\n * The selected values live in the TanStack table's column filter, not here.\n * This translates: ids to values, values to a predicate, a toggle to a new\n * column filter.\n */\nexport class ListFilter<\n T = never,\n TProp extends PropertyName<T> = never,\n TMatchValue = never,\n TRendered = unknown,\n> {\n private _values?: ListFilterValue<TRendered>[] | undefined;\n private valuesFromTableState?: {\n facets: Map<unknown, number>;\n values: ListFilterValue<TRendered>[];\n };\n public readonly context: ListModelContext<T>;\n public readonly property: TProp;\n public readonly mode: FilterMode;\n public readonly matcher: FilterMatcher<T, never, never>;\n public readonly renderItem: PropertyValueRenderMethod<TMatchValue, TRendered>;\n public readonly name?: string;\n public readonly autosave: boolean;\n public readonly manualSave: boolean;\n private readonly onFilterChangeCallbacks = new Set<FilterUpdatedCallback>();\n private readonly defaultSelectedValues?: ListFilterValue<TRendered>[];\n public readonly priority: \"primary\" | \"secondary\";\n public readonly storageKey: string;\n\n public constructor(\n context: ListModelContext<T>,\n shape: ListFilterShape<T, TProp, TMatchValue, TRendered>,\n ) {\n const {\n autosave = context.settingsDefaults?.filters?.autosave ?? false,\n manualSave = context.settingsDefaults?.filters?.manualSave ?? true,\n property,\n mode = \"some\",\n values,\n matcher = equalsPropertyMatcher,\n renderItem = stringCastRenderMethod as PropertyValueRenderMethod<\n TMatchValue,\n TRendered\n >,\n priority = \"primary\",\n name,\n defaultSelected,\n onChange,\n } = shape;\n\n this.context = context;\n this.autosave = autosave;\n this.manualSave = manualSave;\n this.property = property;\n this.storageKey = String(property);\n this.mode = mode;\n this._values = values?.map((v) => ListFilterValue.create(this, v));\n this.matcher = matcher;\n this.renderItem = renderItem;\n this.name = name;\n this.priority = priority;\n this.defaultSelectedValues = defaultSelected?.map((v) =>\n ListFilterValue.create(this, v),\n );\n if (onChange) {\n this.onFilterChangeCallbacks.add(onChange);\n }\n }\n\n public updateInitialState(initialState: InitialTableState): void {\n const initialIds = this.getInitialSelectedIds();\n\n if (initialIds?.length) {\n initialState.columnFilters = [\n ...(initialState.columnFilters ?? []),\n {\n id: this.property as string,\n value: initialIds,\n },\n ];\n }\n }\n\n private getInitialSelectedIds(): string[] | undefined {\n return (\n this.getStoredSelectedIds({\n autosave: this.autosave,\n manualSave: this.manualSave,\n }) ?? this.defaultSelectedValues?.map((v) => v.id)\n );\n }\n\n private getStoredSelectedIds(\n options: ListSettingsOperationOptions,\n ): string[] | undefined {\n return this.context.settings?.get(\"activeFilters\", options)?.[\n this.storageKey\n ];\n }\n\n private getStoredSelectedValues(\n options: ListSettingsOperationOptions,\n ): ListFilterValue<TRendered>[] | undefined {\n return this.getStoredSelectedIds(options)\n ?.map((id) => this.values.find((v) => v.id === id))\n .filter((v): v is ListFilterValue<TRendered> => v !== undefined);\n }\n\n /**\n * Writes every filter's selection in one go — they share a settings key.\n *\n * Takes the two members it reads rather than a `ListFilter<any, …>`: a\n * `Table<never>` is not assignable to a `Table<any>` (a row model sits in a\n * contravariant position deep inside), so a list of concrete filters would\n * not go in.\n */\n public static storeFilters<T>(\n context: ListModelContext<T>,\n filters: StorableFilter[],\n options: ListSettingsOperationOptions,\n ): void {\n const data = Object.fromEntries(\n filters.map((filter) => [\n filter.storageKey,\n filter.getArrayValue().map((v) => v.id),\n ]),\n );\n\n context.settings?.store(\"activeFilters\", data, options);\n }\n\n public updateTableColumnDef(def: ColumnDef<T>): void {\n def.enableColumnFilter = true;\n def.filterFn = this.getTableFilterFn();\n }\n\n private getTableFilterFn(): ColumnDef<T>[\"filterFn\"] {\n return (row, _, filterValue) => {\n const propertyAsString = this.property as string;\n\n /*\n * A custom property is not on the item, so the matcher gets the item\n * itself and decides.\n */\n const filterBy = propertyAsString.startsWith(customPropertyPrefix)\n ? row.original\n : getProperty(row.original as object, propertyAsString);\n\n return this.checkFilterMatches(filterBy, filterValue);\n };\n }\n\n private checkFilterMatches(\n property: unknown,\n filterValueInput: unknown,\n ): boolean {\n if (filterValueInput === null) {\n return true;\n }\n\n const predicate = (filterValue: ListFilterValue<TRendered>) =>\n this.matcher(filterValue.value as never, property as never);\n\n const toFilterValue = (something: unknown) =>\n ListFilterValue.create(this, something);\n\n if (this.mode === \"all\") {\n return toArray(filterValueInput).map(toFilterValue).every(predicate);\n } else if (this.mode === \"some\") {\n const filterArr = toArray(filterValueInput);\n return (\n filterArr.length === 0 || filterArr.map(toFilterValue).some(predicate)\n );\n } else if (this.mode === \"one\") {\n const oneValue = Array.isArray(filterValueInput)\n ? filterValueInput[0]\n : filterValueInput;\n return predicate(toFilterValue(oneValue));\n }\n\n throw new Error(`Unknown filter mode '${this.mode}'`);\n }\n\n protected getTableColumnFilter(): ColumnFilter | undefined {\n return this.context.dataTable\n .getState()\n .columnFilters.find((f) => f.id === this.property);\n }\n\n protected getTableColumn(): Column<T> {\n return getListColumn(this.context.dataTable, this.property);\n }\n\n public getValue(): unknown {\n return this.getTableColumnFilter()?.value ?? null;\n }\n\n /*\n * Rebuilt only when TanStack hands out a new map: it memoizes the faceted\n * values and replaces the map when the data changes. Without this, every\n * row the filter function checks re-hashes every value — `getArrayValue()`\n * resolves each stored id through `values`.\n */\n private getValuesFromTableState(): ListFilterValue<TRendered>[] {\n const facets = this.getTableColumn().getFacetedUniqueValues();\n\n if (this.valuesFromTableState?.facets !== facets) {\n this.valuesFromTableState = {\n facets,\n values: unique(\n Array.from(facets.keys())\n .flatMap((v) => v)\n .filter((v) => v !== undefined && v !== null),\n ).map((v) => ListFilterValue.create(this, v)),\n };\n }\n\n return this.valuesFromTableState.values;\n }\n\n private checkIfValueIsUnknown(value: ListFilterValue<TRendered>): boolean {\n return !this.values.some((v) => v.id === value.id);\n }\n\n /**\n * Drops a selection the data no longer offers — a stored filter value whose\n * item is gone would otherwise filter everything away with no way to undo\n * it.\n */\n public deleteUnknownFilterValues(): void {\n /* Values the data offers are by definition known. */\n if (this._values === undefined) {\n return;\n }\n\n for (const currentValues of this.getArrayValue()) {\n if (this.checkIfValueIsUnknown(currentValues)) {\n this.deactivateValue(currentValues);\n }\n }\n }\n\n /**\n * The values the filter offers — the ones it was given, or the ones the data\n * has.\n *\n * Follows the table, not a snapshot. A binding that keeps one filter instance\n * for the list's lifetime would otherwise hold the answer from before the\n * first batch arrived: an async loader gives the header an empty menu and\n * never fills it. The values are cached per faceted-values map, which\n * TanStack replaces when the data changes.\n */\n public get values(): ListFilterValue<TRendered>[] {\n return this._values ?? this.getValuesFromTableState();\n }\n\n public getArrayValue(): ListFilterValue<TRendered>[] {\n const value = this.getValue();\n return value === null\n ? []\n : toArray(value).map((v) => ListFilterValue.create(this, v));\n }\n\n public isValueActive(value: ListFilterValue<TRendered>): boolean {\n return this.getArrayValue().some((v) => v.equals(value));\n }\n\n public isActive(): boolean {\n return this.getArrayValue().length > 0;\n }\n\n public deactivateValue(value: ListFilterValue<TRendered>): void {\n const currentValueAsArray = this.getArrayValue();\n\n const updatedValue =\n this.mode === \"all\" || this.mode === \"some\"\n ? currentValueAsArray.filter((v) => !v.equals(value))\n : null;\n\n this.getTableColumn().setFilterValue(updatedValue);\n this.callOnChangedHandlers(updatedValue);\n }\n\n private callOnChangedHandlers(\n newValue: ListFilterValue<TRendered>[] | ListFilterValue<TRendered> | null,\n ): void {\n this.notifyFilterUpdated(toArray(newValue).map((v) => v?.value));\n }\n\n /** Tells the listeners — the list resetting its batches among them. */\n protected notifyFilterUpdated(values: unknown[]): void {\n this.onFilterChangeCallbacks.forEach((cb) => cb(values));\n }\n\n public hasChanges(): boolean {\n const currentIds = this.getArrayValue().map((v) => v.id);\n\n const defaultIds =\n this.getStoredSelectedIds({ autosave: false }) ??\n this.defaultSelectedValues?.map((v) => v.id) ??\n [];\n\n return (\n currentIds.length !== defaultIds.length ||\n difference(currentIds, defaultIds).length > 0\n );\n }\n\n public isStoringAvailable(): boolean {\n return !!this.context.settings && this.manualSave;\n }\n\n public resetValues(): void {\n const storedValues =\n this.getStoredSelectedValues({ autosave: false }) ??\n this.defaultSelectedValues;\n\n const resetTo =\n storedValues ?? (this.mode === \"all\" || this.mode === \"some\" ? [] : null);\n\n this.getTableColumn().setFilterValue(resetTo);\n this.callOnChangedHandlers(resetTo);\n }\n\n public clear(): void {\n this.getTableColumn().setFilterValue(null);\n this.callOnChangedHandlers(null);\n }\n\n public toggleValue(newValue: ListFilterValue<TRendered>): void {\n const currentValueAsArray = this.getArrayValue();\n\n let updatedValue:\n ListFilterValue<TRendered>[] | ListFilterValue<TRendered> | null;\n\n if (this.mode === \"all\" || this.mode === \"some\") {\n updatedValue = newValue.isActive\n ? currentValueAsArray.filter((v) => !v.equals(newValue))\n : [...currentValueAsArray, newValue];\n } else {\n updatedValue = newValue.isActive ? null : newValue;\n }\n\n this.getTableColumn().setFilterValue(updatedValue);\n this.callOnChangedHandlers(updatedValue);\n }\n\n /**\n * Whether the filter offers \"Select all\" — a `some` filter with enough\n * values.\n */\n public get isSelectAllAvailable(): boolean {\n return this.mode === \"some\" && this.values.length >= selectAllMinValueCount;\n }\n\n public isEveryValueActive(): boolean {\n return this.values.every((v) => v.isActive);\n }\n\n public selectAll(): void {\n this.setArrayValue(this.values);\n }\n\n /** Makes exactly these values active — what a multiple-selection menu reports. */\n public setActiveValueIds(ids: Iterable<unknown>): void {\n const idSet = new Set(ids);\n this.setArrayValue(this.values.filter((v) => idSet.has(v.id)));\n }\n\n public deselectAll(): void {\n this.setArrayValue([]);\n }\n\n private setArrayValue(value: ListFilterValue<TRendered>[]): void {\n this.getTableColumn().setFilterValue(value);\n this.callOnChangedHandlers(value);\n }\n\n public onFilterUpdated(cb: () => unknown): void {\n this.onFilterChangeCallbacks.add(cb);\n }\n}\n\nexport default ListFilter;\n"],"m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,SAAS,KAAK,SAAS,QACvC,eAAe,SAAS,WACpB,oBAAoB,QAAQ,MAAM,CAAC,EAAE,OAAO,QAAQ,CAAC,IACrD,CAAC,GAAG,qBAAqB,QAAQ;OAErC,eAAe,SAAS,WAAW,OAAO;EAG5C,KAAK,eAAe,CAAC,CAAC,eAAe,YAAY;EACjD,KAAK,sBAAsB,YAAY;CACzC;;;;;CAMA,IAAW,uBAAgC;EACzC,OAAO,KAAK,SAAS,UAAU,KAAK,OAAO,UAAU;CACvD;CAEA,qBAAqC;EACnC,OAAO,KAAK,OAAO,OAAO,MAAM,EAAE,QAAQ;CAC5C;CAEA,YAAyB;EACvB,KAAK,cAAc,KAAK,MAAM;CAChC;;CAGA,kBAAyB,KAA8B;EACrD,MAAM,QAAQ,IAAI,IAAI,GAAG;EACzB,KAAK,cAAc,KAAK,OAAO,QAAQ,MAAM,MAAM,IAAI,EAAE,EAAE,CAAC,CAAC;CAC/D;CAEA,cAA2B;EACzB,KAAK,cAAc,CAAC,CAAC;CACvB;CAEA,cAAsB,OAA2C;EAC/D,KAAK,eAAe,CAAC,CAAC,eAAe,KAAK;EAC1C,KAAK,sBAAsB,KAAK;CAClC;CAEA,gBAAuB,IAAyB;EAC9C,KAAK,wBAAwB,IAAI,EAAE;CACrC;AACF"}
@@ -1,25 +1,50 @@
1
- import { CalendarDate } from "@internationalized/date";
1
+ import { CalendarDate, CalendarDateTime, ZonedDateTime } from "@internationalized/date";
2
2
  import { DateTime } from "luxon";
3
3
  //#region ../components-base/src/list/filter/dateRange.ts
4
4
  /** A range needs both ends present to be one, even if either may be unset. */
5
5
  var isListDateRange = (value) => !!value && typeof value === "object" && "start" in value && "end" in value;
6
- var startOfDay = (date) => DateTime.fromObject({
6
+ var hasTime = (date) => "hour" in date;
7
+ /**
8
+ * The date as a local point in time. A `ZonedDateTime` is the instant it names;
9
+ * anything else is read field by field, since after crossing the remote
10
+ * boundary a `CalendarDate` is a plain object.
11
+ */
12
+ var listDateToDateTime = (date) => date instanceof ZonedDateTime ? DateTime.fromJSDate(date.toDate()) : DateTime.fromObject({
7
13
  year: date.year,
8
14
  month: date.month,
9
- day: date.day
15
+ day: date.day,
16
+ ...hasTime(date) ? {
17
+ hour: date.hour,
18
+ minute: date.minute,
19
+ second: date.second
20
+ } : {}
10
21
  });
11
22
  /**
23
+ * Resolves a range to the instants it spans, for filtering on the server side.
24
+ * Both bounds are inclusive: a date covers its whole day and a date with time
25
+ * its whole minute, in the user's local time zone. A missing side has no
26
+ * bound.
27
+ */
28
+ var resolveListDateRange = (range) => {
29
+ const unit = (date) => hasTime(date) ? "minute" : "day";
30
+ return {
31
+ start: range.start ? listDateToDateTime(range.start).startOf(unit(range.start)).toJSDate() : void 0,
32
+ end: range.end ? listDateToDateTime(range.end).endOf(unit(range.end)).toJSDate() : void 0
33
+ };
34
+ };
35
+ /**
12
36
  * The cell's value as a point in time, or `undefined` when the filter does not
13
37
  * treat it as a date.
14
38
  *
15
- * Three shapes count, each on its own terms: a luxon `DateTime` and an ISO 8601
16
- * string are compared as the instant they name — a date-only string as the
17
- * start of its day — and a `CalendarDate` as its day. Anything else, a plain `{
18
- * year, month, day }` object included, is not a date here.
39
+ * A luxon `DateTime` and an ISO 8601 string are compared as the instant they
40
+ * name — a date-only string as the start of its day. A `CalendarDate` counts as
41
+ * the start of its day, a `CalendarDateTime` as its local time and a
42
+ * `ZonedDateTime` as its instant. Anything else, a plain `{ year, month, day }`
43
+ * object included, is not a date here.
19
44
  */
20
45
  var toDateTime = (value) => {
21
46
  if (value instanceof DateTime) return value;
22
- if (value instanceof CalendarDate) return startOfDay(value);
47
+ if (value instanceof CalendarDate || value instanceof CalendarDateTime || value instanceof ZonedDateTime) return listDateToDateTime(value);
23
48
  if (typeof value === "string") return DateTime.fromISO(value);
24
49
  };
25
50
  /**
@@ -33,10 +58,9 @@ var dateRangeFilterFn = (row, columnId, range) => {
33
58
  if (!range) return true;
34
59
  const dateValue = toDateTime(row.getValue(columnId));
35
60
  if (!dateValue) return true;
36
- const startDate = range.start ? startOfDay(range.start) : void 0;
37
- const endDate = range.end ? startOfDay(range.end).endOf("day") : void 0;
38
- if (startDate && dateValue < startDate) return false;
39
- return !(endDate && dateValue > endDate);
61
+ const { start, end } = resolveListDateRange(range);
62
+ if (start && dateValue.toMillis() < start.getTime()) return false;
63
+ return !(end && dateValue.toMillis() > end.getTime());
40
64
  };
41
65
  /** Turns the column into one a date range filters. */
42
66
  var applyDateRangeColumnDef = (def) => {
@@ -44,6 +68,6 @@ var applyDateRangeColumnDef = (def) => {
44
68
  def.filterFn = dateRangeFilterFn;
45
69
  };
46
70
  //#endregion
47
- export { applyDateRangeColumnDef, dateRangeFilterFn, isListDateRange };
71
+ export { applyDateRangeColumnDef, dateRangeFilterFn, isListDateRange, listDateToDateTime, resolveListDateRange };
48
72
 
49
73
  //# sourceMappingURL=dateRange.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"dateRange.mjs","names":[],"sources":["../../../../../../../components-base/src/list/filter/dateRange.ts"],"sourcesContent":["import { CalendarDate } from \"@internationalized/date\";\nimport type { ColumnDef, Row } from \"@tanstack/table-core\";\nimport { DateTime } from \"luxon\";\n\n/** A calendar date, in whichever shape it reached the filter. */\nexport interface ListDateParts {\n readonly year: number;\n readonly month: number;\n readonly day: number;\n}\n\nexport interface ListDateRange {\n readonly start?: ListDateParts;\n readonly end?: ListDateParts;\n}\n\n/** A range needs both ends present to be one, even if either may be unset. */\nexport const isListDateRange = (value: unknown): value is ListDateRange =>\n !!value && typeof value === \"object\" && \"start\" in value && \"end\" in value;\n\n/*\n * The range's ends are read field by field: they come from the calendar, and\n * after crossing the remote boundary a `CalendarDate` is a plain object.\n */\nconst startOfDay = (date: ListDateParts): DateTime =>\n DateTime.fromObject({\n year: date.year,\n month: date.month,\n day: date.day,\n });\n\n/**\n * The cell's value as a point in time, or `undefined` when the filter does not\n * treat it as a date.\n *\n * Three shapes count, each on its own terms: a luxon `DateTime` and an ISO 8601\n * string are compared as the instant they name — a date-only string as the\n * start of its day — and a `CalendarDate` as its day. Anything else, a plain `{\n * year, month, day }` object included, is not a date here.\n */\nconst toDateTime = (value: unknown): DateTime | undefined => {\n if (value instanceof DateTime) {\n return value;\n }\n if (value instanceof CalendarDate) {\n return startOfDay(value);\n }\n if (typeof value === \"string\") {\n return DateTime.fromISO(value);\n }\n return undefined;\n};\n\n/**\n * Whether a row's date falls inside the selected range.\n *\n * A value that is not a date keeps its row: a filter the data cannot answer\n * should not empty the list. That includes a string luxon cannot parse — the\n * invalid `DateTime` compares as `NaN`, and neither end excludes it.\n */\nexport const dateRangeFilterFn = <T>(\n row: Row<T>,\n columnId: string,\n range?: ListDateRange,\n): boolean => {\n if (!range) {\n return true;\n }\n\n const dateValue = toDateTime(row.getValue(columnId));\n\n if (!dateValue) {\n return true;\n }\n\n const startDate = range.start ? startOfDay(range.start) : undefined;\n /* The whole end day counts, up to its last moment. */\n const endDate = range.end ? startOfDay(range.end).endOf(\"day\") : undefined;\n\n if (startDate && dateValue < startDate) {\n return false;\n }\n\n return !(endDate && dateValue > endDate);\n};\n\n/** Turns the column into one a date range filters. */\nexport const applyDateRangeColumnDef = <T>(def: ColumnDef<T>): void => {\n def.enableColumnFilter = true;\n def.filterFn = dateRangeFilterFn;\n};\n"],"mappings":";;;;AAiBA,IAAa,mBAAmB,UAC9B,CAAC,CAAC,SAAS,OAAO,UAAU,YAAY,WAAW,SAAS,SAAS;AAMvE,IAAM,cAAc,SAClB,SAAS,WAAW;CAClB,MAAM,KAAK;CACX,OAAO,KAAK;CACZ,KAAK,KAAK;AACZ,CAAC;;;;;;;;;;AAWH,IAAM,cAAc,UAAyC;CAC3D,IAAI,iBAAiB,UACnB,OAAO;CAET,IAAI,iBAAiB,cACnB,OAAO,WAAW,KAAK;CAEzB,IAAI,OAAO,UAAU,UACnB,OAAO,SAAS,QAAQ,KAAK;AAGjC;;;;;;;;AASA,IAAa,qBACX,KACA,UACA,UACY;CACZ,IAAI,CAAC,OACH,OAAO;CAGT,MAAM,YAAY,WAAW,IAAI,SAAS,QAAQ,CAAC;CAEnD,IAAI,CAAC,WACH,OAAO;CAGT,MAAM,YAAY,MAAM,QAAQ,WAAW,MAAM,KAAK,IAAI,KAAA;CAE1D,MAAM,UAAU,MAAM,MAAM,WAAW,MAAM,GAAG,CAAC,CAAC,MAAM,KAAK,IAAI,KAAA;CAEjE,IAAI,aAAa,YAAY,WAC3B,OAAO;CAGT,OAAO,EAAE,WAAW,YAAY;AAClC;;AAGA,IAAa,2BAA8B,QAA4B;CACrE,IAAI,qBAAqB;CACzB,IAAI,WAAW;AACjB"}
1
+ {"version":3,"file":"dateRange.mjs","names":[],"sources":["../../../../../../../components-base/src/list/filter/dateRange.ts"],"sourcesContent":["import {\n CalendarDate,\n CalendarDateTime,\n ZonedDateTime,\n} from \"@internationalized/date\";\nimport type { ColumnDef, Row } from \"@tanstack/table-core\";\nimport { DateTime } from \"luxon\";\n\n/**\n * A calendar date, in whichever shape it reached the filter — with a time of\n * day when the filter narrows down by minute.\n */\nexport interface ListDateParts {\n readonly year: number;\n readonly month: number;\n readonly day: number;\n readonly hour?: number;\n readonly minute?: number;\n readonly second?: number;\n}\n\nexport interface ListDateRange {\n readonly start?: ListDateParts;\n readonly end?: ListDateParts;\n}\n\n/** A range needs both ends present to be one, even if either may be unset. */\nexport const isListDateRange = (value: unknown): value is ListDateRange =>\n !!value && typeof value === \"object\" && \"start\" in value && \"end\" in value;\n\nconst hasTime = (date: ListDateParts) => \"hour\" in date;\n\n/**\n * The date as a local point in time. A `ZonedDateTime` is the instant it names;\n * anything else is read field by field, since after crossing the remote\n * boundary a `CalendarDate` is a plain object.\n */\nexport const listDateToDateTime = (date: ListDateParts): DateTime =>\n date instanceof ZonedDateTime\n ? DateTime.fromJSDate(date.toDate())\n : DateTime.fromObject({\n year: date.year,\n month: date.month,\n day: date.day,\n ...(hasTime(date)\n ? { hour: date.hour, minute: date.minute, second: date.second }\n : {}),\n });\n\n/**\n * Resolves a range to the instants it spans, for filtering on the server side.\n * Both bounds are inclusive: a date covers its whole day and a date with time\n * its whole minute, in the user's local time zone. A missing side has no\n * bound.\n */\nexport const resolveListDateRange = (\n range: ListDateRange,\n): { start?: Date; end?: Date } => {\n const unit = (date: ListDateParts) => (hasTime(date) ? \"minute\" : \"day\");\n\n return {\n start: range.start\n ? listDateToDateTime(range.start).startOf(unit(range.start)).toJSDate()\n : undefined,\n end: range.end\n ? listDateToDateTime(range.end).endOf(unit(range.end)).toJSDate()\n : undefined,\n };\n};\n\n/**\n * The cell's value as a point in time, or `undefined` when the filter does not\n * treat it as a date.\n *\n * A luxon `DateTime` and an ISO 8601 string are compared as the instant they\n * name — a date-only string as the start of its day. A `CalendarDate` counts as\n * the start of its day, a `CalendarDateTime` as its local time and a\n * `ZonedDateTime` as its instant. Anything else, a plain `{ year, month, day }`\n * object included, is not a date here.\n */\nconst toDateTime = (value: unknown): DateTime | undefined => {\n if (value instanceof DateTime) {\n return value;\n }\n if (\n value instanceof CalendarDate ||\n value instanceof CalendarDateTime ||\n value instanceof ZonedDateTime\n ) {\n return listDateToDateTime(value);\n }\n if (typeof value === \"string\") {\n return DateTime.fromISO(value);\n }\n return undefined;\n};\n\n/**\n * Whether a row's date falls inside the selected range.\n *\n * A value that is not a date keeps its row: a filter the data cannot answer\n * should not empty the list. That includes a string luxon cannot parse — the\n * invalid `DateTime` compares as `NaN`, and neither end excludes it.\n */\nexport const dateRangeFilterFn = <T>(\n row: Row<T>,\n columnId: string,\n range?: ListDateRange,\n): boolean => {\n if (!range) {\n return true;\n }\n\n const dateValue = toDateTime(row.getValue(columnId));\n\n if (!dateValue) {\n return true;\n }\n\n const { start, end } = resolveListDateRange(range);\n\n if (start && dateValue.toMillis() < start.getTime()) {\n return false;\n }\n\n return !(end && dateValue.toMillis() > end.getTime());\n};\n\n/** Turns the column into one a date range filters. */\nexport const applyDateRangeColumnDef = <T>(def: ColumnDef<T>): void => {\n def.enableColumnFilter = true;\n def.filterFn = dateRangeFilterFn;\n};\n"],"m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,IAAI,IAAI,QAAQ;AACrD;;AAGA,IAAa,2BAA8B,QAA4B;CACrE,IAAI,qBAAqB;CACzB,IAAI,WAAW;AACjB"}
@@ -0,0 +1,53 @@
1
+ import { resolveListDateRange } from "./dateRange.mjs";
2
+ import { CalendarDate, Time, toCalendarDateTime } from "@internationalized/date";
3
+ //#region ../components-base/src/list/filter/dateTimeRangeFields.ts
4
+ var toListCalendarDate = (value) => value ? new CalendarDate(value.year, value.month, value.day) : null;
5
+ var toListTime = (value) => value && "hour" in value ? new Time(value.hour, value.minute) : null;
6
+ var listDateTimeRangeFieldsFromValue = (value) => ({
7
+ startDate: toListCalendarDate(value?.start),
8
+ startTime: toListTime(value?.start),
9
+ endDate: toListCalendarDate(value?.end),
10
+ endTime: toListTime(value?.end)
11
+ });
12
+ var toBound = (date, time) => date ? time ? toCalendarDateTime(date, time) : date : void 0;
13
+ var boundKey = (bound) => bound && [
14
+ bound.year,
15
+ bound.month,
16
+ bound.day,
17
+ bound.hour,
18
+ bound.minute
19
+ ].join("-");
20
+ var isYearComplete = (date) => !!date && date.year >= 1e3;
21
+ /** Not while a year is still being typed: "2" would read as an early end. */
22
+ var isListDateTimeRangeEndBeforeStart = (fields) => {
23
+ if (!isYearComplete(fields.startDate) || !isYearComplete(fields.endDate)) return false;
24
+ const { start, end } = resolveListDateRange({
25
+ start: toBound(fields.startDate, fields.startTime),
26
+ end: toBound(fields.endDate, fields.endTime)
27
+ });
28
+ return !!start && !!end && end < start;
29
+ };
30
+ var isListDateValid = (date, limits = {}) => {
31
+ const minValue = toListCalendarDate(limits.minValue);
32
+ const maxValue = toListCalendarDate(limits.maxValue);
33
+ return !date || !(!isYearComplete(date) || minValue && date.compare(minValue) < 0 || maxValue && date.compare(maxValue) > 0 || limits.isDateUnavailable?.(date));
34
+ };
35
+ /**
36
+ * The range the fields stand for, or `undefined` while it must not be applied:
37
+ * an invalid input keeps the last valid range, and an unchanged one needs no
38
+ * update. `null` clears the filter.
39
+ */
40
+ var getListDateTimeRangeUpdate = (fields, applied, limits) => {
41
+ if (!isListDateValid(fields.startDate, limits) || !isListDateValid(fields.endDate, limits) || isListDateTimeRangeEndBeforeStart(fields)) return;
42
+ const start = toBound(fields.startDate, fields.startTime);
43
+ const end = toBound(fields.endDate, fields.endTime);
44
+ if (boundKey(start) === boundKey(applied?.start) && boundKey(end) === boundKey(applied?.end)) return;
45
+ return start || end ? {
46
+ start,
47
+ end
48
+ } : null;
49
+ };
50
+ //#endregion
51
+ export { getListDateTimeRangeUpdate, isListDateTimeRangeEndBeforeStart, isListDateValid, listDateTimeRangeFieldsFromValue, toListCalendarDate, toListTime };
52
+
53
+ //# sourceMappingURL=dateTimeRangeFields.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dateTimeRangeFields.mjs","names":[],"sources":["../../../../../../../components-base/src/list/filter/dateTimeRangeFields.ts"],"sourcesContent":["import {\n CalendarDate,\n type CalendarDateTime,\n Time,\n toCalendarDateTime,\n} from \"@internationalized/date\";\nimport {\n resolveListDateRange,\n type ListDateParts,\n type ListDateRange,\n} from \"./dateRange\";\n\n/*\n * The rules of the date and time fields a range filter shows with\n * `granularity: \"minute\"`. Which input is valid and when it applies is the same\n * in every binding; the fields and the state holding their input are not.\n */\n\nexport interface ListDateTimeRangeFields {\n readonly startDate: CalendarDate | null;\n readonly startTime: Time | null;\n readonly endDate: CalendarDate | null;\n readonly endTime: Time | null;\n}\n\nexport interface ListDateTimeRangeLimits {\n readonly minValue?: ListDateParts | null;\n readonly maxValue?: ListDateParts | null;\n readonly isDateUnavailable?: (date: CalendarDate) => boolean;\n}\n\ntype Bound = CalendarDate | CalendarDateTime;\n\nexport interface ListDateTimeRange {\n readonly start?: Bound;\n readonly end?: Bound;\n}\n\n/* Field by field: a value from the host of a remote connection is a plain object. */\nexport const toListCalendarDate = (\n value?: ListDateParts | null,\n): CalendarDate | null =>\n value ? new CalendarDate(value.year, value.month, value.day) : null;\n\nexport const toListTime = (\n value?: { readonly hour?: number; readonly minute?: number } | null,\n): Time | null =>\n value && \"hour\" in value ? new Time(value.hour, value.minute) : null;\n\nexport const listDateTimeRangeFieldsFromValue = (\n value: ListDateRange | null,\n): ListDateTimeRangeFields => ({\n startDate: toListCalendarDate(value?.start),\n startTime: toListTime(value?.start),\n endDate: toListCalendarDate(value?.end),\n endTime: toListTime(value?.end),\n});\n\nconst toBound = (date: CalendarDate | null, time: Time | null) =>\n date ? (time ? toCalendarDateTime(date, time) : date) : undefined;\n\nconst boundKey = (bound?: ListDateParts) =>\n bound &&\n [bound.year, bound.month, bound.day, bound.hour, bound.minute].join(\"-\");\n\n// react-aria reports a typed year digit by digit (2, 20, 202, 2026)\nconst isYearComplete = (date: CalendarDate | null) =>\n !!date && date.year >= 1000;\n\n/** Not while a year is still being typed: \"2\" would read as an early end. */\nexport const isListDateTimeRangeEndBeforeStart = (\n fields: ListDateTimeRangeFields,\n): boolean => {\n if (!isYearComplete(fields.startDate) || !isYearComplete(fields.endDate)) {\n return false;\n }\n const { start, end } = resolveListDateRange({\n start: toBound(fields.startDate, fields.startTime),\n end: toBound(fields.endDate, fields.endTime),\n });\n return !!start && !!end && end < start;\n};\n\nexport const isListDateValid = (\n date: CalendarDate | null,\n limits: ListDateTimeRangeLimits = {},\n): boolean => {\n const minValue = toListCalendarDate(limits.minValue);\n const maxValue = toListCalendarDate(limits.maxValue);\n\n return (\n !date ||\n !(\n !isYearComplete(date) ||\n (minValue && date.compare(minValue) < 0) ||\n (maxValue && date.compare(maxValue) > 0) ||\n limits.isDateUnavailable?.(date)\n )\n );\n};\n\n/**\n * The range the fields stand for, or `undefined` while it must not be applied:\n * an invalid input keeps the last valid range, and an unchanged one needs no\n * update. `null` clears the filter.\n */\nexport const getListDateTimeRangeUpdate = (\n fields: ListDateTimeRangeFields,\n applied: ListDateRange | null,\n limits?: ListDateTimeRangeLimits,\n): ListDateTimeRange | null | undefined => {\n if (\n !isListDateValid(fields.startDate, limits) ||\n !isListDateValid(fields.endDate, limits) ||\n isListDateTimeRangeEndBeforeStart(fields)\n ) {\n return undefined;\n }\n\n const start = toBound(fields.startDate, fields.startTime);\n const end = toBound(fields.endDate, fields.endTime);\n\n if (\n boundKey(start) === boundKey(applied?.start) &&\n boundKey(end) === boundKey(applied?.end)\n ) {\n return undefined;\n }\n\n return start || end ? { start, end } : null;\n};\n"],"mappings":";;;AAuCA,IAAa,sBACX,UAEA,QAAQ,IAAI,aAAa,MAAM,MAAM,MAAM,OAAO,MAAM,GAAG,IAAI;AAEjE,IAAa,cACX,UAEA,SAAS,UAAU,QAAQ,IAAI,KAAK,MAAM,MAAM,MAAM,MAAM,IAAI;AAElE,IAAa,oCACX,WAC6B;CAC7B,WAAW,mBAAmB,OAAO,KAAK;CAC1C,WAAW,WAAW,OAAO,KAAK;CAClC,SAAS,mBAAmB,OAAO,GAAG;CACtC,SAAS,WAAW,OAAO,GAAG;AAChC;AAEA,IAAM,WAAW,MAA2B,SAC1C,OAAQ,OAAO,mBAAmB,MAAM,IAAI,IAAI,OAAQ,KAAA;AAE1D,IAAM,YAAY,UAChB,SACA;CAAC,MAAM;CAAM,MAAM;CAAO,MAAM;CAAK,MAAM;CAAM,MAAM;AAAM,CAAC,CAAC,KAAK,GAAG;AAGzE,IAAM,kBAAkB,SACtB,CAAC,CAAC,QAAQ,KAAK,QAAQ;;AAGzB,IAAa,qCACX,WACY;CACZ,IAAI,CAAC,eAAe,OAAO,SAAS,KAAK,CAAC,eAAe,OAAO,OAAO,GACrE,OAAO;CAET,MAAM,EAAE,OAAO,QAAQ,qBAAqB;EAC1C,OAAO,QAAQ,OAAO,WAAW,OAAO,SAAS;EACjD,KAAK,QAAQ,OAAO,SAAS,OAAO,OAAO;CAC7C,CAAC;CACD,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,OAAO,MAAM;AACnC;AAEA,IAAa,mBACX,MACA,SAAkC,CAAC,MACvB;CACZ,MAAM,WAAW,mBAAmB,OAAO,QAAQ;CACnD,MAAM,WAAW,mBAAmB,OAAO,QAAQ;CAEnD,OACE,CAAC,QACD,EACE,CAAC,eAAe,IAAI,KACnB,YAAY,KAAK,QAAQ,QAAQ,IAAI,KACrC,YAAY,KAAK,QAAQ,QAAQ,IAAI,KACtC,OAAO,oBAAoB,IAAI;AAGrC;;;;;;AAOA,IAAa,8BACX,QACA,SACA,WACyC;CACzC,IACE,CAAC,gBAAgB,OAAO,WAAW,MAAM,KACzC,CAAC,gBAAgB,OAAO,SAAS,MAAM,KACvC,kCAAkC,MAAM,GAExC;CAGF,MAAM,QAAQ,QAAQ,OAAO,WAAW,OAAO,SAAS;CACxD,MAAM,MAAM,QAAQ,OAAO,SAAS,OAAO,OAAO;CAElD,IACE,SAAS,KAAK,MAAM,SAAS,SAAS,KAAK,KAC3C,SAAS,GAAG,MAAM,SAAS,SAAS,GAAG,GAEvC;CAGF,OAAO,SAAS,MAAM;EAAE;EAAO;CAAI,IAAI;AACzC"}
@@ -0,0 +1,25 @@
1
+ import { listDateToDateTime } from "./dateRange.mjs";
2
+ import { DateFormatter } from "@internationalized/date";
3
+ //#region ../components-base/src/list/filter/formatDateRange.ts
4
+ /** The active filter chip's text: an end with time shows its time. */
5
+ var formatListDateRange = (value, locale, format) => {
6
+ const formatBound = (bound) => new DateFormatter(locale, {
7
+ year: "numeric",
8
+ month: "numeric",
9
+ day: "numeric",
10
+ ..."hour" in bound ? {
11
+ hour: "2-digit",
12
+ minute: "2-digit",
13
+ hourCycle: "h23"
14
+ } : {}
15
+ }).format(listDateToDateTime(bound).toJSDate());
16
+ const { start, end } = value;
17
+ if (start && end) return `${formatBound(start)} – ${formatBound(end)}`;
18
+ if (start) return format("dateRange.from", { date: formatBound(start) });
19
+ if (end) return format("dateRange.until", { date: formatBound(end) });
20
+ return "";
21
+ };
22
+ //#endregion
23
+ export { formatListDateRange };
24
+
25
+ //# sourceMappingURL=formatDateRange.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatDateRange.mjs","names":[],"sources":["../../../../../../../components-base/src/list/filter/formatDateRange.ts"],"sourcesContent":["import { DateFormatter } from \"@internationalized/date\";\nimport {\n listDateToDateTime,\n type ListDateParts,\n type ListDateRange,\n} from \"./dateRange\";\n\n/** Formats the text of an open range (\"from {date}\", \"until {date}\"). */\nexport type ListDateRangeTextFormat = (\n key: \"dateRange.from\" | \"dateRange.until\",\n values: { date: string },\n) => string;\n\n/** The active filter chip's text: an end with time shows its time. */\nexport const formatListDateRange = (\n value: ListDateRange,\n locale: string,\n format: ListDateRangeTextFormat,\n): string => {\n const formatBound = (bound: ListDateParts) =>\n new DateFormatter(locale, {\n year: \"numeric\",\n month: \"numeric\",\n day: \"numeric\",\n // TimeField always shows 24 hours\n ...(\"hour\" in bound\n ? { hour: \"2-digit\", minute: \"2-digit\", hourCycle: \"h23\" }\n : {}),\n }).format(listDateToDateTime(bound).toJSDate());\n\n const { start, end } = value;\n\n if (start && end) {\n return `${formatBound(start)} – ${formatBound(end)}`;\n }\n if (start) {\n return format(\"dateRange.from\", { date: formatBound(start) });\n }\n if (end) {\n return format(\"dateRange.until\", { date: formatBound(end) });\n }\n return \"\";\n};\n"],"mappings":";;;;AAcA,IAAa,uBACX,OACA,QACA,WACW;CACX,MAAM,eAAe,UACnB,IAAI,cAAc,QAAQ;EACxB,MAAM;EACN,OAAO;EACP,KAAK;EAEL,GAAI,UAAU,QACV;GAAE,MAAM;GAAW,QAAQ;GAAW,WAAW;EAAM,IACvD,CAAC;CACP,CAAC,CAAC,CAAC,OAAO,mBAAmB,KAAK,CAAC,CAAC,SAAS,CAAC;CAEhD,MAAM,EAAE,OAAO,QAAQ;CAEvB,IAAI,SAAS,KACX,OAAO,GAAG,YAAY,KAAK,EAAE,KAAK,YAAY,GAAG;CAEnD,IAAI,OACF,OAAO,OAAO,kBAAkB,EAAE,MAAM,YAAY,KAAK,EAAE,CAAC;CAE9D,IAAI,KACF,OAAO,OAAO,mBAAmB,EAAE,MAAM,YAAY,GAAG,EAAE,CAAC;CAE7D,OAAO;AACT"}
package/dist/js/index.mjs CHANGED
@@ -274,6 +274,7 @@ import { IconSuccess } from "./remote-vue-components/src/icons/components/IconSu
274
274
  import { IconUnavailable } from "./remote-vue-components/src/icons/components/IconUnavailable.mjs";
275
275
  import { IconWarning } from "./remote-vue-components/src/icons/components/IconWarning.mjs";
276
276
  import { createOverlayController, injectOverlayController, useModalController, useOverlayController } from "./remote-vue-components/src/overlays/overlayController.mjs";
277
+ import { resolveListDateRange } from "./components-base/src/list/filter/dateRange.mjs";
277
278
  import { Action } from "./remote-vue-components/src/components/Action.mjs";
278
279
  import { ActionBatch } from "./remote-vue-components/src/components/ActionBatch.mjs";
279
280
  import { BrowserOnly } from "./remote-vue-components/src/components/BrowserOnly.mjs";
@@ -298,4 +299,4 @@ import { Wrap } from "./remote-vue-components/src/components/Wrap.mjs";
298
299
  import { LightBox } from "./remote-vue-components/src/overlays/LightBox.mjs";
299
300
  import { useIsMounted } from "./remote-vue-components/src/composables/useIsMounted.mjs";
300
301
  import { useOnChange } from "./remote-vue-components/src/composables/useOnChange.mjs";
301
- export { AccentBox, Accordion, AccordionGroup, Action, ActionBatch, ActionGroup, Alert, AlertBadge, AlertIcon, AlertText, Align, Area, Autocomplete, Avatar, AvatarStack, Badge, Bar, BigNumber, Breadcrumb, BrowserOnly, Button, CartesianChart, CartesianGrid, ChartGrid, ChartLegend, ChartTooltip, Chat, Checkbox, CheckboxButton, CheckboxGroup, ClearPropsContext, CoachMark, CodeBlock, CodeEditor, Color, ColumnLayout, Combine, ComboBox, ComponentPropsContextProvider, Content, ContextMenu, ContextMenuContent, ContextMenuSection, ContextMenuTrigger, ContextualHelp, ContextualHelpTrigger, CopyButton, CounterBadge, CountryOptions, DatePicker, DateRangePicker, DeprecationWarningProvider, DialogTrigger, Div, DonutChart, FieldDescription, FieldError, FileCard, FileCardList, FileDropZone, FileField, Flex, Form, Header, HeaderNavigation, Heading, Icon, IconAI, IconAIHosting, IconAnalytics, IconApp, IconAscending, IconAttachment, IconAutoresponder, IconBackLink, IconBackup, IconBold, IconCamera, IconCertificate, IconChangelog, IconCheck, IconCheckboxChecked, IconCheckboxEmpty, IconCheckboxIndeterminate, IconChevronDown, IconChevronLeft, IconChevronRight, IconChevronUp, IconClose, IconCode, IconContainer, IconContextMenu, IconContextMenuVertical, IconContract, IconContractPartner, IconContributor, IconCopy, IconCronjob, IconCustomer, IconDanger, IconDashboard, IconDatabase, IconDate, IconDelete, IconDeliveryBox, IconDescending, IconDesktop, IconDirectory, IconDnsSubZone, IconDnsZone, IconDomain, IconDownload, IconEdit, IconEmail, IconEmailArchive, IconExtension, IconExternalLink, IconFailed, IconFeedback, IconFile, IconFilter, IconForwardAddress, IconForwardLink, IconHide, IconHome, IconImage, IconInfo, IconInvite, IconInvoice, IconItalic, IconKnowledgeHint, IconLanguage, IconLeadFyndr, IconLink, IconLock, IconLockOpen, IconLogout, IconMainUser, IconMarketplace, IconMaximize, IconMember, IconMenu, IconMinimize, IconMinus, IconMittwald, IconMobile, IconMonitoring, IconMove, IconNewsletter, IconNotification, IconNumber, IconOrder, IconOrderedList, IconPassword, IconPath, IconPause, IconPayment, IconPending, IconPicture, IconPlus, IconProject, IconQuote, IconRadioOff, IconRadioOn, IconRedo, IconRefresh, IconRegistry, IconSave, IconSearch, IconSecurity, IconSend, IconServer, IconSetProvider, IconSettings, IconShare, IconShow, IconSorting, IconSsh, IconSshKey, IconSshSftp, IconStack, IconStar, IconStarFilled, IconStart, IconStrikeThrough, IconSubdomain, IconSucceeded, IconSuccess, IconSupport, IconTerminate, IconTicket, IconTime, IconUnavailable, IconUndo, IconUnorderedList, IconUpload, IconUser, IconVhost, IconView, IconVolume, IconWarning, IllustratedMessage, Image, ImageCropper, Initials, InlineCode, ItemsGridList, ItemsGridListItem, Kbd, Label, LabeledValue, LayoutCard, Legend, LightBox, LightBoxGallery, LightBoxGalleryItem, LightBoxTrigger, Line, Link, List, ListEmptyView, ListEmptyViewContainer, ListFilter, ListItem, ListItemView, ListItemViewContent, ListLoaderAsync, ListLoaderComposable, ListModel, ListSearch, ListSorting, ListStaticData, ListSummary, ListTable, ListTableBody, ListTableCell, ListTableColumn, ListTableHeader, ListTableRow, LoadingFallbackTrigger, LoadingIndicator, LoadingSpinner, Markdown, MarkdownEditor, MenuItem, MenuTrigger, Message, MessageSeparator, MessageThread, Modal, ModalTrigger, Navigation, NavigationGroup, Notification, NotificationController, NotificationProvider, NumberField, Option, OverlayContent, PasswordCreationField, Popover, PopoverContent, PopoverTrigger, ProgressBar, Radio, RadioButton, RadioGroup, RangeCalendar, Rating, RatingSegment, RemoteRoot, SearchField, Section, Segment, SegmentedControl, Select, Separator, SettingsProvider, SettingsStore, Skeleton, SkeletonMode, SkeletonText, Slider, Switch, Tab, TabNavigation, TabTitle, Table, TableBody, TableCell, TableColumn, TableFooterRow, TableHeader, TableRow, Tabs, Text, TextArea, TextField, TimeField, Tooltip, TooltipTrigger, TranslationProvider, Truncate, TunnelEntry, Wrap, XAxis, YAxis, communicationVersion, createFlowRemoteComponent, createListSettings, createOverlayController, injectContextIcon, injectListModel, injectOverlayController, injectSettings, packageVersion, svgIcon, tablerIcon, useIsMounted, useLanguage, useListMetadata, useListSettings, useModalController, useNotificationController, useOnChange, useOverlayController, useRemoteConnection, useWarnDeprecation };
302
+ export { AccentBox, Accordion, AccordionGroup, Action, ActionBatch, ActionGroup, Alert, AlertBadge, AlertIcon, AlertText, Align, Area, Autocomplete, Avatar, AvatarStack, Badge, Bar, BigNumber, Breadcrumb, BrowserOnly, Button, CartesianChart, CartesianGrid, ChartGrid, ChartLegend, ChartTooltip, Chat, Checkbox, CheckboxButton, CheckboxGroup, ClearPropsContext, CoachMark, CodeBlock, CodeEditor, Color, ColumnLayout, Combine, ComboBox, ComponentPropsContextProvider, Content, ContextMenu, ContextMenuContent, ContextMenuSection, ContextMenuTrigger, ContextualHelp, ContextualHelpTrigger, CopyButton, CounterBadge, CountryOptions, DatePicker, DateRangePicker, DeprecationWarningProvider, DialogTrigger, Div, DonutChart, FieldDescription, FieldError, FileCard, FileCardList, FileDropZone, FileField, Flex, Form, Header, HeaderNavigation, Heading, Icon, IconAI, IconAIHosting, IconAnalytics, IconApp, IconAscending, IconAttachment, IconAutoresponder, IconBackLink, IconBackup, IconBold, IconCamera, IconCertificate, IconChangelog, IconCheck, IconCheckboxChecked, IconCheckboxEmpty, IconCheckboxIndeterminate, IconChevronDown, IconChevronLeft, IconChevronRight, IconChevronUp, IconClose, IconCode, IconContainer, IconContextMenu, IconContextMenuVertical, IconContract, IconContractPartner, IconContributor, IconCopy, IconCronjob, IconCustomer, IconDanger, IconDashboard, IconDatabase, IconDate, IconDelete, IconDeliveryBox, IconDescending, IconDesktop, IconDirectory, IconDnsSubZone, IconDnsZone, IconDomain, IconDownload, IconEdit, IconEmail, IconEmailArchive, IconExtension, IconExternalLink, IconFailed, IconFeedback, IconFile, IconFilter, IconForwardAddress, IconForwardLink, IconHide, IconHome, IconImage, IconInfo, IconInvite, IconInvoice, IconItalic, IconKnowledgeHint, IconLanguage, IconLeadFyndr, IconLink, IconLock, IconLockOpen, IconLogout, IconMainUser, IconMarketplace, IconMaximize, IconMember, IconMenu, IconMinimize, IconMinus, IconMittwald, IconMobile, IconMonitoring, IconMove, IconNewsletter, IconNotification, IconNumber, IconOrder, IconOrderedList, IconPassword, IconPath, IconPause, IconPayment, IconPending, IconPicture, IconPlus, IconProject, IconQuote, IconRadioOff, IconRadioOn, IconRedo, IconRefresh, IconRegistry, IconSave, IconSearch, IconSecurity, IconSend, IconServer, IconSetProvider, IconSettings, IconShare, IconShow, IconSorting, IconSsh, IconSshKey, IconSshSftp, IconStack, IconStar, IconStarFilled, IconStart, IconStrikeThrough, IconSubdomain, IconSucceeded, IconSuccess, IconSupport, IconTerminate, IconTicket, IconTime, IconUnavailable, IconUndo, IconUnorderedList, IconUpload, IconUser, IconVhost, IconView, IconVolume, IconWarning, IllustratedMessage, Image, ImageCropper, Initials, InlineCode, ItemsGridList, ItemsGridListItem, Kbd, Label, LabeledValue, LayoutCard, Legend, LightBox, LightBoxGallery, LightBoxGalleryItem, LightBoxTrigger, Line, Link, List, ListEmptyView, ListEmptyViewContainer, ListFilter, ListItem, ListItemView, ListItemViewContent, ListLoaderAsync, ListLoaderComposable, ListModel, ListSearch, ListSorting, ListStaticData, ListSummary, ListTable, ListTableBody, ListTableCell, ListTableColumn, ListTableHeader, ListTableRow, LoadingFallbackTrigger, LoadingIndicator, LoadingSpinner, Markdown, MarkdownEditor, MenuItem, MenuTrigger, Message, MessageSeparator, MessageThread, Modal, ModalTrigger, Navigation, NavigationGroup, Notification, NotificationController, NotificationProvider, NumberField, Option, OverlayContent, PasswordCreationField, Popover, PopoverContent, PopoverTrigger, ProgressBar, Radio, RadioButton, RadioGroup, RangeCalendar, Rating, RatingSegment, RemoteRoot, SearchField, Section, Segment, SegmentedControl, Select, Separator, SettingsProvider, SettingsStore, Skeleton, SkeletonMode, SkeletonText, Slider, Switch, Tab, TabNavigation, TabTitle, Table, TableBody, TableCell, TableColumn, TableFooterRow, TableHeader, TableRow, Tabs, Text, TextArea, TextField, TimeField, Tooltip, TooltipTrigger, TranslationProvider, Truncate, TunnelEntry, Wrap, XAxis, YAxis, communicationVersion, createFlowRemoteComponent, createListSettings, createOverlayController, injectContextIcon, injectListModel, injectOverlayController, injectSettings, packageVersion, resolveListDateRange as resolveDateRangeFilterValue, svgIcon, tablerIcon, useIsMounted, useLanguage, useListMetadata, useListSettings, useModalController, useNotificationController, useOnChange, useOverlayController, useRemoteConnection, useWarnDeprecation };
@@ -15,23 +15,29 @@ var DeprecationWarningProvider = defineComponent({
15
15
  default: void 0
16
16
  } },
17
17
  setup(props, { slots }) {
18
- provide(deprecationWarningKey, (message) => props.onWarning?.(message));
18
+ const reported = /* @__PURE__ */ new Set();
19
+ provide(deprecationWarningKey, (message) => {
20
+ const onWarning = props.onWarning;
21
+ if (!onWarning || reported.has(message)) return;
22
+ reported.add(message);
23
+ onWarning(message);
24
+ });
19
25
  return () => slots.default?.();
20
26
  }
21
27
  });
28
+ /** Messages already written to `console.warn`, across all providers. */
29
+ var consoleReported = /* @__PURE__ */ new Set();
22
30
  /**
23
- * Warns once per message, in the console and to the provider.
24
- *
25
- * Deduplicated per call site, like Flow's hook: a component that warns on every
26
- * render must not fill the console.
31
+ * Warns once per message, like Flow's hook: in the console once for the whole
32
+ * app, and once to each provider.
27
33
  */
28
34
  var useWarnDeprecation = () => {
29
35
  const onWarning = inject(deprecationWarningKey, void 0);
30
- const reported = /* @__PURE__ */ new Set();
31
36
  return (message) => {
32
- if (reported.has(message)) return;
33
- reported.add(message);
34
- console.warn(message);
37
+ if (!consoleReported.has(message)) {
38
+ consoleReported.add(message);
39
+ console.warn(message);
40
+ }
35
41
  onWarning?.(message);
36
42
  };
37
43
  };
@@ -1 +1 @@
1
- {"version":3,"file":"DeprecationWarningProvider.mjs","names":[],"sources":["../../../../../src/components/DeprecationWarningProvider.ts"],"sourcesContent":["import {\n defineComponent,\n inject,\n provide,\n type InjectionKey,\n type PropType,\n} from \"vue\";\nimport { composition } from \"@/lib/composition\";\n\nexport type DeprecationWarningHandler = (message: string) => void;\n\nconst deprecationWarningKey: InjectionKey<DeprecationWarningHandler> = Symbol(\n \"flowDeprecationWarning\",\n);\n\n/**\n * Collects the deprecation warnings a remote app triggers.\n *\n * `RemoteRoot` installs one that forwards to the host, which is how mStudio\n * learns which deprecated paths an extension still uses.\n */\nexport const DeprecationWarningProvider = defineComponent({\n name: \"DeprecationWarningProvider\",\n\n props: {\n onWarning: {\n type: Function as PropType<DeprecationWarningHandler>,\n default: undefined,\n },\n },\n\n setup(props, { slots }) {\n provide(deprecationWarningKey, (message: string) =>\n props.onWarning?.(message),\n );\n\n return () => slots.default?.();\n },\n});\n\n/**\n * Warns once per message, in the console and to the provider.\n *\n * Deduplicated per call site, like Flow's hook: a component that warns on every\n * render must not fill the console.\n */\nexport const useWarnDeprecation = (): DeprecationWarningHandler => {\n const onWarning = inject(deprecationWarningKey, undefined);\n const reported = new Set<string>();\n\n return (message: string) => {\n if (reported.has(message)) {\n return;\n }\n reported.add(message);\n console.warn(message);\n onWarning?.(message);\n };\n};\n\ncomposition(DeprecationWarningProvider);\n\nexport default DeprecationWarningProvider;\n"],"mappings":";;;AAWA,IAAM,wBAAiE,OACrE,wBACF;;;;;;;AAQA,IAAa,6BAA6B,gBAAgB;CACxD,MAAM;CAEN,OAAO,EACL,WAAW;EACT,MAAM;EACN,SAAS,KAAA;CACX,EACF;CAEA,MAAM,OAAO,EAAE,SAAS;EACtB,QAAQ,wBAAwB,YAC9B,MAAM,YAAY,OAAO,CAC3B;EAEA,aAAa,MAAM,UAAU;CAC/B;AACF,CAAC;;;;;;;AAQD,IAAa,2BAAsD;CACjE,MAAM,YAAY,OAAO,uBAAuB,KAAA,CAAS;CACzD,MAAM,2BAAW,IAAI,IAAY;CAEjC,QAAQ,YAAoB;EAC1B,IAAI,SAAS,IAAI,OAAO,GACtB;EAEF,SAAS,IAAI,OAAO;EACpB,QAAQ,KAAK,OAAO;EACpB,YAAY,OAAO;CACrB;AACF;AAEA,YAAY,0BAA0B"}
1
+ {"version":3,"file":"DeprecationWarningProvider.mjs","names":[],"sources":["../../../../../src/components/DeprecationWarningProvider.ts"],"sourcesContent":["import {\n defineComponent,\n inject,\n provide,\n type InjectionKey,\n type PropType,\n} from \"vue\";\nimport { composition } from \"@/lib/composition\";\n\nexport type DeprecationWarningHandler = (message: string) => void;\n\nconst deprecationWarningKey: InjectionKey<DeprecationWarningHandler> = Symbol(\n \"flowDeprecationWarning\",\n);\n\n/**\n * Collects the deprecation warnings a remote app triggers.\n *\n * `RemoteRoot` installs one that forwards to the host, which is how mStudio\n * learns which deprecated paths an extension still uses.\n */\nexport const DeprecationWarningProvider = defineComponent({\n name: \"DeprecationWarningProvider\",\n\n props: {\n onWarning: {\n type: Function as PropType<DeprecationWarningHandler>,\n default: undefined,\n },\n },\n\n setup(props, { slots }) {\n const reported = new Set<string>();\n\n provide(deprecationWarningKey, (message: string) => {\n const onWarning = props.onWarning;\n if (!onWarning || reported.has(message)) {\n return;\n }\n reported.add(message);\n onWarning(message);\n });\n\n return () => slots.default?.();\n },\n});\n\n/** Messages already written to `console.warn`, across all providers. */\nconst consoleReported = new Set<string>();\n\n/**\n * Warns once per message, like Flow's hook: in the console once for the whole\n * app, and once to each provider.\n */\nexport const useWarnDeprecation = (): DeprecationWarningHandler => {\n const onWarning = inject(deprecationWarningKey, undefined);\n\n return (message: string) => {\n if (!consoleReported.has(message)) {\n consoleReported.add(message);\n console.warn(message);\n }\n onWarning?.(message);\n };\n};\n\ncomposition(DeprecationWarningProvider);\n\nexport default DeprecationWarningProvider;\n"],"mappings":";;;AAWA,IAAM,wBAAiE,OACrE,wBACF;;;;;;;AAQA,IAAa,6BAA6B,gBAAgB;CACxD,MAAM;CAEN,OAAO,EACL,WAAW;EACT,MAAM;EACN,SAAS,KAAA;CACX,EACF;CAEA,MAAM,OAAO,EAAE,SAAS;EACtB,MAAM,2BAAW,IAAI,IAAY;EAEjC,QAAQ,wBAAwB,YAAoB;GAClD,MAAM,YAAY,MAAM;GACxB,IAAI,CAAC,aAAa,SAAS,IAAI,OAAO,GACpC;GAEF,SAAS,IAAI,OAAO;GACpB,UAAU,OAAO;EACnB,CAAC;EAED,aAAa,MAAM,UAAU;CAC/B;AACF,CAAC;;AAGD,IAAM,kCAAkB,IAAI,IAAY;;;;;AAMxC,IAAa,2BAAsD;CACjE,MAAM,YAAY,OAAO,uBAAuB,KAAA,CAAS;CAEzD,QAAQ,YAAoB;EAC1B,IAAI,CAAC,gBAAgB,IAAI,OAAO,GAAG;GACjC,gBAAgB,IAAI,OAAO;GAC3B,QAAQ,KAAK,OAAO;EACtB;EACA,YAAY,OAAO;CACrB;AACF;AAEA,YAAY,0BAA0B"}
@@ -1,3 +1,4 @@
1
+ import { useLanguage } from "../composables/remoteContext.mjs";
1
2
  import { composition } from "../lib/composition.mjs";
2
3
  import { Badge } from "../auto-generated/Badge.mjs";
3
4
  import { Button } from "../auto-generated/Button.mjs";
@@ -10,11 +11,12 @@ import { IconSave } from "../icons/components/IconSave.mjs";
10
11
  import { IconUndo } from "../icons/components/IconUndo.mjs";
11
12
  import watchMobxValue from "../lib/mobxSelector.mjs";
12
13
  import { ListFilter } from "../../../components-base/src/list/filter/ListFilter.mjs";
14
+ import { formatListDateRange } from "../../../components-base/src/list/filter/formatDateRange.mjs";
13
15
  import "../../../components-base/src/index.mjs";
14
16
  import { injectListModel } from "./listContext.mjs";
15
17
  import { useListTexts } from "./locales.mjs";
16
18
  import { listStyles } from "./styles.mjs";
17
- import { formatDateRange, isDateRangeFilter } from "./dateRangeFilter.mjs";
19
+ import { isDateRangeFilter } from "./dateRangeFilter.mjs";
18
20
  import { defineComponent, h } from "vue";
19
21
  //#region src/list/ActiveFilters.ts
20
22
  /**
@@ -33,12 +35,13 @@ var ActiveFilters = defineComponent({
33
35
  setup(props) {
34
36
  const list = injectListModel();
35
37
  const texts = useListTexts();
38
+ const language = useLanguage();
36
39
  const tableRevision = watchMobxValue(() => list.listTable.revision);
37
- const iconButton = (label, icon, onPress, { labelled = true } = {}) => h(TooltipTrigger, { isDisabled: props.isDisabled }, () => [h(Tooltip, null, () => texts.value(label)), h(Button, {
40
+ const iconButton = (label, icon, onPress) => h(TooltipTrigger, { isDisabled: props.isDisabled }, () => [h(Tooltip, null, () => texts.value(label)), h(Button, {
38
41
  size: "s",
39
42
  variant: "plain",
40
43
  color: "secondary",
41
- "aria-label": labelled ? texts.value(label) : void 0,
44
+ "aria-label": texts.value(label),
42
45
  onPress
43
46
  }, () => h(icon))]);
44
47
  return () => {
@@ -51,7 +54,7 @@ var ActiveFilters = defineComponent({
51
54
  key: filter.storageKey,
52
55
  isDisabled: props.isDisabled,
53
56
  onClose: () => filter.clear()
54
- }, () => h(Text, null, () => formatDateRange(range)))] : [];
57
+ }, () => h(Text, null, () => formatListDateRange(range, language.value ?? navigator.language, texts.value)))] : [];
55
58
  }
56
59
  return filter.values.filter((value) => value.isActive).map((value) => h(Badge, {
57
60
  key: value.id,
@@ -65,7 +68,7 @@ var ActiveFilters = defineComponent({
65
68
  manualSave: true
66
69
  })) : void 0;
67
70
  const resetButton = hasChanges ? iconButton("filters.reset", IconUndo, () => list.resetFilters()) : void 0;
68
- const clearButton = chips.length > 1 ? iconButton("filters.clear", IconClose, () => list.filters.forEach((filter) => filter.clear()), { labelled: false }) : void 0;
71
+ const clearButton = chips.length > 1 ? iconButton("filters.clear", IconClose, () => list.filters.forEach((filter) => filter.clear())) : void 0;
69
72
  if (chips.length === 0 && !storeButton && !resetButton) return null;
70
73
  return h(Div, { class: listStyles.activeFilters }, () => [
71
74
  ...chips,
@@ -1 +1 @@
1
- {"version":3,"file":"ActiveFilters.mjs","names":[],"sources":["../../../../../src/list/ActiveFilters.ts"],"sourcesContent":["import {\n Badge,\n Button,\n Div,\n Text,\n Tooltip,\n TooltipTrigger,\n} from \"@/auto-generated\";\nimport { IconClose, IconSave, IconUndo } from \"@/icons\";\nimport { watchMobxValue } from \"@/lib/mobxSelector\";\nimport { ListFilter } from \"@mittwald/flow-components-base\";\nimport type { ListDateRange } from \"@mittwald/flow-components-base\";\nimport { defineComponent, h, type VNodeChild } from \"vue\";\nimport { formatDateRange, isDateRangeFilter } from \"./dateRangeFilter\";\nimport { injectListModel } from \"./listContext\";\nimport { useListTexts, type ListTextKey } from \"./locales\";\nimport { listStyles } from \"./styles\";\nimport type { ListRendered } from \"./types\";\nimport { composition } from \"@/lib/composition\";\n\n/** What the chips need of a filter and its values, and nothing more. */\ninterface ChipDateRangeFilter {\n readonly name?: string;\n getValue(): ListDateRange | null;\n clear(): void;\n}\n\ninterface ChipFilter {\n readonly storageKey: string;\n readonly mode: string;\n readonly values: {\n readonly id: string;\n readonly isActive: boolean;\n deactivate(): void;\n render(): ListRendered;\n }[];\n getArrayValue(): { id: string }[];\n isStoringAvailable(): boolean;\n hasChanges(): boolean;\n}\n\n/**\n * The selected filter values, and what can be done with the set of them.\n *\n * Shown beside the filter menus rather than inside them, so a selection made in\n * one menu stays visible while another is open — and can be taken back one\n * value at a time.\n */\nexport const ActiveFilters = defineComponent({\n name: \"ListActiveFilters\",\n\n props: {\n isDisabled: { type: Boolean, default: false },\n },\n\n setup(props) {\n const list = injectListModel();\n const texts = useListTexts();\n\n /* Every read here is of the table's filter state. */\n const tableRevision = watchMobxValue(() => list.listTable.revision);\n\n const iconButton = (\n label: ListTextKey,\n icon: unknown,\n onPress: () => void,\n { labelled = true }: { labelled?: boolean } = {},\n ): VNodeChild =>\n h(TooltipTrigger, { isDisabled: props.isDisabled }, () => [\n h(Tooltip, null, () => texts.value(label)),\n h(\n Button,\n {\n size: \"s\",\n variant: \"plain\",\n color: \"secondary\",\n \"aria-label\": labelled ? texts.value(label) : undefined,\n onPress,\n },\n () => h(icon as never),\n ),\n ]);\n\n return () => {\n void tableRevision.value;\n\n const filters = list.filters as unknown as ChipFilter[];\n\n const chips = filters.flatMap((filter) => {\n /* One chip for the whole range, and closing it clears the range. */\n if (isDateRangeFilter(filter)) {\n const range = (filter as unknown as ChipDateRangeFilter).getValue();\n\n return range\n ? [\n h(\n Badge,\n {\n key: filter.storageKey,\n isDisabled: props.isDisabled,\n onClose: () =>\n (filter as unknown as ChipDateRangeFilter).clear(),\n },\n () => h(Text, null, () => formatDateRange(range)),\n ),\n ]\n : [];\n }\n\n return filter.values\n .filter((value) => value.isActive)\n .map((value) =>\n h(\n Badge,\n {\n key: value.id,\n isDisabled: props.isDisabled,\n onClose: () => value.deactivate(),\n },\n () => h(Text, null, () => value.render()),\n ),\n );\n });\n\n const hasChanges = filters.some((filter) => filter.hasChanges());\n const storingAvailable = filters.some((filter) =>\n filter.isStoringAvailable(),\n );\n\n const storeButton =\n storingAvailable && hasChanges\n ? iconButton(\"filters.store\", IconSave, () =>\n ListFilter.storeFilters(list, filters, {\n autosave: false,\n manualSave: true,\n }),\n )\n : undefined;\n\n const resetButton = hasChanges\n ? iconButton(\"filters.reset\", IconUndo, () => list.resetFilters())\n : undefined;\n\n const clearButton =\n chips.length > 1\n ? iconButton(\n \"filters.clear\",\n IconClose,\n () => list.filters.forEach((filter) => filter.clear()),\n /*\n * Flow's `ActiveFilters` gives this one no `aria-label`, unlike\n * its two siblings — the tooltip is all it has. Kept, so the\n * host builds the same button; the label belongs in Flow first.\n */\n { labelled: false },\n )\n : undefined;\n\n if (chips.length === 0 && !storeButton && !resetButton) {\n return null;\n }\n\n return h(Div, { class: listStyles.activeFilters }, () => [\n ...chips,\n storeButton,\n resetButton,\n clearButton,\n ]);\n };\n },\n});\n\ncomposition(ActiveFilters);\n\nexport default ActiveFilters;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,IAAa,gBAAgB,gBAAgB;CAC3C,MAAM;CAEN,OAAO,EACL,YAAY;EAAE,MAAM;EAAS,SAAS;CAAM,EAC9C;CAEA,MAAM,OAAO;EACX,MAAM,OAAO,gBAAgB;EAC7B,MAAM,QAAQ,aAAa;EAG3B,MAAM,gBAAgB,qBAAqB,KAAK,UAAU,QAAQ;EAElE,MAAM,cACJ,OACA,MACA,SACA,EAAE,WAAW,SAAiC,CAAC,MAE/C,EAAE,gBAAgB,EAAE,YAAY,MAAM,WAAW,SAAS,CACxD,EAAE,SAAS,YAAY,MAAM,MAAM,KAAK,CAAC,GACzC,EACE,QACA;GACE,MAAM;GACN,SAAS;GACT,OAAO;GACP,cAAc,WAAW,MAAM,MAAM,KAAK,IAAI,KAAA;GAC9C;EACF,SACM,EAAE,IAAa,CACvB,CACF,CAAC;EAEH,aAAa;GACX,cAAmB;GAEnB,MAAM,UAAU,KAAK;GAErB,MAAM,QAAQ,QAAQ,SAAS,WAAW;IAExC,IAAI,kBAAkB,MAAM,GAAG;KAC7B,MAAM,QAAS,OAA0C,SAAS;KAElE,OAAO,QACH,CACE,EACE,OACA;MACE,KAAK,OAAO;MACZ,YAAY,MAAM;MAClB,eACG,OAA0C,MAAM;KACrD,SACM,EAAE,MAAM,YAAY,gBAAgB,KAAK,CAAC,CAClD,CACF,IACA,CAAC;IACP;IAEA,OAAO,OAAO,OACX,QAAQ,UAAU,MAAM,QAAQ,CAAC,CACjC,KAAK,UACJ,EACE,OACA;KACE,KAAK,MAAM;KACX,YAAY,MAAM;KAClB,eAAe,MAAM,WAAW;IAClC,SACM,EAAE,MAAM,YAAY,MAAM,OAAO,CAAC,CAC1C,CACF;GACJ,CAAC;GAED,MAAM,aAAa,QAAQ,MAAM,WAAW,OAAO,WAAW,CAAC;GAK/D,MAAM,cAJmB,QAAQ,MAAM,WACrC,OAAO,mBAAmB,CAI1B,KAAoB,aAChB,WAAW,iBAAiB,gBAC1B,WAAW,aAAa,MAAM,SAAS;IACrC,UAAU;IACV,YAAY;GACd,CAAC,CACH,IACA,KAAA;GAEN,MAAM,cAAc,aAChB,WAAW,iBAAiB,gBAAgB,KAAK,aAAa,CAAC,IAC/D,KAAA;GAEJ,MAAM,cACJ,MAAM,SAAS,IACX,WACE,iBACA,iBACM,KAAK,QAAQ,SAAS,WAAW,OAAO,MAAM,CAAC,GAMrD,EAAE,UAAU,MAAM,CACpB,IACA,KAAA;GAEN,IAAI,MAAM,WAAW,KAAK,CAAC,eAAe,CAAC,aACzC,OAAO;GAGT,OAAO,EAAE,KAAK,EAAE,OAAO,WAAW,cAAc,SAAS;IACvD,GAAG;IACH;IACA;IACA;GACF,CAAC;EACH;CACF;AACF,CAAC;AAED,YAAY,aAAa"}
1
+ {"version":3,"file":"ActiveFilters.mjs","names":[],"sources":["../../../../../src/list/ActiveFilters.ts"],"sourcesContent":["import {\n Badge,\n Button,\n Div,\n Text,\n Tooltip,\n TooltipTrigger,\n} from \"@/auto-generated\";\nimport { IconClose, IconSave, IconUndo } from \"@/icons\";\nimport { watchMobxValue } from \"@/lib/mobxSelector\";\nimport { useLanguage } from \"@/composables/remoteContext\";\nimport {\n formatListDateRange,\n ListFilter,\n} from \"@mittwald/flow-components-base\";\nimport type { ListDateRange } from \"@mittwald/flow-components-base\";\nimport { defineComponent, h, type VNodeChild } from \"vue\";\nimport { isDateRangeFilter } from \"./dateRangeFilter\";\nimport { injectListModel } from \"./listContext\";\nimport { useListTexts, type ListTextKey } from \"./locales\";\nimport { listStyles } from \"./styles\";\nimport type { ListRendered } from \"./types\";\nimport { composition } from \"@/lib/composition\";\n\n/** What the chips need of a filter and its values, and nothing more. */\ninterface ChipDateRangeFilter {\n readonly name?: string;\n getValue(): ListDateRange | null;\n clear(): void;\n}\n\ninterface ChipFilter {\n readonly storageKey: string;\n readonly mode: string;\n readonly values: {\n readonly id: string;\n readonly isActive: boolean;\n deactivate(): void;\n render(): ListRendered;\n }[];\n getArrayValue(): { id: string }[];\n isStoringAvailable(): boolean;\n hasChanges(): boolean;\n}\n\n/**\n * The selected filter values, and what can be done with the set of them.\n *\n * Shown beside the filter menus rather than inside them, so a selection made in\n * one menu stays visible while another is open — and can be taken back one\n * value at a time.\n */\nexport const ActiveFilters = defineComponent({\n name: \"ListActiveFilters\",\n\n props: {\n isDisabled: { type: Boolean, default: false },\n },\n\n setup(props) {\n const list = injectListModel();\n const texts = useListTexts();\n /* As in React's remote root: the host's language, else the browser's. */\n const language = useLanguage();\n\n /* Every read here is of the table's filter state. */\n const tableRevision = watchMobxValue(() => list.listTable.revision);\n\n const iconButton = (\n label: ListTextKey,\n icon: unknown,\n onPress: () => void,\n ): VNodeChild =>\n h(TooltipTrigger, { isDisabled: props.isDisabled }, () => [\n h(Tooltip, null, () => texts.value(label)),\n h(\n Button,\n {\n size: \"s\",\n variant: \"plain\",\n color: \"secondary\",\n \"aria-label\": texts.value(label),\n onPress,\n },\n () => h(icon as never),\n ),\n ]);\n\n return () => {\n void tableRevision.value;\n\n const filters = list.filters as unknown as ChipFilter[];\n\n const chips = filters.flatMap((filter) => {\n /* One chip for the whole range, and closing it clears the range. */\n if (isDateRangeFilter(filter)) {\n const range = (filter as unknown as ChipDateRangeFilter).getValue();\n\n return range\n ? [\n h(\n Badge,\n {\n key: filter.storageKey,\n isDisabled: props.isDisabled,\n onClose: () =>\n (filter as unknown as ChipDateRangeFilter).clear(),\n },\n () =>\n h(Text, null, () =>\n formatListDateRange(\n range,\n language.value ?? navigator.language,\n texts.value,\n ),\n ),\n ),\n ]\n : [];\n }\n\n return filter.values\n .filter((value) => value.isActive)\n .map((value) =>\n h(\n Badge,\n {\n key: value.id,\n isDisabled: props.isDisabled,\n onClose: () => value.deactivate(),\n },\n () => h(Text, null, () => value.render()),\n ),\n );\n });\n\n const hasChanges = filters.some((filter) => filter.hasChanges());\n const storingAvailable = filters.some((filter) =>\n filter.isStoringAvailable(),\n );\n\n const storeButton =\n storingAvailable && hasChanges\n ? iconButton(\"filters.store\", IconSave, () =>\n ListFilter.storeFilters(list, filters, {\n autosave: false,\n manualSave: true,\n }),\n )\n : undefined;\n\n const resetButton = hasChanges\n ? iconButton(\"filters.reset\", IconUndo, () => list.resetFilters())\n : undefined;\n\n const clearButton =\n chips.length > 1\n ? iconButton(\"filters.clear\", IconClose, () =>\n list.filters.forEach((filter) => filter.clear()),\n )\n : undefined;\n\n if (chips.length === 0 && !storeButton && !resetButton) {\n return null;\n }\n\n return h(Div, { class: listStyles.activeFilters }, () => [\n ...chips,\n storeButton,\n resetButton,\n clearButton,\n ]);\n };\n },\n});\n\ncomposition(ActiveFilters);\n\nexport default ActiveFilters;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoDA,IAAa,gBAAgB,gBAAgB;CAC3C,MAAM;CAEN,OAAO,EACL,YAAY;EAAE,MAAM;EAAS,SAAS;CAAM,EAC9C;CAEA,MAAM,OAAO;EACX,MAAM,OAAO,gBAAgB;EAC7B,MAAM,QAAQ,aAAa;EAE3B,MAAM,WAAW,YAAY;EAG7B,MAAM,gBAAgB,qBAAqB,KAAK,UAAU,QAAQ;EAElE,MAAM,cACJ,OACA,MACA,YAEA,EAAE,gBAAgB,EAAE,YAAY,MAAM,WAAW,SAAS,CACxD,EAAE,SAAS,YAAY,MAAM,MAAM,KAAK,CAAC,GACzC,EACE,QACA;GACE,MAAM;GACN,SAAS;GACT,OAAO;GACP,cAAc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aAAa"}
@@ -23,6 +23,7 @@ import { listStyles } from "./styles.mjs";
23
23
  import { ModalTrigger } from "../overlays/triggers.mjs";
24
24
  import { isDateRangeFilter } from "./dateRangeFilter.mjs";
25
25
  import { Modal } from "../overlays/Modal.mjs";
26
+ import { DateTimeRangeFields } from "./DateTimeRangeFields.mjs";
26
27
  import { defineComponent, h } from "vue";
27
28
  //#region src/list/AllFiltersModal.ts
28
29
  var accordion = (key, heading, expanded, content) => h(Accordion, {
@@ -35,8 +36,8 @@ var renderDateRangeAccordion = (filter, expanded, texts) => {
35
36
  return accordion(`filter-${name}`, name, expanded, () => h(Flex, {
36
37
  direction: "column",
37
38
  gap: "m"
38
- }, () => [h(RangeCalendar, {
39
- ...filter.dateRangeOptions,
39
+ }, () => [filter.granularity === "minute" ? h(DateTimeRangeFields, { filter }) : h(RangeCalendar, {
40
+ ...filter.rangeCalendarProps,
40
41
  value,
41
42
  onChange: (range) => filter.setValue(range)
42
43
  }), value ? h(Button, {