filtercn 0.1.2 → 0.2.1
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/README.md +20 -5
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +2 -2
- package/dist/commands/init.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/templates/index.d.ts +1 -10
- package/dist/templates/index.d.ts.map +1 -1
- package/dist/templates/index.js +877 -713
- package/dist/templates/index.js.map +1 -1
- package/dist/utils/dependencies.d.ts.map +1 -1
- package/dist/utils/dependencies.js +4 -12
- package/dist/utils/dependencies.js.map +1 -1
- package/dist/utils/detect-project.js +1 -1
- package/dist/utils/detect-project.js.map +1 -1
- package/dist/utils/file-writer.d.ts.map +1 -1
- package/dist/utils/file-writer.js +1 -1
- package/dist/utils/file-writer.js.map +1 -1
- package/package.json +8 -2
- package/src/commands/init.ts +9 -26
- package/src/index.ts +1 -5
- package/src/templates/index.ts +871 -707
- package/src/utils/dependencies.ts +6 -18
- package/src/utils/detect-project.ts +1 -1
- package/src/utils/file-writer.ts +2 -5
package/README.md
CHANGED
|
@@ -56,7 +56,7 @@ Here is a quick example of how to wrap your data table with the filter:
|
|
|
56
56
|
```tsx
|
|
57
57
|
"use client";
|
|
58
58
|
|
|
59
|
-
import { FilterProvider,
|
|
59
|
+
import { FilterProvider, FilterBar } from "@/components/conditional-filter";
|
|
60
60
|
import type { FilterFieldDefinition } from "@/components/conditional-filter";
|
|
61
61
|
|
|
62
62
|
// 1. Define the fields your users can filter by
|
|
@@ -72,6 +72,7 @@ const filterFields: FilterFieldDefinition[] = [
|
|
|
72
72
|
]
|
|
73
73
|
},
|
|
74
74
|
{ name: "price", label: "Budget", type: "number" },
|
|
75
|
+
{ name: "created_at", label: "Created", type: "date" }, // Now supports shadcn Calendar
|
|
75
76
|
];
|
|
76
77
|
|
|
77
78
|
export default function MyPage() {
|
|
@@ -79,17 +80,31 @@ export default function MyPage() {
|
|
|
79
80
|
<div className="p-8 space-y-4">
|
|
80
81
|
<h1 className="text-2xl font-bold">Projects</h1>
|
|
81
82
|
|
|
82
|
-
{/* 2. Wrap the
|
|
83
|
-
<FilterProvider
|
|
84
|
-
|
|
83
|
+
{/* 2. Wrap the toolbar in the provider */}
|
|
84
|
+
<FilterProvider
|
|
85
|
+
config={{
|
|
86
|
+
fields: filterFields,
|
|
87
|
+
paramStyle: "underscore",
|
|
88
|
+
allowConjunctionToggle: true, // Show AND/OR toggle
|
|
89
|
+
searchParamName: "q" // Global search param tracking
|
|
90
|
+
}}
|
|
91
|
+
>
|
|
92
|
+
<FilterBar searchPlaceholder="Search projects..." />
|
|
85
93
|
</FilterProvider>
|
|
86
94
|
|
|
87
|
-
{/* Your data table goes here */}
|
|
95
|
+
{/* Your data table goes here. It should read from the URL parameters. */}
|
|
88
96
|
</div>
|
|
89
97
|
);
|
|
90
98
|
}
|
|
91
99
|
```
|
|
92
100
|
|
|
101
|
+
### New in v0.2.0
|
|
102
|
+
- **Global Search:** `FilterBar` now includes a full-text search input with a built-in 300ms debounce.
|
|
103
|
+
- **Date Pickers:** Date fields now automatically render using the `shadcn/ui` Calendar component.
|
|
104
|
+
- **Param Prefixes:** Use `paramPrefix: "filter_"` in your config to namespace all query params.
|
|
105
|
+
- **AND/OR Conjunction:** Users can now toggle between mapping filters with `AND` or `OR` logic.
|
|
106
|
+
- **Async Comboboxes:** Full debounce support for `useFilterOptions` when fetching dynamic records from your API.
|
|
107
|
+
|
|
93
108
|
## Options
|
|
94
109
|
|
|
95
110
|
If you have modified the component files and want to reset them to their original state, or if the installation failed halfway and you want to try again, use the `--force` flag:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAUA,UAAU,WAAW;IACnB,KAAK,EAAE,OAAO,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;CACb;AAED,wBAAsB,WAAW,CAAC,OAAO,EAAE,WAAW,iBA6FrD"}
|
package/dist/commands/init.js
CHANGED
|
@@ -2,10 +2,10 @@ import path from "node:path";
|
|
|
2
2
|
import chalk from "chalk";
|
|
3
3
|
import ora from "ora";
|
|
4
4
|
import prompts from "prompts";
|
|
5
|
+
import { getTemplateFiles } from "../templates/index.js";
|
|
6
|
+
import { checkPeerDependencies, getShadcnInstallHint, installDependencies } from "../utils/dependencies.js";
|
|
5
7
|
import { detectProject } from "../utils/detect-project.js";
|
|
6
8
|
import { writeAllTemplates } from "../utils/file-writer.js";
|
|
7
|
-
import { checkPeerDependencies, installDependencies, getShadcnInstallHint, } from "../utils/dependencies.js";
|
|
8
|
-
import { getTemplateFiles } from "../templates/index.js";
|
|
9
9
|
import { logger } from "../utils/logger.js";
|
|
10
10
|
export async function initCommand(options) {
|
|
11
11
|
const cwd = path.resolve(options.cwd);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC5G,OAA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C,WAAW,CAAC,KAAK,iCAAiC,CAAC,CACjH,CAAC;IACF,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AAClB,CAAC"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,UAAU,CAAC;KAChB,WAAW,CAAC,6EAA6E,CAAC;KAC1F,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,OAAO;KACJ,OAAO,CAAC,MAAM,CAAC;KACf,WAAW,CAAC,6DAA6D,CAAC;KAC1E,MAAM,CAAC,aAAa,EAAE,0BAA0B,EAAE,KAAK,CAAC;KACxD,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,UAAU,CAAC;KAChB,WAAW,CAAC,6EAA6E,CAAC;KAC1F,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,OAAO;KACJ,OAAO,CAAC,MAAM,CAAC;KACf,WAAW,CAAC,6DAA6D,CAAC;KAC1E,MAAM,CAAC,aAAa,EAAE,0BAA0B,EAAE,KAAK,CAAC;KACxD,MAAM,CAAC,kBAAkB,EAAE,uDAAuD,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC;KAClG,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;IACrB,MAAM,WAAW,CAAC;QAChB,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,GAAG,EAAE,IAAI,CAAC,GAAG;KACd,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEL,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* Each key is the relative path within the component directory,
|
|
4
|
-
* and each value is the file content.
|
|
5
|
-
*
|
|
6
|
-
* The `ALIAS` placeholder is replaced with the user's actual import alias.
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Returns all template files mapped to their relative paths
|
|
10
|
-
* within the component directory. The alias placeholder will
|
|
11
|
-
* be replaced by the init command.
|
|
2
|
+
* Auto-generated templates for the FilterCN CLI
|
|
12
3
|
*/
|
|
13
4
|
export declare function getTemplateFiles(alias: string): Record<string, string>;
|
|
14
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/templates/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/templates/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAo0CH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAyBtE"}
|