@mittwald/flow-remote-vue-components 1.6.0-next.24 → 1.6.0-next.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/js/components-base/src/index.mjs +4 -2
- package/dist/js/components-base/src/list/filter/ListDateRangeFilter.mjs +1 -0
- package/dist/js/components-base/src/list/filter/ListDateRangeFilter.mjs.map +1 -1
- package/dist/js/components-base/src/list/filter/ListFilter.mjs +4 -1
- package/dist/js/components-base/src/list/filter/ListFilter.mjs.map +1 -1
- package/dist/js/components-base/src/list/filter/dateRange.mjs +37 -13
- package/dist/js/components-base/src/list/filter/dateRange.mjs.map +1 -1
- package/dist/js/components-base/src/list/filter/dateTimeRangeFields.mjs +53 -0
- package/dist/js/components-base/src/list/filter/dateTimeRangeFields.mjs.map +1 -0
- package/dist/js/components-base/src/list/filter/formatDateRange.mjs +25 -0
- package/dist/js/components-base/src/list/filter/formatDateRange.mjs.map +1 -0
- package/dist/js/index.mjs +2 -1
- package/dist/js/remote-vue-components/src/list/ActiveFilters.mjs +5 -2
- package/dist/js/remote-vue-components/src/list/ActiveFilters.mjs.map +1 -1
- package/dist/js/remote-vue-components/src/list/AllFiltersModal.mjs +3 -2
- package/dist/js/remote-vue-components/src/list/AllFiltersModal.mjs.map +1 -1
- package/dist/js/remote-vue-components/src/list/DateTimeRangeFields.mjs +100 -0
- package/dist/js/remote-vue-components/src/list/DateTimeRangeFields.mjs.map +1 -0
- package/dist/js/remote-vue-components/src/list/Header.mjs +11 -7
- package/dist/js/remote-vue-components/src/list/Header.mjs.map +1 -1
- package/dist/js/remote-vue-components/src/list/dateRangeFilter.mjs +14 -6
- package/dist/js/remote-vue-components/src/list/dateRangeFilter.mjs.map +1 -1
- package/dist/js/remote-vue-components/src/list/locales.mjs +14 -0
- package/dist/js/remote-vue-components/src/list/locales.mjs.map +1 -1
- package/dist/js/remote-vue-components/src/list/styles.mjs +7 -1
- package/dist/js/remote-vue-components/src/list/styles.mjs.map +1 -1
- package/dist/js/remote-vue-components/src/version.mjs +1 -1
- package/dist/types/_bundled/flow-components-base/index.d.ts +3 -1
- package/dist/types/_bundled/flow-components-base/list/filter/ListFilter.d.ts +2 -0
- package/dist/types/_bundled/flow-components-base/list/filter/dateRange.d.ts +24 -1
- package/dist/types/_bundled/flow-components-base/list/filter/dateTimeRangeFields.d.ts +34 -0
- package/dist/types/_bundled/flow-components-base/list/filter/formatDateRange.d.ts +7 -0
- package/dist/types/list/DateTimeRangeFields.d.ts +43 -0
- package/dist/types/list/dateRangeFilter.d.ts +6 -6
- package/dist/types/list/index.d.ts +1 -0
- package/dist/types/list/locales.d.ts +14 -0
- package/dist/types/list/styles.d.ts +6 -0
- package/dist/types/list/types.d.ts +8 -2
- package/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 };
|
|
@@ -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;
|
|
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
|
-
|
|
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;CACA;CAIA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA,0CAA2C,IAAI,IAA2B;CAC1E;CACA;CACA;CAEA,YACE,SACA,OACA;EACA,MAAM,EACJ,WAAW,QAAQ,kBAAkB,SAAS,YAAY,OAC1D,aAAa,QAAQ,kBAAkB,SAAS,cAAc,MAC9D,UACA,OAAO,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AAc,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"],"mappings":";;;;;;AAqBA,IAAM,yBACJ,aACA,kBACG,gBAAgB;;AAGrB,IAAM,yBAAyB;AAE/B,IAAM,0BACJ,UACG,OAAO,KAAK;;;;;;;;;;;;;;AAqBjB,IAAa,aAAb,MAKE;CACA;CACA;CAIA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA,0CA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AAK,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
|
|
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
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* start of its day
|
|
18
|
-
*
|
|
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
|
|
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
|
|
37
|
-
|
|
38
|
-
|
|
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 {
|
|
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"],"mappings":";;;;AA2BA,IAAa,mBAAmB,UAC9B,CAAC,CAAC,SAAS,OAAO,UAAU,YAAY,WAAW,SAAS,SAAS;AAEvE,IAAM,WAAW,SAAwB,UAAU;;;;;;AAOnD,IAAa,sBAAsB,SACjC,gBAAgB,gBACZ,SAAS,WAAW,KAAK,OAAO,CAAC,IACjC,SAAS,WAAW;CAClB,MAAM,KAAK;CACX,OAAO,KAAK;CACZ,KAAK,KAAK;CACV,GAAI,QAAQ,IAAI,IACZ;EAAE,MAAM,KAAK;EAAM,QAAQ,KAAK;EAAQ,QAAQ,KAAK;CAAO,IAC5D,CAAC;AACP,CAAC;;;;;;;AAQP,IAAa,wBACX,UACiC;CACjC,MAAM,QAAQ,SAAyB,QAAQ,IAAI,IAAI,WAAW;CAElE,OAAO;EACL,OAAO,MAAM,QACT,mBAAmB,MAAM,KAAK,CAAC,CAAC,QAAQ,KAAK,MAAM,KAAK,CAAC,CAAC,CAAC,SAAS,IACpE,KAAA;EACJ,KAAK,MAAM,MACP,mBAAmB,MAAM,GAAG,CAAC,CAAC,MAAM,KAAK,MAAM,GAAG,CAAC,CAAC,CAAC,SAAS,IAC9D,KAAA;CACN;AACF;;;;;;;;;;;AAYA,IAAM,cAAc,UAAyC;CAC3D,IAAI,iBAAiB,UACnB,OAAO;CAET,IACE,iBAAiB,gBACjB,iBAAiB,oBACjB,iBAAiB,eAEjB,OAAO,mBAAmB,KAAK;CAEjC,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,EAAE,OAAO,QAAQ,qBAAqB,KAAK;CAEjD,IAAI,SAAS,UAAU,SAAS,IAAI,MAAM,QAAQ,GAChD,OAAO;CAGT,OAAO,EAAE,OAAO,UAAU,SAAS,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;C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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 };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useLanguage } from "../composables/remoteContext.mjs";
|
|
1
2
|
import { composition } from "../lib/composition.mjs";
|
|
2
3
|
import { Badge } from "../auto-generated/Badge.mjs";
|
|
3
4
|
import { Button } from "../auto-generated/Button.mjs";
|
|
@@ -10,11 +11,12 @@ import { IconSave } from "../icons/components/IconSave.mjs";
|
|
|
10
11
|
import { IconUndo } from "../icons/components/IconUndo.mjs";
|
|
11
12
|
import watchMobxValue from "../lib/mobxSelector.mjs";
|
|
12
13
|
import { ListFilter } from "../../../components-base/src/list/filter/ListFilter.mjs";
|
|
14
|
+
import { formatListDateRange } from "../../../components-base/src/list/filter/formatDateRange.mjs";
|
|
13
15
|
import "../../../components-base/src/index.mjs";
|
|
14
16
|
import { injectListModel } from "./listContext.mjs";
|
|
15
17
|
import { useListTexts } from "./locales.mjs";
|
|
16
18
|
import { listStyles } from "./styles.mjs";
|
|
17
|
-
import {
|
|
19
|
+
import { isDateRangeFilter } from "./dateRangeFilter.mjs";
|
|
18
20
|
import { defineComponent, h } from "vue";
|
|
19
21
|
//#region src/list/ActiveFilters.ts
|
|
20
22
|
/**
|
|
@@ -33,6 +35,7 @@ var ActiveFilters = defineComponent({
|
|
|
33
35
|
setup(props) {
|
|
34
36
|
const list = injectListModel();
|
|
35
37
|
const texts = useListTexts();
|
|
38
|
+
const language = useLanguage();
|
|
36
39
|
const tableRevision = watchMobxValue(() => list.listTable.revision);
|
|
37
40
|
const iconButton = (label, icon, onPress) => h(TooltipTrigger, { isDisabled: props.isDisabled }, () => [h(Tooltip, null, () => texts.value(label)), h(Button, {
|
|
38
41
|
size: "s",
|
|
@@ -51,7 +54,7 @@ var ActiveFilters = defineComponent({
|
|
|
51
54
|
key: filter.storageKey,
|
|
52
55
|
isDisabled: props.isDisabled,
|
|
53
56
|
onClose: () => filter.clear()
|
|
54
|
-
}, () => h(Text, null, () =>
|
|
57
|
+
}, () => h(Text, null, () => formatListDateRange(range, language.value ?? navigator.language, texts.value)))] : [];
|
|
55
58
|
}
|
|
56
59
|
return filter.values.filter((value) => value.isActive).map((value) => h(Badge, {
|
|
57
60
|
key: value.id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActiveFilters.mjs","names":[],"sources":["../../../../../src/list/ActiveFilters.ts"],"sourcesContent":["import {\n Badge,\n Button,\n Div,\n Text,\n Tooltip,\n TooltipTrigger,\n} from \"@/auto-generated\";\nimport { IconClose, IconSave, IconUndo } from \"@/icons\";\nimport { watchMobxValue } from \"@/lib/mobxSelector\";\nimport {
|
|
1
|
+
{"version":3,"file":"ActiveFilters.mjs","names":[],"sources":["../../../../../src/list/ActiveFilters.ts"],"sourcesContent":["import {\n Badge,\n Button,\n Div,\n Text,\n Tooltip,\n TooltipTrigger,\n} from \"@/auto-generated\";\nimport { IconClose, IconSave, IconUndo } from \"@/icons\";\nimport { watchMobxValue } from \"@/lib/mobxSelector\";\nimport { useLanguage } from \"@/composables/remoteContext\";\nimport {\n formatListDateRange,\n ListFilter,\n} from \"@mittwald/flow-components-base\";\nimport type { ListDateRange } from \"@mittwald/flow-components-base\";\nimport { defineComponent, h, type VNodeChild } from \"vue\";\nimport { isDateRangeFilter } from \"./dateRangeFilter\";\nimport { injectListModel } from \"./listContext\";\nimport { useListTexts, type ListTextKey } from \"./locales\";\nimport { listStyles } from \"./styles\";\nimport type { ListRendered } from \"./types\";\nimport { composition } from \"@/lib/composition\";\n\n/** What the chips need of a filter and its values, and nothing more. */\ninterface ChipDateRangeFilter {\n readonly name?: string;\n getValue(): ListDateRange | null;\n clear(): void;\n}\n\ninterface ChipFilter {\n readonly storageKey: string;\n readonly mode: string;\n readonly values: {\n readonly id: string;\n readonly isActive: boolean;\n deactivate(): void;\n render(): ListRendered;\n }[];\n getArrayValue(): { id: string }[];\n isStoringAvailable(): boolean;\n hasChanges(): boolean;\n}\n\n/**\n * The selected filter values, and what can be done with the set of them.\n *\n * Shown beside the filter menus rather than inside them, so a selection made in\n * one menu stays visible while another is open — and can be taken back one\n * value at a time.\n */\nexport const ActiveFilters = defineComponent({\n name: \"ListActiveFilters\",\n\n props: {\n isDisabled: { type: Boolean, default: false },\n },\n\n setup(props) {\n const list = injectListModel();\n const texts = useListTexts();\n /* As in React's remote root: the host's language, else the browser's. */\n const language = useLanguage();\n\n /* Every read here is of the table's filter state. */\n const tableRevision = watchMobxValue(() => list.listTable.revision);\n\n const iconButton = (\n label: ListTextKey,\n icon: unknown,\n onPress: () => void,\n ): VNodeChild =>\n h(TooltipTrigger, { isDisabled: props.isDisabled }, () => [\n h(Tooltip, null, () => texts.value(label)),\n h(\n Button,\n {\n size: \"s\",\n variant: \"plain\",\n color: \"secondary\",\n \"aria-label\": texts.value(label),\n onPress,\n },\n () => h(icon as never),\n ),\n ]);\n\n return () => {\n void tableRevision.value;\n\n const filters = list.filters as unknown as ChipFilter[];\n\n const chips = filters.flatMap((filter) => {\n /* One chip for the whole range, and closing it clears the range. */\n if (isDateRangeFilter(filter)) {\n const range = (filter as unknown as ChipDateRangeFilter).getValue();\n\n return range\n ? [\n h(\n Badge,\n {\n key: filter.storageKey,\n isDisabled: props.isDisabled,\n onClose: () =>\n (filter as unknown as ChipDateRangeFilter).clear(),\n },\n () =>\n h(Text, null, () =>\n formatListDateRange(\n range,\n language.value ?? navigator.language,\n texts.value,\n ),\n ),\n ),\n ]\n : [];\n }\n\n return filter.values\n .filter((value) => value.isActive)\n .map((value) =>\n h(\n Badge,\n {\n key: value.id,\n isDisabled: props.isDisabled,\n onClose: () => value.deactivate(),\n },\n () => h(Text, null, () => value.render()),\n ),\n );\n });\n\n const hasChanges = filters.some((filter) => filter.hasChanges());\n const storingAvailable = filters.some((filter) =>\n filter.isStoringAvailable(),\n );\n\n const storeButton =\n storingAvailable && hasChanges\n ? iconButton(\"filters.store\", IconSave, () =>\n ListFilter.storeFilters(list, filters, {\n autosave: false,\n manualSave: true,\n }),\n )\n : undefined;\n\n const resetButton = hasChanges\n ? iconButton(\"filters.reset\", IconUndo, () => list.resetFilters())\n : undefined;\n\n const clearButton =\n chips.length > 1\n ? iconButton(\"filters.clear\", IconClose, () =>\n list.filters.forEach((filter) => filter.clear()),\n )\n : undefined;\n\n if (chips.length === 0 && !storeButton && !resetButton) {\n return null;\n }\n\n return h(Div, { class: listStyles.activeFilters }, () => [\n ...chips,\n storeButton,\n resetButton,\n clearButton,\n ]);\n };\n },\n});\n\ncomposition(ActiveFilters);\n\nexport default ActiveFilters;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoDA,IAAa,gBAAgB,gBAAgB;CAC3C,MAAM;CAEN,OAAO,EACL,YAAY;EAAE,MAAM;EAAS,SAAS;CAAM,EAC9C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K,aAAa,CAAC,IAC/D,KAAA;GAEJ,MAAM,cACJ,MAAM,SAAS,IACX,WAAW,iBAAiB,iBAC1B,KAAK,QAAQ,SAAS,WAAW,OAAO,MAAM,CAAC,CACjD,IACA,KAAA;GAEN,IAAI,MAAM,WAAW,KAAK,CAAC,eAAe,CAAC,aACzC,OAAO;GAGT,OAAO,EAAE,KAAK,EAAE,OAAO,WAAW,cAAc,SAAS;IACvD,GAAG;IACH;IACA;IACA;GACF,CAAC;EACH;CACF;AACF,CAAC;AAED,YAAY,aAAa"}
|
|
@@ -23,6 +23,7 @@ import { listStyles } from "./styles.mjs";
|
|
|
23
23
|
import { ModalTrigger } from "../overlays/triggers.mjs";
|
|
24
24
|
import { isDateRangeFilter } from "./dateRangeFilter.mjs";
|
|
25
25
|
import { Modal } from "../overlays/Modal.mjs";
|
|
26
|
+
import { DateTimeRangeFields } from "./DateTimeRangeFields.mjs";
|
|
26
27
|
import { defineComponent, h } from "vue";
|
|
27
28
|
//#region src/list/AllFiltersModal.ts
|
|
28
29
|
var accordion = (key, heading, expanded, content) => h(Accordion, {
|
|
@@ -35,8 +36,8 @@ var renderDateRangeAccordion = (filter, expanded, texts) => {
|
|
|
35
36
|
return accordion(`filter-${name}`, name, expanded, () => h(Flex, {
|
|
36
37
|
direction: "column",
|
|
37
38
|
gap: "m"
|
|
38
|
-
}, () => [h(RangeCalendar, {
|
|
39
|
-
...filter.
|
|
39
|
+
}, () => [filter.granularity === "minute" ? h(DateTimeRangeFields, { filter }) : h(RangeCalendar, {
|
|
40
|
+
...filter.rangeCalendarProps,
|
|
40
41
|
value,
|
|
41
42
|
onChange: (range) => filter.setValue(range)
|
|
42
43
|
}), value ? h(Button, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AllFiltersModal.mjs","names":[],"sources":["../../../../../src/list/AllFiltersModal.ts"],"sourcesContent":["import {\n Accordion,\n AccordionGroup,\n ActionGroup,\n Button,\n Checkbox,\n CheckboxGroup,\n Content,\n Flex,\n Heading,\n Radio,\n RadioGroup,\n RangeCalendar,\n Section,\n SkeletonText,\n Text,\n} from \"@/auto-generated\";\nimport { IconFilter } from \"@/icons\";\nimport { watchMobxValue } from \"@/lib/mobxSelector\";\nimport { Modal } from \"@/overlays/Modal\";\nimport { createOverlayController } from \"@/overlays/overlayController\";\nimport { ModalTrigger } from \"@/overlays/triggers\";\nimport { defineComponent, h, type VNodeChild } from \"vue\";\nimport { isDateRangeFilter } from \"./dateRangeFilter\";\nimport { injectListModel, type AnyListModel } from \"./listContext\";\nimport { useListTexts, type ListTextFormatter } from \"./locales\";\nimport { listStyles } from \"./styles\";\nimport type { ListRendered } from \"./types\";\nimport { composition } from \"@/lib/composition\";\n\n/*\n * What this modal needs of a filter and a sorting. Not the classes: a list of\n * concrete filters is not assignable to a list of generic ones — a row model\n * sits in a contravariant position deep inside `Column`.\n */\ninterface ModalFilterValue {\n readonly id: string;\n readonly isActive: boolean;\n toggle(): void;\n render(): ListRendered;\n}\n\ninterface ModalFilter {\n readonly name?: string;\n readonly property: unknown;\n readonly mode: string;\n readonly priority: \"primary\" | \"secondary\";\n readonly values: ModalFilterValue[];\n readonly isSelectAllAvailable: boolean;\n isActive(): boolean;\n isEveryValueActive(): boolean;\n selectAll(): void;\n deselectAll(): void;\n clear(): void;\n}\n\ninterface ModalSorting {\n readonly id: string;\n readonly name?: string;\n readonly property: unknown;\n readonly directionName?: string;\n isSorted(): boolean;\n enable(): void;\n}\n\nconst accordion = (\n key: string,\n heading: string,\n expanded: boolean,\n content: () => VNodeChild,\n): VNodeChild =>\n h(Accordion, { key, defaultExpanded: expanded }, () => [\n h(Heading, null, () => heading),\n h(Content, null, content),\n ]);\n\ninterface ModalDateRangeFilter {\n readonly name?: string;\n readonly property: unknown;\n readonly dateRangeOptions?: Record<string, unknown>;\n getValue(): unknown;\n setValue(range: unknown): void;\n clear(): void;\n}\n\nconst renderDateRangeAccordion = (\n filter: ModalDateRangeFilter,\n expanded: boolean,\n texts: ListTextFormatter,\n): VNodeChild => {\n const name = filter.name ?? String(filter.property);\n const value = filter.getValue();\n\n return accordion(`filter-${name}`, name, expanded, () =>\n h(Flex, { direction: \"column\", gap: \"m\" }, () => [\n h(RangeCalendar, {\n ...filter.dateRangeOptions,\n value,\n onChange: (range: unknown) => filter.setValue(range),\n } as never),\n value\n ? h(\n Button,\n {\n size: \"s\",\n color: \"secondary\",\n variant: \"soft\",\n onPress: () => filter.clear(),\n },\n () => texts(\"filters.clearSelection\"),\n )\n : null,\n ]),\n );\n};\n\n/*\n * Flow's `FilterAccordionCheckboxGroup`: outside the checkbox group, so it is\n * not one of the values, and indeterminate while only some of them are on.\n */\nconst renderSelectAllCheckbox = (\n filter: ModalFilter,\n texts: ListTextFormatter,\n): VNodeChild => {\n const isEveryValueActive = filter.isEveryValueActive();\n\n return h(\n Checkbox,\n {\n key: \"select-all\",\n class: listStyles.selectAllCheckbox,\n isSelected: isEveryValueActive,\n isIndeterminate: filter.isActive() && !isEveryValueActive,\n onChange: () =>\n isEveryValueActive ? filter.deselectAll() : filter.selectAll(),\n },\n () =>\n texts(isEveryValueActive ? \"filters.deselectAll\" : \"filters.selectAll\"),\n );\n};\n\nconst renderFilterAccordion = (\n filter: ModalFilter,\n expanded: boolean,\n texts: ListTextFormatter,\n): VNodeChild => {\n const name = filter.name ?? String(filter.property);\n const activeIds = filter.values.filter((v) => v.isActive).map((v) => v.id);\n\n const content = (): VNodeChild =>\n filter.mode === \"one\"\n ? h(Flex, { direction: \"column\", gap: \"m\" }, () => [\n h(\n RadioGroup,\n {\n /*\n * Keyed on the selection, like Flow's: the group is controlled\n * and only remounting makes it pick up a value that changed from\n * outside — a chip removed, a reset.\n */\n key: activeIds[0],\n value: activeIds[0],\n m: [1, 1],\n \"aria-label\": name,\n },\n () =>\n filter.values.map((value) =>\n h(\n Radio,\n {\n key: value.id,\n value: value.id,\n onPress: () => {\n if (!value.isActive) {\n value.toggle();\n }\n },\n },\n () => value.render(),\n ),\n ),\n ),\n activeIds.length > 0\n ? h(\n Button,\n {\n size: \"s\",\n color: \"secondary\",\n variant: \"soft\",\n onPress: () => filter.clear(),\n },\n () => texts(\"filters.clearSelection\"),\n )\n : null,\n ])\n : [\n filter.isSelectAllAvailable\n ? renderSelectAllCheckbox(filter, texts)\n : null,\n h(\n CheckboxGroup,\n { value: activeIds, m: [1, 1], \"aria-label\": name },\n () =>\n filter.values.map((value) =>\n h(\n Checkbox,\n {\n key: value.id,\n value: value.id,\n onPress: () => value.toggle(),\n },\n () => value.render(),\n ),\n ),\n ),\n ];\n\n return accordion(`filter-${name}`, name, expanded, content);\n};\n\nconst renderSortingAccordion = (\n sortings: ModalSorting[],\n expanded: boolean,\n texts: ListTextFormatter,\n): VNodeChild => {\n const active = sortings.find((s) => s.isSorted());\n\n return accordion(\"sorting\", texts(\"sorting\"), expanded, () =>\n h(RadioGroup, { value: active?.id, m: [1, 1] }, () =>\n sortings.map((sorting) =>\n h(\n Radio,\n {\n key: sorting.id,\n value: sorting.id,\n onPress: () => sorting.enable(),\n },\n () =>\n `${sorting.name ?? String(sorting.property)} ${sorting.directionName ?? \"\"}`.trim(),\n ),\n ),\n ),\n );\n};\n\nconst renderViewModeAccordion = (\n list: AnyListModel,\n modes: (\"list\" | \"table\" | \"tiles\")[],\n selected: \"list\" | \"table\" | \"tiles\",\n expanded: boolean,\n texts: ListTextFormatter,\n): VNodeChild =>\n accordion(\"viewMode\", texts(\"settings.viewMode\"), expanded, () =>\n h(RadioGroup, { value: selected, m: [1, 1] }, () =>\n modes.map((mode) =>\n h(\n Radio,\n { key: mode, value: mode, onPress: () => list.viewMode.set(mode) },\n () => texts(`settings.viewMode.${mode}`),\n ),\n ),\n ),\n );\n\n/**\n * Every filter, sorting and view mode in one off-canvas modal.\n *\n * The mobile path to what the header shows as separate menus on desktop — and\n * on desktop too, where a list has secondary filters that the header leaves\n * out. It drives the same model objects, so a value ticked here is the same\n * event as one ticked in a menu.\n */\nexport const AllFiltersModal = defineComponent({\n name: \"ListAllFiltersModal\",\n\n props: {\n isDisabled: { type: Boolean, default: false },\n /** The layouts this list can show, from the header. */\n viewModes: {\n type: Array as () => (\"list\" | \"table\" | \"tiles\")[],\n default: () => [],\n },\n },\n\n setup(props) {\n const list = injectListModel();\n const texts = useListTexts();\n const controller = createOverlayController();\n\n const isInitiallyLoading = watchMobxValue(\n () => list.loaderState.isInitiallyLoading,\n );\n const viewMode = watchMobxValue(() => list.viewMode.value);\n const totalItemCount = watchMobxValue(() => {\n void list.listTable.revision;\n return list.batches.getTotalItemsCount();\n });\n /* Every value below is read off the table's filter and sorting state. */\n const tableRevision = watchMobxValue(() => list.listTable.revision);\n\n return () => {\n void tableRevision.value;\n\n const format = texts.value;\n const filters = list.filters as unknown as ModalFilter[];\n const sortings = list.visibleSorting as unknown as ModalSorting[];\n const modes = props.viewModes;\n\n const accordionCount =\n (modes.length > 1 ? 1 : 0) +\n (sortings.length > 0 ? 1 : 0) +\n filters.length;\n\n if (accordionCount === 0) {\n return null;\n }\n\n /* Two or fewer open by default — more than that is a wall of controls. */\n const expanded = accordionCount <= 2;\n\n const accordions: VNodeChild[] = [\n modes.length > 1\n ? renderViewModeAccordion(\n list,\n modes,\n viewMode.value,\n expanded,\n format,\n )\n : null,\n sortings.length > 0\n ? renderSortingAccordion(sortings, expanded, format)\n : null,\n ...filters.map((filter) =>\n isDateRangeFilter(filter)\n ? renderDateRangeAccordion(\n filter as unknown as ModalDateRangeFilter,\n expanded,\n format,\n )\n : renderFilterAccordion(filter, expanded, format),\n ),\n ];\n\n const hasSecondaryFilters = filters.some(\n (filter) => filter.priority === \"secondary\",\n );\n\n const showCount = format(\n totalItemCount.value === 1 ? \"results.show.one\" : \"results.show.other\",\n { totalItemCount: totalItemCount.value },\n );\n\n return h(ModalTrigger, { controller }, () => [\n h(\n Button,\n {\n class: [\n listStyles.hideOnMobile,\n hasSecondaryFilters ? undefined : listStyles.hideOnDesktop,\n ]\n .filter(Boolean)\n .join(\" \"),\n variant: \"outline\",\n color: \"secondary\",\n isDisabled: props.isDisabled,\n },\n () => [h(Text, null, () => format(\"filters.all\")), h(IconFilter)],\n ),\n\n h(\n Button,\n {\n class: listStyles.hideOnDesktop,\n variant: \"outline\",\n color: \"secondary\",\n \"aria-label\": format(\"filters.all\"),\n },\n () => h(IconFilter),\n ),\n\n h(Modal, { offCanvas: true, controller }, () => [\n h(Heading, null, () => format(\"filters.all\")),\n h(Content, null, () =>\n h(Section, null, () => h(AccordionGroup, null, () => accordions)),\n ),\n h(ActionGroup, null, () => [\n h(Button, { onPress: () => controller.close() }, () =>\n h(Text, null, () =>\n isInitiallyLoading.value\n ? h(SkeletonText, { width: \"16ch\" })\n : showCount,\n ),\n ),\n h(\n Button,\n {\n color: \"secondary\",\n variant: \"soft\",\n onPress: () => {\n list.resetFilters();\n controller.close();\n },\n },\n () => format(\"reset\"),\n ),\n ]),\n ]),\n ]);\n };\n },\n});\n\ncomposition(AllFiltersModal);\n\nexport default AllFiltersModal;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAiEA,IAAM,aACJ,KACA,SACA,UACA,YAEA,EAAE,WAAW;CAAE;CAAK,iBAAiB;AAAS,SAAS,CACrD,EAAE,SAAS,YAAY,OAAO,GAC9B,EAAE,SAAS,MAAM,OAAO,CAC1B,CAAC;AAWH,IAAM,4BACJ,QACA,UACA,UACe;CACf,MAAM,OAAO,OAAO,QAAQ,OAAO,OAAO,QAAQ;CAClD,MAAM,QAAQ,OAAO,SAAS;CAE9B,OAAO,UAAU,UAAU,QAAQ,MAAM,gBACvC,EAAE,MAAM;EAAE,WAAW;EAAU,KAAK;CAAI,SAAS,CAC/C,EAAE,eAAe;EACf,GAAG,OAAO;EACV;EACA,WAAW,UAAmB,OAAO,SAAS,KAAK;CACrD,CAAU,GACV,QACI,EACE,QACA;EACE,MAAM;EACN,OAAO;EACP,SAAS;EACT,eAAe,OAAO,MAAM;CAC9B,SACM,MAAM,wBAAwB,CACtC,IACA,IACN,CAAC,CACH;AACF;AAM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AE,aAAa,YAAY,CACzB,EAAE,QAAQ,EAAE,eAAe,WAAW,MAAM,EAAE,SAC5C,EAAE,MAAM,YACN,mBAAmB,QACf,EAAE,cAAc,EAAE,OAAO,OAAO,CAAC,IACjC,SACN,CACF,GACA,EACE,QACA;MACE,OAAO;MACP,SAAS;MACT,eAAe;OACb,KAAK,aAAa;OAClB,WAAW,MAAM;MACnB;KACF,SACM,OAAO,OAAO,CACtB,CACF,CAAC;IACH,CAAC;GACH,CAAC;EACH;CACF;AACF,CAAC;AAED,YAAY,eAAe"}
|
|
1
|
+
{"version":3,"file":"AllFiltersModal.mjs","names":[],"sources":["../../../../../src/list/AllFiltersModal.ts"],"sourcesContent":["import {\n Accordion,\n AccordionGroup,\n ActionGroup,\n Button,\n Checkbox,\n CheckboxGroup,\n Content,\n Flex,\n Heading,\n Radio,\n RadioGroup,\n RangeCalendar,\n Section,\n SkeletonText,\n Text,\n} from \"@/auto-generated\";\nimport { IconFilter } from \"@/icons\";\nimport { watchMobxValue } from \"@/lib/mobxSelector\";\nimport { Modal } from \"@/overlays/Modal\";\nimport { createOverlayController } from \"@/overlays/overlayController\";\nimport { ModalTrigger } from \"@/overlays/triggers\";\nimport { defineComponent, h, type VNodeChild } from \"vue\";\nimport { isDateRangeFilter } from \"./dateRangeFilter\";\nimport {\n DateTimeRangeFields,\n type DateTimeRangeFilter,\n} from \"./DateTimeRangeFields\";\nimport { injectListModel, type AnyListModel } from \"./listContext\";\nimport { useListTexts, type ListTextFormatter } from \"./locales\";\nimport { listStyles } from \"./styles\";\nimport type { ListRendered } from \"./types\";\nimport { composition } from \"@/lib/composition\";\nimport type { ListDateRange } from \"@mittwald/flow-components-base\";\n\n/*\n * What this modal needs of a filter and a sorting. Not the classes: a list of\n * concrete filters is not assignable to a list of generic ones — a row model\n * sits in a contravariant position deep inside `Column`.\n */\ninterface ModalFilterValue {\n readonly id: string;\n readonly isActive: boolean;\n toggle(): void;\n render(): ListRendered;\n}\n\ninterface ModalFilter {\n readonly name?: string;\n readonly property: unknown;\n readonly mode: string;\n readonly priority: \"primary\" | \"secondary\";\n readonly values: ModalFilterValue[];\n readonly isSelectAllAvailable: boolean;\n isActive(): boolean;\n isEveryValueActive(): boolean;\n selectAll(): void;\n deselectAll(): void;\n clear(): void;\n}\n\ninterface ModalSorting {\n readonly id: string;\n readonly name?: string;\n readonly property: unknown;\n readonly directionName?: string;\n isSorted(): boolean;\n enable(): void;\n}\n\nconst accordion = (\n key: string,\n heading: string,\n expanded: boolean,\n content: () => VNodeChild,\n): VNodeChild =>\n h(Accordion, { key, defaultExpanded: expanded }, () => [\n h(Heading, null, () => heading),\n h(Content, null, content),\n ]);\n\ninterface ModalDateRangeFilter extends DateTimeRangeFilter {\n readonly name?: string;\n readonly property: unknown;\n readonly granularity: \"day\" | \"minute\";\n readonly rangeCalendarProps: Record<string, unknown>;\n}\n\nconst renderDateRangeAccordion = (\n filter: ModalDateRangeFilter,\n expanded: boolean,\n texts: ListTextFormatter,\n): VNodeChild => {\n const name = filter.name ?? String(filter.property);\n const value = filter.getValue();\n\n return accordion(`filter-${name}`, name, expanded, () =>\n h(Flex, { direction: \"column\", gap: \"m\" }, () => [\n filter.granularity === \"minute\"\n ? h(DateTimeRangeFields, { filter })\n : h(RangeCalendar, {\n ...filter.rangeCalendarProps,\n value,\n onChange: (range: ListDateRange) => filter.setValue(range),\n } as never),\n value\n ? h(\n Button,\n {\n size: \"s\",\n color: \"secondary\",\n variant: \"soft\",\n onPress: () => filter.clear(),\n },\n () => texts(\"filters.clearSelection\"),\n )\n : null,\n ]),\n );\n};\n\n/*\n * Flow's `FilterAccordionCheckboxGroup`: outside the checkbox group, so it is\n * not one of the values, and indeterminate while only some of them are on.\n */\nconst renderSelectAllCheckbox = (\n filter: ModalFilter,\n texts: ListTextFormatter,\n): VNodeChild => {\n const isEveryValueActive = filter.isEveryValueActive();\n\n return h(\n Checkbox,\n {\n key: \"select-all\",\n class: listStyles.selectAllCheckbox,\n isSelected: isEveryValueActive,\n isIndeterminate: filter.isActive() && !isEveryValueActive,\n onChange: () =>\n isEveryValueActive ? filter.deselectAll() : filter.selectAll(),\n },\n () =>\n texts(isEveryValueActive ? \"filters.deselectAll\" : \"filters.selectAll\"),\n );\n};\n\nconst renderFilterAccordion = (\n filter: ModalFilter,\n expanded: boolean,\n texts: ListTextFormatter,\n): VNodeChild => {\n const name = filter.name ?? String(filter.property);\n const activeIds = filter.values.filter((v) => v.isActive).map((v) => v.id);\n\n const content = (): VNodeChild =>\n filter.mode === \"one\"\n ? h(Flex, { direction: \"column\", gap: \"m\" }, () => [\n h(\n RadioGroup,\n {\n /*\n * Keyed on the selection, like Flow's: the group is controlled\n * and only remounting makes it pick up a value that changed from\n * outside — a chip removed, a reset.\n */\n key: activeIds[0],\n value: activeIds[0],\n m: [1, 1],\n \"aria-label\": name,\n },\n () =>\n filter.values.map((value) =>\n h(\n Radio,\n {\n key: value.id,\n value: value.id,\n onPress: () => {\n if (!value.isActive) {\n value.toggle();\n }\n },\n },\n () => value.render(),\n ),\n ),\n ),\n activeIds.length > 0\n ? h(\n Button,\n {\n size: \"s\",\n color: \"secondary\",\n variant: \"soft\",\n onPress: () => filter.clear(),\n },\n () => texts(\"filters.clearSelection\"),\n )\n : null,\n ])\n : [\n filter.isSelectAllAvailable\n ? renderSelectAllCheckbox(filter, texts)\n : null,\n h(\n CheckboxGroup,\n { value: activeIds, m: [1, 1], \"aria-label\": name },\n () =>\n filter.values.map((value) =>\n h(\n Checkbox,\n {\n key: value.id,\n value: value.id,\n onPress: () => value.toggle(),\n },\n () => value.render(),\n ),\n ),\n ),\n ];\n\n return accordion(`filter-${name}`, name, expanded, content);\n};\n\nconst renderSortingAccordion = (\n sortings: ModalSorting[],\n expanded: boolean,\n texts: ListTextFormatter,\n): VNodeChild => {\n const active = sortings.find((s) => s.isSorted());\n\n return accordion(\"sorting\", texts(\"sorting\"), expanded, () =>\n h(RadioGroup, { value: active?.id, m: [1, 1] }, () =>\n sortings.map((sorting) =>\n h(\n Radio,\n {\n key: sorting.id,\n value: sorting.id,\n onPress: () => sorting.enable(),\n },\n () =>\n `${sorting.name ?? String(sorting.property)} ${sorting.directionName ?? \"\"}`.trim(),\n ),\n ),\n ),\n );\n};\n\nconst renderViewModeAccordion = (\n list: AnyListModel,\n modes: (\"list\" | \"table\" | \"tiles\")[],\n selected: \"list\" | \"table\" | \"tiles\",\n expanded: boolean,\n texts: ListTextFormatter,\n): VNodeChild =>\n accordion(\"viewMode\", texts(\"settings.viewMode\"), expanded, () =>\n h(RadioGroup, { value: selected, m: [1, 1] }, () =>\n modes.map((mode) =>\n h(\n Radio,\n { key: mode, value: mode, onPress: () => list.viewMode.set(mode) },\n () => texts(`settings.viewMode.${mode}`),\n ),\n ),\n ),\n );\n\n/**\n * Every filter, sorting and view mode in one off-canvas modal.\n *\n * The mobile path to what the header shows as separate menus on desktop — and\n * on desktop too, where a list has secondary filters that the header leaves\n * out. It drives the same model objects, so a value ticked here is the same\n * event as one ticked in a menu.\n */\nexport const AllFiltersModal = defineComponent({\n name: \"ListAllFiltersModal\",\n\n props: {\n isDisabled: { type: Boolean, default: false },\n /** The layouts this list can show, from the header. */\n viewModes: {\n type: Array as () => (\"list\" | \"table\" | \"tiles\")[],\n default: () => [],\n },\n },\n\n setup(props) {\n const list = injectListModel();\n const texts = useListTexts();\n const controller = createOverlayController();\n\n const isInitiallyLoading = watchMobxValue(\n () => list.loaderState.isInitiallyLoading,\n );\n const viewMode = watchMobxValue(() => list.viewMode.value);\n const totalItemCount = watchMobxValue(() => {\n void list.listTable.revision;\n return list.batches.getTotalItemsCount();\n });\n /* Every value below is read off the table's filter and sorting state. */\n const tableRevision = watchMobxValue(() => list.listTable.revision);\n\n return () => {\n void tableRevision.value;\n\n const format = texts.value;\n const filters = list.filters as unknown as ModalFilter[];\n const sortings = list.visibleSorting as unknown as ModalSorting[];\n const modes = props.viewModes;\n\n const accordionCount =\n (modes.length > 1 ? 1 : 0) +\n (sortings.length > 0 ? 1 : 0) +\n filters.length;\n\n if (accordionCount === 0) {\n return null;\n }\n\n /* Two or fewer open by default — more than that is a wall of controls. */\n const expanded = accordionCount <= 2;\n\n const accordions: VNodeChild[] = [\n modes.length > 1\n ? renderViewModeAccordion(\n list,\n modes,\n viewMode.value,\n expanded,\n format,\n )\n : null,\n sortings.length > 0\n ? renderSortingAccordion(sortings, expanded, format)\n : null,\n ...filters.map((filter) =>\n isDateRangeFilter(filter)\n ? renderDateRangeAccordion(\n filter as unknown as ModalDateRangeFilter,\n expanded,\n format,\n )\n : renderFilterAccordion(filter, expanded, format),\n ),\n ];\n\n const hasSecondaryFilters = filters.some(\n (filter) => filter.priority === \"secondary\",\n );\n\n const showCount = format(\n totalItemCount.value === 1 ? \"results.show.one\" : \"results.show.other\",\n { totalItemCount: totalItemCount.value },\n );\n\n return h(ModalTrigger, { controller }, () => [\n h(\n Button,\n {\n class: [\n listStyles.hideOnMobile,\n hasSecondaryFilters ? undefined : listStyles.hideOnDesktop,\n ]\n .filter(Boolean)\n .join(\" \"),\n variant: \"outline\",\n color: \"secondary\",\n isDisabled: props.isDisabled,\n },\n () => [h(Text, null, () => format(\"filters.all\")), h(IconFilter)],\n ),\n\n h(\n Button,\n {\n class: listStyles.hideOnDesktop,\n variant: \"outline\",\n color: \"secondary\",\n \"aria-label\": format(\"filters.all\"),\n },\n () => h(IconFilter),\n ),\n\n h(Modal, { offCanvas: true, controller }, () => [\n h(Heading, null, () => format(\"filters.all\")),\n h(Content, null, () =>\n h(Section, null, () => h(AccordionGroup, null, () => accordions)),\n ),\n h(ActionGroup, null, () => [\n h(Button, { onPress: () => controller.close() }, () =>\n h(Text, null, () =>\n isInitiallyLoading.value\n ? h(SkeletonText, { width: \"16ch\" })\n : showCount,\n ),\n ),\n h(\n Button,\n {\n color: \"secondary\",\n variant: \"soft\",\n onPress: () => {\n list.resetFilters();\n controller.close();\n },\n },\n () => format(\"reset\"),\n ),\n ]),\n ]),\n ]);\n };\n },\n});\n\ncomposition(AllFiltersModal);\n\n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