@colixsystems/widget-sdk 0.161.0 → 0.162.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 +22 -1
- package/dist/contract.cjs +57 -1
- package/dist/contract.js +57 -1
- package/dist/index.d.ts +82 -0
- package/dist/index.js +15 -0
- package/dist/index.native.js +15 -0
- package/dist/list-tokens.js +68 -0
- package/dist/list-view.js +215 -0
- package/dist/list.js +7 -0
- package/dist/list.native.js +7 -0
- package/dist/text-roles.js +102 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -73,7 +73,26 @@ See the design reference for the full architecture: [`docs/architecture/widget-m
|
|
|
73
73
|
|
|
74
74
|
## Status
|
|
75
75
|
|
|
76
|
-
`v0.
|
|
76
|
+
`v0.162.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**.
|
|
77
|
+
|
|
78
|
+
### What's new in 0.162.0 (contract 1.125.0)
|
|
79
|
+
|
|
80
|
+
**Themed list rows: `List`, `ListRow`, `EmptyState`, and the `list` theme scope.** Each widget that showed records used to hand-roll its rows from `View` + `Pressable`, so two lists in one app disagreed on padding, dividers and corners. `<ListRow>` draws one row whose padding, minimum height, divider, corner radius and background come from **Theme Settings > Lists** (`themeConfig.components.list`), and `<List>` spaces its rows and passes any override down to them. Unthemed, a row is the flush, hairline band the built-in Data List always drew. When the theme sets a `gap`, rows become separate tiles on the surface, outlined by the divider. A selected row carries an accent bar as well as the tint, the last row of a `<List>` has no divider, a pressable row never drops below 44px, and every override passes the same bounds a theme value does. `<EmptyState>` is the matching "nothing here" panel.
|
|
81
|
+
|
|
82
|
+
```jsx
|
|
83
|
+
<List>
|
|
84
|
+
{items.map((item) => (
|
|
85
|
+
<ListRow key={item.id} title={item.name} subtitle={item.email} onPress={() => open(item)} selected={item.id === selectedId} />
|
|
86
|
+
))}
|
|
87
|
+
</List>
|
|
88
|
+
{items.length === 0 ? <EmptyState icon="inbox" title="No orders yet" message="New orders appear here." /> : null}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
To let an author restyle one widget's rows, declare the style fields `listRowPadding`, `listRowMinHeight`, `listRowGap`, `listRowRadius`, `listRowBackground`, `listDividerColor` and `listDividerWidth`. They follow the theme until set, like the `card*` fields do, and you pass them through as the matching `ListRow` props (`rowPadding`, …).
|
|
92
|
+
|
|
93
|
+
**`textRoleStyle(role, theme.typography, theme.colors)`** returns the complete style of a semantic text tier (`display`, `title`, `subtitle`, `body`, `caption`, `overline`) — size, absolute line height, weight, tracking, case, the tier's face and its colour. The built-in widgets use the same function, so your text matches theirs.
|
|
94
|
+
|
|
95
|
+
Additive: a theme without a `list` scope renders exactly as before.
|
|
77
96
|
|
|
78
97
|
### What's new in 0.161.0 (contract 1.124.0)
|
|
79
98
|
|
|
@@ -1767,6 +1786,8 @@ import { defineWidget, validateManifest, useDatastoreQuery, Text, View } from "@
|
|
|
1767
1786
|
- `MarkdownInput` — the authoring half of `<RichText>` (sc-6970). `<MarkdownInput value={draft} onChange={setDraft} />` is a multi-line field, a toolbar whose buttons wrap the current SELECTION in markdown markers (bold, italic, code, H2, H3, bullets, numbered list, each toggling back off), and a live `<RichText>` preview of the result underneath — the way to let an app USER write formatted text, instead of a bare `TextInput` plus hand-rolled buttons that can only splice literal tags into the value. Props: `value`, `onChange(next)`, `placeholder`, `previewLabel` (default `Preview`), `showPreview` (default true), `renderImage` (passed through to the preview), `minHeight` (150) and `maxHeight` (280) so a long draft scrolls inside its box, `accessibilityLabel`, `style`, `testID`.
|
|
1768
1787
|
- `parseMarkdown`, `markdownToPlainText`, `parseMarkdownImage`, `formatMarkdownImage`, `stripHtmlToMarkdown`, `MARKDOWN_IMAGE_SIZES` — the same grammar as pure helpers, for content you inspect rather than render: the block list, a marker-free projection (list previews, search, a11y labels), the one-line image form read and written, a legacy-HTML row normalised to markdown on read, and the closed size list (`small` | `medium` | `large` | `full`).
|
|
1769
1788
|
- `isSafeMarkdownImageSrc`, `isHttpImageSrc`, `normaliseMarkdownImageSize`, `readMarkdownAlt` — the image half of that grammar, for a widget rendering images itself via `renderImage`. `isSafeMarkdownImageSrc` is the same allowlist the parser applies (an `http(s)` URL or a filestore id; a `javascript:` scheme is refused), so the widget and the parser cannot disagree about which src is renderable.
|
|
1789
|
+
- `List`, `ListRow`, `EmptyState` — the themed list building blocks. `<ListRow title subtitle leading trailing onPress selected divider>` draws one record row from the theme's `list` scope (padding, height, gap, radius, background, divider); `<List>` spaces its rows and hands overrides down; `<EmptyState icon title message>` is the "nothing here" panel. Never hand-roll a row from `View` + `Pressable`.
|
|
1790
|
+
- `textRoleStyle(role, typography, colors)`, `TEXT_ROLES` — the style of a semantic text tier, shared with the built-in widgets.
|
|
1770
1791
|
- `WidgetContextProvider` — React context provider that the host (Studio, Player, exported app) wraps widgets with.
|
|
1771
1792
|
|
|
1772
1793
|
## Design & visual polish
|
package/dist/contract.cjs
CHANGED
|
@@ -433,6 +433,18 @@ const DANGER_BUTTON_FIELDS = Object.freeze({
|
|
|
433
433
|
borderColor: "dangerBorderColor",
|
|
434
434
|
});
|
|
435
435
|
|
|
436
|
+
// The list-row vocabulary. Bound by name as well as to the Data List, so a
|
|
437
|
+
// custom widget that declares `listRowPadding` follows "Lists" like a built-in.
|
|
438
|
+
const LIST_ROW_FIELDS = Object.freeze({
|
|
439
|
+
rowPadding: "listRowPadding",
|
|
440
|
+
rowMinHeight: "listRowMinHeight",
|
|
441
|
+
gap: "listRowGap",
|
|
442
|
+
radius: "listRowRadius",
|
|
443
|
+
background: "listRowBackground",
|
|
444
|
+
dividerColor: "listDividerColor",
|
|
445
|
+
dividerWidth: "listDividerWidth",
|
|
446
|
+
});
|
|
447
|
+
|
|
436
448
|
const THEME_COMPONENTS = Object.freeze({
|
|
437
449
|
button: Object.freeze({
|
|
438
450
|
label: "Buttons",
|
|
@@ -584,6 +596,24 @@ const THEME_COMPONENTS = Object.freeze({
|
|
|
584
596
|
"appstudio.button": Object.freeze({ color: "ringColor", width: "ringWidth" }),
|
|
585
597
|
}),
|
|
586
598
|
}),
|
|
599
|
+
// Record rows: `<ListRow>` reads this scope directly; the fields bind it
|
|
600
|
+
// onto widgets. No uiDefault on the height: it has no theme token.
|
|
601
|
+
list: Object.freeze({
|
|
602
|
+
label: "Lists",
|
|
603
|
+
universalFields: LIST_ROW_FIELDS,
|
|
604
|
+
tokens: Object.freeze({
|
|
605
|
+
rowPadding: Object.freeze({ type: "size", min: 0, max: 32, uiDefault: "spacing.md" }),
|
|
606
|
+
rowMinHeight: Object.freeze({ type: "size", min: 32, max: 96 }),
|
|
607
|
+
gap: Object.freeze({ type: "size", min: 0, max: 24 }),
|
|
608
|
+
radius: Object.freeze({ type: "size", min: 0, max: 32 }),
|
|
609
|
+
background: Object.freeze({ type: "color" }),
|
|
610
|
+
dividerColor: Object.freeze({ type: "color", uiDefault: "colors.border" }),
|
|
611
|
+
dividerWidth: Object.freeze({ type: "size", min: 0, max: 4 }),
|
|
612
|
+
}),
|
|
613
|
+
targets: Object.freeze({
|
|
614
|
+
"appstudio.data-list": LIST_ROW_FIELDS,
|
|
615
|
+
}),
|
|
616
|
+
}),
|
|
587
617
|
});
|
|
588
618
|
|
|
589
619
|
// sc-4505 — the value types a widget event payload field may declare. Narrower
|
|
@@ -2173,6 +2203,27 @@ const PRIMITIVES = [
|
|
|
2173
2203
|
rnComponent: null,
|
|
2174
2204
|
docsUrl: null,
|
|
2175
2205
|
},
|
|
2206
|
+
{
|
|
2207
|
+
name: "List",
|
|
2208
|
+
description:
|
|
2209
|
+
"Themed list container. `<List>{rows.map((r) => <ListRow key={r.id} title={r.name} />)}</List>`. Spaces and insets its `<ListRow>` children the way the app's look says (flush rows with hairlines, or separated rounded rows), and hands any row override you pass (`rowPadding`, `rowMinHeight`, `gap`, `radius`, `background`, `dividerColor`, `dividerWidth`) down to every row. Props: those overrides, `style`, `testID`. Put it inside a `ScrollView` (or bound its height) for long lists.",
|
|
2210
|
+
rnComponent: null,
|
|
2211
|
+
docsUrl: null,
|
|
2212
|
+
},
|
|
2213
|
+
{
|
|
2214
|
+
name: "ListRow",
|
|
2215
|
+
description:
|
|
2216
|
+
'Themed list row. `<ListRow title={item.name} subtitle={item.email} leading={<Icon name="user" size={20} />} trailing={<Text>…</Text>} onPress={() => open(item)} selected={item.id === selectedId} />`. THE way to draw one row of records: its padding, minimum height, divider, corner radius and background come from the theme\'s Lists settings, so every list in the app matches — never hand-roll a row from `View` + `Pressable`. Props: `title`, `subtitle` (rendered in the subtitle / caption text tiers), `leading` / `trailing` nodes, `children` (replaces the title block, for a multi-column row), `onPress` (makes it a button with a press state), `selected`, `disabled`, `divider` (default true; pass false on the last row), `accessibilityLabel`, `style`, `testID`, plus the same per-row overrides `<List>` takes. Declare `listRowPadding` / `listRowRadius` / … style fields and pass them through to let an author override one widget.',
|
|
2217
|
+
rnComponent: null,
|
|
2218
|
+
docsUrl: null,
|
|
2219
|
+
},
|
|
2220
|
+
{
|
|
2221
|
+
name: "EmptyState",
|
|
2222
|
+
description:
|
|
2223
|
+
'Themed empty / zero-data state. `<EmptyState icon="inbox" title="No orders yet" message="New orders appear here." />`. THE way to say "nothing here" — a muted panel with an icon, a title and a caption, centred, in the app\'s own surface and text tiers. Props: `icon` (a lucide icon name, default "inbox"; pass null for none), `title`, `message`, `children` (an action, e.g. a button), `style`, `testID`.',
|
|
2224
|
+
rnComponent: null,
|
|
2225
|
+
docsUrl: null,
|
|
2226
|
+
},
|
|
2176
2227
|
];
|
|
2177
2228
|
|
|
2178
2229
|
const CATEGORIES = [
|
|
@@ -4357,7 +4408,12 @@ const CONTRACT = deepFreeze({
|
|
|
4357
4408
|
// 1.123.0: behaviour (sc-8595) — useDatastoreQuery / useDatastoreRecord
|
|
4358
4409
|
// keep their data while a changed query or refetch runs; `loading` only
|
|
4359
4410
|
// until the first result for the table/record, new `fetching` flag.
|
|
4360
|
-
|
|
4411
|
+
// 1.125.0: additive — the `list` component scope (row padding, height, gap,
|
|
4412
|
+
// radius, background, divider) and the `List` / `ListRow` / `EmptyState`
|
|
4413
|
+
// primitives that read it, plus `textRoleStyle` and its role helpers.
|
|
4414
|
+
// Widgets each hand-rolled their rows, so two lists in one app disagreed.
|
|
4415
|
+
// Additive: a theme without `list` paints the rows exactly as before.
|
|
4416
|
+
version: "1.125.0",
|
|
4361
4417
|
sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
|
|
4362
4418
|
hooks: HOOKS,
|
|
4363
4419
|
primitives: PRIMITIVES,
|
package/dist/contract.js
CHANGED
|
@@ -433,6 +433,18 @@ const DANGER_BUTTON_FIELDS = Object.freeze({
|
|
|
433
433
|
borderColor: "dangerBorderColor",
|
|
434
434
|
});
|
|
435
435
|
|
|
436
|
+
// The list-row vocabulary. Bound by name as well as to the Data List, so a
|
|
437
|
+
// custom widget that declares `listRowPadding` follows "Lists" like a built-in.
|
|
438
|
+
const LIST_ROW_FIELDS = Object.freeze({
|
|
439
|
+
rowPadding: "listRowPadding",
|
|
440
|
+
rowMinHeight: "listRowMinHeight",
|
|
441
|
+
gap: "listRowGap",
|
|
442
|
+
radius: "listRowRadius",
|
|
443
|
+
background: "listRowBackground",
|
|
444
|
+
dividerColor: "listDividerColor",
|
|
445
|
+
dividerWidth: "listDividerWidth",
|
|
446
|
+
});
|
|
447
|
+
|
|
436
448
|
const THEME_COMPONENTS = Object.freeze({
|
|
437
449
|
button: Object.freeze({
|
|
438
450
|
label: "Buttons",
|
|
@@ -584,6 +596,24 @@ const THEME_COMPONENTS = Object.freeze({
|
|
|
584
596
|
"appstudio.button": Object.freeze({ color: "ringColor", width: "ringWidth" }),
|
|
585
597
|
}),
|
|
586
598
|
}),
|
|
599
|
+
// Record rows: `<ListRow>` reads this scope directly; the fields bind it
|
|
600
|
+
// onto widgets. No uiDefault on the height: it has no theme token.
|
|
601
|
+
list: Object.freeze({
|
|
602
|
+
label: "Lists",
|
|
603
|
+
universalFields: LIST_ROW_FIELDS,
|
|
604
|
+
tokens: Object.freeze({
|
|
605
|
+
rowPadding: Object.freeze({ type: "size", min: 0, max: 32, uiDefault: "spacing.md" }),
|
|
606
|
+
rowMinHeight: Object.freeze({ type: "size", min: 32, max: 96 }),
|
|
607
|
+
gap: Object.freeze({ type: "size", min: 0, max: 24 }),
|
|
608
|
+
radius: Object.freeze({ type: "size", min: 0, max: 32 }),
|
|
609
|
+
background: Object.freeze({ type: "color" }),
|
|
610
|
+
dividerColor: Object.freeze({ type: "color", uiDefault: "colors.border" }),
|
|
611
|
+
dividerWidth: Object.freeze({ type: "size", min: 0, max: 4 }),
|
|
612
|
+
}),
|
|
613
|
+
targets: Object.freeze({
|
|
614
|
+
"appstudio.data-list": LIST_ROW_FIELDS,
|
|
615
|
+
}),
|
|
616
|
+
}),
|
|
587
617
|
});
|
|
588
618
|
|
|
589
619
|
// sc-4505 — the value types a widget event payload field may declare. Narrower
|
|
@@ -2173,6 +2203,27 @@ const PRIMITIVES = [
|
|
|
2173
2203
|
rnComponent: null,
|
|
2174
2204
|
docsUrl: null,
|
|
2175
2205
|
},
|
|
2206
|
+
{
|
|
2207
|
+
name: "List",
|
|
2208
|
+
description:
|
|
2209
|
+
"Themed list container. `<List>{rows.map((r) => <ListRow key={r.id} title={r.name} />)}</List>`. Spaces and insets its `<ListRow>` children the way the app's look says (flush rows with hairlines, or separated rounded rows), and hands any row override you pass (`rowPadding`, `rowMinHeight`, `gap`, `radius`, `background`, `dividerColor`, `dividerWidth`) down to every row. Props: those overrides, `style`, `testID`. Put it inside a `ScrollView` (or bound its height) for long lists.",
|
|
2210
|
+
rnComponent: null,
|
|
2211
|
+
docsUrl: null,
|
|
2212
|
+
},
|
|
2213
|
+
{
|
|
2214
|
+
name: "ListRow",
|
|
2215
|
+
description:
|
|
2216
|
+
'Themed list row. `<ListRow title={item.name} subtitle={item.email} leading={<Icon name="user" size={20} />} trailing={<Text>…</Text>} onPress={() => open(item)} selected={item.id === selectedId} />`. THE way to draw one row of records: its padding, minimum height, divider, corner radius and background come from the theme\'s Lists settings, so every list in the app matches — never hand-roll a row from `View` + `Pressable`. Props: `title`, `subtitle` (rendered in the subtitle / caption text tiers), `leading` / `trailing` nodes, `children` (replaces the title block, for a multi-column row), `onPress` (makes it a button with a press state), `selected`, `disabled`, `divider` (default true; pass false on the last row), `accessibilityLabel`, `style`, `testID`, plus the same per-row overrides `<List>` takes. Declare `listRowPadding` / `listRowRadius` / … style fields and pass them through to let an author override one widget.',
|
|
2217
|
+
rnComponent: null,
|
|
2218
|
+
docsUrl: null,
|
|
2219
|
+
},
|
|
2220
|
+
{
|
|
2221
|
+
name: "EmptyState",
|
|
2222
|
+
description:
|
|
2223
|
+
'Themed empty / zero-data state. `<EmptyState icon="inbox" title="No orders yet" message="New orders appear here." />`. THE way to say "nothing here" — a muted panel with an icon, a title and a caption, centred, in the app\'s own surface and text tiers. Props: `icon` (a lucide icon name, default "inbox"; pass null for none), `title`, `message`, `children` (an action, e.g. a button), `style`, `testID`.',
|
|
2224
|
+
rnComponent: null,
|
|
2225
|
+
docsUrl: null,
|
|
2226
|
+
},
|
|
2176
2227
|
];
|
|
2177
2228
|
|
|
2178
2229
|
const CATEGORIES = [
|
|
@@ -4353,7 +4404,12 @@ const CONTRACT = deepFreeze({
|
|
|
4353
4404
|
// 1.123.0: behaviour (sc-8595) — useDatastoreQuery / useDatastoreRecord
|
|
4354
4405
|
// keep their data while a changed query or refetch runs; `loading` only
|
|
4355
4406
|
// until the first result for the table/record, new `fetching` flag.
|
|
4356
|
-
|
|
4407
|
+
// 1.125.0: additive — the `list` component scope (row padding, height, gap,
|
|
4408
|
+
// radius, background, divider) and the `List` / `ListRow` / `EmptyState`
|
|
4409
|
+
// primitives that read it, plus `textRoleStyle` and its role helpers.
|
|
4410
|
+
// Widgets each hand-rolled their rows, so two lists in one app disagreed.
|
|
4411
|
+
// Additive: a theme without `list` paints the rows exactly as before.
|
|
4412
|
+
version: "1.125.0",
|
|
4357
4413
|
sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
|
|
4358
4414
|
hooks: HOOKS,
|
|
4359
4415
|
primitives: PRIMITIVES,
|
package/dist/index.d.ts
CHANGED
|
@@ -2553,6 +2553,88 @@ export const Overlay: (props: {
|
|
|
2553
2553
|
children?: ReactNode;
|
|
2554
2554
|
}) => any;
|
|
2555
2555
|
|
|
2556
|
+
/** Per-list row overrides; unset values follow Theme Settings > Lists. */
|
|
2557
|
+
export interface ListRowTokens {
|
|
2558
|
+
rowPadding?: number;
|
|
2559
|
+
rowMinHeight?: number;
|
|
2560
|
+
/** Space between rows. Above 0, rows are separate tiles on the muted surface. */
|
|
2561
|
+
gap?: number;
|
|
2562
|
+
radius?: number;
|
|
2563
|
+
background?: string;
|
|
2564
|
+
dividerColor?: string;
|
|
2565
|
+
dividerWidth?: number;
|
|
2566
|
+
}
|
|
2567
|
+
|
|
2568
|
+
/**
|
|
2569
|
+
* Themed list container. Spaces and insets its `<ListRow>` children the way the
|
|
2570
|
+
* app's look says, and hands its overrides down to every row.
|
|
2571
|
+
*/
|
|
2572
|
+
export const List: (props: ListRowTokens & {
|
|
2573
|
+
style?: any;
|
|
2574
|
+
testID?: string;
|
|
2575
|
+
children?: ReactNode;
|
|
2576
|
+
}) => any;
|
|
2577
|
+
|
|
2578
|
+
/**
|
|
2579
|
+
* Themed list row. Padding, height, divider, radius and background come from
|
|
2580
|
+
* the theme's `list` scope, so every list in the app matches.
|
|
2581
|
+
*
|
|
2582
|
+
* @example
|
|
2583
|
+
* <List>
|
|
2584
|
+
* {items.map((item) => (
|
|
2585
|
+
* <ListRow key={item.id} title={item.name} subtitle={item.email} onPress={() => open(item)} />
|
|
2586
|
+
* ))}
|
|
2587
|
+
* </List>
|
|
2588
|
+
*/
|
|
2589
|
+
export const ListRow: (props: ListRowTokens & {
|
|
2590
|
+
title?: ReactNode;
|
|
2591
|
+
subtitle?: ReactNode;
|
|
2592
|
+
leading?: ReactNode;
|
|
2593
|
+
trailing?: ReactNode;
|
|
2594
|
+
/** Makes the row a button with a press state. */
|
|
2595
|
+
onPress?: () => void;
|
|
2596
|
+
selected?: boolean;
|
|
2597
|
+
disabled?: boolean;
|
|
2598
|
+
/** Defaults to true; pass false on the last row. */
|
|
2599
|
+
divider?: boolean;
|
|
2600
|
+
accessibilityLabel?: string;
|
|
2601
|
+
style?: any;
|
|
2602
|
+
testID?: string;
|
|
2603
|
+
/** Replaces the title block, e.g. for a multi-column row. */
|
|
2604
|
+
children?: ReactNode;
|
|
2605
|
+
}) => any;
|
|
2606
|
+
|
|
2607
|
+
/** Themed empty / zero-data state: icon, title and caption on the muted surface. */
|
|
2608
|
+
export const EmptyState: (props: {
|
|
2609
|
+
/** A lucide icon name; defaults to "inbox". Pass null for none. */
|
|
2610
|
+
icon?: string | null;
|
|
2611
|
+
title?: ReactNode;
|
|
2612
|
+
message?: ReactNode;
|
|
2613
|
+
style?: any;
|
|
2614
|
+
testID?: string;
|
|
2615
|
+
children?: ReactNode;
|
|
2616
|
+
}) => any;
|
|
2617
|
+
|
|
2618
|
+
export type TextRole = "display" | "title" | "subtitle" | "body" | "caption" | "overline";
|
|
2619
|
+
export const TEXT_ROLES: readonly TextRole[];
|
|
2620
|
+
export const TEXT_TRANSFORMS: readonly string[];
|
|
2621
|
+
export const LINE_HEIGHT_RATIO: number;
|
|
2622
|
+
export const LEGACY_FONT_ROLE_ALIASES: Readonly<Record<string, TextRole>>;
|
|
2623
|
+
export const DEFAULT_TEXT_ROLE: TextRole;
|
|
2624
|
+
export const ROLE_FACES: Readonly<Record<TextRole, "heading" | "body">>;
|
|
2625
|
+
export function normaliseTextRole(value: unknown): TextRole;
|
|
2626
|
+
export function roleTokens(role: string, typography: any): Record<string, any> | null;
|
|
2627
|
+
export function roleColor(tokens: any, colors: any): string | undefined;
|
|
2628
|
+
/**
|
|
2629
|
+
* The full text style for a semantic tier — size, absolute line height, weight,
|
|
2630
|
+
* tracking, case, the tier's face and its colour — from the theme.
|
|
2631
|
+
*
|
|
2632
|
+
* @example
|
|
2633
|
+
* const theme = useTheme();
|
|
2634
|
+
* <Text style={textRoleStyle("caption", theme.typography, theme.colors)}>Updated 2m ago</Text>
|
|
2635
|
+
*/
|
|
2636
|
+
export function textRoleStyle(role: TextRole | string, typography: any, colors?: any): Record<string, any>;
|
|
2637
|
+
|
|
2556
2638
|
// ----------------------------------------------------- formatted content
|
|
2557
2639
|
// sc-6970 — widgets have no HTML path: they render through React Native
|
|
2558
2640
|
// primitives, which have no `dangerouslySetInnerHTML` on either host. Content
|
package/dist/index.js
CHANGED
|
@@ -189,6 +189,21 @@ export {
|
|
|
189
189
|
applyPendingReactions,
|
|
190
190
|
} from "./emoji-reactions.js";
|
|
191
191
|
export { insertAtCaret, pushRecentEmoji } from "./emoji-picker-tokens.js";
|
|
192
|
+
// Themed list building blocks; rows follow the theme's `list` scope.
|
|
193
|
+
export { List, ListRow, EmptyState } from "./list.js";
|
|
194
|
+
// The semantic text tiers, shared with the built-in widgets.
|
|
195
|
+
export {
|
|
196
|
+
textRoleStyle,
|
|
197
|
+
TEXT_ROLES,
|
|
198
|
+
TEXT_TRANSFORMS,
|
|
199
|
+
LINE_HEIGHT_RATIO,
|
|
200
|
+
LEGACY_FONT_ROLE_ALIASES,
|
|
201
|
+
DEFAULT_TEXT_ROLE,
|
|
202
|
+
ROLE_FACES,
|
|
203
|
+
normaliseTextRole,
|
|
204
|
+
roleTokens,
|
|
205
|
+
roleColor,
|
|
206
|
+
} from "./text-roles.js";
|
|
192
207
|
export { normalizeLucideIconName } from "./lucideIconName.js";
|
|
193
208
|
export { pressableLift } from "./interaction.js";
|
|
194
209
|
export { styleGroup } from "./style-group.js";
|
package/dist/index.native.js
CHANGED
|
@@ -182,6 +182,21 @@ export {
|
|
|
182
182
|
applyPendingReactions,
|
|
183
183
|
} from "./emoji-reactions.js";
|
|
184
184
|
export { insertAtCaret, pushRecentEmoji } from "./emoji-picker-tokens.js";
|
|
185
|
+
// Themed list building blocks; rows follow the theme's `list` scope.
|
|
186
|
+
export { List, ListRow, EmptyState } from "./list.native.js";
|
|
187
|
+
// The semantic text tiers, shared with the built-in widgets.
|
|
188
|
+
export {
|
|
189
|
+
textRoleStyle,
|
|
190
|
+
TEXT_ROLES,
|
|
191
|
+
TEXT_TRANSFORMS,
|
|
192
|
+
LINE_HEIGHT_RATIO,
|
|
193
|
+
LEGACY_FONT_ROLE_ALIASES,
|
|
194
|
+
DEFAULT_TEXT_ROLE,
|
|
195
|
+
ROLE_FACES,
|
|
196
|
+
normaliseTextRole,
|
|
197
|
+
roleTokens,
|
|
198
|
+
roleColor,
|
|
199
|
+
} from "./text-roles.js";
|
|
185
200
|
export { normalizeLucideIconName } from "./lucideIconName.js";
|
|
186
201
|
export { pressableLift } from "./interaction.native.js";
|
|
187
202
|
export { styleGroup } from "./style-group.js";
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// The values `<List>` / `<ListRow>` paint with, resolved from the theme's `list`
|
|
2
|
+
// component scope. Platform-free, like overlay-tokens.js, so both hosts render
|
|
3
|
+
// a row from the same numbers and tests can pin them without a renderer.
|
|
4
|
+
|
|
5
|
+
import { DEFAULT_THEME_TOKENS } from "./_theme-tokens.js";
|
|
6
|
+
import { mixHex } from "./contract.js";
|
|
7
|
+
import { normaliseThemeComponents } from "./theme-components.js";
|
|
8
|
+
|
|
9
|
+
// A row with no themed height still meets the 44px touch-target floor.
|
|
10
|
+
export const LIST_ROW_MIN_HEIGHT = 44;
|
|
11
|
+
|
|
12
|
+
// The per-row overrides a widget may pass, named as the theme tokens are.
|
|
13
|
+
export const LIST_TOKEN_NAMES = Object.freeze([
|
|
14
|
+
"rowPadding",
|
|
15
|
+
"rowMinHeight",
|
|
16
|
+
"gap",
|
|
17
|
+
"radius",
|
|
18
|
+
"background",
|
|
19
|
+
"dividerColor",
|
|
20
|
+
"dividerWidth",
|
|
21
|
+
]);
|
|
22
|
+
|
|
23
|
+
function isSet(value) {
|
|
24
|
+
return value !== undefined && value !== null && value !== "";
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function pick(overrides, scope, name) {
|
|
28
|
+
if (overrides && isSet(overrides[name])) return overrides[name];
|
|
29
|
+
if (scope && isSet(scope[name])) return scope[name];
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Resolve one list's row values: explicit override, then the theme's `list`
|
|
35
|
+
* scope, then the theme tokens. Both layers pass the contract's own bounds, so
|
|
36
|
+
* a hand-edited or planned value cannot reach a native style unvalidated.
|
|
37
|
+
* Unthemed, a row is the flush band with a 1px hairline the Data List drew;
|
|
38
|
+
* a `gap` makes separate tiles on the surface, outlined by the divider.
|
|
39
|
+
*
|
|
40
|
+
* @param {object} theme — the resolved workspace theme (`useTheme()` shape).
|
|
41
|
+
* @param {object} [overrides] — per-list values keyed by LIST_TOKEN_NAMES.
|
|
42
|
+
*/
|
|
43
|
+
export function resolveListTokens(theme, overrides) {
|
|
44
|
+
const base = theme && typeof theme === "object" ? theme : DEFAULT_THEME_TOKENS;
|
|
45
|
+
const fallback = DEFAULT_THEME_TOKENS;
|
|
46
|
+
const colors = base.colors || fallback.colors;
|
|
47
|
+
const spacing = base.spacing || fallback.spacing;
|
|
48
|
+
const scope = base.components && base.components.list;
|
|
49
|
+
const own = normaliseThemeComponents({ list: overrides }).list;
|
|
50
|
+
|
|
51
|
+
const gap = pick(own, scope, "gap") ?? 0;
|
|
52
|
+
const separated = gap > 0;
|
|
53
|
+
const background = pick(own, scope, "background") ?? (separated ? colors.surface : undefined);
|
|
54
|
+
return {
|
|
55
|
+
rowPadding: pick(own, scope, "rowPadding") ?? spacing.md,
|
|
56
|
+
rowMinHeight: pick(own, scope, "rowMinHeight") ?? LIST_ROW_MIN_HEIGHT,
|
|
57
|
+
gap,
|
|
58
|
+
separated,
|
|
59
|
+
// A flush band has square ends; a divider would curve into round ones.
|
|
60
|
+
radius: separated ? pick(own, scope, "radius") ?? 0 : 0,
|
|
61
|
+
background,
|
|
62
|
+
dividerColor: pick(own, scope, "dividerColor") ?? colors.border,
|
|
63
|
+
dividerWidth: pick(own, scope, "dividerWidth") ?? 1,
|
|
64
|
+
selectedBackground: colors.primarySoft || colors.surfaceMuted,
|
|
65
|
+
selectedAccent: colors.primary,
|
|
66
|
+
pressedBackground: mixHex(colors.onSurface, background || colors.surface, 0.94),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
// The ONE implementation behind the `<List>`, `<ListRow>` and `<EmptyState>`
|
|
2
|
+
// SDK primitives. The platform bindings (`list.js` / `list.native.js`) differ
|
|
3
|
+
// only in where the primitives come from, so the hosts cannot drift.
|
|
4
|
+
//
|
|
5
|
+
// Every widget drawing a list of records used to hand-roll its rows, so two
|
|
6
|
+
// widgets in one app disagreed on padding, dividers and radius. These read the
|
|
7
|
+
// theme's `list` scope, which a look sets once for the whole app.
|
|
8
|
+
|
|
9
|
+
import React from "react";
|
|
10
|
+
import { useHostTheme } from "./hooks.js";
|
|
11
|
+
import { DEFAULT_THEME_TOKENS } from "./_theme-tokens.js";
|
|
12
|
+
import { Icon } from "./icon.js";
|
|
13
|
+
import { resolveListTokens, LIST_TOKEN_NAMES } from "./list-tokens.js";
|
|
14
|
+
import { textRoleStyle } from "./text-roles.js";
|
|
15
|
+
|
|
16
|
+
// Outside a widget host (a test, a preview) the defaults still paint a row.
|
|
17
|
+
function useListTheme() {
|
|
18
|
+
return useHostTheme() || DEFAULT_THEME_TOKENS;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function listOverrides(props) {
|
|
22
|
+
const out = {};
|
|
23
|
+
for (const name of LIST_TOKEN_NAMES) {
|
|
24
|
+
if (props[name] !== undefined && props[name] !== null) out[name] = props[name];
|
|
25
|
+
}
|
|
26
|
+
return out;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Bind the shared list components to one platform's primitives.
|
|
31
|
+
*
|
|
32
|
+
* @param {{View: any, Text: any, Pressable: any}} rn
|
|
33
|
+
*/
|
|
34
|
+
export function makeList(rn) {
|
|
35
|
+
const { View, Text, Pressable } = rn;
|
|
36
|
+
const ListContext = React.createContext(null);
|
|
37
|
+
|
|
38
|
+
function List(props) {
|
|
39
|
+
const { children, style, testID } = props;
|
|
40
|
+
const theme = useListTheme();
|
|
41
|
+
const inherited = React.useContext(ListContext);
|
|
42
|
+
const overrides = { ...inherited, ...listOverrides(props) };
|
|
43
|
+
const tokens = resolveListTokens(theme, overrides);
|
|
44
|
+
// No divider under the last row: the list's own edge ends it.
|
|
45
|
+
const rows = React.Children.toArray(children);
|
|
46
|
+
const last = rows.length - 1;
|
|
47
|
+
const content = rows.map((row, i) =>
|
|
48
|
+
i === last && React.isValidElement(row) && row.props.divider === undefined
|
|
49
|
+
? React.cloneElement(row, { divider: false })
|
|
50
|
+
: row,
|
|
51
|
+
);
|
|
52
|
+
return React.createElement(
|
|
53
|
+
ListContext.Provider,
|
|
54
|
+
{ value: overrides },
|
|
55
|
+
React.createElement(View, { style: [{ gap: tokens.gap }, style], testID }, content),
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
List.displayName = "List";
|
|
59
|
+
|
|
60
|
+
function ListRow(props) {
|
|
61
|
+
const {
|
|
62
|
+
title,
|
|
63
|
+
subtitle,
|
|
64
|
+
leading,
|
|
65
|
+
trailing,
|
|
66
|
+
onPress,
|
|
67
|
+
selected = false,
|
|
68
|
+
disabled = false,
|
|
69
|
+
divider = true,
|
|
70
|
+
accessibilityLabel,
|
|
71
|
+
style,
|
|
72
|
+
testID,
|
|
73
|
+
children,
|
|
74
|
+
} = props;
|
|
75
|
+
const theme = useListTheme();
|
|
76
|
+
const inherited = React.useContext(ListContext);
|
|
77
|
+
const tokens = resolveListTokens(theme, {
|
|
78
|
+
...inherited,
|
|
79
|
+
...listOverrides(props),
|
|
80
|
+
});
|
|
81
|
+
const { colors, spacing, typography } = theme;
|
|
82
|
+
|
|
83
|
+
const pressable = typeof onPress === "function";
|
|
84
|
+
// A tile is outlined; a flush band is separated by its bottom divider.
|
|
85
|
+
const edge = tokens.separated
|
|
86
|
+
? tokens.dividerWidth > 0
|
|
87
|
+
? { borderWidth: tokens.dividerWidth, borderColor: tokens.dividerColor }
|
|
88
|
+
: null
|
|
89
|
+
: divider && tokens.dividerWidth > 0
|
|
90
|
+
? { borderBottomWidth: tokens.dividerWidth, borderColor: tokens.dividerColor }
|
|
91
|
+
: null;
|
|
92
|
+
const rowStyle = {
|
|
93
|
+
flexDirection: "row",
|
|
94
|
+
alignItems: "center",
|
|
95
|
+
gap: spacing.md,
|
|
96
|
+
paddingHorizontal: tokens.rowPadding,
|
|
97
|
+
paddingVertical: tokens.rowPadding,
|
|
98
|
+
// A dense look may shrink a static row, never a tap target.
|
|
99
|
+
minHeight: pressable ? Math.max(tokens.rowMinHeight, 44) : tokens.rowMinHeight,
|
|
100
|
+
borderRadius: tokens.radius,
|
|
101
|
+
...(tokens.background ? { backgroundColor: tokens.background } : null),
|
|
102
|
+
...edge,
|
|
103
|
+
// A tint alone is too faint to read as the current row.
|
|
104
|
+
...(selected
|
|
105
|
+
? {
|
|
106
|
+
backgroundColor: tokens.selectedBackground,
|
|
107
|
+
borderLeftWidth: 3,
|
|
108
|
+
borderLeftColor: tokens.selectedAccent,
|
|
109
|
+
}
|
|
110
|
+
: null),
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const body =
|
|
114
|
+
children !== undefined
|
|
115
|
+
? children
|
|
116
|
+
: React.createElement(
|
|
117
|
+
View,
|
|
118
|
+
{ style: { flex: 1, gap: 2 } },
|
|
119
|
+
title !== undefined && title !== null
|
|
120
|
+
? React.createElement(
|
|
121
|
+
Text,
|
|
122
|
+
{
|
|
123
|
+
style: textRoleStyle("subtitle", typography, colors),
|
|
124
|
+
numberOfLines: 1,
|
|
125
|
+
},
|
|
126
|
+
title,
|
|
127
|
+
)
|
|
128
|
+
: null,
|
|
129
|
+
subtitle !== undefined && subtitle !== null
|
|
130
|
+
? React.createElement(
|
|
131
|
+
Text,
|
|
132
|
+
{
|
|
133
|
+
style: textRoleStyle("caption", typography, colors),
|
|
134
|
+
numberOfLines: 2,
|
|
135
|
+
},
|
|
136
|
+
subtitle,
|
|
137
|
+
)
|
|
138
|
+
: null,
|
|
139
|
+
);
|
|
140
|
+
const content = [leading || null, body, trailing || null];
|
|
141
|
+
|
|
142
|
+
if (!pressable) {
|
|
143
|
+
return React.createElement(
|
|
144
|
+
View,
|
|
145
|
+
{
|
|
146
|
+
style: [rowStyle, style],
|
|
147
|
+
testID,
|
|
148
|
+
accessibilityLabel,
|
|
149
|
+
accessible: accessibilityLabel ? true : undefined,
|
|
150
|
+
},
|
|
151
|
+
...content,
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
return React.createElement(
|
|
155
|
+
Pressable,
|
|
156
|
+
{
|
|
157
|
+
onPress,
|
|
158
|
+
disabled,
|
|
159
|
+
// accessibilityRole + aria-*: the pair that announces on both hosts.
|
|
160
|
+
accessibilityRole: "button",
|
|
161
|
+
accessibilityLabel,
|
|
162
|
+
"aria-selected": selected,
|
|
163
|
+
"aria-disabled": disabled,
|
|
164
|
+
testID,
|
|
165
|
+
style: ({ pressed }) => [
|
|
166
|
+
rowStyle,
|
|
167
|
+
pressed ? { backgroundColor: tokens.pressedBackground } : null,
|
|
168
|
+
disabled ? { opacity: 0.5 } : null,
|
|
169
|
+
style,
|
|
170
|
+
],
|
|
171
|
+
},
|
|
172
|
+
...content,
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
ListRow.displayName = "ListRow";
|
|
176
|
+
|
|
177
|
+
function EmptyState({ icon = "inbox", title, message, children, style, testID }) {
|
|
178
|
+
const { colors, spacing, radii, typography } = useListTheme();
|
|
179
|
+
return React.createElement(
|
|
180
|
+
View,
|
|
181
|
+
{
|
|
182
|
+
style: [
|
|
183
|
+
{
|
|
184
|
+
padding: spacing.lg,
|
|
185
|
+
borderRadius: radii.md,
|
|
186
|
+
backgroundColor: colors.surfaceMuted,
|
|
187
|
+
alignItems: "center",
|
|
188
|
+
gap: spacing.sm,
|
|
189
|
+
},
|
|
190
|
+
style,
|
|
191
|
+
],
|
|
192
|
+
testID,
|
|
193
|
+
},
|
|
194
|
+
icon ? React.createElement(Icon, { name: icon, size: 20, color: colors.onSurfaceMuted }) : null,
|
|
195
|
+
title
|
|
196
|
+
? React.createElement(
|
|
197
|
+
Text,
|
|
198
|
+
{ style: { ...textRoleStyle("subtitle", typography, colors), textAlign: "center" } },
|
|
199
|
+
title,
|
|
200
|
+
)
|
|
201
|
+
: null,
|
|
202
|
+
message
|
|
203
|
+
? React.createElement(
|
|
204
|
+
Text,
|
|
205
|
+
{ style: { ...textRoleStyle("caption", typography, colors), textAlign: "center" } },
|
|
206
|
+
message,
|
|
207
|
+
)
|
|
208
|
+
: null,
|
|
209
|
+
children || null,
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
EmptyState.displayName = "EmptyState";
|
|
213
|
+
|
|
214
|
+
return { List, ListRow, EmptyState };
|
|
215
|
+
}
|
package/dist/list.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// `<List>`, `<ListRow>`, `<EmptyState>` (web). Binds ./list-view.js to
|
|
2
|
+
// react-native-web; see ./primitives.js for why not the bare specifier.
|
|
3
|
+
|
|
4
|
+
import * as ReactNative from "react-native-web";
|
|
5
|
+
import { makeList } from "./list-view.js";
|
|
6
|
+
|
|
7
|
+
export const { List, ListRow, EmptyState } = makeList(ReactNative);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// `<List>`, `<ListRow>`, `<EmptyState>` (native). Binds ./list-view.js to
|
|
2
|
+
// React Native's own primitives; only the import differs from ./list.js.
|
|
3
|
+
|
|
4
|
+
import { View, Text, Pressable } from "react-native";
|
|
5
|
+
import { makeList } from "./list-view.js";
|
|
6
|
+
|
|
7
|
+
export const { List, ListRow, EmptyState } = makeList({ View, Text, Pressable });
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// REQ-THEME-ROLE — the semantic text tiers, resolved against a theme.
|
|
2
|
+
//
|
|
3
|
+
// The ONE implementation behind every role-styled text: the built-in widgets
|
|
4
|
+
// (frontend `_shared/textStyle.js` re-exports it), the SDK's own themed
|
|
5
|
+
// components, and any custom widget that calls `textRoleStyle`. Platform-free,
|
|
6
|
+
// so both hosts and the exported app resolve a tier identically.
|
|
7
|
+
|
|
8
|
+
// Leading is a MULTIPLE of the font size; 1.4 is the platform body ratio.
|
|
9
|
+
export const LINE_HEIGHT_RATIO = 1.4;
|
|
10
|
+
|
|
11
|
+
export const TEXT_TRANSFORMS = ["none", "uppercase", "capitalize"];
|
|
12
|
+
|
|
13
|
+
// The role names the TIER; `theme.typography.roles` owns what it looks like.
|
|
14
|
+
export const TEXT_ROLES = [
|
|
15
|
+
"display",
|
|
16
|
+
"title",
|
|
17
|
+
"subtitle",
|
|
18
|
+
"body",
|
|
19
|
+
"caption",
|
|
20
|
+
"overline",
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
// sc-3862's `heading` value predates the tiers and must keep resolving.
|
|
24
|
+
export const LEGACY_FONT_ROLE_ALIASES = Object.freeze({ heading: "title" });
|
|
25
|
+
|
|
26
|
+
export const DEFAULT_TEXT_ROLE = "body";
|
|
27
|
+
|
|
28
|
+
// Structural, not a token: the tier decides which of the two faces it takes.
|
|
29
|
+
export const ROLE_FACES = Object.freeze({
|
|
30
|
+
display: "heading",
|
|
31
|
+
title: "heading",
|
|
32
|
+
subtitle: "body",
|
|
33
|
+
body: "body",
|
|
34
|
+
caption: "body",
|
|
35
|
+
overline: "body",
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
export function normaliseTextRole(value) {
|
|
39
|
+
const raw = typeof value === "string" ? value.trim() : "";
|
|
40
|
+
const aliased = LEGACY_FONT_ROLE_ALIASES[raw] || raw;
|
|
41
|
+
return TEXT_ROLES.includes(aliased) ? aliased : DEFAULT_TEXT_ROLE;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** The role's token set as the host resolved it, or null. */
|
|
45
|
+
export function roleTokens(role, typography) {
|
|
46
|
+
const roles = typography && typography.roles;
|
|
47
|
+
const tokens = roles && roles[normaliseTextRole(role)];
|
|
48
|
+
return tokens || null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* The colour a role paints in: the theme's explicit override, else the surface
|
|
53
|
+
* token the role names — resolved per render so a dark surface recolours it.
|
|
54
|
+
*/
|
|
55
|
+
export function roleColor(tokens, colors) {
|
|
56
|
+
if (!tokens) return undefined;
|
|
57
|
+
const explicit = typeof tokens.color === "string" ? tokens.color.trim() : "";
|
|
58
|
+
if (explicit) return explicit;
|
|
59
|
+
if (!colors || typeof tokens.colorToken !== "string") return undefined;
|
|
60
|
+
return colors[tokens.colorToken];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* The complete text style for a semantic tier: size, absolute line height,
|
|
65
|
+
* weight, tracking, case, the tier's face and its colour.
|
|
66
|
+
*
|
|
67
|
+
* @param {string} role — one of TEXT_ROLES; a legacy `heading` is aliased.
|
|
68
|
+
* @param {object} typography — the resolved theme's typography tokens.
|
|
69
|
+
* @param {object} [colors] — the resolved theme's colours, for `colorToken`.
|
|
70
|
+
*/
|
|
71
|
+
export function textRoleStyle(role, typography, colors) {
|
|
72
|
+
const resolved = normaliseTextRole(role);
|
|
73
|
+
const tokens = roleTokens(resolved, typography) || {};
|
|
74
|
+
const size =
|
|
75
|
+
typeof tokens.fontSize === "number" && Number.isFinite(tokens.fontSize)
|
|
76
|
+
? tokens.fontSize
|
|
77
|
+
: undefined;
|
|
78
|
+
const ratio =
|
|
79
|
+
typeof tokens.lineHeight === "number" && Number.isFinite(tokens.lineHeight)
|
|
80
|
+
? tokens.lineHeight
|
|
81
|
+
: LINE_HEIGHT_RATIO;
|
|
82
|
+
const family = !typography
|
|
83
|
+
? undefined
|
|
84
|
+
: ROLE_FACES[resolved] === "heading"
|
|
85
|
+
? typography.headingFontFamily || typography.fontFamily
|
|
86
|
+
: typography.fontFamily;
|
|
87
|
+
const color = roleColor(tokens, colors);
|
|
88
|
+
return {
|
|
89
|
+
...(size ? { fontSize: size, lineHeight: Math.round(size * ratio) } : null),
|
|
90
|
+
...(tokens.fontWeight ? { fontWeight: tokens.fontWeight } : null),
|
|
91
|
+
...(tokens.fontStyle ? { fontStyle: tokens.fontStyle } : null),
|
|
92
|
+
...(typeof tokens.letterSpacing === "number" &&
|
|
93
|
+
Number.isFinite(tokens.letterSpacing)
|
|
94
|
+
? { letterSpacing: tokens.letterSpacing }
|
|
95
|
+
: null),
|
|
96
|
+
...(TEXT_TRANSFORMS.includes(tokens.textTransform)
|
|
97
|
+
? { textTransform: tokens.textTransform }
|
|
98
|
+
: null),
|
|
99
|
+
...(family ? { fontFamily: family } : null),
|
|
100
|
+
...(color ? { color } : null),
|
|
101
|
+
};
|
|
102
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@colixsystems/widget-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.162.0",
|
|
4
4
|
"description": "Common widget interface for AppStudio. Implements WidgetManifest, WidgetContext, property schema, and helper hooks.",
|
|
5
5
|
"homepage": "https://github.com/Colix-AB/AppStudio",
|
|
6
6
|
"type": "module",
|