@planningcenter/tapestry 4.10.0-rc.12 → 4.10.0-rc.13
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/components/DataTable/CollectionEditorsLazy.d.ts.map +1 -1
- package/dist/components/DataTable/CollectionEditorsLazy.js +5 -5
- package/dist/components/DataTable/CollectionEditorsLazy.js.map +1 -1
- package/dist/components/DataTable/CollectionEditorsStatic.d.ts +1 -1
- package/dist/components/DataTable/CollectionEditorsStatic.d.ts.map +1 -1
- package/dist/components/DataTable/CollectionEditorsStatic.js +5 -5
- package/dist/components/DataTable/CollectionEditorsStatic.js.map +1 -1
- package/dist/components/DataTable/FilterTypes.d.ts +17 -8
- package/dist/components/DataTable/FilterTypes.d.ts.map +1 -1
- package/dist/components/DataTable/collectionFilter.d.ts +13 -10
- package/dist/components/DataTable/collectionFilter.d.ts.map +1 -1
- package/dist/components/DataTable/collectionFilter.js +4 -3
- package/dist/components/DataTable/collectionFilter.js.map +1 -1
- package/dist/components/DataTable/dateFilter.d.ts +5 -3
- package/dist/components/DataTable/dateFilter.d.ts.map +1 -1
- package/dist/components/DataTable/dateFilter.js +2 -2
- package/dist/components/DataTable/dateFilter.js.map +1 -1
- package/dist/components/DataTable/dayFilter.d.ts +4 -3
- package/dist/components/DataTable/dayFilter.d.ts.map +1 -1
- package/dist/components/DataTable/dayFilter.js +2 -2
- package/dist/components/DataTable/dayFilter.js.map +1 -1
- package/dist/components/DataTable/filterKeys.d.ts +1 -1
- package/dist/components/DataTable/filterKeys.d.ts.map +1 -1
- package/dist/components/DataTable/index.d.ts +8 -3
- package/dist/components/DataTable/index.d.ts.map +1 -1
- package/dist/components/DataTable/numberFilter.d.ts +7 -3
- package/dist/components/DataTable/numberFilter.d.ts.map +1 -1
- package/dist/components/DataTable/numberFilter.js +19 -6
- package/dist/components/DataTable/numberFilter.js.map +1 -1
- package/dist/components/DataTable/presenceFilter.d.ts +4 -1
- package/dist/components/DataTable/presenceFilter.d.ts.map +1 -1
- package/dist/components/DataTable/presenceFilter.js +2 -2
- package/dist/components/DataTable/presenceFilter.js.map +1 -1
- package/dist/components/DataTable/textFilter.d.ts +3 -1
- package/dist/components/DataTable/textFilter.d.ts.map +1 -1
- package/dist/components/DataTable/textFilter.js +4 -4
- package/dist/components/DataTable/textFilter.js.map +1 -1
- package/dist/components/DataTable/useSearchFilter.d.ts +1 -1
- package/dist/components/DataTable/utils.d.ts +1 -0
- package/dist/components/DataTable/utils.d.ts.map +1 -1
- package/dist/components/DataTable/utils.js +1 -1
- package/dist/components/DataTable/utils.js.map +1 -1
- package/dist/reactRender.css +1854 -1854
- package/dist/reactRender.css.map +1 -1
- package/dist/reactRenderLegacy.css +1854 -1854
- package/dist/reactRenderLegacy.css.map +1 -1
- package/package.json +2 -2
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import "./index.css";
|
|
2
2
|
import "./filters.css";
|
|
3
|
+
export type { CollectionFilterValue } from "./CollectionEditorsShared";
|
|
4
|
+
export type { CollectionActiveFilter, CollectionOperatorName, } from "./collectionFilter";
|
|
3
5
|
export type { DataTableElementProps, DataTableLoadingState, DataTableProps, DataTableSelection, } from "./DataTable";
|
|
4
6
|
export { DataTable } from "./DataTable";
|
|
5
7
|
export type { BooleanColumn, CurrencyColumn, CustomColumn, DataTableColumn, DataTableColumnAlign, DataTableColumnType, DateColumn, DateTimeColumn, EnumColumn, NumberColumn, StringColumn, } from "./DataTableColumn";
|
|
8
|
+
export type { DateActiveFilter, DateFilterValue, DateOperatorName, } from "./dateFilter";
|
|
9
|
+
export type { DayActiveFilter, DayFilterValue, DayOperatorName, } from "./dayFilter";
|
|
6
10
|
export * from "./filters";
|
|
7
|
-
export type { ActiveFilter, FilterItemConfig, FilterNode, FilterNodeGroup, FilterNodeItem, FilterNodeScoped, Operator, } from "./FilterTypes";
|
|
8
|
-
export type { NumberFilterValue } from "./numberFilter";
|
|
9
|
-
export type { PresenceFilterConfig } from "./presenceFilter";
|
|
11
|
+
export type { ActiveFilter, ActiveFilterValue, FilterItemConfig, FilterNode, FilterNodeGroup, FilterNodeItem, FilterNodeScoped, Operator, } from "./FilterTypes";
|
|
12
|
+
export type { NumberActiveFilter, NumberFilterValue, NumberOperatorName, } from "./numberFilter";
|
|
13
|
+
export type { PresenceActiveFilter, PresenceFilterConfig, PresenceFilterValue, PresenceOperatorName, } from "./presenceFilter";
|
|
10
14
|
export type { ScopedFilterConfig, ScopedFilterOptions } from "./scopedFilter";
|
|
15
|
+
export type { TextActiveFilter, TextFilterValue, TextOperatorName, } from "./textFilter";
|
|
11
16
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AACpB,OAAO,eAAe,CAAA;AAEtB,YAAY,EACV,qBAAqB,EACrB,qBAAqB,EACrB,cAAc,EACd,kBAAkB,GACnB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,YAAY,EACV,aAAa,EACb,cAAc,EACd,YAAY,EACZ,eAAe,EACf,oBAAoB,EACpB,mBAAmB,EACnB,UAAU,EACV,cAAc,EACd,UAAU,EACV,YAAY,EACZ,YAAY,GACb,MAAM,mBAAmB,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,YAAY,EACV,YAAY,EACZ,gBAAgB,EAChB,UAAU,EACV,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,QAAQ,GACT,MAAM,eAAe,CAAA;AACtB,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AACpB,OAAO,eAAe,CAAA;AAEtB,YAAY,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAA;AACtE,YAAY,EACV,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,oBAAoB,CAAA;AAC3B,YAAY,EACV,qBAAqB,EACrB,qBAAqB,EACrB,cAAc,EACd,kBAAkB,GACnB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,YAAY,EACV,aAAa,EACb,cAAc,EACd,YAAY,EACZ,eAAe,EACf,oBAAoB,EACpB,mBAAmB,EACnB,UAAU,EACV,cAAc,EACd,UAAU,EACV,YAAY,EACZ,YAAY,GACb,MAAM,mBAAmB,CAAA;AAC1B,YAAY,EACV,gBAAgB,EAChB,eAAe,EACf,gBAAgB,GACjB,MAAM,cAAc,CAAA;AACrB,YAAY,EACV,eAAe,EACf,cAAc,EACd,eAAe,GAChB,MAAM,aAAa,CAAA;AACpB,cAAc,WAAW,CAAA;AACzB,YAAY,EACV,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,UAAU,EACV,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,QAAQ,GACT,MAAM,eAAe,CAAA;AACtB,YAAY,EACV,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,gBAAgB,CAAA;AACvB,YAAY,EACV,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,kBAAkB,CAAA;AACzB,YAAY,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AAC7E,YAAY,EACV,gBAAgB,EAChB,eAAe,EACf,gBAAgB,GACjB,MAAM,cAAc,CAAA"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { FilterItemConfig, FilterNodeItem } from "./FilterTypes";
|
|
2
|
-
export type NumberFilterValue = number | [number, number];
|
|
1
|
+
import type { ActiveFilter, FilterItemConfig, FilterNodeItem } from "./FilterTypes";
|
|
3
2
|
export declare const GTE: {
|
|
4
3
|
readonly inputType: {
|
|
5
4
|
readonly type: "number";
|
|
@@ -80,8 +79,13 @@ declare const ALL_NUMBER_OPERATORS: ({
|
|
|
80
79
|
readonly name: "between";
|
|
81
80
|
})[];
|
|
82
81
|
export type NumberOperatorName = (typeof ALL_NUMBER_OPERATORS)[number]["name"];
|
|
82
|
+
/** A number; a pair for `between`, either side of which may still be empty. */
|
|
83
|
+
export type NumberFilterValue = number | [number | undefined, number | undefined] | undefined;
|
|
84
|
+
export type NumberActiveFilter = ActiveFilter<NumberFilterValue, NumberOperatorName>;
|
|
83
85
|
/** Constraints applied to every input of the filter, including both sides of a range. */
|
|
84
86
|
export interface NumberConstraints {
|
|
87
|
+
/** Number of decimal places allowed, always shown (e.g. `2` shows `5` as `5.00`). */
|
|
88
|
+
decimalPlaces?: number;
|
|
85
89
|
/** Highest value allowed. Typed values above it are clamped. */
|
|
86
90
|
max?: number;
|
|
87
91
|
/** Lowest value allowed. Typed values below it are clamped. */
|
|
@@ -89,6 +93,6 @@ export interface NumberConstraints {
|
|
|
89
93
|
/** Increment for the stepper buttons and arrow keys. Typed values snap to it. */
|
|
90
94
|
step?: number;
|
|
91
95
|
}
|
|
92
|
-
export declare function numberFilter({ excludes, includes, max, min, step, ...config }: FilterItemConfig<NumberOperatorName> & NumberConstraints): FilterNodeItem;
|
|
96
|
+
export declare function numberFilter({ decimalPlaces, excludes, includes, max, min, step, ...config }: FilterItemConfig<NumberOperatorName> & NumberConstraints): FilterNodeItem;
|
|
93
97
|
export {};
|
|
94
98
|
//# sourceMappingURL=numberFilter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"numberFilter.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/numberFilter.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"numberFilter.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/numberFilter.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,YAAY,EAEZ,gBAAgB,EAChB,cAAc,EAEf,MAAM,eAAe,CAAA;AAGtB,eAAO,MA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MBER_OPERATORS = [GTE, LTE, NUMBER_RANGE];
|
|
39
|
-
function numberFilter({ excludes, includes, max, min, step, ...config }) {
|
|
39
|
+
function numberFilter({ decimalPlaces, excludes, includes, max, min, step, ...config }) {
|
|
40
40
|
const filter = {
|
|
41
41
|
...config,
|
|
42
|
-
createActiveFilterInstance: (activeFilter, operator) => new
|
|
42
|
+
createActiveFilterInstance: (activeFilter, operator) => new NumberActiveFilterInstance(filter, operator, activeFilter.value, {
|
|
43
|
+
formatOptions: decimalPlaces === undefined
|
|
44
|
+
? undefined
|
|
45
|
+
: {
|
|
46
|
+
maximumFractionDigits: decimalPlaces,
|
|
47
|
+
minimumFractionDigits: decimalPlaces,
|
|
48
|
+
},
|
|
49
|
+
max,
|
|
50
|
+
min,
|
|
51
|
+
step,
|
|
52
|
+
}),
|
|
43
53
|
operators: resolveOperators(ALL_NUMBER_OPERATORS, {
|
|
44
54
|
default: DEFAULT_NUMBER_OPERATORS,
|
|
45
55
|
excludes,
|
|
@@ -48,14 +58,14 @@ function numberFilter({ excludes, includes, max, min, step, ...config }) {
|
|
|
48
58
|
};
|
|
49
59
|
return filter;
|
|
50
60
|
}
|
|
51
|
-
class
|
|
61
|
+
class NumberActiveFilterInstance extends ActiveFilterInstance {
|
|
52
62
|
constraints;
|
|
53
63
|
constructor(filter, operator, value, constraints) {
|
|
54
64
|
super(filter, operator, value);
|
|
55
65
|
this.constraints = constraints;
|
|
56
66
|
}
|
|
57
67
|
formatValue() {
|
|
58
|
-
const formatter = new Intl.NumberFormat();
|
|
68
|
+
const formatter = new Intl.NumberFormat(undefined, this.constraints.formatOptions);
|
|
59
69
|
return [this.value]
|
|
60
70
|
.flat()
|
|
61
71
|
.filter((value) => value !== undefined)
|
|
@@ -69,12 +79,15 @@ class NumberActiveFilter extends ActiveFilterInstance {
|
|
|
69
79
|
? {
|
|
70
80
|
initialValues: [start, end],
|
|
71
81
|
labels: [`${label} from`, `${label} to`],
|
|
72
|
-
toValue: (
|
|
82
|
+
toValue: ([from, to]) => [
|
|
83
|
+
from,
|
|
84
|
+
to,
|
|
85
|
+
],
|
|
73
86
|
}
|
|
74
87
|
: {
|
|
75
88
|
initialValues: [start],
|
|
76
89
|
labels: [label],
|
|
77
|
-
toValue: (
|
|
90
|
+
toValue: ([value]) => value,
|
|
78
91
|
};
|
|
79
92
|
return (React__default.createElement(NumberEditor, { key: name, constraints: this.constraints, labels: labels, values: initialValues, onCommit: (committed) => onChange({ value: toValue(committed) }, { complete: committed.every((value) => value !== undefined) }) }));
|
|
80
93
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"numberFilter.js","sources":["../../../src/components/DataTable/numberFilter.tsx"],"sourcesContent":["import { Flex } from \"@components/flex\"\nimport {\n NumberStepper,\n type NumberStepperElementProps,\n} from \"@components/number-stepper\"\nimport React, { useRef, useState } from \"react\"\n\nimport { ActiveFilterInstance } from \"./ActiveFilterInstance\"\nimport type {\n FilterChange,\n FilterItemConfig,\n FilterNodeItem,\n Operator,\n} from \"./FilterTypes\"\nimport { resolveOperators } from \"./resolveOperators\"\n\nexport type NumberFilterValue = number | [number, number]\n\nexport const GTE = {\n inputType: { type: \"number\" },\n label: \">=\",\n name: \"gte\",\n} as const satisfies Operator\nexport const GT = {\n inputType: { type: \"number\" },\n label: \">\",\n name: \"gt\",\n} as const satisfies Operator\nexport const LT = {\n inputType: { type: \"number\" },\n label: \"<\",\n name: \"lt\",\n} as const satisfies Operator\nexport const EQ = {\n inputType: { type: \"number\" },\n label: \"is\",\n name: \"eq\",\n} as const satisfies Operator\nexport const LTE = {\n inputType: { type: \"number\" },\n label: \"<=\",\n name: \"lte\",\n} as const satisfies Operator\nexport const NUMBER_RANGE = {\n inputType: { type: \"number-range\" },\n label: \"between\",\n name: \"between\",\n} as const satisfies Operator\n\nconst ALL_NUMBER_OPERATORS = [EQ, GT, GTE, LT, LTE, NUMBER_RANGE]\nconst DEFAULT_NUMBER_OPERATORS = [GTE, LTE, NUMBER_RANGE]\n\nexport type NumberOperatorName = (typeof ALL_NUMBER_OPERATORS)[number][\"name\"]\n\n/** Constraints applied to every input of the filter, including both sides of a range. */\nexport interface NumberConstraints {\n /** Highest value allowed. Typed values above it are clamped. */\n max?: number\n /** Lowest value allowed. Typed values below it are clamped. */\n min?: number\n /** Increment for the stepper buttons and arrow keys. Typed values snap to it. */\n step?: number\n}\n\nexport function numberFilter({\n excludes,\n includes,\n max,\n min,\n step,\n ...config\n}: FilterItemConfig<NumberOperatorName> & NumberConstraints): FilterNodeItem {\n const filter: FilterNodeItem = {\n ...config,\n createActiveFilterInstance: (activeFilter, operator) =>\n new NumberActiveFilter(\n filter,\n operator,\n activeFilter.value as NumberFilterValue,\n { max, min, step }\n ),\n operators: resolveOperators(ALL_NUMBER_OPERATORS, {\n default: DEFAULT_NUMBER_OPERATORS,\n excludes,\n includes,\n }),\n }\n return filter\n}\n\ntype NumberInputConstraints = Pick<\n NumberStepperElementProps,\n \"max\" | \"min\" | \"step\"\n>\n\nclass NumberActiveFilter extends ActiveFilterInstance<NumberFilterValue> {\n constructor(\n filter: FilterNodeItem,\n operator: Operator,\n value: NumberFilterValue,\n readonly constraints: NumberInputConstraints\n ) {\n super(filter, operator, value)\n }\n\n formatValue() {\n const formatter = new Intl.NumberFormat()\n return [this.value]\n .flat()\n .filter((value) => value !== undefined)\n .map((value) => formatter.format(value))\n .join(\" and \")\n }\n\n renderEditor(onChange: FilterChange) {\n const { inputType, label, name } = this.operator\n const [start, end] = [this.value].flat()\n const { initialValues, labels, toValue } =\n inputType.type === \"number-range\"\n ? {\n initialValues: [start, end],\n labels: [`${label} from`, `${label} to`],\n toValue: (committed: NumberInputValue[]) => committed,\n }\n : {\n initialValues: [start],\n labels: [label],\n toValue: (committed: NumberInputValue[]) => committed[0],\n }\n return (\n <NumberEditor\n key={name}\n constraints={this.constraints}\n labels={labels}\n values={initialValues}\n onCommit={(committed) =>\n onChange(\n { value: toValue(committed) },\n { complete: committed.every((value) => value !== undefined) }\n )\n }\n />\n )\n }\n}\n\ntype NumberInputValue = number | undefined\n\nfunction lower(a: NumberInputValue, b: NumberInputValue) {\n if (a === undefined || b === undefined) return a ?? b\n return Math.min(a, b)\n}\n\nfunction higher(a: NumberInputValue, b: NumberInputValue) {\n if (a === undefined || b === undefined) return a ?? b\n return Math.max(a, b)\n}\n\n// React Aria parses typed text in its own blur and Enter handlers, after ours,\n// so parsed values go in a ref and commit from the wrapper's blur (which\n// bubbles after parsing) or Enter's keyup.\nfunction NumberEditor({\n constraints,\n labels,\n onCommit,\n values: initialValues,\n}: {\n constraints: NumberInputConstraints\n labels: string[]\n onCommit: (values: NumberInputValue[]) => void\n values: NumberInputValue[]\n}) {\n const values = useRef(initialValues)\n const [[start, end], setRange] = useState(initialValues)\n const lastCommitted = useRef(initialValues)\n const shouldCommitOnKeyUp = useRef(false)\n const commit = () => {\n lastCommitted.current = values.current\n onCommit(values.current)\n }\n const changed = () =>\n values.current.some(\n (value, index) => value !== lastCommitted.current[index]\n )\n const isRange = labels.length > 1\n return (\n <Flex\n align=\"center\"\n // Popover content aligns to start; stretch so both inputs fit\n alignSelf={isRange ? \"stretch\" : undefined}\n className={isRange ? \"tds-data-table-filters-number-range\" : undefined}\n gap={1}\n onBlur={() => {\n if (changed()) commit()\n }}\n >\n {labels.map((label, index) => (\n <React.Fragment key={label}>\n {index > 0 && <span>and</span>}\n <NumberStepper\n // eslint-disable-next-line jsx-a11y/no-autofocus -- the editor only ever renders inside a chip popover that just opened, per ARIA dialog practices\n autoFocus={index === 0}\n defaultValue={initialValues[index]}\n {...constraints}\n hideLabel\n label={label}\n max={index === 0 ? lower(constraints.max, end) : constraints.max}\n min={index === 1 ? higher(constraints.min, start) : constraints.min}\n onChange={(value) => {\n const next = [...values.current]\n next[index] = Number.isNaN(value) ? undefined : value\n values.current = next\n setRange(next)\n }}\n onKeyDown={(e) => {\n shouldCommitOnKeyUp.current =\n e.key === \"Enter\" && !e.nativeEvent.isComposing\n }}\n onKeyUp={(e) => {\n if (e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9B,QAAAA,cAAA,CAAA,aAAA,CAAC;;;;AAEC,YAAA,SAAS,EAAE,KAAK,KAAK,CAAC,EACtB,YAAY,EAAE,aAAa,CAAC,KAAK,CAAC,EAAA,GAC9B,WAAW,EACf,SAAS,EAAA,IAAA,EACT,KAAK,EAAE,KAAK,EACZ,GAAG,EAAE,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,WAAW,CAAC,GAAG,EAChE,GAAG,EAAE,KAAK,KAAK,CAAC,GAAG,MAAM,CAAC,WAAW,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,WAAW,CAAC,GAAG,EACnE,QAAQ,EAAE,CAAC,KAAK,KAAI;gBAClB,MAAM,IAAI,GAAG,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC;AAChC,gBAAA,IAAI,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,SAAS,GAAG,KAAK;AACrD,gBAAA,MAAM,CAAC,OAAO,GAAG,IAAI;gBACrB,QAAQ,CAAC,IAAI,CAAC;AAChB,YAAA,CAAC,EACD,SAAS,EAAE,CAAC,CAAC,KAAI;AACf,gBAAA,mBAAmB,CAAC,OAAO;oBACzB,CAAC,CAAC,GAAG,KAAK,OAAO,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,WAAW;AACnD,YAAA,CAAC,EACD,OAAO,EAAE,CAAC,CAAC,KAAI;gBACb,IAAI,CAAC,CAAC,GAAG,KAAK,OAAO,IAAI,CAAC,mBAAmB,CAAC,OAAO;oBAAE;AACvD,gBAAA,mBAAmB,CAAC,OAAO,GAAG,KAAK;AACnC,gBAAA,MAAM,EAAE;AACV,YAAA,CAAC,GACD,CACa,CAClB,CAAC,CACG;AAEX;;;;"}
|
|
1
|
+
{"version":3,"file":"numberFilter.js","sources":["../../../src/components/DataTable/numberFilter.tsx"],"sourcesContent":["import { Flex } from \"@components/flex\"\nimport {\n NumberStepper,\n type NumberStepperElementProps,\n} from \"@components/number-stepper\"\nimport React, { useRef, useState } from \"react\"\n\nimport { ActiveFilterInstance } from \"./ActiveFilterInstance\"\nimport type {\n ActiveFilter,\n FilterChange,\n FilterItemConfig,\n FilterNodeItem,\n Operator,\n} from \"./FilterTypes\"\nimport { resolveOperators } from \"./resolveOperators\"\n\nexport const GTE = {\n inputType: { type: \"number\" },\n label: \">=\",\n name: \"gte\",\n} as const satisfies Operator\nexport const GT = {\n inputType: { type: \"number\" },\n label: \">\",\n name: \"gt\",\n} as const satisfies Operator\nexport const LT = {\n inputType: { type: \"number\" },\n label: \"<\",\n name: \"lt\",\n} as const satisfies Operator\nexport const EQ = {\n inputType: { type: \"number\" },\n label: \"is\",\n name: \"eq\",\n} as const satisfies Operator\nexport const LTE = {\n inputType: { type: \"number\" },\n label: \"<=\",\n name: \"lte\",\n} as const satisfies Operator\nexport const NUMBER_RANGE = {\n inputType: { type: \"number-range\" },\n label: \"between\",\n name: \"between\",\n} as const satisfies Operator\n\nconst ALL_NUMBER_OPERATORS = [EQ, GT, GTE, LT, LTE, NUMBER_RANGE]\nconst DEFAULT_NUMBER_OPERATORS = [GTE, LTE, NUMBER_RANGE]\n\nexport type NumberOperatorName = (typeof ALL_NUMBER_OPERATORS)[number][\"name\"]\n\n/** A number; a pair for `between`, either side of which may still be empty. */\nexport type NumberFilterValue =\n | number\n | [number | undefined, number | undefined]\n | undefined\n\nexport type NumberActiveFilter = ActiveFilter<\n NumberFilterValue,\n NumberOperatorName\n>\n\n/** Constraints applied to every input of the filter, including both sides of a range. */\nexport interface NumberConstraints {\n /** Number of decimal places allowed, always shown (e.g. `2` shows `5` as `5.00`). */\n decimalPlaces?: number\n /** Highest value allowed. Typed values above it are clamped. */\n max?: number\n /** Lowest value allowed. Typed values below it are clamped. */\n min?: number\n /** Increment for the stepper buttons and arrow keys. Typed values snap to it. */\n step?: number\n}\n\nexport function numberFilter({\n decimalPlaces,\n excludes,\n includes,\n max,\n min,\n step,\n ...config\n}: FilterItemConfig<NumberOperatorName> & NumberConstraints): FilterNodeItem {\n const filter: FilterNodeItem = {\n ...config,\n createActiveFilterInstance: (activeFilter, operator) =>\n new NumberActiveFilterInstance(\n filter,\n operator,\n activeFilter.value as NumberFilterValue,\n {\n formatOptions:\n decimalPlaces === undefined\n ? undefined\n : {\n maximumFractionDigits: decimalPlaces,\n minimumFractionDigits: decimalPlaces,\n },\n max,\n min,\n step,\n }\n ),\n operators: resolveOperators(ALL_NUMBER_OPERATORS, {\n default: DEFAULT_NUMBER_OPERATORS,\n excludes,\n includes,\n }),\n }\n return filter\n}\n\ntype NumberInputConstraints = Pick<\n NumberStepperElementProps,\n \"formatOptions\" | \"max\" | \"min\" | \"step\"\n>\n\nclass NumberActiveFilterInstance extends ActiveFilterInstance<NumberFilterValue> {\n constructor(\n filter: FilterNodeItem,\n operator: Operator,\n value: NumberFilterValue,\n readonly constraints: NumberInputConstraints\n ) {\n super(filter, operator, value)\n }\n\n formatValue() {\n const formatter = new Intl.NumberFormat(\n undefined,\n this.constraints.formatOptions\n )\n return [this.value]\n .flat()\n .filter((value) => value !== undefined)\n .map((value) => formatter.format(value))\n .join(\" and \")\n }\n\n renderEditor(onChange: FilterChange) {\n const { inputType, label, name } = this.operator\n const [start, end] = [this.value].flat()\n const { initialValues, labels, toValue } =\n inputType.type === \"number-range\"\n ? {\n initialValues: [start, end],\n labels: [`${label} from`, `${label} to`],\n toValue: ([from, to]: NumberInputValue[]): NumberFilterValue => [\n from,\n to,\n ],\n }\n : {\n initialValues: [start],\n labels: [label],\n toValue: ([value]: NumberInputValue[]): NumberFilterValue => value,\n }\n return (\n <NumberEditor\n key={name}\n constraints={this.constraints}\n labels={labels}\n values={initialValues}\n onCommit={(committed) =>\n onChange(\n { value: toValue(committed) },\n { complete: committed.every((value) => value !== undefined) }\n )\n }\n />\n )\n }\n}\n\ntype NumberInputValue = number | undefined\n\nfunction lower(a: NumberInputValue, b: NumberInputValue) {\n if (a === undefined || b === undefined) return a ?? b\n return Math.min(a, b)\n}\n\nfunction higher(a: NumberInputValue, b: NumberInputValue) {\n if (a === undefined || b === undefined) return a ?? b\n return Math.max(a, b)\n}\n\n// React Aria parses typed text in its own blur and Enter handlers, after ours,\n// so parsed values go in a ref and commit from the wrapper's blur (which\n// bubbles after parsing) or Enter's keyup.\nfunction NumberEditor({\n constraints,\n labels,\n onCommit,\n values: initialValues,\n}: {\n constraints: NumberInputConstraints\n labels: string[]\n onCommit: (values: NumberInputValue[]) => void\n values: NumberInputValue[]\n}) {\n const values = useRef(initialValues)\n const [[start, end], setRange] = useState(initialValues)\n const lastCommitted = useRef(initialValues)\n const shouldCommitOnKeyUp = useRef(false)\n const commit = () => {\n lastCommitted.current = values.current\n onCommit(values.current)\n }\n const changed = () =>\n values.current.some(\n (value, index) => value !== lastCommitted.current[index]\n )\n const isRange = labels.length > 1\n return (\n <Flex\n align=\"center\"\n // Popover content aligns to start; stretch so both inputs fit\n alignSelf={isRange ? \"stretch\" : undefined}\n className={isRange ? \"tds-data-table-filters-number-range\" : undefined}\n gap={1}\n onBlur={() => {\n if (changed()) commit()\n }}\n >\n {labels.map((label, index) => (\n <React.Fragment key={label}>\n {index > 0 && <span>and</span>}\n <NumberStepper\n // eslint-disable-next-line jsx-a11y/no-autofocus -- the editor only ever renders inside a chip popover that just opened, per ARIA dialog practices\n autoFocus={index === 0}\n defaultValue={initialValues[index]}\n {...constraints}\n hideLabel\n label={label}\n max={index === 0 ? lower(constraints.max, end) : constraints.max}\n min={index === 1 ? higher(constraints.min, start) : constraints.min}\n onChange={(value) => {\n const next = [...values.current]\n next[index] = Number.isNaN(value) ? undefined : value\n values.current = next\n setRange(next)\n }}\n onKeyDown={(e) => {\n shouldCommitOnKeyUp.current =\n e.key === \"Enter\" && !e.nativeEvent.isComposing\n }}\n onKeyUp={(e) => {\n if (e.key !== \"Enter\" || !shouldCommitOnKeyUp.current) return\n shouldCommitOnKeyUp.current = false\n commit()\n }}\n />\n </React.Fragment>\n ))}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ACD,CACa,CAClB,CAAC,CACG;AAEX;;;;"}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import type { FilterItemConfig, FilterNodeItem } from "./FilterTypes";
|
|
1
|
+
import type { ActiveFilter, FilterItemConfig, FilterNodeItem } from "./FilterTypes";
|
|
2
|
+
export type PresenceOperatorName = "not_present" | "present";
|
|
3
|
+
export type PresenceFilterValue = undefined;
|
|
4
|
+
export type PresenceActiveFilter = ActiveFilter<PresenceFilterValue, PresenceOperatorName>;
|
|
2
5
|
export type PresenceFilterConfig = Omit<FilterItemConfig, "excludes" | "includes"> & {
|
|
3
6
|
/** Adds a `not_present` operator, labeling its chip and option. */
|
|
4
7
|
negatedLabel?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presenceFilter.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/presenceFilter.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"presenceFilter.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/presenceFilter.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EACZ,gBAAgB,EAChB,cAAc,EAEf,MAAM,eAAe,CAAA;AAEtB,MAAM,MAAM,oBAAoB,GAAG,aAAa,GAAG,SAAS,CAAA;AAE5D,MAAM,MAAM,mBAAmB,GAAG,SAAS,CAAA;AAE3C,MAAM,MAAM,oBAAoB,GAAG,YAAY,CAC7C,mBAAmB,EACnB,oBAAoB,CACrB,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG,IAAI,CACrC,gBAAgB,EAChB,UAAU,GAAG,UAAU,CACxB,GAAG;IACF,mEAAmE;IACnE,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAED,wBAAgB,cAAc,CAAC,EAC7B,KAAK,EACL,YAAY,EACZ,GAAG,MAAM,EACV,EAAE,oBAAoB,GAAG,cAAc,CAkBvC"}
|
|
@@ -12,13 +12,13 @@ function presenceFilter({ label, negatedLabel, ...config }) {
|
|
|
12
12
|
});
|
|
13
13
|
const filter = {
|
|
14
14
|
...config,
|
|
15
|
-
createActiveFilterInstance: (_activeFilter, operator) => new
|
|
15
|
+
createActiveFilterInstance: (_activeFilter, operator) => new PresenceActiveFilterInstance(filter, operator, undefined),
|
|
16
16
|
label,
|
|
17
17
|
operators,
|
|
18
18
|
};
|
|
19
19
|
return filter;
|
|
20
20
|
}
|
|
21
|
-
class
|
|
21
|
+
class PresenceActiveFilterInstance extends ActiveFilterInstance {
|
|
22
22
|
get isCompleteWithoutInput() {
|
|
23
23
|
return true;
|
|
24
24
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presenceFilter.js","sources":["../../../src/components/DataTable/presenceFilter.tsx"],"sourcesContent":["import { ActiveFilterInstance } from \"./ActiveFilterInstance\"\nimport type {
|
|
1
|
+
{"version":3,"file":"presenceFilter.js","sources":["../../../src/components/DataTable/presenceFilter.tsx"],"sourcesContent":["import { ActiveFilterInstance } from \"./ActiveFilterInstance\"\nimport type {\n ActiveFilter,\n FilterItemConfig,\n FilterNodeItem,\n Operator,\n} from \"./FilterTypes\"\n\nexport type PresenceOperatorName = \"not_present\" | \"present\"\n\nexport type PresenceFilterValue = undefined\n\nexport type PresenceActiveFilter = ActiveFilter<\n PresenceFilterValue,\n PresenceOperatorName\n>\n\nexport type PresenceFilterConfig = Omit<\n FilterItemConfig,\n \"excludes\" | \"includes\"\n> & {\n /** Adds a `not_present` operator, labeling its chip and option. */\n negatedLabel?: string\n}\n\nexport function presenceFilter({\n label,\n negatedLabel,\n ...config\n}: PresenceFilterConfig): FilterNodeItem {\n const operators: Operator[] = [\n { inputType: { type: \"presence\" }, label, name: \"present\" },\n ]\n if (negatedLabel)\n operators.push({\n inputType: { type: \"presence\" },\n label: negatedLabel,\n name: \"not_present\",\n })\n const filter: FilterNodeItem = {\n ...config,\n createActiveFilterInstance: (_activeFilter, operator) =>\n new PresenceActiveFilterInstance(filter, operator, undefined),\n label,\n operators,\n }\n return filter\n}\n\nclass PresenceActiveFilterInstance extends ActiveFilterInstance<PresenceFilterValue> {\n get isCompleteWithoutInput() {\n return true\n }\n\n toSegments() {\n return [this.operator.label]\n }\n\n formatValue() {\n return []\n }\n\n renderEditor() {\n return null\n }\n}\n"],"names":[],"mappings":";;AAyBM,SAAU,cAAc,CAAC,EAC7B,KAAK,EACL,YAAY,EACZ,GAAG,MAAM,EACY,EAAA;AACrB,IAAA,MAAM,SAAS,GAAe;AAC5B,QAAA,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE;KAC5D;AACD,IAAA,IAAI,YAAY;QACd,SAAS,CAAC,IAAI,CAAC;AACb,YAAA,SAAS,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE;AAC/B,YAAA,KAAK,EAAE,YAAY;AACnB,YAAA,IAAI,EAAE,aAAa;AACpB,SAAA,CAAC;AACJ,IAAA,MAAM,MAAM,GAAmB;AAC7B,QAAA,GAAG,MAAM;AACT,QAAA,0BAA0B,EAAE,CAAC,aAAa,EAAE,QAAQ,KAClD,IAAI,4BAA4B,CAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,CAAC;QAC/D,KAAK;QACL,SAAS;KACV;AACD,IAAA,OAAO,MAAM;AACf;AAEA,MAAM,4BAA6B,SAAQ,oBAAyC,CAAA;AAClF,IAAA,IAAI,sBAAsB,GAAA;AACxB,QAAA,OAAO,IAAI;IACb;IAEA,UAAU,GAAA;AACR,QAAA,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;IAC9B;IAEA,WAAW,GAAA;AACT,QAAA,OAAO,EAAE;IACX;IAEA,YAAY,GAAA;AACV,QAAA,OAAO,IAAI;IACb;AACD;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FilterItemConfig, FilterNodeItem } from "./FilterTypes";
|
|
1
|
+
import type { ActiveFilter, FilterItemConfig, FilterNodeItem } from "./FilterTypes";
|
|
2
2
|
export declare const EQ: {
|
|
3
3
|
readonly inputType: {
|
|
4
4
|
readonly type: "text";
|
|
@@ -53,6 +53,8 @@ declare const ALL_TEXT_OPERATORS: ({
|
|
|
53
53
|
readonly name: "starts_with";
|
|
54
54
|
})[];
|
|
55
55
|
export type TextOperatorName = (typeof ALL_TEXT_OPERATORS)[number]["name"];
|
|
56
|
+
export type TextFilterValue = string | undefined;
|
|
57
|
+
export type TextActiveFilter = ActiveFilter<TextFilterValue, TextOperatorName>;
|
|
56
58
|
export declare function textFilter({ excludes, includes, ...config }: FilterItemConfig<TextOperatorName>): FilterNodeItem;
|
|
57
59
|
export {};
|
|
58
60
|
//# sourceMappingURL=textFilter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textFilter.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/textFilter.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"textFilter.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/textFilter.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,YAAY,EAEZ,gBAAgB,EAChB,cAAc,EAEf,MAAM,eAAe,CAAA;AAItB,eAAO,MAAM,EAAE;;;;;;CAIc,CAAA;AAC7B,eAAO,MAAM,QAAQ;;;;;;CAIQ,CAAA;AAC7B,eAAO,MAAM,GAAG;;;;;;CAIa,CAAA;AAC7B,eAAO,MAAM,WAAW;;;;;;CAIK,CAAA;AAE7B,QAAA,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;IAAmC,CAAA;AAG3D,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAA;AAE1E,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,SAAS,CAAA;AAEhD,MAAM,MAAM,gBAAgB,GAAG,YAAY,CAAC,eAAe,EAAE,gBAAgB,CAAC,CAAA;AAE9E,wBAAgB,UAAU,CAAC,EACzB,QAAQ,EACR,QAAQ,EACR,GAAG,MAAM,EACV,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,GAAG,cAAc,CAgBrD"}
|
|
@@ -29,7 +29,7 @@ const DEFAULT_TEXT_OPERATORS = [CONTAINS];
|
|
|
29
29
|
function textFilter({ excludes, includes, ...config }) {
|
|
30
30
|
const filter = {
|
|
31
31
|
...config,
|
|
32
|
-
createActiveFilterInstance: (activeFilter, operator) => new
|
|
32
|
+
createActiveFilterInstance: (activeFilter, operator) => new TextActiveFilterInstance(filter, operator, activeFilter.value),
|
|
33
33
|
operators: resolveOperators(ALL_TEXT_OPERATORS, {
|
|
34
34
|
default: DEFAULT_TEXT_OPERATORS,
|
|
35
35
|
excludes,
|
|
@@ -38,15 +38,15 @@ function textFilter({ excludes, includes, ...config }) {
|
|
|
38
38
|
};
|
|
39
39
|
return filter;
|
|
40
40
|
}
|
|
41
|
-
class
|
|
41
|
+
class TextActiveFilterInstance extends ActiveFilterInstance {
|
|
42
42
|
formatValue() {
|
|
43
|
-
return this.value;
|
|
43
|
+
return this.value ?? "";
|
|
44
44
|
}
|
|
45
45
|
renderEditor(onChange) {
|
|
46
46
|
return (React__default.createElement(TextEditor, { label: this.operator.label, value: this.value, onCommit: (value) => onChange({ value }, { complete: !isEmptyValue(value) }) }));
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
function TextEditor({ label, onCommit, value: initialValue, }) {
|
|
49
|
+
function TextEditor({ label, onCommit, value: initialValue = "", }) {
|
|
50
50
|
const [value, setValue] = useState(initialValue);
|
|
51
51
|
const lastCommitted = useRef(initialValue);
|
|
52
52
|
const commit = () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textFilter.js","sources":["../../../src/components/DataTable/textFilter.tsx"],"sourcesContent":["import { Input } from \"@components/input\"\nimport React, { useRef, useState } from \"react\"\n\nimport { ActiveFilterInstance } from \"./ActiveFilterInstance\"\nimport type {\n FilterChange,\n FilterItemConfig,\n FilterNodeItem,\n Operator,\n} from \"./FilterTypes\"\nimport { resolveOperators } from \"./resolveOperators\"\nimport { isEmptyValue } from \"./utils\"\n\nexport const EQ = {\n inputType: { type: \"text\" },\n label: \"is\",\n name: \"eq\",\n} as const satisfies Operator\nexport const CONTAINS = {\n inputType: { type: \"text\" },\n label: \"contains\",\n name: \"contains\",\n} as const satisfies Operator\nexport const NOT = {\n inputType: { type: \"text\" },\n label: \"is not\",\n name: \"not\",\n} as const satisfies Operator\nexport const STARTS_WITH = {\n inputType: { type: \"text\" },\n label: \"starts with\",\n name: \"starts_with\",\n} as const satisfies Operator\n\nconst ALL_TEXT_OPERATORS = [EQ, CONTAINS, NOT, STARTS_WITH]\nconst DEFAULT_TEXT_OPERATORS = [CONTAINS]\n\nexport type TextOperatorName = (typeof ALL_TEXT_OPERATORS)[number][\"name\"]\n\nexport function textFilter({\n excludes,\n includes,\n ...config\n}: FilterItemConfig<TextOperatorName>): FilterNodeItem {\n const filter: FilterNodeItem = {\n ...config,\n createActiveFilterInstance: (activeFilter, operator) =>\n new
|
|
1
|
+
{"version":3,"file":"textFilter.js","sources":["../../../src/components/DataTable/textFilter.tsx"],"sourcesContent":["import { Input } from \"@components/input\"\nimport React, { useRef, useState } from \"react\"\n\nimport { ActiveFilterInstance } from \"./ActiveFilterInstance\"\nimport type {\n ActiveFilter,\n FilterChange,\n FilterItemConfig,\n FilterNodeItem,\n Operator,\n} from \"./FilterTypes\"\nimport { resolveOperators } from \"./resolveOperators\"\nimport { isEmptyValue } from \"./utils\"\n\nexport const EQ = {\n inputType: { type: \"text\" },\n label: \"is\",\n name: \"eq\",\n} as const satisfies Operator\nexport const CONTAINS = {\n inputType: { type: \"text\" },\n label: \"contains\",\n name: \"contains\",\n} as const satisfies Operator\nexport const NOT = {\n inputType: { type: \"text\" },\n label: \"is not\",\n name: \"not\",\n} as const satisfies Operator\nexport const STARTS_WITH = {\n inputType: { type: \"text\" },\n label: \"starts with\",\n name: \"starts_with\",\n} as const satisfies Operator\n\nconst ALL_TEXT_OPERATORS = [EQ, CONTAINS, NOT, STARTS_WITH]\nconst DEFAULT_TEXT_OPERATORS = [CONTAINS]\n\nexport type TextOperatorName = (typeof ALL_TEXT_OPERATORS)[number][\"name\"]\n\nexport type TextFilterValue = string | undefined\n\nexport type TextActiveFilter = ActiveFilter<TextFilterValue, TextOperatorName>\n\nexport function textFilter({\n excludes,\n includes,\n ...config\n}: FilterItemConfig<TextOperatorName>): FilterNodeItem {\n const filter: FilterNodeItem = {\n ...config,\n createActiveFilterInstance: (activeFilter, operator) =>\n new TextActiveFilterInstance(\n filter,\n operator,\n activeFilter.value as TextFilterValue\n ),\n operators: resolveOperators(ALL_TEXT_OPERATORS, {\n default: DEFAULT_TEXT_OPERATORS,\n excludes,\n includes,\n }),\n }\n return filter\n}\n\nclass TextActiveFilterInstance extends ActiveFilterInstance<TextFilterValue> {\n formatValue() {\n return this.value ?? \"\"\n }\n\n renderEditor(onChange: FilterChange) {\n return (\n <TextEditor\n label={this.operator.label}\n value={this.value}\n onCommit={(value) =>\n onChange({ value }, { complete: !isEmptyValue(value) })\n }\n />\n )\n }\n}\n\nfunction TextEditor({\n label,\n onCommit,\n value: initialValue = \"\",\n}: {\n label: string\n onCommit: (value: string) => void\n value: TextFilterValue\n}) {\n const [value, setValue] = useState(initialValue)\n const lastCommitted = useRef(initialValue)\n const commit = () => {\n lastCommitted.current = value\n onCommit(value)\n }\n return (\n <Input\n // eslint-disable-next-line jsx-a11y/no-autofocus -- the editor only ever renders inside a chip popover that just opened, per ARIA dialog practices\n autoFocus\n hideLabel\n label={label}\n value={value}\n onChange={(e) => setValue(e.target.value)}\n onBlur={() => {\n if (value !== lastCommitted.current) commit()\n }}\n onKeyDown={(e) => {\n if (e.key === \"Enter\" && !e.repeat && !e.nativeEvent.isComposing) {\n commit()\n }\n }}\n />\n )\n}\n"],"names":["React"],"mappings":";;;;;;AAcO,MAAM,EAAE,G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CH_FILTER_NAME = "q";
|
|
|
4
4
|
export declare const SEARCH_FILTER_OPERATOR = "contains";
|
|
5
5
|
export declare const isSearchFilter: (filter: ActiveFilter) => boolean;
|
|
6
6
|
export declare function useSearchFilter(activeFilters: ActiveFilter[], onActiveFiltersChange: (activeFilters: ActiveFilter[]) => void): {
|
|
7
|
-
chipFilters: ActiveFilter<
|
|
7
|
+
chipFilters: ActiveFilter<import("./FilterTypes").ActiveFilterValue, string>[];
|
|
8
8
|
clearFilters: () => void;
|
|
9
9
|
onChipFiltersChange: (chipFilters: ActiveFilter[]) => void;
|
|
10
10
|
onSearchChange: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { FilterNodeItem, FilterNodeScoped } from "./FilterTypes";
|
|
2
|
+
/** A new filter starts on its first operator; order operators with `includes` to choose it. */
|
|
2
3
|
export declare function getDefaultOperatorName(node: FilterNodeItem): string;
|
|
3
4
|
export declare function isEmptyValue(value: unknown): boolean;
|
|
4
5
|
/** Whether a filter delegates to scoped options. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAErE,+FAA+F;AAC/F,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,cAAc,GAAG,MAAM,CAGnE;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAGpD;AAED,oDAAoD;AACpD,wBAAgB,cAAc,CAC5B,MAAM,EAAE,cAAc,GACrB,MAAM,IAAI,gBAAgB,CAE5B;AAED,sFAAsF;AACtF,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,gBAAgB,EACxB,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,WAMzC;AAED,oFAAoF;AACpF,wBAAgB,YAAY,CAAC,MAAM,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,WAInE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
/** A new filter starts on its first operator; order operators with `includes` to choose it. */
|
|
2
2
|
function getDefaultOperatorName(node) {
|
|
3
3
|
const operatorName = node.operators?.[0]?.name;
|
|
4
4
|
return typeof operatorName === "string" ? operatorName : "default";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../../src/components/DataTable/utils.ts"],"sourcesContent":["import type { FilterNodeItem, FilterNodeScoped } from \"./FilterTypes\"\n\n
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../src/components/DataTable/utils.ts"],"sourcesContent":["import type { FilterNodeItem, FilterNodeScoped } from \"./FilterTypes\"\n\n/** A new filter starts on its first operator; order operators with `includes` to choose it. */\nexport function getDefaultOperatorName(node: FilterNodeItem): string {\n const operatorName = node.operators?.[0]?.name\n return typeof operatorName === \"string\" ? operatorName : \"default\"\n}\n\nexport function isEmptyValue(value: unknown): boolean {\n if (value === undefined || value === null || value === \"\") return true\n return Array.isArray(value) && value.length === 0\n}\n\n/** Whether a filter delegates to scoped options. */\nexport function isScopedFilter(\n filter: FilterNodeItem\n): filter is FilterNodeScoped {\n return Array.isArray((filter as FilterNodeScoped).options)\n}\n\n/** Lazy scopes aren't known until the editor loads them, so any one might be free. */\nexport function hasAvailableScope(\n filter: FilterNodeScoped,\n isScopeTaken: (scope: string) => boolean\n) {\n return (\n isLazyScoped(filter) ||\n filter.options.some(({ value }) => !isScopeTaken(value))\n )\n}\n\n/** Whether `scope` is one of the filter's scopes. Lazy scopes are assumed to be. */\nexport function isKnownScope(filter: FilterNodeScoped, scope: string) {\n return (\n isLazyScoped(filter) || filter.options.some(({ value }) => value === scope)\n )\n}\n\nfunction isLazyScoped(filter: FilterNodeScoped) {\n return filter.options.length === 0\n}\n"],"names":[],"mappings":"AAEA;AACM,SAAU,sBAAsB,CAAC,IAAoB,EAAA;IACzD,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC,EAAE,IAAI;AAC9C,IAAA,OAAO,OAAO,YAAY,KAAK,QAAQ,GAAG,YAAY,GAAG,SAAS;AACpE;AAEM,SAAU,YAAY,CAAC,KAAc,EAAA;IACzC,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,EAAE;AAAE,QAAA,OAAO,IAAI;AACtE,IAAA,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;AACnD;AAEA;AACM,SAAU,cAAc,CAC5B,MAAsB,EAAA;IAEtB,OAAO,KAAK,CAAC,OAAO,CAAE,MAA2B,CAAC,OAAO,CAAC;AAC5D;AAEA;AACM,SAAU,iBAAiB,CAC/B,MAAwB,EACxB,YAAwC,EAAA;AAExC,IAAA,QACE,YAAY,CAAC,MAAM,CAAC;AACpB,QAAA,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;AAE5D;AAEA;AACM,SAAU,YAAY,CAAC,MAAwB,EAAE,KAAa,EAAA;IAClE,QACE,YAAY,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,KAAK,KAAK,KAAK,CAAC;AAE/E;AAEA,SAAS,YAAY,CAAC,MAAwB,EAAA;AAC5C,IAAA,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC;AACpC;;;;"}
|