@sigx/lynx-zero 0.4.9

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.
Files changed (100) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +25 -0
  3. package/dist/components/SwiperIndicator.d.ts +43 -0
  4. package/dist/components/SwiperIndicator.d.ts.map +1 -0
  5. package/dist/components/SwiperIndicator.js +272 -0
  6. package/dist/components/SwiperIndicator.js.map +1 -0
  7. package/dist/contract.d.ts +95 -0
  8. package/dist/contract.d.ts.map +1 -0
  9. package/dist/contract.js +30 -0
  10. package/dist/contract.js.map +1 -0
  11. package/dist/index.d.ts +30 -0
  12. package/dist/index.d.ts.map +1 -0
  13. package/dist/index.js +41 -0
  14. package/dist/index.js.map +1 -0
  15. package/dist/layout/Center.d.ts +7 -0
  16. package/dist/layout/Center.d.ts.map +1 -0
  17. package/dist/layout/Center.js +25 -0
  18. package/dist/layout/Center.js.map +1 -0
  19. package/dist/layout/Col.d.ts +8 -0
  20. package/dist/layout/Col.d.ts.map +1 -0
  21. package/dist/layout/Col.js +34 -0
  22. package/dist/layout/Col.js.map +1 -0
  23. package/dist/layout/Row.d.ts +8 -0
  24. package/dist/layout/Row.d.ts.map +1 -0
  25. package/dist/layout/Row.js +34 -0
  26. package/dist/layout/Row.js.map +1 -0
  27. package/dist/layout/ScrollView.d.ts +6 -0
  28. package/dist/layout/ScrollView.d.ts.map +1 -0
  29. package/dist/layout/ScrollView.js +19 -0
  30. package/dist/layout/ScrollView.js.map +1 -0
  31. package/dist/layout/Spacer.d.ts +4 -0
  32. package/dist/layout/Spacer.d.ts.map +1 -0
  33. package/dist/layout/Spacer.js +12 -0
  34. package/dist/layout/Spacer.js.map +1 -0
  35. package/dist/preset/index.d.ts +31 -0
  36. package/dist/preset/index.d.ts.map +1 -0
  37. package/dist/preset/index.js +72 -0
  38. package/dist/preset/index.js.map +1 -0
  39. package/dist/shared/press.d.ts +3 -0
  40. package/dist/shared/press.d.ts.map +1 -0
  41. package/dist/shared/press.js +7 -0
  42. package/dist/shared/press.js.map +1 -0
  43. package/dist/shared/styles.d.ts +27 -0
  44. package/dist/shared/styles.d.ts.map +1 -0
  45. package/dist/shared/styles.js +62 -0
  46. package/dist/shared/styles.js.map +1 -0
  47. package/dist/shared/tabs-selection.d.ts +25 -0
  48. package/dist/shared/tabs-selection.d.ts.map +1 -0
  49. package/dist/shared/tabs-selection.js +45 -0
  50. package/dist/shared/tabs-selection.js.map +1 -0
  51. package/dist/styles/tokens.css +98 -0
  52. package/dist/theme/StatusBarSync.d.ts +42 -0
  53. package/dist/theme/StatusBarSync.d.ts.map +1 -0
  54. package/dist/theme/StatusBarSync.js +89 -0
  55. package/dist/theme/StatusBarSync.js.map +1 -0
  56. package/dist/theme/ThemeProvider.d.ts +144 -0
  57. package/dist/theme/ThemeProvider.d.ts.map +1 -0
  58. package/dist/theme/ThemeProvider.js +328 -0
  59. package/dist/theme/ThemeProvider.js.map +1 -0
  60. package/dist/theme/color-mix.d.ts +21 -0
  61. package/dist/theme/color-mix.d.ts.map +1 -0
  62. package/dist/theme/color-mix.js +65 -0
  63. package/dist/theme/color-mix.js.map +1 -0
  64. package/dist/theme/registry.d.ts +182 -0
  65. package/dist/theme/registry.d.ts.map +1 -0
  66. package/dist/theme/registry.js +182 -0
  67. package/dist/theme/registry.js.map +1 -0
  68. package/dist/theme/theme-state.d.ts +43 -0
  69. package/dist/theme/theme-state.d.ts.map +1 -0
  70. package/dist/theme/theme-state.js +94 -0
  71. package/dist/theme/theme-state.js.map +1 -0
  72. package/dist/theme/use-screen-theme.d.ts +4 -0
  73. package/dist/theme/use-screen-theme.d.ts.map +1 -0
  74. package/dist/theme/use-screen-theme.js +43 -0
  75. package/dist/theme/use-screen-theme.js.map +1 -0
  76. package/dist/theme/use-theme-colors.d.ts +48 -0
  77. package/dist/theme/use-theme-colors.d.ts.map +1 -0
  78. package/dist/theme/use-theme-colors.js +69 -0
  79. package/dist/theme/use-theme-colors.js.map +1 -0
  80. package/package.json +80 -0
  81. package/src/components/SwiperIndicator.tsx +519 -0
  82. package/src/contract.ts +136 -0
  83. package/src/index.ts +101 -0
  84. package/src/layout/Center.tsx +41 -0
  85. package/src/layout/Col.tsx +53 -0
  86. package/src/layout/Row.tsx +53 -0
  87. package/src/layout/ScrollView.tsx +38 -0
  88. package/src/layout/Spacer.tsx +18 -0
  89. package/src/preset/index.ts +77 -0
  90. package/src/shared/press.ts +6 -0
  91. package/src/shared/styles.ts +82 -0
  92. package/src/shared/tabs-selection.ts +57 -0
  93. package/src/styles/tokens.css +98 -0
  94. package/src/theme/StatusBarSync.tsx +104 -0
  95. package/src/theme/ThemeProvider.tsx +492 -0
  96. package/src/theme/color-mix.ts +68 -0
  97. package/src/theme/registry.ts +290 -0
  98. package/src/theme/theme-state.ts +112 -0
  99. package/src/theme/use-screen-theme.ts +42 -0
  100. package/src/theme/use-theme-colors.ts +99 -0
