@colixsystems/widget-sdk 0.50.0 → 0.52.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/README.md +10 -2
- package/dist/hooks.js +5 -2
- package/dist/icon.js +3 -2
- package/dist/index.d.ts +9 -0
- package/dist/index.js +1 -0
- package/dist/index.native.js +1 -0
- package/dist/lucideIconName.cjs +17 -0
- package/dist/lucideIconName.js +19 -0
- package/dist/lucideIconNames.cjs +172 -0
- package/dist/lucideIconNames.js +172 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -51,7 +51,15 @@ See the design reference for the full architecture: [`docs/architecture/widget-m
|
|
|
51
51
|
|
|
52
52
|
## Status
|
|
53
53
|
|
|
54
|
-
`v0.
|
|
54
|
+
`v0.52.0` — pre-publish. The package surface (types, function names, export paths) is the v1 contract; runtime behaviour for some hooks is stubbed (each hook documents what's wired and what isn't). It is **not yet published to npm**.
|
|
55
|
+
|
|
56
|
+
### What's new in 0.52.0
|
|
57
|
+
|
|
58
|
+
**Lucide icon names accept any case (sc-2088).** A new `normalizeLucideIconName(name)` export maps a human-typed icon name to the PascalCase form Lucide exports its components under — `arrow-right`, `arrow_right`, `arrow right`, `arrowRight`, and `ArrowRight` all resolve to `ArrowRight`; `building-2` → `Building2`. The lucide.dev gallery and its copy button hand you kebab-case, so authors no longer have to hand-convert. The `<Icon name="…">` primitive normalizes its `name` before lookup, and the `icon` propertySchema type accepts any case. Additive — one new pure export; no existing export changed signature. `CONTRACT` is unchanged.
|
|
59
|
+
|
|
60
|
+
### What's new in 0.51.0
|
|
61
|
+
|
|
62
|
+
**`datastoreTemplate` tables can ship sample `rows` (sc-2070).** Each `WidgetDatastoreTemplateTable` now takes an optional `rows` array — sample data seeded into the table at install time so the widget renders with real content instead of an empty state. Each entry is an object keyed by column `name`; only the scalar/array column types are seedable (`STRING`, `TEXT`, `NUMBER`, `FLOAT`, `BOOL`, `DATE`, `STRING_ARRAY`, `INT_ARRAY`). RELATION, FILE, USER, and USER_GROUP columns are rejected at validation time (a sample row has no way to express their ids). A `null` value skips that cell; at most 25 rows per table. The "Seed data" action and every install path seed these rows in the same transaction that creates the tables. Additive — `rows` is optional and existing templates that omit it behave exactly as before.
|
|
55
63
|
|
|
56
64
|
### What's new in 0.49.0
|
|
57
65
|
|
|
@@ -102,7 +110,7 @@ See the design reference for the full architecture: [`docs/architecture/widget-m
|
|
|
102
110
|
|
|
103
111
|
### What's new in 0.42.0
|
|
104
112
|
|
|
105
|
-
**RELATION columns hydrate with a display label (sc-1181).** Record reads now return `{ id, label }` for ONE_TO_ONE / ONE_TO_MANY and `[{ id, label }, ...]` for MANY_TO_MANY (empty array when no links) — `label` is the value of the column pointed at by the new optional `display_column_id` on `DatastoreSchemaColumn`, or, when unset, the first STRING/TEXT column on the target table. Widgets should render `record.<rel>.label` (or `record.<rel>.map(r => r.label).join(", ")` for M:M) directly; `.id` is still there for the foreign-key case. The cell-formatting helpers in the built-in `DataList
|
|
113
|
+
**RELATION columns hydrate with a display label (sc-1181).** Record reads now return `{ id, label }` for ONE_TO_ONE / ONE_TO_MANY and `[{ id, label }, ...]` for MANY_TO_MANY (empty array when no links) — `label` is the value of the column pointed at by the new optional `display_column_id` on `DatastoreSchemaColumn`, or, when unset, the first STRING/TEXT column on the target table. Widgets should render `record.<rel>.label` (or `record.<rel>.map(r => r.label).join(", ")` for M:M) directly; `.id` is still there for the foreign-key case. The cell-formatting helpers in the built-in `DataList` and `FieldValue` widgets already walk arrays and prefer `label` over `name` / `id` — author widgets that need the same can copy that pattern. `CONTRACT.version` is unchanged.
|
|
106
114
|
|
|
107
115
|
### What's new in 0.41.0
|
|
108
116
|
|
package/dist/hooks.js
CHANGED
|
@@ -569,8 +569,11 @@ function toDatastoreError(err) {
|
|
|
569
569
|
* resolves to the `{ data, meta }` list envelope VERBATIM (the client no
|
|
570
570
|
* longer unwraps to a bare array), so we read `res.data` (defaulting to `[]`)
|
|
571
571
|
* into component state. Author column values inside each row keep whatever
|
|
572
|
-
* the author named them.
|
|
573
|
-
*
|
|
572
|
+
* the author named them. `query.sort` accepts `"col:desc"` or `{ field, dir }`;
|
|
573
|
+
* `query.filter` accepts a `{ col: "op:value" }` map or a `[{ column,
|
|
574
|
+
* operator, value }]` array — the client normalises both to the wire form. We
|
|
575
|
+
* re-fetch when [table, JSON.stringify(query)] changes. `refetch` re-runs the
|
|
576
|
+
* same call on demand.
|
|
574
577
|
*
|
|
575
578
|
* When `table` is falsy (e.g. the user hasn't bound a `tableRef` property
|
|
576
579
|
* yet), the hook resolves to { data: [], loading: false, error: null,
|
package/dist/icon.js
CHANGED
|
@@ -16,10 +16,11 @@
|
|
|
16
16
|
|
|
17
17
|
import React from "react";
|
|
18
18
|
import * as LucideIcons from "lucide-react-native";
|
|
19
|
+
import { normalizeLucideIconName } from "./lucideIconName.js";
|
|
19
20
|
|
|
20
21
|
export function Icon({ name, size, color }) {
|
|
21
|
-
const
|
|
22
|
-
|
|
22
|
+
const resolved = normalizeLucideIconName(name);
|
|
23
|
+
const candidate = resolved ? LucideIcons[resolved] : null;
|
|
23
24
|
const Component = candidate || LucideIcons.Square;
|
|
24
25
|
const pixelSize = Number.isFinite(size) && size > 0 ? size : 24;
|
|
25
26
|
return React.createElement(Component, {
|
package/dist/index.d.ts
CHANGED
|
@@ -168,6 +168,15 @@ export interface WidgetDatastoreTemplateTable {
|
|
|
168
168
|
*/
|
|
169
169
|
publicGrant?: { canRead?: boolean; canWrite?: boolean; canDelete?: boolean };
|
|
170
170
|
columns: WidgetDatastoreTemplateColumn[];
|
|
171
|
+
/**
|
|
172
|
+
* Optional sample rows seeded into the table at install time so the widget
|
|
173
|
+
* renders with real data instead of an empty state. Each key is a column
|
|
174
|
+
* `name`; only non-relation/file/user columns are seedable (RELATION, FILE,
|
|
175
|
+
* USER, USER_GROUP are rejected). `null` skips that cell. Max 25 rows.
|
|
176
|
+
*/
|
|
177
|
+
rows?: Array<
|
|
178
|
+
Record<string, string | number | boolean | string[] | number[] | null>
|
|
179
|
+
>;
|
|
171
180
|
}
|
|
172
181
|
|
|
173
182
|
export interface WidgetDatastoreTemplate {
|
package/dist/index.js
CHANGED
package/dist/index.native.js
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// CommonJS twin of lucideIconName.js for the backend (the page service +
|
|
2
|
+
// any other Node consumer require this). Keep the two in sync — same
|
|
3
|
+
// algorithm, same behaviour. See lucideIconName.js for the rationale.
|
|
4
|
+
"use strict";
|
|
5
|
+
|
|
6
|
+
function normalizeLucideIconName(name) {
|
|
7
|
+
if (typeof name !== "string") return "";
|
|
8
|
+
const trimmed = name.trim();
|
|
9
|
+
if (trimmed === "") return "";
|
|
10
|
+
return trimmed
|
|
11
|
+
.split(/[-_\s]+/)
|
|
12
|
+
.filter(Boolean)
|
|
13
|
+
.map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1))
|
|
14
|
+
.join("");
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
module.exports = { normalizeLucideIconName };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Normalize a human-typed Lucide icon name to the PascalCase form Lucide
|
|
2
|
+
// exports its components under. The lucide.dev gallery shows kebab-case
|
|
3
|
+
// (`arrow-right`) and its copy button hands you kebab-case, but
|
|
4
|
+
// `lucide-react` / `lucide-react-native` key their components in PascalCase
|
|
5
|
+
// (`ArrowRight`). This bridges the two so any of kebab / snake / spaced /
|
|
6
|
+
// camel / PascalCase resolves: `arrow-right`, `arrow_right`, `arrow right`,
|
|
7
|
+
// `arrowRight`, and `ArrowRight` all become `ArrowRight`; `building-2` becomes
|
|
8
|
+
// `Building2`. Non-strings and blanks return "" so callers fall back to a
|
|
9
|
+
// placeholder. Already-PascalCase names pass through unchanged.
|
|
10
|
+
export function normalizeLucideIconName(name) {
|
|
11
|
+
if (typeof name !== "string") return "";
|
|
12
|
+
const trimmed = name.trim();
|
|
13
|
+
if (trimmed === "") return "";
|
|
14
|
+
return trimmed
|
|
15
|
+
.split(/[-_\s]+/)
|
|
16
|
+
.filter(Boolean)
|
|
17
|
+
.map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1))
|
|
18
|
+
.join("");
|
|
19
|
+
}
|