@sigx/lynx-zero 0.4.9 → 0.5.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/LICENSE +21 -21
- package/README.md +25 -25
- package/dist/styles/tokens.css +98 -98
- package/dist/theme/ThemeProvider.d.ts +25 -1
- package/dist/theme/ThemeProvider.d.ts.map +1 -1
- package/dist/theme/ThemeProvider.js +17 -0
- package/dist/theme/ThemeProvider.js.map +1 -1
- package/package.json +13 -8
- package/src/components/SwiperIndicator.tsx +519 -519
- package/src/contract.ts +136 -136
- package/src/index.ts +101 -101
- package/src/layout/Center.tsx +41 -41
- package/src/layout/Col.tsx +53 -53
- package/src/layout/Row.tsx +53 -53
- package/src/layout/ScrollView.tsx +38 -38
- package/src/layout/Spacer.tsx +18 -18
- package/src/preset/index.ts +77 -77
- package/src/shared/press.ts +6 -6
- package/src/shared/styles.ts +82 -82
- package/src/shared/tabs-selection.ts +57 -57
- package/src/styles/tokens.css +98 -98
- package/src/theme/StatusBarSync.tsx +104 -104
- package/src/theme/ThemeProvider.tsx +532 -492
- package/src/theme/color-mix.ts +68 -68
- package/src/theme/registry.ts +290 -290
- package/src/theme/theme-state.ts +112 -112
- package/src/theme/use-screen-theme.ts +42 -42
- package/src/theme/use-theme-colors.ts +99 -99
package/src/contract.ts
CHANGED
|
@@ -1,136 +1,136 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The shared design-system contract.
|
|
3
|
-
*
|
|
4
|
-
* `@sigx/lynx-zero` is the design-system-neutral foundation that DS packages
|
|
5
|
-
* (`@sigx/lynx-daisyui`, `@sigx/lynx-heroui`, …) build on. This module is the
|
|
6
|
-
* *vocabulary* they agree on — size scales, semantic colors, theme token
|
|
7
|
-
* names, and common prop shapes — so that switching an app from one design
|
|
8
|
-
* system to another is mostly an import swap, not a rewrite.
|
|
9
|
-
*
|
|
10
|
-
* Rules of the contract:
|
|
11
|
-
*
|
|
12
|
-
* - DS packages **extend** these types, they never redeclare them. A daisy
|
|
13
|
-
* button is `color: ColorVariant` plus daisy-specific extras; its size IS
|
|
14
|
-
* `SizeScale`. Drift fails `pnpm typecheck`.
|
|
15
|
-
* - `variant` is intentionally NOT in the contract — fill style (outline,
|
|
16
|
-
* soft, bordered, flat, …) is design-system chrome and differs per DS.
|
|
17
|
-
* - Theme CSS custom-property NAMES are part of the contract (see below);
|
|
18
|
-
* the *values* come from each DS's registered themes.
|
|
19
|
-
*
|
|
20
|
-
* ## Structural token-name contract
|
|
21
|
-
*
|
|
22
|
-
* Every DS theme resolves against the same custom-property names:
|
|
23
|
-
*
|
|
24
|
-
* - Colors: `--color-<ColorToken>` (e.g. `--color-primary`, `--color-base-100`)
|
|
25
|
-
* - Roundness: `--radius-selector` | `--radius-field` | `--radius-box`
|
|
26
|
-
* - Sizing: `--size-selector` | `--size-field`, `--size-xs` … `--size-lg`
|
|
27
|
-
* - Text ramp: `--text-xs` … `--text-3xl` (app text, font-scaled)
|
|
28
|
-
* - Controls: `--font-xs` … `--font-lg` (control-internal labels, unscaled)
|
|
29
|
-
* - Misc: `--disabled-opacity`
|
|
30
|
-
*/
|
|
31
|
-
import type { Define } from '@sigx/lynx';
|
|
32
|
-
|
|
33
|
-
/** The shared component size scale. */
|
|
34
|
-
export type SizeScale = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Semantic color names — the shared `color` prop vocabulary. A DS maps each
|
|
38
|
-
* onto its palette (HeroUI: `danger`→`error`, `default`→`neutral`, …).
|
|
39
|
-
*
|
|
40
|
-
* Single source of truth: the `ColorVariant` union, the `-content` / `-soft`
|
|
41
|
-
* token derivations, and the runtime `COLOR_TOKENS` Set all derive from this
|
|
42
|
-
* tuple.
|
|
43
|
-
*/
|
|
44
|
-
export const COLOR_VARIANT_LIST = [
|
|
45
|
-
'primary', 'secondary', 'accent', 'neutral',
|
|
46
|
-
'info', 'success', 'warning', 'error',
|
|
47
|
-
] as const;
|
|
48
|
-
|
|
49
|
-
export type ColorVariant = typeof COLOR_VARIANT_LIST[number];
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Tokens authored by every theme: each variant + its `-content` pairing,
|
|
53
|
-
* plus the base surfaces.
|
|
54
|
-
*/
|
|
55
|
-
export type CoreColorToken =
|
|
56
|
-
| ColorVariant
|
|
57
|
-
| `${ColorVariant}-content`
|
|
58
|
-
| 'base-100' | 'base-200' | 'base-300' | 'base-content';
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Soft (tinted-surface) tokens — one per variant, emitted as
|
|
62
|
-
* `--color-<variant>-soft`. Lynx CSS can't alpha-compose `var()` colors, so
|
|
63
|
-
* these are *materialized in the palette*: computed at theme registration
|
|
64
|
-
* (`Theme.softMix` of the variant color mixed into `base-100`) unless the
|
|
65
|
-
* theme provides them explicitly. They are what soft/flat component fills
|
|
66
|
-
* read (`btn-soft`, hero's `flat`).
|
|
67
|
-
*/
|
|
68
|
-
export type SoftColorToken = `${ColorVariant}-soft`;
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* The full set of semantic color tokens every *registered* theme carries,
|
|
72
|
-
* exposed as `--color-<token>` CSS custom properties. Authors write the core
|
|
73
|
-
* tokens; the registry completes the soft ones.
|
|
74
|
-
*/
|
|
75
|
-
export type ColorToken = CoreColorToken | SoftColorToken;
|
|
76
|
-
|
|
77
|
-
const COLOR_TOKEN_LIST: readonly ColorToken[] = [
|
|
78
|
-
...COLOR_VARIANT_LIST.flatMap((v): ColorToken[] => [v, `${v}-content`, `${v}-soft`]),
|
|
79
|
-
'base-100', 'base-200', 'base-300', 'base-content',
|
|
80
|
-
];
|
|
81
|
-
|
|
82
|
-
const COLOR_TOKENS: ReadonlySet<ColorToken> = new Set(COLOR_TOKEN_LIST);
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Resolve a color value to a CSS color string.
|
|
86
|
-
*
|
|
87
|
-
* - Known semantic tokens (e.g. `'base-100'`) → `var(--color-base-100)`.
|
|
88
|
-
* - Anything else (`'#ffaa00'`, `'rgb(…)'`, `'var(--my-custom)'`) passes
|
|
89
|
-
* through unchanged.
|
|
90
|
-
*/
|
|
91
|
-
export function resolveColorToken(value: string): string {
|
|
92
|
-
return (COLOR_TOKENS as ReadonlySet<string>).has(value)
|
|
93
|
-
? `var(--color-${value})`
|
|
94
|
-
: value;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Accepts a semantic color token (autocompleted) OR any raw CSS color
|
|
99
|
-
* string (`'#fff'`, `'rgb(…)'`, `'var(--foo)'`).
|
|
100
|
-
*/
|
|
101
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-object-type, @typescript-eslint/ban-types
|
|
102
|
-
export type BackgroundValue = ColorToken | (string & {});
|
|
103
|
-
|
|
104
|
-
// ---------------------------------------------------------------------------
|
|
105
|
-
// Common prop fragments — DS component props intersect these instead of
|
|
106
|
-
// redeclaring the conventions.
|
|
107
|
-
// ---------------------------------------------------------------------------
|
|
108
|
-
|
|
109
|
-
/** Arbitrary extra classes appended after the DS-computed ones. */
|
|
110
|
-
export type WithClass = Define.Prop<'class', string, false>;
|
|
111
|
-
|
|
112
|
-
/** Disabled: non-interactive + DS disabled styling. */
|
|
113
|
-
export type WithDisabled = Define.Prop<'disabled', boolean, false>;
|
|
114
|
-
|
|
115
|
-
/** Semantic color of the component (`primary`, `error`, …). */
|
|
116
|
-
export type WithColor = Define.Prop<'color', ColorVariant, false>;
|
|
117
|
-
|
|
118
|
-
/** Component size on the shared scale. */
|
|
119
|
-
export type WithSize = Define.Prop<'size', SizeScale, false>;
|
|
120
|
-
|
|
121
|
-
/** The shared press event — sigx convention is `onPress`, not `onTap`/`onClick`. */
|
|
122
|
-
export type PressEvent = Define.Event<'press', void>;
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Accessibility passthrough for interactive components — mirrors the
|
|
126
|
-
* `accessibility-*` surface `@sigx/lynx-gestures`'s `Pressable` accepts on
|
|
127
|
-
* its host view (the same node that owns the gesture handler, so
|
|
128
|
-
* screen-reader activation works). DS components intersect this and forward
|
|
129
|
-
* the props verbatim.
|
|
130
|
-
*/
|
|
131
|
-
export type WithAccessibility =
|
|
132
|
-
& Define.Prop<'accessibility-element', boolean, false>
|
|
133
|
-
& Define.Prop<'accessibility-label', string, false>
|
|
134
|
-
& Define.Prop<'accessibility-role', string, false>
|
|
135
|
-
& Define.Prop<'accessibility-trait', string, false>
|
|
136
|
-
& Define.Prop<'accessibility-status', string, false>;
|
|
1
|
+
/**
|
|
2
|
+
* The shared design-system contract.
|
|
3
|
+
*
|
|
4
|
+
* `@sigx/lynx-zero` is the design-system-neutral foundation that DS packages
|
|
5
|
+
* (`@sigx/lynx-daisyui`, `@sigx/lynx-heroui`, …) build on. This module is the
|
|
6
|
+
* *vocabulary* they agree on — size scales, semantic colors, theme token
|
|
7
|
+
* names, and common prop shapes — so that switching an app from one design
|
|
8
|
+
* system to another is mostly an import swap, not a rewrite.
|
|
9
|
+
*
|
|
10
|
+
* Rules of the contract:
|
|
11
|
+
*
|
|
12
|
+
* - DS packages **extend** these types, they never redeclare them. A daisy
|
|
13
|
+
* button is `color: ColorVariant` plus daisy-specific extras; its size IS
|
|
14
|
+
* `SizeScale`. Drift fails `pnpm typecheck`.
|
|
15
|
+
* - `variant` is intentionally NOT in the contract — fill style (outline,
|
|
16
|
+
* soft, bordered, flat, …) is design-system chrome and differs per DS.
|
|
17
|
+
* - Theme CSS custom-property NAMES are part of the contract (see below);
|
|
18
|
+
* the *values* come from each DS's registered themes.
|
|
19
|
+
*
|
|
20
|
+
* ## Structural token-name contract
|
|
21
|
+
*
|
|
22
|
+
* Every DS theme resolves against the same custom-property names:
|
|
23
|
+
*
|
|
24
|
+
* - Colors: `--color-<ColorToken>` (e.g. `--color-primary`, `--color-base-100`)
|
|
25
|
+
* - Roundness: `--radius-selector` | `--radius-field` | `--radius-box`
|
|
26
|
+
* - Sizing: `--size-selector` | `--size-field`, `--size-xs` … `--size-lg`
|
|
27
|
+
* - Text ramp: `--text-xs` … `--text-3xl` (app text, font-scaled)
|
|
28
|
+
* - Controls: `--font-xs` … `--font-lg` (control-internal labels, unscaled)
|
|
29
|
+
* - Misc: `--disabled-opacity`
|
|
30
|
+
*/
|
|
31
|
+
import type { Define } from '@sigx/lynx';
|
|
32
|
+
|
|
33
|
+
/** The shared component size scale. */
|
|
34
|
+
export type SizeScale = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Semantic color names — the shared `color` prop vocabulary. A DS maps each
|
|
38
|
+
* onto its palette (HeroUI: `danger`→`error`, `default`→`neutral`, …).
|
|
39
|
+
*
|
|
40
|
+
* Single source of truth: the `ColorVariant` union, the `-content` / `-soft`
|
|
41
|
+
* token derivations, and the runtime `COLOR_TOKENS` Set all derive from this
|
|
42
|
+
* tuple.
|
|
43
|
+
*/
|
|
44
|
+
export const COLOR_VARIANT_LIST = [
|
|
45
|
+
'primary', 'secondary', 'accent', 'neutral',
|
|
46
|
+
'info', 'success', 'warning', 'error',
|
|
47
|
+
] as const;
|
|
48
|
+
|
|
49
|
+
export type ColorVariant = typeof COLOR_VARIANT_LIST[number];
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Tokens authored by every theme: each variant + its `-content` pairing,
|
|
53
|
+
* plus the base surfaces.
|
|
54
|
+
*/
|
|
55
|
+
export type CoreColorToken =
|
|
56
|
+
| ColorVariant
|
|
57
|
+
| `${ColorVariant}-content`
|
|
58
|
+
| 'base-100' | 'base-200' | 'base-300' | 'base-content';
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Soft (tinted-surface) tokens — one per variant, emitted as
|
|
62
|
+
* `--color-<variant>-soft`. Lynx CSS can't alpha-compose `var()` colors, so
|
|
63
|
+
* these are *materialized in the palette*: computed at theme registration
|
|
64
|
+
* (`Theme.softMix` of the variant color mixed into `base-100`) unless the
|
|
65
|
+
* theme provides them explicitly. They are what soft/flat component fills
|
|
66
|
+
* read (`btn-soft`, hero's `flat`).
|
|
67
|
+
*/
|
|
68
|
+
export type SoftColorToken = `${ColorVariant}-soft`;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* The full set of semantic color tokens every *registered* theme carries,
|
|
72
|
+
* exposed as `--color-<token>` CSS custom properties. Authors write the core
|
|
73
|
+
* tokens; the registry completes the soft ones.
|
|
74
|
+
*/
|
|
75
|
+
export type ColorToken = CoreColorToken | SoftColorToken;
|
|
76
|
+
|
|
77
|
+
const COLOR_TOKEN_LIST: readonly ColorToken[] = [
|
|
78
|
+
...COLOR_VARIANT_LIST.flatMap((v): ColorToken[] => [v, `${v}-content`, `${v}-soft`]),
|
|
79
|
+
'base-100', 'base-200', 'base-300', 'base-content',
|
|
80
|
+
];
|
|
81
|
+
|
|
82
|
+
const COLOR_TOKENS: ReadonlySet<ColorToken> = new Set(COLOR_TOKEN_LIST);
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Resolve a color value to a CSS color string.
|
|
86
|
+
*
|
|
87
|
+
* - Known semantic tokens (e.g. `'base-100'`) → `var(--color-base-100)`.
|
|
88
|
+
* - Anything else (`'#ffaa00'`, `'rgb(…)'`, `'var(--my-custom)'`) passes
|
|
89
|
+
* through unchanged.
|
|
90
|
+
*/
|
|
91
|
+
export function resolveColorToken(value: string): string {
|
|
92
|
+
return (COLOR_TOKENS as ReadonlySet<string>).has(value)
|
|
93
|
+
? `var(--color-${value})`
|
|
94
|
+
: value;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Accepts a semantic color token (autocompleted) OR any raw CSS color
|
|
99
|
+
* string (`'#fff'`, `'rgb(…)'`, `'var(--foo)'`).
|
|
100
|
+
*/
|
|
101
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type, @typescript-eslint/ban-types
|
|
102
|
+
export type BackgroundValue = ColorToken | (string & {});
|
|
103
|
+
|
|
104
|
+
// ---------------------------------------------------------------------------
|
|
105
|
+
// Common prop fragments — DS component props intersect these instead of
|
|
106
|
+
// redeclaring the conventions.
|
|
107
|
+
// ---------------------------------------------------------------------------
|
|
108
|
+
|
|
109
|
+
/** Arbitrary extra classes appended after the DS-computed ones. */
|
|
110
|
+
export type WithClass = Define.Prop<'class', string, false>;
|
|
111
|
+
|
|
112
|
+
/** Disabled: non-interactive + DS disabled styling. */
|
|
113
|
+
export type WithDisabled = Define.Prop<'disabled', boolean, false>;
|
|
114
|
+
|
|
115
|
+
/** Semantic color of the component (`primary`, `error`, …). */
|
|
116
|
+
export type WithColor = Define.Prop<'color', ColorVariant, false>;
|
|
117
|
+
|
|
118
|
+
/** Component size on the shared scale. */
|
|
119
|
+
export type WithSize = Define.Prop<'size', SizeScale, false>;
|
|
120
|
+
|
|
121
|
+
/** The shared press event — sigx convention is `onPress`, not `onTap`/`onClick`. */
|
|
122
|
+
export type PressEvent = Define.Event<'press', void>;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Accessibility passthrough for interactive components — mirrors the
|
|
126
|
+
* `accessibility-*` surface `@sigx/lynx-gestures`'s `Pressable` accepts on
|
|
127
|
+
* its host view (the same node that owns the gesture handler, so
|
|
128
|
+
* screen-reader activation works). DS components intersect this and forward
|
|
129
|
+
* the props verbatim.
|
|
130
|
+
*/
|
|
131
|
+
export type WithAccessibility =
|
|
132
|
+
& Define.Prop<'accessibility-element', boolean, false>
|
|
133
|
+
& Define.Prop<'accessibility-label', string, false>
|
|
134
|
+
& Define.Prop<'accessibility-role', string, false>
|
|
135
|
+
& Define.Prop<'accessibility-trait', string, false>
|
|
136
|
+
& Define.Prop<'accessibility-status', string, false>;
|
package/src/index.ts
CHANGED
|
@@ -1,101 +1,101 @@
|
|
|
1
|
-
// @sigx/lynx-zero — design-system-neutral UI foundation.
|
|
2
|
-
//
|
|
3
|
-
// Holds what every design-system package (@sigx/lynx-daisyui,
|
|
4
|
-
// @sigx/lynx-heroui, …) shares: the props/token contract, the theme engine,
|
|
5
|
-
// layout primitives, style utilities and press-feedback defaults
|
|
6
|
-
// (see signalxjs/lynx#219).
|
|
7
|
-
|
|
8
|
-
// The shared contract: scales, semantic colors, prop fragments,
|
|
9
|
-
// token-name conventions.
|
|
10
|
-
export type {
|
|
11
|
-
SizeScale,
|
|
12
|
-
ColorVariant,
|
|
13
|
-
ColorToken,
|
|
14
|
-
CoreColorToken,
|
|
15
|
-
SoftColorToken,
|
|
16
|
-
BackgroundValue,
|
|
17
|
-
WithClass,
|
|
18
|
-
WithDisabled,
|
|
19
|
-
WithColor,
|
|
20
|
-
WithSize,
|
|
21
|
-
WithAccessibility,
|
|
22
|
-
PressEvent,
|
|
23
|
-
} from './contract.js';
|
|
24
|
-
export { resolveColorToken, COLOR_VARIANT_LIST } from './contract.js';
|
|
25
|
-
|
|
26
|
-
// Box-model style helpers.
|
|
27
|
-
export type { SpacingValue, BoxProps } from './shared/styles.js';
|
|
28
|
-
export { resolveSpacing, resolveBoxStyle } from './shared/styles.js';
|
|
29
|
-
|
|
30
|
-
// Press-feedback defaults for interactive components.
|
|
31
|
-
export { PRESSED_SCALE, PRESSED_OPACITY } from './shared/press.js';
|
|
32
|
-
|
|
33
|
-
// Headless tabs selection — shared behavior behind every DS's Tabs/Tab.
|
|
34
|
-
export { useTabsSelection, provideTabsSelection } from './shared/tabs-selection.js';
|
|
35
|
-
export type { TabsSelection } from './shared/tabs-selection.js';
|
|
36
|
-
|
|
37
|
-
// Theme engine — registry mechanism, provider, headless controller. Theme
|
|
38
|
-
// *data* (palettes, generated first-paint CSS classes) lives in each
|
|
39
|
-
// design-system package, which seeds the registry at module load.
|
|
40
|
-
export {
|
|
41
|
-
ThemeProvider,
|
|
42
|
-
useTheme,
|
|
43
|
-
listThemes,
|
|
44
|
-
registerTheme,
|
|
45
|
-
extendTheme,
|
|
46
|
-
pickThemeFor,
|
|
47
|
-
pairOf,
|
|
48
|
-
variantOf,
|
|
49
|
-
colorsOf,
|
|
50
|
-
radiusOf,
|
|
51
|
-
sizesOf,
|
|
52
|
-
} from './theme/ThemeProvider.js';
|
|
53
|
-
export type {
|
|
54
|
-
ThemeName,
|
|
55
|
-
ThemeController,
|
|
56
|
-
ThemeProviderProps,
|
|
57
|
-
Theme,
|
|
58
|
-
ThemePalette,
|
|
59
|
-
ThemeRadius,
|
|
60
|
-
ThemeSizes,
|
|
61
|
-
ThemeVariant,
|
|
62
|
-
} from './theme/ThemeProvider.js';
|
|
63
|
-
// Palette completion (soft tints) + the JS-side color mixer behind it.
|
|
64
|
-
export { completeTheme } from './theme/registry.js';
|
|
65
|
-
export type { ThemeInput, ThemePaletteInput } from './theme/registry.js';
|
|
66
|
-
export { mixColors } from './theme/color-mix.js';
|
|
67
|
-
// Scoped palette → concrete values for native consumers that can't read
|
|
68
|
-
// CSS custom properties (platform inputs, sigx-richtext, SVG fills).
|
|
69
|
-
export { useThemeColors, toHexColor, withAlpha } from './theme/use-theme-colors.js';
|
|
70
|
-
export type { ThemeColors } from './theme/use-theme-colors.js';
|
|
71
|
-
// Headless theme handle: import and call from anywhere — stores, services,
|
|
72
|
-
// effects, app-boot — with no `<ThemeProvider>` ancestor required.
|
|
73
|
-
export { themeController } from './theme/theme-state.js';
|
|
74
|
-
export { StatusBarSync } from './theme/StatusBarSync.js';
|
|
75
|
-
export type { StatusBarSyncProps } from './theme/StatusBarSync.js';
|
|
76
|
-
// Per-screen theming (`useScreenTheme`) is deliberately NOT re-exported here:
|
|
77
|
-
// it statically imports the optional `@sigx/lynx-navigation` peer, and a
|
|
78
|
-
// barrel re-export would force that resolution onto every consumer. Import it
|
|
79
|
-
// from the subpath instead: `@sigx/lynx-zero/screen-theme`.
|
|
80
|
-
|
|
81
|
-
// Layout primitives — design-system-neutral structure (flex containers,
|
|
82
|
-
// spacing, scrolling); no design-system class names involved.
|
|
83
|
-
export { Row } from './layout/Row.js';
|
|
84
|
-
export type { RowProps } from './layout/Row.js';
|
|
85
|
-
export { Col } from './layout/Col.js';
|
|
86
|
-
export type { ColProps } from './layout/Col.js';
|
|
87
|
-
export { Center } from './layout/Center.js';
|
|
88
|
-
export type { CenterProps } from './layout/Center.js';
|
|
89
|
-
export { Spacer } from './layout/Spacer.js';
|
|
90
|
-
export type { SpacerProps } from './layout/Spacer.js';
|
|
91
|
-
export { ScrollView } from './layout/ScrollView.js';
|
|
92
|
-
export type { ScrollViewProps } from './layout/ScrollView.js';
|
|
93
|
-
|
|
94
|
-
// Swiper page indicator — design-system-neutral (pure tokens + headless
|
|
95
|
-
// gesture/motion hooks, no DS class names). Both design systems re-export it.
|
|
96
|
-
export { SwiperIndicator } from './components/SwiperIndicator.js';
|
|
97
|
-
export type {
|
|
98
|
-
SwiperIndicatorProps,
|
|
99
|
-
SwiperIndicatorVariant,
|
|
100
|
-
SwiperIndicatorSize,
|
|
101
|
-
} from './components/SwiperIndicator.js';
|
|
1
|
+
// @sigx/lynx-zero — design-system-neutral UI foundation.
|
|
2
|
+
//
|
|
3
|
+
// Holds what every design-system package (@sigx/lynx-daisyui,
|
|
4
|
+
// @sigx/lynx-heroui, …) shares: the props/token contract, the theme engine,
|
|
5
|
+
// layout primitives, style utilities and press-feedback defaults
|
|
6
|
+
// (see signalxjs/lynx#219).
|
|
7
|
+
|
|
8
|
+
// The shared contract: scales, semantic colors, prop fragments,
|
|
9
|
+
// token-name conventions.
|
|
10
|
+
export type {
|
|
11
|
+
SizeScale,
|
|
12
|
+
ColorVariant,
|
|
13
|
+
ColorToken,
|
|
14
|
+
CoreColorToken,
|
|
15
|
+
SoftColorToken,
|
|
16
|
+
BackgroundValue,
|
|
17
|
+
WithClass,
|
|
18
|
+
WithDisabled,
|
|
19
|
+
WithColor,
|
|
20
|
+
WithSize,
|
|
21
|
+
WithAccessibility,
|
|
22
|
+
PressEvent,
|
|
23
|
+
} from './contract.js';
|
|
24
|
+
export { resolveColorToken, COLOR_VARIANT_LIST } from './contract.js';
|
|
25
|
+
|
|
26
|
+
// Box-model style helpers.
|
|
27
|
+
export type { SpacingValue, BoxProps } from './shared/styles.js';
|
|
28
|
+
export { resolveSpacing, resolveBoxStyle } from './shared/styles.js';
|
|
29
|
+
|
|
30
|
+
// Press-feedback defaults for interactive components.
|
|
31
|
+
export { PRESSED_SCALE, PRESSED_OPACITY } from './shared/press.js';
|
|
32
|
+
|
|
33
|
+
// Headless tabs selection — shared behavior behind every DS's Tabs/Tab.
|
|
34
|
+
export { useTabsSelection, provideTabsSelection } from './shared/tabs-selection.js';
|
|
35
|
+
export type { TabsSelection } from './shared/tabs-selection.js';
|
|
36
|
+
|
|
37
|
+
// Theme engine — registry mechanism, provider, headless controller. Theme
|
|
38
|
+
// *data* (palettes, generated first-paint CSS classes) lives in each
|
|
39
|
+
// design-system package, which seeds the registry at module load.
|
|
40
|
+
export {
|
|
41
|
+
ThemeProvider,
|
|
42
|
+
useTheme,
|
|
43
|
+
listThemes,
|
|
44
|
+
registerTheme,
|
|
45
|
+
extendTheme,
|
|
46
|
+
pickThemeFor,
|
|
47
|
+
pairOf,
|
|
48
|
+
variantOf,
|
|
49
|
+
colorsOf,
|
|
50
|
+
radiusOf,
|
|
51
|
+
sizesOf,
|
|
52
|
+
} from './theme/ThemeProvider.js';
|
|
53
|
+
export type {
|
|
54
|
+
ThemeName,
|
|
55
|
+
ThemeController,
|
|
56
|
+
ThemeProviderProps,
|
|
57
|
+
Theme,
|
|
58
|
+
ThemePalette,
|
|
59
|
+
ThemeRadius,
|
|
60
|
+
ThemeSizes,
|
|
61
|
+
ThemeVariant,
|
|
62
|
+
} from './theme/ThemeProvider.js';
|
|
63
|
+
// Palette completion (soft tints) + the JS-side color mixer behind it.
|
|
64
|
+
export { completeTheme } from './theme/registry.js';
|
|
65
|
+
export type { ThemeInput, ThemePaletteInput } from './theme/registry.js';
|
|
66
|
+
export { mixColors } from './theme/color-mix.js';
|
|
67
|
+
// Scoped palette → concrete values for native consumers that can't read
|
|
68
|
+
// CSS custom properties (platform inputs, sigx-richtext, SVG fills).
|
|
69
|
+
export { useThemeColors, toHexColor, withAlpha } from './theme/use-theme-colors.js';
|
|
70
|
+
export type { ThemeColors } from './theme/use-theme-colors.js';
|
|
71
|
+
// Headless theme handle: import and call from anywhere — stores, services,
|
|
72
|
+
// effects, app-boot — with no `<ThemeProvider>` ancestor required.
|
|
73
|
+
export { themeController } from './theme/theme-state.js';
|
|
74
|
+
export { StatusBarSync } from './theme/StatusBarSync.js';
|
|
75
|
+
export type { StatusBarSyncProps } from './theme/StatusBarSync.js';
|
|
76
|
+
// Per-screen theming (`useScreenTheme`) is deliberately NOT re-exported here:
|
|
77
|
+
// it statically imports the optional `@sigx/lynx-navigation` peer, and a
|
|
78
|
+
// barrel re-export would force that resolution onto every consumer. Import it
|
|
79
|
+
// from the subpath instead: `@sigx/lynx-zero/screen-theme`.
|
|
80
|
+
|
|
81
|
+
// Layout primitives — design-system-neutral structure (flex containers,
|
|
82
|
+
// spacing, scrolling); no design-system class names involved.
|
|
83
|
+
export { Row } from './layout/Row.js';
|
|
84
|
+
export type { RowProps } from './layout/Row.js';
|
|
85
|
+
export { Col } from './layout/Col.js';
|
|
86
|
+
export type { ColProps } from './layout/Col.js';
|
|
87
|
+
export { Center } from './layout/Center.js';
|
|
88
|
+
export type { CenterProps } from './layout/Center.js';
|
|
89
|
+
export { Spacer } from './layout/Spacer.js';
|
|
90
|
+
export type { SpacerProps } from './layout/Spacer.js';
|
|
91
|
+
export { ScrollView } from './layout/ScrollView.js';
|
|
92
|
+
export type { ScrollViewProps } from './layout/ScrollView.js';
|
|
93
|
+
|
|
94
|
+
// Swiper page indicator — design-system-neutral (pure tokens + headless
|
|
95
|
+
// gesture/motion hooks, no DS class names). Both design systems re-export it.
|
|
96
|
+
export { SwiperIndicator } from './components/SwiperIndicator.js';
|
|
97
|
+
export type {
|
|
98
|
+
SwiperIndicatorProps,
|
|
99
|
+
SwiperIndicatorVariant,
|
|
100
|
+
SwiperIndicatorSize,
|
|
101
|
+
} from './components/SwiperIndicator.js';
|
package/src/layout/Center.tsx
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import { component, type Define } from '@sigx/lynx';
|
|
2
|
-
import type { BackgroundValue } from '../contract.js';
|
|
3
|
-
import { resolveBoxStyle } from '../shared/styles.js';
|
|
4
|
-
|
|
5
|
-
export type CenterProps =
|
|
6
|
-
& Define.Prop<'width', number | string, false>
|
|
7
|
-
& Define.Prop<'height', number | string, false>
|
|
8
|
-
& Define.Prop<'flex', number, false>
|
|
9
|
-
& Define.Prop<'background', BackgroundValue, false>
|
|
10
|
-
& Define.Prop<'borderRadius', number, false>
|
|
11
|
-
& Define.Prop<'class', string, false>
|
|
12
|
-
& Define.Slot<'default'>;
|
|
13
|
-
|
|
14
|
-
export const Center = component<CenterProps>(({ props, slots }) => {
|
|
15
|
-
const getStyle = (): Record<string, string | number> => {
|
|
16
|
-
const style: Record<string, string | number> = {
|
|
17
|
-
display: 'flex',
|
|
18
|
-
justifyContent: 'center',
|
|
19
|
-
alignItems: 'center',
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const box = resolveBoxStyle({
|
|
23
|
-
width: props.width,
|
|
24
|
-
height: props.height,
|
|
25
|
-
flex: props.flex,
|
|
26
|
-
background: props.background,
|
|
27
|
-
borderRadius: props.borderRadius,
|
|
28
|
-
});
|
|
29
|
-
for (const key in box) {
|
|
30
|
-
style[key] = box[key] as string | number;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return style;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
return () => (
|
|
37
|
-
<view class={props.class} style={getStyle()}>
|
|
38
|
-
{slots.default?.()}
|
|
39
|
-
</view>
|
|
40
|
-
);
|
|
41
|
-
});
|
|
1
|
+
import { component, type Define } from '@sigx/lynx';
|
|
2
|
+
import type { BackgroundValue } from '../contract.js';
|
|
3
|
+
import { resolveBoxStyle } from '../shared/styles.js';
|
|
4
|
+
|
|
5
|
+
export type CenterProps =
|
|
6
|
+
& Define.Prop<'width', number | string, false>
|
|
7
|
+
& Define.Prop<'height', number | string, false>
|
|
8
|
+
& Define.Prop<'flex', number, false>
|
|
9
|
+
& Define.Prop<'background', BackgroundValue, false>
|
|
10
|
+
& Define.Prop<'borderRadius', number, false>
|
|
11
|
+
& Define.Prop<'class', string, false>
|
|
12
|
+
& Define.Slot<'default'>;
|
|
13
|
+
|
|
14
|
+
export const Center = component<CenterProps>(({ props, slots }) => {
|
|
15
|
+
const getStyle = (): Record<string, string | number> => {
|
|
16
|
+
const style: Record<string, string | number> = {
|
|
17
|
+
display: 'flex',
|
|
18
|
+
justifyContent: 'center',
|
|
19
|
+
alignItems: 'center',
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const box = resolveBoxStyle({
|
|
23
|
+
width: props.width,
|
|
24
|
+
height: props.height,
|
|
25
|
+
flex: props.flex,
|
|
26
|
+
background: props.background,
|
|
27
|
+
borderRadius: props.borderRadius,
|
|
28
|
+
});
|
|
29
|
+
for (const key in box) {
|
|
30
|
+
style[key] = box[key] as string | number;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return style;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
return () => (
|
|
37
|
+
<view class={props.class} style={getStyle()}>
|
|
38
|
+
{slots.default?.()}
|
|
39
|
+
</view>
|
|
40
|
+
);
|
|
41
|
+
});
|