package/src/index.ts ADDED
@@ -0,0 +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';
@@ -0,0 +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
+ });
@@ -0,0 +1,53 @@
1
+ import { component, type Define } from '@sigx/lynx';
2
+ import type { BackgroundValue } from '../contract.js';
3
+ import { type SpacingValue, resolveBoxStyle } from '../shared/styles.js';
4
+
5
+ export type ColProps =
6
+ & Define.Prop<'gap', number, false>
7
+ & Define.Prop<'align', 'flex-start' | 'center' | 'flex-end' | 'stretch' | 'baseline', false>
8
+ & Define.Prop<'justify', 'flex-start' | 'center' | 'flex-end' | 'space-between' | 'space-around' | 'space-evenly', false>
9
+ & Define.Prop<'wrap', boolean, false>
10
+ & Define.Prop<'padding', SpacingValue, false>
11
+ & Define.Prop<'margin', SpacingValue, false>
12
+ & Define.Prop<'width', number | string, false>
13
+ & Define.Prop<'height', number | string, false>
14
+ & Define.Prop<'flex', number, false>
15
+ & Define.Prop<'background', BackgroundValue, false>
16
+ & Define.Prop<'borderRadius', number, false>
17
+ & Define.Prop<'class', string, false>
18
+ & Define.Slot<'default'>;
19
+
20
+ export const Col = component<ColProps>(({ props, slots }) => {
21
+ const getStyle = (): Record<string, string | number> => {
22
+ const style: Record<string, string | number> = {
23
+ display: 'flex',
24
+ flexDirection: 'column',
25
+ };
26
+
27
+ if (props.gap !== undefined) style.gap = props.gap;
28
+ if (props.align) style.alignItems = props.align;
29
+ if (props.justify) style.justifyContent = props.justify;
30
+ if (props.wrap) style.flexWrap = 'wrap';
31
+
32
+ const box = resolveBoxStyle({
33
+ width: props.width,
34
+ height: props.height,
35
+ flex: props.flex,
36
+ background: props.background,
37
+ borderRadius: props.borderRadius,
38
+ padding: props.padding,
39
+ margin: props.margin,
40
+ });
41
+ for (const key in box) {
42
+ style[key] = box[key] as string | number;
43
+ }
44
+
45
+ return style;
46
+ };
47
+
48
+ return () => (
49
+ <view class={props.class} style={getStyle()}>
50
+ {slots.default?.()}
51
+ </view>
52
+ );
53
+ });
@@ -0,0 +1,53 @@
1
+ import { component, type Define } from '@sigx/lynx';
2
+ import type { BackgroundValue } from '../contract.js';
3
+ import { type SpacingValue, resolveBoxStyle } from '../shared/styles.js';
4
+
5
+ export type RowProps =
6
+ & Define.Prop<'gap', number, false>
7
+ & Define.Prop<'align', 'flex-start' | 'center' | 'flex-end' | 'stretch' | 'baseline', false>
8
+ & Define.Prop<'justify', 'flex-start' | 'center' | 'flex-end' | 'space-between' | 'space-around' | 'space-evenly', false>
9
+ & Define.Prop<'wrap', boolean, false>
10
+ & Define.Prop<'padding', SpacingValue, false>
11
+ & Define.Prop<'margin', SpacingValue, false>
12
+ & Define.Prop<'width', number | string, false>
13
+ & Define.Prop<'height', number | string, false>
14
+ & Define.Prop<'flex', number, false>
15
+ & Define.Prop<'background', BackgroundValue, false>
16
+ & Define.Prop<'borderRadius', number, false>
17
+ & Define.Prop<'class', string, false>
18
+ & Define.Slot<'default'>;
19
+
20
+ export const Row = component<RowProps>(({ props, slots }) => {
21
+ const getStyle = (): Record<string, string | number> => {
22
+ const style: Record<string, string | number> = {
23
+ display: 'flex',
24
+ flexDirection: 'row',
25
+ };
26
+
27
+ if (props.gap !== undefined) style.gap = props.gap;
28
+ if (props.align) style.alignItems = props.align;
29
+ if (props.justify) style.justifyContent = props.justify;
30
+ if (props.wrap) style.flexWrap = 'wrap';
31
+
32
+ const box = resolveBoxStyle({
33
+ width: props.width,
34
+ height: props.height,
35
+ flex: props.flex,
36
+ background: props.background,
37
+ borderRadius: props.borderRadius,
38
+ padding: props.padding,
39
+ margin: props.margin,
40
+ });
41
+ for (const key in box) {
42
+ style[key] = box[key] as string | number;
43
+ }
44
+
45
+ return style;
46
+ };
47
+
48
+ return () => (
49
+ <view class={props.class} style={getStyle()}>
50
+ {slots.default?.()}
51
+ </view>
52
+ );
53
+ });
@@ -0,0 +1,38 @@
1
+ import { component, type Define } from '@sigx/lynx';
2
+
3
+ export type ScrollViewProps =
4
+ & Define.Prop<'direction', 'vertical' | 'horizontal', false>
5
+ & Define.Prop<'height', number | string, false>
6
+ & Define.Prop<'width', number | string, false>
7
+ & Define.Prop<'flex', number, false>
8
+ & Define.Prop<'showScrollbar', boolean, false>
9
+ & Define.Prop<'bounces', boolean, false>
10
+ & Define.Prop<'class', string, false>
11
+ & Define.Slot<'default'>;
12
+
13
+ export const ScrollView = component<ScrollViewProps>(({ props, slots }) => {
14
+ const getStyle = (): Record<string, string | number> => {
15
+ const style: Record<string, string | number> = {};
16
+ if (props.height !== undefined) style.height = props.height;
17
+ if (props.width !== undefined) style.width = props.width;
18
+ if (props.flex !== undefined) style.flex = props.flex;
19
+ return style;
20
+ };
21
+
22
+ return () => {
23
+ const dir = props.direction ?? 'vertical';
24
+ return (
25
+ <scroll-view
26
+ class={props.class}
27
+ style={getStyle()}
28
+ scroll-orientation={dir}
29
+ scroll-y={dir === 'vertical' ? true : undefined}
30
+ scroll-x={dir === 'horizontal' ? true : undefined}
31
+ show-scrollbar={props.showScrollbar}
32
+ bounces={props.bounces}
33
+ >
34
+ {slots.default?.()}
35
+ </scroll-view>
36
+ );
37
+ };
38
+ });
@@ -0,0 +1,18 @@
1
+ import { component, type Define } from '@sigx/lynx';
2
+
3
+ export type SpacerProps =
4
+ & Define.Prop<'size', number, false>
5
+ & Define.Prop<'class', string, false>;
6
+
7
+ export const Spacer = component<SpacerProps>(({ props }) => {
8
+ const getStyle = (): Record<string, string | number> => {
9
+ if (props.size !== undefined) {
10
+ return { width: props.size, height: props.size };
11
+ }
12
+ return { flex: 1 };
13
+ };
14
+
15
+ return () => (
16
+ <view class={props.class} style={getStyle()} />
17
+ );
18
+ });
@@ -0,0 +1,77 @@
1
+ import type { Config } from 'tailwindcss';
2
+ import plugin from 'tailwindcss/plugin';
3
+ import { COLOR_VARIANT_LIST } from '../contract.js';
4
+
5
+ /**
6
+ * The design-system-neutral Tailwind preset pieces — the parts of a DS preset
7
+ * that are really the *contract*, not the design system:
8
+ *
9
+ * • `contractColors`: every semantic color token (incl. the `*-soft`
10
+ * tints) → `var(--color-*)`, so utilities like `bg-primary` and
11
+ * `text-base-content` resolve against the active theme of whichever
12
+ * design system is mounted.
13
+ * • `contractFontSizes`: re-points Tailwind's `text-xs`…`text-3xl`
14
+ * font-size utilities at the shared `--text-*` ramp (defaults in
15
+ * `styles/tokens.css`, multiplied app-wide by the theme controller's
16
+ * `fontScale`). Merged via `theme.extend.fontSize`, so larger Tailwind
17
+ * keys (`text-4xl`+) keep their rem defaults.
18
+ * • `lynxLayoutPlugin`: ships `flex-fill` — the Lynx-correct "fill
19
+ * remaining space" utility. In Lynx (like React Native) the `flex: 1`
20
+ * shorthand expands to `flex: 1 1 auto`, where `flexBasis: 'auto'` sizes
21
+ * the box to its content first, collapsing the layout chain; Tailwind's
22
+ * own `flex-1` expands to the same broken shorthand. `flex-fill` writes
23
+ * the long-form properties so the result actually fills.
24
+ *
25
+ * Design-system presets compose these (`@sigx/lynx-daisyui/preset`,
26
+ * `@sigx/lynx-heroui/preset`) and layer any DS-specific extensions on top;
27
+ * apps normally consume the DS preset, not this one directly.
28
+ */
29
+
30
+ export const contractColors: Record<string, string> = Object.fromEntries([
31
+ ...COLOR_VARIANT_LIST.flatMap((v) => [
32
+ [v, `var(--color-${v})`],
33
+ [`${v}-content`, `var(--color-${v}-content)`],
34
+ [`${v}-soft`, `var(--color-${v}-soft)`],
35
+ ]),
36
+ ['base-100', 'var(--color-base-100)'],
37
+ ['base-200', 'var(--color-base-200)'],
38
+ ['base-300', 'var(--color-base-300)'],
39
+ ['base-content', 'var(--color-base-content)'],
40
+ ]);
41
+
42
+ export const contractFontSizes: Record<string, string> = {
43
+ 'xs': 'var(--text-xs)',
44
+ 'sm': 'var(--text-sm)',
45
+ 'base': 'var(--text-base)',
46
+ 'lg': 'var(--text-lg)',
47
+ 'xl': 'var(--text-xl)',
48
+ '2xl': 'var(--text-2xl)',
49
+ '3xl': 'var(--text-3xl)',
50
+ };
51
+
52
+ export const lynxLayoutPlugin = plugin(({ addUtilities }) => {
53
+ addUtilities({
54
+ // Long-form flex-fill — the Lynx-correct "take remaining space along
55
+ // the main axis" utility. Default flex direction column; consumers
56
+ // who want a horizontal fill compose with `flex-row` on the parent.
57
+ '.flex-fill': {
58
+ flexGrow: '1',
59
+ flexShrink: '1',
60
+ flexBasis: '0',
61
+ minHeight: '0',
62
+ display: 'flex',
63
+ flexDirection: 'column',
64
+ },
65
+ });
66
+ });
67
+
68
+ /** The composed neutral preset — what DS presets spread. */
69
+ export const zeroPreset: Partial<Config> = {
70
+ theme: {
71
+ extend: {
72
+ colors: contractColors,
73
+ fontSize: contractFontSizes,
74
+ },
75
+ },
76
+ plugins: [lynxLayoutPlugin],
77
+ };
@@ -0,0 +1,6 @@
1
+ // Shared press-feedback defaults applied across interactive components in
2
+ // every design system. Lynx has no CSS `:active` support, so press feedback
3
+ // comes from `<Pressable>` (in `@sigx/lynx-gestures`) flipping inline
4
+ // opacity/transform on the main thread.
5
+ export const PRESSED_SCALE = 0.97;
6
+ export const PRESSED_OPACITY = 0.85;
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Box-model style helpers shared by layout primitives and design-system
3
+ * components. Color values resolve through the semantic token contract
4
+ * (`resolveColorToken`), so `<Col background="base-100">` works identically
5
+ * under every design system's active theme.
6
+ */
7
+ import { resolveColorToken, type BackgroundValue } from '../contract.js';
8
+
9
+ export type SpacingValue = number | {
10
+ x?: number;
11
+ y?: number;
12
+ top?: number;
13
+ right?: number;
14
+ bottom?: number;
15
+ left?: number;
16
+ };
17
+
18
+ export interface BoxProps {
19
+ width?: number | string;
20
+ height?: number | string;
21
+ flex?: number;
22
+ background?: BackgroundValue;
23
+ borderRadius?: number;
24
+ padding?: SpacingValue;
25
+ margin?: SpacingValue;
26
+ }
27
+
28
+ export function resolveSpacing(
29
+ value: SpacingValue | undefined,
30
+ prefix: 'padding' | 'margin'
31
+ ): Record<string, number> {
32
+ if (value === undefined) return {};
33
+
34
+ if (typeof value === 'number') {
35
+ return {
36
+ [`${prefix}Top`]: value,
37
+ [`${prefix}Right`]: value,
38
+ [`${prefix}Bottom`]: value,
39
+ [`${prefix}Left`]: value,
40
+ };
41
+ }
42
+
43
+ const style: Record<string, number> = {};
44
+
45
+ if (value.top !== undefined) style[`${prefix}Top`] = value.top;
46
+ else if (value.y !== undefined) style[`${prefix}Top`] = value.y;
47
+
48
+ if (value.bottom !== undefined) style[`${prefix}Bottom`] = value.bottom;
49
+ else if (value.y !== undefined) style[`${prefix}Bottom`] = value.y;
50
+
51
+ if (value.right !== undefined) style[`${prefix}Right`] = value.right;
52
+ else if (value.x !== undefined) style[`${prefix}Right`] = value.x;
53
+
54
+ if (value.left !== undefined) style[`${prefix}Left`] = value.left;
55
+ else if (value.x !== undefined) style[`${prefix}Left`] = value.x;
56
+
57
+ return style;
58
+ }
59
+
60
+ export function resolveBoxStyle(props: BoxProps): Record<string, unknown> {
61
+ const style: Record<string, unknown> = {};
62
+
63
+ if (props.width !== undefined) style.width = props.width;
64
+ if (props.height !== undefined) style.height = props.height;
65
+ if (props.flex !== undefined) {
66
+ // Lynx (like React Native) expands `flex: n` shorthand to
67
+ // `flex: n n auto`, where `flexBasis: 'auto'` means "size to content
68
+ // first" — which collapses the layout chain. Write the long-form so
69
+ // `<Center flex={1}>` etc. actually fill remaining space.
70
+ style.flexGrow = props.flex;
71
+ style.flexShrink = 1;
72
+ style.flexBasis = 0;
73
+ style.minHeight = 0;
74
+ }
75
+ if (props.background !== undefined) style.backgroundColor = resolveColorToken(props.background);
76
+ if (props.borderRadius !== undefined) style.borderRadius = props.borderRadius;
77
+
78
+ Object.assign(style, resolveSpacing(props.padding, 'padding'));
79
+ Object.assign(style, resolveSpacing(props.margin, 'margin'));
80
+
81
+ return style;
82
+ }
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Headless tabs selection — the shared behavior behind every design system's
3
+ * `Tabs`/`Tab` pair (extracted once daisy and hero both duplicated it; the
4
+ * #219 pilot was the evidence gate).
5
+ *
6
+ * The DS's `Tabs` container provides a `TabsSelection` built from its
7
+ * `activeTab`/`onChange` props; each `Tab` injects it to derive its active
8
+ * state from its `value` and to report presses. Explicit per-tab
9
+ * `active`/`onPress` props take precedence in the DS components, so the
10
+ * fully-controlled per-tab style keeps working.
11
+ *
12
+ * Reactivity: `provideTabsSelection` is called once at the container's setup
13
+ * with *getters* into the container's reactive props, so `isActive()` reads
14
+ * track the current `activeTab` value on every render.
15
+ */
16
+ import { defineInjectable, defineProvide } from '@sigx/lynx';
17
+
18
+ export interface TabsSelection {
19
+ /** Whether the tab with this `value` is the selected one. Reactive. */
20
+ isActive(value: string): boolean;
21
+ /** Report a press on the tab with this `value` (drives `onChange`). */
22
+ select(value: string): void;
23
+ }
24
+
25
+ const NO_SELECTION: TabsSelection = {
26
+ isActive: () => false,
27
+ select: () => {},
28
+ };
29
+
30
+ /**
31
+ * Inject the nearest enclosing `Tabs` container's selection. Outside any
32
+ * container this resolves to an inert selection (never active, presses
33
+ * no-op), so a bare `Tab` driven purely by `active`/`onPress` still works.
34
+ */
35
+ export const useTabsSelection = defineInjectable<TabsSelection>(() => NO_SELECTION);
36
+
37
+ /**
38
+ * Provide a selection for the subtree. Call from the DS `Tabs` container's
39
+ * setup with getters into its reactive props:
40
+ *
41
+ * ```ts
42
+ * provideTabsSelection(
43
+ * () => props.activeTab,
44
+ * (v) => props.onChange?.(v),
45
+ * );
46
+ * ```
47
+ */
48
+ export function provideTabsSelection(
49
+ getActive: () => string | undefined,
50
+ onSelect: (value: string) => void,
51
+ ): void {
52
+ const selection: TabsSelection = {
53
+ isActive: (value) => getActive() === value,
54
+ select: onSelect,
55
+ };
56
+ defineProvide(useTabsSelection, () => selection);
57
+ }
@@ -0,0 +1,98 @@
1
+ /* Theme-agnostic structural design tokens.
2
+ *
3
+ * Theme COLORS come from the theme registry (seeded by the design-system package) and are
4
+ * applied as inline CSS custom properties by <ThemeProvider>. These
5
+ * radius / sizing / component tokens are identical across themes, so they
6
+ * ship once here under the `.lynx-zero` base class that <ThemeProvider> puts on
7
+ * its host view; CSS inheritance propagates them to every descendant. A theme
8
+ * may still override roundness via its `radius` field. */
9
+
10
+ .lynx-zero {
11
+ /* ── Roundness (DaisyUI v5 contract) ── */
12
+ --radius-selector: 8px;
13
+ --radius-field: 8px;
14
+ --radius-box: 16px;
15
+
16
+ /* ── Base size units (DaisyUI v5 contract) ──
17
+ * A theme's `sizes` ({ field, selector }) overrides these; <ThemeProvider>
18
+ * re-derives the component dimensions below from them in JS. We deliberately
19
+ * do NOT use `calc(var() * n)` in CSS — it's unproven in Lynx's runtime CSS
20
+ * engine. Defaults below are base 4px × the per-token multiples shown. */
21
+ --size-selector: 4px;
22
+ --size-field: 4px;
23
+
24
+ /* ── Field sizing scale (button / input / select) — field × 6/8/12/16 ── */
25
+ --size-xs: 24px;
26
+ --size-sm: 32px;
27
+ --size-md: 48px;
28
+ --size-lg: 64px;
29
+
30
+ /* ── Text ramp (public <Text> / <Heading> sizes) ──
31
+ * The xs→3xl scale the `text-*` utilities resolve to (the daisy preset maps
32
+ * Tailwind's fontSize keys onto these vars). Literal px so they resolve on
33
+ * the first paint, like every other structural token. Anchored on a 17px
34
+ * base — the iOS HIG Body size, so bare <Text> (the default) reads as native
35
+ * body — and stepped as an even ~1.2 modular scale (each step ≈1.17–1.21×).
36
+ *
37
+ * The controller's `fontScale` multiplies this ramp app-wide; <ThemeProvider>
38
+ * re-emits the literals in JS (no `calc(var() * n)` — unproven in Lynx).
39
+ * NOTE: keep in sync with FONT_DEFAULTS in theme/ThemeProvider.tsx. */
40
+ --text-xs: 12px;
41
+ --text-sm: 14px;
42
+ --text-base: 17px;
43
+ --text-lg: 20px;
44
+ --text-xl: 24px;
45
+ --text-2xl: 28px;
46
+ --text-3xl: 34px;
47
+
48
+ /* ── Font sizes (control-internal: button / input / badge labels) ──
49
+ * A separate axis from the text ramp above and deliberately NOT scaled with
50
+ * it — control chrome stays fixed. Kept as independent literals (no
51
+ * var→var indirection; unproven in Lynx) even though values mirror the ramp. */
52
+ --font-xs: 12px;
53
+ --font-sm: 14px;
54
+ --font-md: 14px;
55
+ --font-lg: 18px;
56
+
57
+ /* ── Spacing ── */
58
+ --padding-btn-xs: 8px;
59
+ --padding-btn-sm: 12px;
60
+ --padding-btn-md: 16px;
61
+ --padding-btn-lg: 24px;
62
+ --padding-box: 16px;
63
+ --padding-box-compact: 8px;
64
+ --gap-box: 8px;
65
+
66
+ /* ── Borders ── */
67
+ --border-btn: 1px;
68
+ --border-card: 1px;
69
+
70
+ /* ── Selector-driven sizes (checkbox / toggle / badge) — selector × the
71
+ * multiples shown; <ThemeProvider> re-derives these from `sizes.selector`. ── */
72
+ --checkbox-xs: 16px; /* ×4 */
73
+ --checkbox-sm: 20px; /* ×5 */
74
+ --checkbox-md: 24px; /* ×6 */
75
+ --checkbox-lg: 32px; /* ×8 */
76
+ --toggle-width-xs: 32px; /* ×8 */
77
+ --toggle-width-sm: 40px; /* ×10 */
78
+ --toggle-width-md: 48px; /* ×12 */
79
+ --toggle-width-lg: 56px; /* ×14 */
80
+ --toggle-height-xs: 24px; /* ×6 */
81
+ --toggle-height-sm: 24px; /* ×6 */
82
+ --toggle-height-md: 28px; /* ×7 */
83
+ --toggle-height-lg: 32px; /* ×8 */
84
+ --toggle-thumb-xs: 16px; /* ×4 */
85
+ --toggle-thumb-sm: 16px; /* ×4 */
86
+ --toggle-thumb-md: 20px; /* ×5 */
87
+ --toggle-thumb-lg: 24px; /* ×6 */
88
+ --badge-xs: 16px; /* ×4 */
89
+ --badge-sm: 20px; /* ×5 */
90
+ --badge-md: 24px; /* ×6 */
91
+ --badge-lg: 32px; /* ×8 */
92
+ --step-indicator: 32px;
93
+ --progress-height: 8px;
94
+ --modal-max-width: 400px;
95
+
96
+ /* ── Opacity ── */
97
+ --disabled-opacity: 0.5;
98
+ }