@nexub/react 5.6.0 → 5.7.0
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/accessibility.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "5.
|
|
2
|
+
"version": "5.7.0",
|
|
3
3
|
"standard": "WCAG 2.2 Level AA",
|
|
4
4
|
"method": {
|
|
5
5
|
"automated": "axe-core rules tagged wcag2a, wcag2aa, wcag21a, wcag21aa and wcag22aa, run on every Storybook story in light and dark on every pull request; a new violation fails the build.",
|
|
@@ -1,36 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import type
|
|
3
|
-
export type FilterFieldType
|
|
4
|
-
export
|
|
5
|
-
export interface FilterField {
|
|
6
|
-
id: string;
|
|
7
|
-
label: string;
|
|
8
|
-
type: FilterFieldType;
|
|
9
|
-
/** Choices for `type: 'select'`. */
|
|
10
|
-
options?: {
|
|
11
|
-
value: string;
|
|
12
|
-
label: string;
|
|
13
|
-
}[];
|
|
14
|
-
}
|
|
15
|
-
export interface FilterRule {
|
|
16
|
-
id: string;
|
|
17
|
-
field: string;
|
|
18
|
-
operator: FilterOperator;
|
|
19
|
-
/** Always a string (dates as YYYY-MM-DD), so the query serialises as-is. */
|
|
20
|
-
value: string;
|
|
21
|
-
}
|
|
22
|
-
export interface FilterGroup {
|
|
23
|
-
id: string;
|
|
24
|
-
combinator: 'and' | 'or';
|
|
25
|
-
rules: Array<FilterRule | FilterGroup>;
|
|
26
|
-
}
|
|
27
|
-
/** Operators offered for each field type, in menu order. */
|
|
28
|
-
export declare const filterOperators: Record<FilterFieldType, FilterOperator[]>;
|
|
29
|
-
export declare const isFilterGroup: (r: FilterRule | FilterGroup) => r is FilterGroup;
|
|
30
|
-
/** An empty top-level group, a starting `value`. */
|
|
31
|
-
export declare const emptyFilter: () => FilterGroup;
|
|
32
|
-
/** Rules with a field, operator and (unless "is empty") a value. Counts nested groups too. */
|
|
33
|
-
export declare function countFilters(group: FilterGroup): number;
|
|
2
|
+
import { countFilters, emptyFilter, filterOperators, isFilterGroup, type FilterField, type FilterFieldType, type FilterGroup, type FilterOperator, type FilterRule } from '@nexub/core';
|
|
3
|
+
export type { FilterFieldType, FilterOperator, FilterField, FilterRule, FilterGroup };
|
|
4
|
+
export { filterOperators, isFilterGroup, emptyFilter, countFilters };
|
|
34
5
|
export interface FilterBuilderProps {
|
|
35
6
|
fields: FilterField[];
|
|
36
7
|
value?: FilterGroup;
|
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { Plus, X } from "@nexub/icons";
|
|
5
|
+
import {
|
|
6
|
+
countFilters,
|
|
7
|
+
emptyFilter,
|
|
8
|
+
filterId as uid,
|
|
9
|
+
filterOperators,
|
|
10
|
+
isFilterGroup,
|
|
11
|
+
newFilterRule
|
|
12
|
+
} from "@nexub/core";
|
|
5
13
|
import { cn } from "../../utils/cn.js";
|
|
6
14
|
import { useControllableState } from "../../hooks/useControllableState.js";
|
|
7
15
|
import { useNexubMessages } from "../NexubProvider/NexubProvider.js";
|
|
@@ -10,22 +18,6 @@ import { IconButton } from "../IconButton/IconButton.js";
|
|
|
10
18
|
import { Input } from "../Input/Input.js";
|
|
11
19
|
import { Select } from "../Select/Select.js";
|
|
12
20
|
import { SegmentedControl } from "../SegmentedControl/SegmentedControl.js";
|
|
13
|
-
const filterOperators = {
|
|
14
|
-
text: ["contains", "equals", "notEquals", "startsWith", "isEmpty"],
|
|
15
|
-
number: ["equals", "notEquals", "greaterThan", "lessThan"],
|
|
16
|
-
select: ["equals", "notEquals"],
|
|
17
|
-
date: ["equals", "before", "after"]
|
|
18
|
-
};
|
|
19
|
-
const isFilterGroup = (r) => "rules" in r;
|
|
20
|
-
let seq = 0;
|
|
21
|
-
const uid = () => `f${(++seq).toString(36)}${Math.random().toString(36).slice(2, 6)}`;
|
|
22
|
-
const emptyFilter = () => ({ id: uid(), combinator: "and", rules: [] });
|
|
23
|
-
function countFilters(group) {
|
|
24
|
-
return group.rules.reduce(
|
|
25
|
-
(n, r) => n + (isFilterGroup(r) ? countFilters(r) : r.operator === "isEmpty" || r.value !== "" ? 1 : 0),
|
|
26
|
-
0
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
21
|
function FilterBuilder({ fields, value: valueProp, defaultValue, onValueChange, maxDepth = 1, className }) {
|
|
30
22
|
const [value = emptyFilter(), setValue] = useControllableState({
|
|
31
23
|
value: valueProp,
|
|
@@ -49,12 +41,7 @@ function GroupView({ group, fields, depth, maxDepth, onChange, onRemove, classNa
|
|
|
49
41
|
const t = useNexubMessages();
|
|
50
42
|
const first = fields[0];
|
|
51
43
|
const setRules = (rules) => onChange({ ...group, rules });
|
|
52
|
-
const newRule = () => (
|
|
53
|
-
id: uid(),
|
|
54
|
-
field: first?.id ?? "",
|
|
55
|
-
operator: filterOperators[first?.type ?? "text"][0],
|
|
56
|
-
value: ""
|
|
57
|
-
});
|
|
44
|
+
const newRule = () => newFilterRule(first);
|
|
58
45
|
return /* @__PURE__ */ jsxs(
|
|
59
46
|
"div",
|
|
60
47
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nexub/react",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.7.0",
|
|
4
4
|
"description": "React component library for Nexub Design System — 90+ accessible, themeable UI components built on Radix UI primitives.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -81,14 +81,14 @@
|
|
|
81
81
|
"date-fns": "^4.4.0",
|
|
82
82
|
"react-day-picker": "^10.0.2",
|
|
83
83
|
"tailwind-merge": "^3.7.0",
|
|
84
|
-
"@nexub/core": "5.
|
|
85
|
-
"@nexub/icons": "5.
|
|
84
|
+
"@nexub/core": "5.7.0",
|
|
85
|
+
"@nexub/icons": "5.7.0"
|
|
86
86
|
},
|
|
87
87
|
"peerDependencies": {
|
|
88
88
|
"react": ">=19 <20",
|
|
89
89
|
"react-dom": ">=19 <20",
|
|
90
90
|
"@tanstack/react-virtual": "^3.14.22",
|
|
91
|
-
"@nexub/tokens": "^5.
|
|
91
|
+
"@nexub/tokens": "^5.7.0"
|
|
92
92
|
},
|
|
93
93
|
"peerDependenciesMeta": {
|
|
94
94
|
"@tanstack/react-virtual": {
|
|
@@ -120,8 +120,8 @@
|
|
|
120
120
|
"vaul": "1.1.2",
|
|
121
121
|
"vite": "^8.3.5",
|
|
122
122
|
"vitest": "^5.0.5",
|
|
123
|
-
"@nexub/themes": "5.
|
|
124
|
-
"@nexub/tokens": "5.
|
|
123
|
+
"@nexub/themes": "5.7.0",
|
|
124
|
+
"@nexub/tokens": "5.7.0"
|
|
125
125
|
},
|
|
126
126
|
"scripts": {
|
|
127
127
|
"build": "rm -rf dist && tsup && tsc -p tsconfig.build.json && rm -f dist/vendor/*.d.ts && node scripts/check-dts.mjs && tailwindcss -i src/styles.css -o dist/styles.css --minify && cp -R ../themes/src/fonts dist/fonts",
|