torch-glare 2.4.5 → 2.5.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/apps/lib/components/DataViews/{badgeAdapter.ts → badge.ts} +2 -2
- package/apps/lib/components/DataViews/cell.tsx +324 -0
- package/apps/lib/components/DataViews/context.ts +144 -0
- package/apps/lib/components/DataViews/data-views.tsx +383 -0
- package/apps/lib/components/DataViews/filters/children.tsx +98 -0
- package/apps/lib/components/DataViews/filters/custom.tsx +34 -0
- package/apps/lib/components/DataViews/filters/filters.tsx +163 -0
- package/apps/lib/components/DataViews/filters/index.ts +4 -0
- package/apps/lib/components/DataViews/filters/labelled.tsx +20 -0
- package/apps/lib/components/DataViews/filters/presets.tsx +65 -0
- package/apps/lib/components/DataViews/filters/summary.tsx +65 -0
- package/apps/lib/components/DataViews/filters/sync.tsx +35 -0
- package/apps/lib/components/DataViews/filters/values.ts +173 -0
- package/apps/lib/components/DataViews/header.tsx +217 -0
- package/apps/lib/components/DataViews/hooks/index.ts +5 -0
- package/apps/lib/components/DataViews/hooks/useActiveRow.ts +22 -0
- package/apps/lib/components/DataViews/hooks/useControllable.ts +52 -0
- package/apps/lib/components/DataViews/index.ts +74 -26
- package/apps/lib/components/DataViews/panel/columns.tsx +153 -0
- package/apps/lib/components/DataViews/panel/controls.tsx +106 -0
- package/apps/lib/components/DataViews/panel/index.ts +3 -0
- package/apps/lib/components/DataViews/panel/panel.tsx +164 -0
- package/apps/lib/components/DataViews/panel/saved-views.tsx +67 -0
- package/apps/lib/components/DataViews/panel/section.tsx +79 -0
- package/apps/lib/components/DataViews/panel/sort.tsx +42 -0
- package/apps/lib/components/DataViews/panel/tab.tsx +31 -0
- package/apps/lib/components/DataViews/slots.ts +63 -0
- package/apps/lib/components/DataViews/states.tsx +38 -0
- package/apps/lib/components/DataViews/types.ts +485 -178
- package/apps/lib/components/DataViews/views/board-view.tsx +379 -0
- package/apps/lib/components/DataViews/views/card-rows.tsx +36 -0
- package/apps/lib/components/DataViews/views/inbox-view.tsx +257 -0
- package/apps/lib/components/DataViews/views/pane-views.tsx +192 -0
- package/apps/lib/components/DataViews/views/table-view.tsx +426 -0
- package/apps/lib/components/DataViews/views/tree-view.tsx +365 -0
- package/apps/lib/components/FormBuilder/context.ts +20 -6
- package/apps/lib/components/FormBuilder/field-kind.ts +28 -0
- package/apps/lib/components/FormBuilder/fields/DateField.tsx +3 -3
- package/apps/lib/components/FormBuilder/fields/FieldShell.tsx +7 -6
- package/apps/lib/components/FormBuilder/fields/PhoneField.tsx +7 -6
- package/apps/lib/components/FormBuilder/fields/SelectField.tsx +7 -7
- package/apps/lib/components/FormBuilder/fields/TableField.tsx +1 -1
- package/apps/lib/components/FormBuilder/fields/TextField.tsx +9 -9
- package/apps/lib/components/FormBuilder/form-builder.tsx +55 -3
- package/apps/lib/components/FormBuilder/index.ts +3 -1
- package/apps/lib/components/FormBuilder/types.ts +40 -0
- package/apps/lib/components/TabSwitch.tsx +16 -4
- package/apps/lib/components/TreeFolder/TreeFolder.tsx +6 -3
- package/apps/lib/components/TreeFolder/TreeFolderRow.tsx +16 -14
- package/apps/lib/components/TreeFolder/index.ts +1 -1
- package/apps/lib/components/TreeFolder/useTreeFolderDnD.ts +70 -207
- package/apps/lib/hooks/useDragDrop.tsx +365 -0
- package/apps/lib/hooks/useInfiniteScroll.ts +108 -0
- package/apps/lib/registry.json +216 -4
- package/apps/lib/tsconfig.tsbuildinfo +1 -1
- package/apps/lib/utils/dataViews/path.ts +67 -0
- package/apps/lib/utils/dataViews/query.ts +73 -0
- package/apps/lib/utils/dataViews/types.ts +187 -0
- package/dist/bin/index.js +8 -4
- package/dist/bin/index.js.map +1 -1
- package/dist/src/commands/add.d.ts +3 -2
- package/dist/src/commands/add.d.ts.map +1 -1
- package/dist/src/commands/add.js +27 -35
- package/dist/src/commands/add.js.map +1 -1
- package/dist/src/commands/hook.d.ts.map +1 -1
- package/dist/src/commands/hook.js +23 -13
- package/dist/src/commands/hook.js.map +1 -1
- package/dist/src/commands/init.d.ts.map +1 -1
- package/dist/src/commands/init.js +6 -2
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/layout.d.ts.map +1 -1
- package/dist/src/commands/layout.js +23 -13
- package/dist/src/commands/layout.js.map +1 -1
- package/dist/src/commands/provider.d.ts.map +1 -1
- package/dist/src/commands/provider.js +22 -12
- package/dist/src/commands/provider.js.map +1 -1
- package/dist/src/commands/utils.d.ts.map +1 -1
- package/dist/src/commands/utils.js +21 -28
- package/dist/src/commands/utils.js.map +1 -1
- package/dist/src/shared/copyComponentsRecursively.d.ts +5 -3
- package/dist/src/shared/copyComponentsRecursively.d.ts.map +1 -1
- package/dist/src/shared/copyComponentsRecursively.js +5 -6
- package/dist/src/shared/copyComponentsRecursively.js.map +1 -1
- package/dist/src/shared/getDependenciesAndInstallNestedComponents.js +1 -1
- package/dist/src/shared/getDependenciesAndInstallNestedComponents.js.map +1 -1
- package/dist/src/shared/installDependencies.d.ts +16 -1
- package/dist/src/shared/installDependencies.d.ts.map +1 -1
- package/dist/src/shared/installDependencies.js +41 -21
- package/dist/src/shared/installDependencies.js.map +1 -1
- package/dist/src/shared/installFromPlan.d.ts +23 -0
- package/dist/src/shared/installFromPlan.d.ts.map +1 -0
- package/dist/src/shared/installFromPlan.js +77 -0
- package/dist/src/shared/installFromPlan.js.map +1 -0
- package/dist/src/shared/resolveEntry.d.ts +21 -0
- package/dist/src/shared/resolveEntry.d.ts.map +1 -0
- package/dist/src/shared/resolveEntry.js +54 -0
- package/dist/src/shared/resolveEntry.js.map +1 -0
- package/dist/src/shared/suggestOtherCommand.d.ts +8 -0
- package/dist/src/shared/suggestOtherCommand.d.ts.map +1 -0
- package/dist/src/shared/suggestOtherCommand.js +34 -0
- package/dist/src/shared/suggestOtherCommand.js.map +1 -0
- package/dist/src/shared/tailwindInit.d.ts +3 -1
- package/dist/src/shared/tailwindInit.d.ts.map +1 -1
- package/dist/src/shared/tailwindInit.js +3 -1
- package/dist/src/shared/tailwindInit.js.map +1 -1
- package/dist/src/shared/wireStylesheet.d.ts +32 -0
- package/dist/src/shared/wireStylesheet.d.ts.map +1 -0
- package/dist/src/shared/wireStylesheet.js +92 -0
- package/dist/src/shared/wireStylesheet.js.map +1 -0
- package/dist/src/types/main.d.ts +6 -0
- package/dist/src/types/main.d.ts.map +1 -1
- package/docs/components/breadcrumb.md +1 -1
- package/docs/components/button-group.md +1 -1
- package/docs/components/button.md +1 -1
- package/docs/components/card.md +1 -1
- package/docs/components/checkbox.md +1 -1
- package/docs/components/data-views/backend-response.md +324 -0
- package/docs/components/data-views/examples/a11y-rtl.md +250 -0
- package/docs/components/data-views/examples/api-orders-route.md +130 -0
- package/docs/components/data-views/examples/fields.md +362 -0
- package/docs/components/data-views/examples/filters.md +308 -0
- package/docs/components/data-views/examples/inbox-routing.md +218 -0
- package/docs/components/data-views/examples/index.md +29 -0
- package/docs/components/data-views/examples/overview.md +244 -0
- package/docs/components/data-views/examples/panel.md +212 -0
- package/docs/components/data-views/examples/scale.md +231 -0
- package/docs/components/data-views/examples/server-side.md +210 -0
- package/docs/components/data-views/examples/state.md +250 -0
- package/docs/components/data-views/examples/tree-custom.md +388 -0
- package/docs/components/data-views/examples/view-registry.md +313 -0
- package/docs/components/data-views/examples/views.md +534 -0
- package/docs/components/data-views/guide.md +405 -0
- package/docs/components/data-views/index.md +1504 -0
- package/docs/components/data-views/migration.md +79 -0
- package/docs/components/date-picker.md +0 -1
- package/docs/components/form-builder.md +3 -2
- package/docs/components/form-renderer.md +2 -1
- package/docs/components/form.md +1 -1
- package/docs/components/input-field.md +1 -1
- package/docs/components/input-otp.md +1 -1
- package/docs/components/input.md +1 -1
- package/docs/components/labeled-check-box.md +1 -1
- package/docs/components/labeled-radio.md +1 -1
- package/docs/components/radio-card.md +1 -1
- package/docs/components/radio.md +1 -1
- package/docs/components/search-field.md +1 -1
- package/docs/components/section-block.md +1 -1
- package/docs/components/select.md +1 -1
- package/docs/components/simple-select.md +1 -1
- package/docs/components/switch.md +1 -1
- package/docs/components/tab-switch.md +1 -1
- package/docs/components/table.md +1 -1
- package/docs/components/text-editor.md +1 -1
- package/docs/components/textarea.md +1 -1
- package/docs/components/toggle-button.md +1 -1
- package/docs/components/toggle.md +1 -1
- package/docs/components/tree-folder.md +110 -0
- package/docs/how-to/forms-with-form-builder.md +2 -2
- package/docs/reference/cli.md +28 -3
- package/docs/reference/components.md +16 -6
- package/docs/tutorials/component-composition.md +11 -13
- package/docs/tutorials/getting-started.md +7 -0
- package/package.json +3 -2
- package/apps/lib/components/DataViews/DataViewRadio.tsx +0 -49
- package/apps/lib/components/DataViews/DataViewsConfigPanel.tsx +0 -393
- package/apps/lib/components/DataViews/DataViewsHeader.tsx +0 -207
- package/apps/lib/components/DataViews/DataViewsLayout.tsx +0 -332
- package/apps/lib/components/DataViews/FilterPanel.tsx +0 -493
- package/apps/lib/components/DataViews/HeaderSearch.tsx +0 -93
- package/apps/lib/components/DataViews/InboxView.tsx +0 -463
- package/apps/lib/components/DataViews/InboxViewCard.tsx +0 -127
- package/apps/lib/components/DataViews/KanbanView.tsx +0 -336
- package/apps/lib/components/DataViews/PanelControls.tsx +0 -39
- package/apps/lib/components/DataViews/SettingsPanel.tsx +0 -279
- package/apps/lib/components/DataViews/TableView.tsx +0 -212
- package/apps/lib/components/DataViews/TreeView.tsx +0 -364
- package/apps/lib/components/DataViews/fieldRenderers.tsx +0 -299
- package/apps/lib/components/DataViews/filters/DatePickerRangeFilter.tsx +0 -87
- package/apps/lib/components/DataViews/filters/DateRangePopover.tsx +0 -120
- package/apps/lib/components/DataViews/filters/PresetChips.tsx +0 -45
- package/apps/lib/components/DataViews/filters/RangeSliderWithInputs.tsx +0 -165
- package/apps/lib/components/DataViews/tree/TreeDrawer.tsx +0 -50
- package/apps/lib/components/DataViews/tree/TreeSidebar.tsx +0 -74
- package/apps/lib/hooks/useDataViewsState.ts +0 -175
- package/apps/lib/utils/dataViews/columnUtils.ts +0 -132
- package/apps/lib/utils/dataViews/fieldUtils.ts +0 -197
- package/apps/lib/utils/dataViews/nestedDataUtils.tsx +0 -371
- package/apps/lib/utils/dataViews/pathUtils.ts +0 -139
- package/apps/lib/utils/dataViews/rangeUtils.ts +0 -234
- package/apps/lib/utils/dataViews/treeUtils.ts +0 -396
- package/docs/components/data-views-config-panel.md +0 -208
- package/docs/components/data-views-layout.md +0 -291
- package/docs/components/inbox-view.md +0 -170
- package/docs/components/kanban-view.md +0 -135
- package/docs/components/table-view.md +0 -141
- package/docs/components/tree-view.md +0 -147
- package/docs/how-to/data-views-from-backend-response.md +0 -194
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { Path, Row } from "./types";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Split cache. Bounded on purpose — the previous implementation used an unbounded module-level
|
|
5
|
+
* `Map`, which in a long-lived app grows for every distinct path string it ever sees. Paths come
|
|
6
|
+
* from a fixed field config in practice, so a small cap costs nothing and removes the leak.
|
|
7
|
+
*/
|
|
8
|
+
const CACHE_LIMIT = 512;
|
|
9
|
+
const cache = new Map<string, string[]>();
|
|
10
|
+
|
|
11
|
+
function split(path: Path): string[] {
|
|
12
|
+
const hit = cache.get(path);
|
|
13
|
+
if (hit) return hit;
|
|
14
|
+
const parts = path.split(".");
|
|
15
|
+
if (cache.size >= CACHE_LIMIT) cache.clear();
|
|
16
|
+
cache.set(path, parts);
|
|
17
|
+
return parts;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Read a dotted path off a row. Returns `undefined` for any missing link in the chain. */
|
|
21
|
+
export function getByPath(obj: unknown, path: Path | undefined | null): unknown {
|
|
22
|
+
if (obj == null || path == null || path === "") return undefined;
|
|
23
|
+
if (typeof obj !== "object") return undefined;
|
|
24
|
+
let cur: unknown = obj;
|
|
25
|
+
for (const key of split(path)) {
|
|
26
|
+
if (cur == null) return undefined;
|
|
27
|
+
cur = (cur as Record<string, unknown>)[key];
|
|
28
|
+
}
|
|
29
|
+
return cur;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Read a path and coerce to string for display/compare. `undefined`/`null` become `""`. */
|
|
33
|
+
export function getString(obj: unknown, path: Path | undefined | null): string {
|
|
34
|
+
const v = getByPath(obj, path);
|
|
35
|
+
return v == null ? "" : String(v);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** `"created_at"` / `"createdAt"` → `"Created At"`. Uses the last segment of a dotted path. */
|
|
39
|
+
export function formatPathLabel(path: Path): string {
|
|
40
|
+
if (!path) return "";
|
|
41
|
+
const tail = path.includes(".") ? path.split(".").pop()! : path;
|
|
42
|
+
|
|
43
|
+
if (tail.includes("_")) {
|
|
44
|
+
return tail
|
|
45
|
+
.split("_")
|
|
46
|
+
.filter(Boolean)
|
|
47
|
+
.map((w) => w.charAt(0).toUpperCase() + w.slice(1))
|
|
48
|
+
.join(" ");
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return tail
|
|
52
|
+
.replace(/([A-Z])/g, " $1")
|
|
53
|
+
.replace(/^./, (s) => s.toUpperCase())
|
|
54
|
+
.trim();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The default row identity: the first of `row.id`, `row._id`, `row.uuid`, else the array index.
|
|
59
|
+
*
|
|
60
|
+
* The previous implementation fell back through three candidates ending in the array index, so
|
|
61
|
+
* selection and drag-and-drop both broke the moment rows were reordered. Pass `getRowId` when
|
|
62
|
+
* your id lives elsewhere.
|
|
63
|
+
*/
|
|
64
|
+
export function defaultGetRowId(row: Row, index: number): string {
|
|
65
|
+
const id = row.id ?? row._id ?? row.uuid;
|
|
66
|
+
return id == null ? String(index) : String(id);
|
|
67
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { DataViewsQuery, FilterState, Sort } from "./types";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The wire format for a `DataViewsQuery`, both directions.
|
|
5
|
+
*
|
|
6
|
+
* A query is written in the browser and read on the server, and the two have to agree exactly.
|
|
7
|
+
* Keeping the encoder and the decoder in one file is what makes that true by construction —
|
|
8
|
+
* split across a page and a route handler, they drift the first time either side gains a field.
|
|
9
|
+
*
|
|
10
|
+
* No React here, like its neighbours `path.ts` and `types.ts`, so a route handler can import it.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/** A query nobody has touched yet: everything, first page. */
|
|
14
|
+
export function emptyQuery(overrides?: Partial<DataViewsQuery>): DataViewsQuery {
|
|
15
|
+
return { search: "", filters: {}, sort: null, page: 1, pageSize: 10, ...overrides };
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Browser → wire.
|
|
20
|
+
*
|
|
21
|
+
* `filters` goes as JSON because it is a nested structure, not a flat list of values. `sort` goes
|
|
22
|
+
* as `total:desc` — one parameter rather than two, since neither half means anything alone.
|
|
23
|
+
*
|
|
24
|
+
* Extra parameters an endpoint of your own needs are yours to append:
|
|
25
|
+
*
|
|
26
|
+
* ```ts
|
|
27
|
+
* const params = queryToParams(query);
|
|
28
|
+
* params.set("shape", "wide");
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export function queryToParams(query: DataViewsQuery): URLSearchParams {
|
|
32
|
+
return new URLSearchParams({
|
|
33
|
+
search: query.search,
|
|
34
|
+
filters: JSON.stringify(query.filters),
|
|
35
|
+
sort: query.sort ? `${query.sort.path}:${query.sort.direction}` : "",
|
|
36
|
+
page: String(query.page),
|
|
37
|
+
pageSize: String(query.pageSize),
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Wire → server.
|
|
43
|
+
*
|
|
44
|
+
* Malformed `filters` is treated as "no filters" rather than a 400: a filter you cannot parse
|
|
45
|
+
* should not take the page down. `pageSize` is clamped, because it arrives from the client and a
|
|
46
|
+
* request for a million rows is a request to fall over.
|
|
47
|
+
*/
|
|
48
|
+
export function parseQuery(url: URL): DataViewsQuery {
|
|
49
|
+
const params = url.searchParams;
|
|
50
|
+
|
|
51
|
+
let filters: FilterState = {};
|
|
52
|
+
const raw = params.get("filters");
|
|
53
|
+
if (raw) {
|
|
54
|
+
try {
|
|
55
|
+
filters = JSON.parse(raw) as FilterState;
|
|
56
|
+
} catch {
|
|
57
|
+
filters = {};
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const [sortPath, sortDir] = (params.get("sort") ?? "").split(":");
|
|
62
|
+
const sort: Sort = sortPath
|
|
63
|
+
? { path: sortPath, direction: sortDir === "desc" ? "desc" : "asc" }
|
|
64
|
+
: null;
|
|
65
|
+
|
|
66
|
+
return {
|
|
67
|
+
search: params.get("search") ?? "",
|
|
68
|
+
filters,
|
|
69
|
+
sort,
|
|
70
|
+
page: Math.max(1, Number(params.get("page")) || 1),
|
|
71
|
+
pageSize: Math.min(500, Math.max(1, Number(params.get("pageSize")) || 10)),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The vocabulary DataViews speaks — nothing more.
|
|
3
|
+
*
|
|
4
|
+
* DataViews does no data work: it never filters, searches, sorts, groups, or infers a schema.
|
|
5
|
+
* Those are the app's job, almost always server-side. What is described here is only what the
|
|
6
|
+
* component needs in order to **paint** rows and to **emit intent** back to you:
|
|
7
|
+
* `FilterState` and `Sort` are things it hands you so you can go and query, not things it applies.
|
|
8
|
+
*
|
|
9
|
+
* These types live in the utils layer so the dependency runs one way — the component imports its
|
|
10
|
+
* vocabulary from here, and nothing here imports React or any component.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import type { ReactNode } from "react";
|
|
14
|
+
|
|
15
|
+
/** A row is any record. DataViews never assumes a shape beyond the id resolved by `getRowId`. */
|
|
16
|
+
export type Row = Record<string, unknown>;
|
|
17
|
+
|
|
18
|
+
/** A dotted accessor into a row, e.g. `"customer.name"`. */
|
|
19
|
+
export type Path = string;
|
|
20
|
+
|
|
21
|
+
export type FieldType =
|
|
22
|
+
| "text"
|
|
23
|
+
| "number"
|
|
24
|
+
| "date"
|
|
25
|
+
| "boolean"
|
|
26
|
+
| "hidden"
|
|
27
|
+
| "enum-badge"
|
|
28
|
+
| "badge-array"
|
|
29
|
+
| "currency"
|
|
30
|
+
| "number-format"
|
|
31
|
+
| "progress-bar"
|
|
32
|
+
| "star-rating"
|
|
33
|
+
| "icon-text"
|
|
34
|
+
| "two-line"
|
|
35
|
+
| "avatar"
|
|
36
|
+
| "link"
|
|
37
|
+
| "image"
|
|
38
|
+
| "date-format";
|
|
39
|
+
|
|
40
|
+
export type BadgeVariant =
|
|
41
|
+
| "green"
|
|
42
|
+
| "greenLight"
|
|
43
|
+
| "cocktailGreen"
|
|
44
|
+
| "yellow"
|
|
45
|
+
| "redOrange"
|
|
46
|
+
| "redLight"
|
|
47
|
+
| "rose"
|
|
48
|
+
| "purple"
|
|
49
|
+
| "bluePurple"
|
|
50
|
+
| "blue"
|
|
51
|
+
| "navy"
|
|
52
|
+
| "gray"
|
|
53
|
+
| "highlight";
|
|
54
|
+
|
|
55
|
+
/** Palette keys for a board column pill. */
|
|
56
|
+
export type ColumnColor = "gray" | "purple" | "orange" | "blue" | "green" | "red";
|
|
57
|
+
|
|
58
|
+
export type CurrencyOptions = {
|
|
59
|
+
symbol?: string;
|
|
60
|
+
locale?: string;
|
|
61
|
+
decimals?: number;
|
|
62
|
+
code?: string;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/** How one field is read and painted. You author these — nothing is inferred from the data. */
|
|
66
|
+
export type FieldConfig = {
|
|
67
|
+
path: Path;
|
|
68
|
+
label?: string;
|
|
69
|
+
type?: FieldType;
|
|
70
|
+
visible?: boolean;
|
|
71
|
+
|
|
72
|
+
/** Value → badge colour, for `enum-badge` / `badge-array`. */
|
|
73
|
+
variants?: Record<string, BadgeVariant>;
|
|
74
|
+
defaultVariant?: BadgeVariant;
|
|
75
|
+
variant?: BadgeVariant;
|
|
76
|
+
|
|
77
|
+
limit?: number;
|
|
78
|
+
currency?: string | CurrencyOptions;
|
|
79
|
+
format?: Intl.NumberFormatOptions;
|
|
80
|
+
thresholds?: [number, number];
|
|
81
|
+
max?: number;
|
|
82
|
+
icon?: string;
|
|
83
|
+
iconPosition?: "before" | "after";
|
|
84
|
+
secondaryPath?: Path;
|
|
85
|
+
linkType?: "mailto" | "tel" | "url";
|
|
86
|
+
fallbackPath?: Path;
|
|
87
|
+
dateFormat?: string | Intl.DateTimeFormatOptions;
|
|
88
|
+
trueLabel?: string;
|
|
89
|
+
falseLabel?: string;
|
|
90
|
+
trueVariant?: BadgeVariant;
|
|
91
|
+
falseVariant?: BadgeVariant;
|
|
92
|
+
|
|
93
|
+
/** Paint this field yourself. Wins over `type`. */
|
|
94
|
+
render?: (value: unknown, row: Row) => ReactNode;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
/** A column as the user has arranged it — the projection the config panel edits. */
|
|
98
|
+
export type ColumnState = {
|
|
99
|
+
path: Path;
|
|
100
|
+
label: string;
|
|
101
|
+
visible: boolean;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
type SortDirection = "asc" | "desc";
|
|
105
|
+
/** Which column the header shows as sorted. Emitted on click; the component never re-orders rows. */
|
|
106
|
+
export type Sort = { path: Path; direction: SortDirection } | null;
|
|
107
|
+
|
|
108
|
+
type NumericRange = { kind: "number"; min?: number; max?: number };
|
|
109
|
+
type DateRange = { kind: "date"; from?: string; to?: string };
|
|
110
|
+
type RangeValue = NumericRange | DateRange;
|
|
111
|
+
/** A categorical selection, or a range. */
|
|
112
|
+
export type FilterValue = string[] | RangeValue;
|
|
113
|
+
/** Keyed by field path. */
|
|
114
|
+
export type FilterState = Record<Path, FilterValue>;
|
|
115
|
+
|
|
116
|
+
/** A one-click shortcut on a numeric filter, e.g. "Under 500". */
|
|
117
|
+
export type NumberPreset = { label: string; min?: number; max?: number };
|
|
118
|
+
/** A one-click shortcut on a date filter, e.g. "Last 30 days". */
|
|
119
|
+
export type DatePreset = { label: string; from?: string; to?: string };
|
|
120
|
+
/** `Filters.Presets` takes both shapes; each control renders the ones it understands. */
|
|
121
|
+
export type Preset = NumberPreset | DatePreset;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Everything the user asked for, in one object.
|
|
125
|
+
*
|
|
126
|
+
* This is the whole contract between `DataViews` and your data layer. The component collects it —
|
|
127
|
+
* a search typed in the header, filters set in the rail, a column header clicked, a page turned —
|
|
128
|
+
* and hands it over whole; going and fetching the matching rows is your half.
|
|
129
|
+
*
|
|
130
|
+
* It is one object rather than five callbacks because it is one question. A query with a new
|
|
131
|
+
* filter and a stale page number is not a query anyone meant to ask, and keeping the parts
|
|
132
|
+
* together is what lets the component keep them consistent — changing a filter resets `page` to 1,
|
|
133
|
+
* because a different result set has no page 4 to stay on.
|
|
134
|
+
*/
|
|
135
|
+
export interface DataViewsQuery {
|
|
136
|
+
search: string;
|
|
137
|
+
filters: FilterState;
|
|
138
|
+
sort: Sort;
|
|
139
|
+
/** 1-based. */
|
|
140
|
+
page: number;
|
|
141
|
+
pageSize: number;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** How a filter maps between its control's value and `FilterState`. */
|
|
145
|
+
type FilterKind = "choice" | "number" | "date" | "text";
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* What `DataViews.Filters` learned about one of its children.
|
|
149
|
+
*
|
|
150
|
+
* You never write these: filters are authored as `FormBuilder` fields, and `Filters` reads each
|
|
151
|
+
* child's `name`, `label` and bounds off the element to build this. It exists because the mapping
|
|
152
|
+
* to `FilterState` needs to know a slider from a multi-select — a `[0, 500]` is a numeric range,
|
|
153
|
+
* while `["a", "b"]` is a selection, and the two are indistinguishable once they are just values.
|
|
154
|
+
*/
|
|
155
|
+
export type FilterFieldDescriptor = {
|
|
156
|
+
path: Path;
|
|
157
|
+
label?: string;
|
|
158
|
+
kind: FilterKind;
|
|
159
|
+
/** Single-valued choice (`FormBuilder.Select`) rather than multi (`.MultiSelect`). */
|
|
160
|
+
single?: boolean;
|
|
161
|
+
/** Slider bounds, read from the child. A slider resting on them emits no filter at all. */
|
|
162
|
+
min?: number;
|
|
163
|
+
max?: number;
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
export type TreeNode = {
|
|
167
|
+
id: string;
|
|
168
|
+
row: Row;
|
|
169
|
+
children: TreeNode[];
|
|
170
|
+
depth: number;
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
/** Emitted by a board or tree drag. The component never applies it. */
|
|
174
|
+
export type MoveIntent = {
|
|
175
|
+
id: string;
|
|
176
|
+
from: string | null;
|
|
177
|
+
to: string | null;
|
|
178
|
+
index?: number;
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
/** A pre-grouped column for the board view. You build these; the component only paints them. */
|
|
182
|
+
export type RowGroup = {
|
|
183
|
+
id: string;
|
|
184
|
+
label: string;
|
|
185
|
+
color?: ColumnColor;
|
|
186
|
+
rows: Row[];
|
|
187
|
+
};
|
package/dist/bin/index.js
CHANGED
|
@@ -30,20 +30,24 @@ program
|
|
|
30
30
|
.action((component, options) => add(component, !!options.force));
|
|
31
31
|
program
|
|
32
32
|
.command("hook [hook]")
|
|
33
|
+
.option("-f, --force", "Overwrite it if it already exists")
|
|
33
34
|
.description("Add a hook interactively or install a specified one")
|
|
34
|
-
.action((hook) => addHook(hook
|
|
35
|
+
.action((hook, options) => addHook(hook, !!options.force));
|
|
35
36
|
program
|
|
36
37
|
.command("layout [layout]")
|
|
38
|
+
.option("-f, --force", "Overwrite it if it already exists")
|
|
37
39
|
.description("Add a Layout interactively or install a specified one")
|
|
38
|
-
.action((layout) => addLayout(layout
|
|
40
|
+
.action((layout, options) => addLayout(layout, !!options.force));
|
|
39
41
|
program
|
|
40
42
|
.command("util [util]")
|
|
43
|
+
.option("-f, --force", "Overwrite it if it already exists")
|
|
41
44
|
.description("Add a utils interactively or install a specified one")
|
|
42
|
-
.action((util) => addUtil(util));
|
|
45
|
+
.action((util, options) => addUtil(util, !!options.force));
|
|
43
46
|
program
|
|
44
47
|
.command("provider [provider]")
|
|
48
|
+
.option("-f, --force", "Overwrite it if it already exists")
|
|
45
49
|
.description("Add a provider interactively or install a specified one")
|
|
46
|
-
.action((provider) => addProvider(provider
|
|
50
|
+
.action((provider, options) => addProvider(provider, !!options.force));
|
|
47
51
|
program
|
|
48
52
|
.command("update")
|
|
49
53
|
.description("Update everything installed")
|
package/dist/bin/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../cli/bin/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAElD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAC/D,4EAA4E;AAC5E,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,KAAK,CAC5B,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,oBAAoB,CAAC,EAAE,OAAO,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,CAAC,uDAAuD,CAAC;KACpE,MAAM,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;AAEnE,OAAO;KACJ,OAAO,CAAC,aAAa,CAAC;KACpB,MAAM,CAAC,aAAa,EAAE,mCAAmC,CAAC;KAC5D,WAAW,CAAC,sDAAsD,CAAC;KACnE,MAAM,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;AAE7D,OAAO;KACJ,OAAO,CAAC,qBAAqB,CAAC;KAC5B,MAAM,CAAC,aAAa,EAAE,mCAAmC,CAAC;KAC5D,WAAW,CAAC,yDAAyD,CAAC;KACtE,MAAM,CAAC,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;AAEzE,OAAO;KACJ,OAAO,CAAC,QAAQ,CAAC;KACjB,WAAW,CAAC,6BAA6B,CAAC;KAC1C,MAAM,CAAC,GAAG,EAAE,CAAC,yBAAyB,EAAE,CAAC,CAAC;AAE7C,OAAO;KACJ,OAAO,CAAC,KAAK,CAAC;KACd,WAAW,CAAC,kDAAkD,CAAC;KAC/D,MAAM,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC;AAE5B,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Add a component and everything it needs.
|
|
3
|
+
*
|
|
3
4
|
* @param {string} component - The name of the component to add.
|
|
4
|
-
* @param {boolean} replace -
|
|
5
|
+
* @param {boolean} replace - Overwrite what is already there, dependencies included.
|
|
5
6
|
*/
|
|
6
7
|
export declare function add(component?: string, replace?: boolean): Promise<void>;
|
|
7
8
|
//# sourceMappingURL=add.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../../cli/src/commands/add.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../../cli/src/commands/add.ts"],"names":[],"mappings":"AAoBA;;;;;GAKG;AACH,wBAAsB,GAAG,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,OAAO,GAAE,OAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CA2CrF"}
|
package/dist/src/commands/add.js
CHANGED
|
@@ -1,71 +1,63 @@
|
|
|
1
1
|
import path from "path";
|
|
2
|
-
import fs from "fs";
|
|
3
2
|
import inquirer from "inquirer";
|
|
4
3
|
import { fileURLToPath } from "url";
|
|
5
4
|
import { ensureDirectoryExists } from "../shared/ensureDirectoryExists.js";
|
|
6
5
|
import { getInstallPaths } from "../shared/getInstallPaths.js";
|
|
7
6
|
import { copyComponentsRecursively } from "../shared/copyComponentsRecursively.js";
|
|
8
7
|
import { getAvailableFiles } from "../shared/getAvailableFiles.js";
|
|
9
|
-
import {
|
|
8
|
+
import { installDependencies } from "../shared/installDependencies.js";
|
|
9
|
+
import { installFromPlan, reportInstall } from "../shared/installFromPlan.js";
|
|
10
|
+
import { isInstalled, resolveEntry } from "../shared/resolveEntry.js";
|
|
10
11
|
import { getConfig } from "../shared/getConfig.js";
|
|
12
|
+
import { suggestOtherCommand } from "../shared/suggestOtherCommand.js";
|
|
11
13
|
import { CONFIG_FILE } from "./init.js";
|
|
12
14
|
const __filename = fileURLToPath(import.meta.url);
|
|
13
|
-
// Get the current file and directory paths
|
|
14
15
|
const __dirname = path.dirname(__filename);
|
|
15
|
-
// Define the path to the templates directory
|
|
16
16
|
const templatesDir = path.resolve(__dirname, "../../../apps/lib/components");
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
18
|
+
* Add a component and everything it needs.
|
|
19
|
+
*
|
|
19
20
|
* @param {string} component - The name of the component to add.
|
|
20
|
-
* @param {boolean} replace -
|
|
21
|
+
* @param {boolean} replace - Overwrite what is already there, dependencies included.
|
|
21
22
|
*/
|
|
22
23
|
export async function add(component, replace = false) {
|
|
23
24
|
const targetFile = getConfig(CONFIG_FILE);
|
|
24
25
|
const availableComponents = getAvailableFiles(templatesDir);
|
|
25
|
-
// If no component is provided, prompt the user to select one
|
|
26
26
|
if (!component) {
|
|
27
27
|
component = await promptComponentSelection(availableComponents);
|
|
28
28
|
}
|
|
29
|
-
|
|
30
|
-
const resolved = resolveComponentEntry(component, availableComponents, templatesDir);
|
|
29
|
+
const resolved = resolveEntry(component, availableComponents, templatesDir);
|
|
31
30
|
if (!resolved) {
|
|
32
31
|
console.error(`❌ Component "${component}" not found.`);
|
|
32
|
+
// It may well exist — as a hook, util, layout or provider. Say which command to use rather
|
|
33
|
+
// than leaving the caller to guess.
|
|
34
|
+
const hint = suggestOtherCommand(component);
|
|
35
|
+
if (hint)
|
|
36
|
+
console.error(` ${hint}`);
|
|
33
37
|
return;
|
|
34
38
|
}
|
|
39
|
+
// The registry knows the whole graph, so resolve it in one pass. `replace` reaches every item
|
|
40
|
+
// in the plan, which is what `--force` has always implied and never did.
|
|
41
|
+
const name = resolved.replace(/\.(tsx|ts)$/, "");
|
|
42
|
+
const result = installFromPlan("components", name, targetFile, replace);
|
|
43
|
+
if (result) {
|
|
44
|
+
reportInstall(resolved, result, targetFile.path);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
// Not in the registry — something added to apps/lib before `pnpm run registry` was re-run.
|
|
48
|
+
// Copy it alone and say so, rather than pretending the dependencies were handled.
|
|
49
|
+
console.warn(`⚠️ "${resolved}" is not in registry.json, so its dependencies cannot be resolved.\n` +
|
|
50
|
+
` Copying the files only. Re-run \`pnpm run registry\` in the library to fix this.`);
|
|
35
51
|
const { source, targetDir } = getInstallPaths(resolved, targetFile, templatesDir, "components");
|
|
36
|
-
|
|
37
|
-
if (isFileExists(targetDir, resolved) && !replace) {
|
|
52
|
+
if (isInstalled(targetDir, resolved) && !replace) {
|
|
38
53
|
console.log(`⚠️ Component "${resolved}" already exists.`);
|
|
39
54
|
return;
|
|
40
55
|
}
|
|
41
|
-
// Ensure the target directory exists
|
|
42
|
-
// if the directory is not exists, create it
|
|
43
56
|
ensureDirectoryExists(targetDir);
|
|
44
|
-
// Copy the component (directory or file) and install dependencies
|
|
45
57
|
copyComponentsRecursively(source, targetDir);
|
|
58
|
+
installDependencies(source);
|
|
46
59
|
console.log(`✅ ${resolved} has been added to ${targetFile.path}!`);
|
|
47
60
|
}
|
|
48
|
-
/**
|
|
49
|
-
* Resolve a user-provided component name to an actual entry in the templates
|
|
50
|
-
* directory. Tries (in order):
|
|
51
|
-
* 1. exact match (e.g. "Button.tsx" or "DataViews")
|
|
52
|
-
* 2. with `.tsx` suffix (e.g. user typed "Button")
|
|
53
|
-
* 3. with `.ts` suffix (for non-JSX modules)
|
|
54
|
-
* Returns the matching entry name, or null if nothing matches.
|
|
55
|
-
*/
|
|
56
|
-
function resolveComponentEntry(input, available, dir) {
|
|
57
|
-
if (available.includes(input))
|
|
58
|
-
return input;
|
|
59
|
-
const candidates = [`${input}.tsx`, `${input}.ts`];
|
|
60
|
-
for (const c of candidates) {
|
|
61
|
-
if (available.includes(c))
|
|
62
|
-
return c;
|
|
63
|
-
}
|
|
64
|
-
// Last-ditch: see if it exists on disk even if `getAvailableFiles` missed it.
|
|
65
|
-
if (fs.existsSync(path.join(dir, input)))
|
|
66
|
-
return input;
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
61
|
/**
|
|
70
62
|
* Prompt the user to select a component from a list.
|
|
71
63
|
* @param {string[]} availableComponents - Array of available components.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add.js","sourceRoot":"","sources":["../../../cli/src/commands/add.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MA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,CAAC;IAC7C,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAC5B,OAAO,CAAC,GAAG,CAAC,KAAK,QAAQ,sBAAsB,UAAU,CAAC,IAAI,GAAG,CAAC,CAAC;AACvE,CAAC;AAED;;;;GAIG;AACH,KAAK,UAAU,wBAAwB,CAAC,mBAA6B;IACjE,MAAM,EAAE,iBAAiB,EAAE,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC;QAChD;YACI,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,mBAAmB;YACzB,OAAO,EAAE,wCAAwC;YACjD,OAAO,EAAE,mBAAmB;SAC/B;KACJ,CAAC,CAAC;IACH,OAAO,iBAAiB,CAAC;AAC7B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hook.d.ts","sourceRoot":"","sources":["../../../cli/src/commands/hook.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hook.d.ts","sourceRoot":"","sources":["../../../cli/src/commands/hook.ts"],"names":[],"mappings":"AAmBA;;;;GAIG;AACH,wBAAsB,OAAO,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,OAAO,GAAE,OAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAuCpF"}
|
|
@@ -7,7 +7,8 @@ import { getInstallPaths } from "../shared/getInstallPaths.js";
|
|
|
7
7
|
import { copyComponentsRecursively } from "../shared/copyComponentsRecursively.js";
|
|
8
8
|
import { getConfig } from "../shared/getConfig.js";
|
|
9
9
|
import { CONFIG_FILE } from "./init.js";
|
|
10
|
-
import {
|
|
10
|
+
import { installFromPlan, reportInstall } from "../shared/installFromPlan.js";
|
|
11
|
+
import { isInstalled, resolveEntry } from "../shared/resolveEntry.js";
|
|
11
12
|
const __filename = fileURLToPath(import.meta.url);
|
|
12
13
|
const __dirname = path.dirname(__filename);
|
|
13
14
|
// Define the path to the hooks templates directory
|
|
@@ -24,23 +25,32 @@ export async function addHook(hook, replace = false) {
|
|
|
24
25
|
if (!hook) {
|
|
25
26
|
hook = await promptHookSelection(availableHooks);
|
|
26
27
|
}
|
|
27
|
-
//
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
// Resolve the name the way every other command does — a bare `hook` name, a name with
|
|
29
|
+
// its extension, or a folder all reach the same entry.
|
|
30
|
+
const resolved = resolveEntry(hook, availableHooks, hooksTemplatesDir);
|
|
31
|
+
if (!resolved) {
|
|
32
|
+
console.error(`❌ Hook "${hook}" not found.`);
|
|
30
33
|
return;
|
|
31
34
|
}
|
|
32
|
-
//
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
// The registry resolves the whole graph in one pass, so `replace` reaches every item — and a
|
|
36
|
+
// dependency is never skipped-and-forgotten the way the per-file walker used to skip it.
|
|
37
|
+
const name = resolved.replace(/\.(tsx|ts)$/, "");
|
|
38
|
+
const result = installFromPlan("hooks", name, targetFile, replace);
|
|
39
|
+
if (result) {
|
|
40
|
+
reportInstall(resolved, result, targetFile.path);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
// Not in registry.json — copy it alone, and say why the dependencies were not resolved.
|
|
44
|
+
console.warn(`⚠️ "${resolved}" is not in registry.json, so its dependencies cannot be resolved.\n` +
|
|
45
|
+
` Copying the file only. Re-run \`pnpm run registry\` in the library to fix this.`);
|
|
46
|
+
const { source, targetDir } = getInstallPaths(resolved, targetFile, hooksTemplatesDir, "hooks");
|
|
47
|
+
if (isInstalled(targetDir, resolved) && !replace) {
|
|
48
|
+
console.log(`⚠️ Hook "${resolved}" already exists.`);
|
|
39
49
|
return;
|
|
40
50
|
}
|
|
41
|
-
|
|
51
|
+
ensureDirectoryExists(targetDir);
|
|
42
52
|
copyComponentsRecursively(source, targetDir);
|
|
43
|
-
console.log(`✅ ${
|
|
53
|
+
console.log(`✅ ${resolved} has been added to ${targetFile.path}!`);
|
|
44
54
|
}
|
|
45
55
|
/**
|
|
46
56
|
* Get a list of available hooks from the hooks templates directory.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hook.js","sourceRoot":"","sources":["../../../cli/src/commands/hook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,yBAAyB,EAAE,MAAM,wCAAwC,CAAC;AACnF,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"hook.js","sourceRoot":"","sources":["../../../cli/src/commands/hook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,yBAAyB,EAAE,MAAM,wCAAwC,CAAC;AACnF,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC9E,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEtE,MAAM,UAAU,GAAG,aAAa,C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AAQ,EAAE,UAAU,EAAE,iBAAiB,EAAE,OAAO,CAAC,CAAC;IAChG,IAAI,WAAW,CAAC,SAAS,EAAE,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;QAC/C,OAAO,CAAC,GAAG,CAAC,YAAY,QAAQ,mBAAmB,CAAC,CAAC;QACrD,OAAO;IACX,CAAC;IACD,qBAAqB,CAAC,SAAS,CAAC,CAAC;IACjC,yBAAyB,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAC7C,OAAO,CAAC,GAAG,CAAC,KAAK,QAAQ,sBAAsB,UAAU,CAAC,IAAI,GAAG,CAAC,CAAC;AACvE,CAAC;AAED;;;;GAIG;AACH,SAAS,iBAAiB,CAAC,iBAAyB;IAChD,OAAO,EAAE,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC,GAAG,CAAC,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;AACxF,CAAC;AAED;;;;GAIG;AACH,KAAK,UAAU,mBAAmB,CAAC,cAAwB;IACvD,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC;QAC3C;YACI,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,cAAc;YACpB,OAAO,EAAE,mCAAmC;YAC5C,OAAO,EAAE,cAAc;SAC1B;KACJ,CAAC,CAAC;IACH,OAAO,YAAY,CAAC;AACxB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../cli/src/commands/init.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../cli/src/commands/init.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,WAAW,eAAe,CAAC;AAGxC,wBAAsB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAehD"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import { tailwindInit } from "../shared/tailwindInit.js";
|
|
3
|
+
import { wireStylesheet } from "../shared/wireStylesheet.js";
|
|
3
4
|
export const CONFIG_FILE = "glare.json";
|
|
4
5
|
export async function initConfig() {
|
|
5
6
|
const defaultConfig = { path: "./" };
|
|
@@ -10,7 +11,10 @@ export async function initConfig() {
|
|
|
10
11
|
else {
|
|
11
12
|
console.log("⚠️ glare.json already exists, skipping creation.");
|
|
12
13
|
}
|
|
13
|
-
//
|
|
14
|
-
|
|
14
|
+
// Install the Tailwind packages, then actually wire them into the project's stylesheet.
|
|
15
|
+
// Installing them and stopping — which is what this did — leaves a project that builds fine
|
|
16
|
+
// and renders every design token unstyled, with no error to explain it.
|
|
17
|
+
const { isV3 } = tailwindInit();
|
|
18
|
+
wireStylesheet(isV3);
|
|
15
19
|
}
|
|
16
20
|
//# sourceMappingURL=init.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../../cli/src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../../cli/src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAM7D,MAAM,CAAC,MAAM,WAAW,GAAG,YAAY,CAAC;AAGxC,MAAM,CAAC,KAAK,UAAU,UAAU;IAC5B,MAAM,aAAa,GAAgB,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IAElD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;QAC9B,EAAE,CAAC,aAAa,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QACtE,OAAO,CAAC,GAAG,CAAC,yCAAyC,CAAC,CAAC;IAC3D,CAAC;SAAM,CAAC;QACJ,OAAO,CAAC,GAAG,CAAC,kDAAkD,CAAC,CAAC;IACpE,CAAC;IAED,wFAAwF;IACxF,4FAA4F;IAC5F,wEAAwE;IACxE,MAAM,EAAE,IAAI,EAAE,GAAG,YAAY,EAAE,CAAC;IAChC,cAAc,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../../cli/src/commands/layout.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../../cli/src/commands/layout.ts"],"names":[],"mappings":"AAkBA;;;;GAIG;AACH,wBAAsB,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,GAAE,OAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAuCxF"}
|