@sigx/lynx-daisyui 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/buttons/Button.js +53 -0
  2. package/dist/data/Avatar.js +46 -0
  3. package/dist/feedback/Alert.js +13 -0
  4. package/dist/feedback/Badge.js +17 -0
  5. package/dist/feedback/Loading.js +16 -0
  6. package/dist/feedback/Modal.js +23 -0
  7. package/dist/feedback/Progress.js +17 -0
  8. package/dist/feedback/Skeleton.js +18 -0
  9. package/dist/feedback/Steps.js +16 -0
  10. package/dist/forms/Checkbox.js +32 -0
  11. package/dist/forms/FormField.js +5 -0
  12. package/dist/forms/Input.js +25 -0
  13. package/dist/forms/Radio.js +28 -0
  14. package/dist/forms/Select.js +33 -0
  15. package/dist/forms/Textarea.js +31 -0
  16. package/dist/forms/Toggle.js +32 -0
  17. package/dist/index.d.ts +60 -58
  18. package/dist/index.js +38 -678
  19. package/dist/layout/Card.js +39 -0
  20. package/dist/layout/Center.d.ts +2 -1
  21. package/dist/layout/Center.js +24 -0
  22. package/dist/layout/Col.d.ts +2 -2
  23. package/dist/layout/Col.js +33 -0
  24. package/dist/layout/Divider.js +27 -0
  25. package/dist/layout/Row.d.ts +2 -2
  26. package/dist/layout/Row.js +33 -0
  27. package/dist/layout/ScrollView.js +18 -0
  28. package/dist/layout/Spacer.js +11 -0
  29. package/dist/navigation/NavHeader.js +62 -0
  30. package/dist/navigation/NavTabBar.js +58 -0
  31. package/dist/navigation/Tabs.js +18 -0
  32. package/dist/preset/index.js +66 -40
  33. package/dist/shared/press.d.ts +2 -0
  34. package/dist/shared/press.js +6 -0
  35. package/dist/shared/styles.d.ts +29 -1
  36. package/dist/shared/styles.js +90 -0
  37. package/dist/theme/ThemeProvider.js +83 -0
  38. package/dist/typography/Heading.js +19 -0
  39. package/dist/typography/Text.d.ts +11 -1
  40. package/dist/typography/Text.js +25 -0
  41. package/package.json +8 -9
  42. package/dist/index.js.map +0 -1
  43. package/dist/preset/index.js.map +0 -1
@@ -0,0 +1,39 @@
1
+ import { jsx as _jsx } from "@sigx/lynx/jsx-runtime";
2
+ import { component, compound } from '@sigx/lynx';
3
+ const _Card = component(({ props, slots }) => {
4
+ const getClasses = () => {
5
+ const c = ['card'];
6
+ if (props.bordered)
7
+ c.push('card-bordered');
8
+ if (props.compact)
9
+ c.push('card-compact');
10
+ if (props.shadow === true)
11
+ c.push('shadow-md');
12
+ else if (props.shadow === 'sm')
13
+ c.push('shadow-sm');
14
+ else if (props.shadow === 'md')
15
+ c.push('shadow-md');
16
+ else if (props.shadow === 'lg')
17
+ c.push('shadow-lg');
18
+ else if (props.shadow === undefined)
19
+ c.push('shadow-md');
20
+ if (props.class)
21
+ c.push(props.class);
22
+ return c.join(' ');
23
+ };
24
+ return () => _jsx("view", { class: getClasses(), children: slots.default?.() });
25
+ });
26
+ const CardBody = component(({ props, slots }) => {
27
+ return () => (_jsx("view", { class: `card-body${props.class ? ' ' + props.class : ''}`, children: slots.default?.() }));
28
+ });
29
+ const CardTitle = component(({ props, slots }) => {
30
+ return () => (_jsx("text", { class: `card-title${props.class ? ' ' + props.class : ''}`, children: slots.default?.() }));
31
+ });
32
+ const CardActions = component(({ props, slots }) => {
33
+ return () => (_jsx("view", { class: `card-actions${props.class ? ' ' + props.class : ''}`, children: slots.default?.() }));
34
+ });
35
+ export const Card = compound(_Card, {
36
+ Body: CardBody,
37
+ Title: CardTitle,
38
+ Actions: CardActions,
39
+ });
@@ -1,5 +1,6 @@
1
1
  import { type Define } from '@sigx/lynx';
2
- export type CenterProps = Define.Prop<'width', number | string, false> & Define.Prop<'height', number | string, false> & Define.Prop<'flex', number, false> & Define.Prop<'background', string, false> & Define.Prop<'borderRadius', number, false> & Define.Prop<'class', string, false> & Define.Slot<'default'>;
2
+ import { type BackgroundValue } from '../shared/styles.js';
3
+ export type CenterProps = Define.Prop<'width', number | string, false> & Define.Prop<'height', number | string, false> & Define.Prop<'flex', number, false> & Define.Prop<'background', BackgroundValue, false> & Define.Prop<'borderRadius', number, false> & Define.Prop<'class', string, false> & Define.Slot<'default'>;
3
4
  export declare const Center: import("@sigx/runtime-core").ComponentFactory<CenterProps, void, {
4
5
  default: () => import("@sigx/runtime-core").JSXElement | import("@sigx/runtime-core").JSXElement[] | null;
5
6
  }>;
@@ -0,0 +1,24 @@
1
+ import { jsx as _jsx } from "@sigx/lynx/jsx-runtime";
2
+ import { component } from '@sigx/lynx';
3
+ import { resolveBoxStyle } from '../shared/styles.js';
4
+ export const Center = component(({ props, slots }) => {
5
+ const getStyle = () => {
6
+ const style = {
7
+ display: 'flex',
8
+ justifyContent: 'center',
9
+ alignItems: 'center',
10
+ };
11
+ const box = resolveBoxStyle({
12
+ width: props.width,
13
+ height: props.height,
14
+ flex: props.flex,
15
+ background: props.background,
16
+ borderRadius: props.borderRadius,
17
+ });
18
+ for (const key in box) {
19
+ style[key] = box[key];
20
+ }
21
+ return style;
22
+ };
23
+ return () => (_jsx("view", { class: props.class, style: getStyle(), children: slots.default?.() }));
24
+ });
@@ -1,6 +1,6 @@
1
1
  import { type Define } from '@sigx/lynx';
2
- import { type SpacingValue } from '../shared/styles';
3
- export type ColProps = Define.Prop<'gap', number, false> & Define.Prop<'align', 'flex-start' | 'center' | 'flex-end' | 'stretch' | 'baseline', false> & Define.Prop<'justify', 'flex-start' | 'center' | 'flex-end' | 'space-between' | 'space-around' | 'space-evenly', false> & Define.Prop<'wrap', boolean, false> & Define.Prop<'padding', SpacingValue, false> & Define.Prop<'margin', SpacingValue, false> & Define.Prop<'width', number | string, false> & Define.Prop<'height', number | string, false> & Define.Prop<'flex', number, false> & Define.Prop<'background', string, false> & Define.Prop<'borderRadius', number, false> & Define.Prop<'class', string, false> & Define.Slot<'default'>;
2
+ import { type SpacingValue, type BackgroundValue } from '../shared/styles.js';
3
+ export type ColProps = Define.Prop<'gap', number, false> & Define.Prop<'align', 'flex-start' | 'center' | 'flex-end' | 'stretch' | 'baseline', false> & Define.Prop<'justify', 'flex-start' | 'center' | 'flex-end' | 'space-between' | 'space-around' | 'space-evenly', false> & Define.Prop<'wrap', boolean, false> & Define.Prop<'padding', SpacingValue, false> & Define.Prop<'margin', SpacingValue, false> & Define.Prop<'width', number | string, false> & Define.Prop<'height', number | string, false> & Define.Prop<'flex', number, false> & Define.Prop<'background', BackgroundValue, false> & Define.Prop<'borderRadius', number, false> & Define.Prop<'class', string, false> & Define.Slot<'default'>;
4
4
  export declare const Col: import("@sigx/runtime-core").ComponentFactory<ColProps, void, {
5
5
  default: () => import("@sigx/runtime-core").JSXElement | import("@sigx/runtime-core").JSXElement[] | null;
6
6
  }>;
@@ -0,0 +1,33 @@
1
+ import { jsx as _jsx } from "@sigx/lynx/jsx-runtime";
2
+ import { component } from '@sigx/lynx';
3
+ import { resolveBoxStyle } from '../shared/styles.js';
4
+ export const Col = component(({ props, slots }) => {
5
+ const getStyle = () => {
6
+ const style = {
7
+ display: 'flex',
8
+ flexDirection: 'column',
9
+ };
10
+ if (props.gap !== undefined)
11
+ style.gap = props.gap;
12
+ if (props.align)
13
+ style.alignItems = props.align;
14
+ if (props.justify)
15
+ style.justifyContent = props.justify;
16
+ if (props.wrap)
17
+ style.flexWrap = 'wrap';
18
+ const box = resolveBoxStyle({
19
+ width: props.width,
20
+ height: props.height,
21
+ flex: props.flex,
22
+ background: props.background,
23
+ borderRadius: props.borderRadius,
24
+ padding: props.padding,
25
+ margin: props.margin,
26
+ });
27
+ for (const key in box) {
28
+ style[key] = box[key];
29
+ }
30
+ return style;
31
+ };
32
+ return () => (_jsx("view", { class: props.class, style: getStyle(), children: slots.default?.() }));
33
+ });
@@ -0,0 +1,27 @@
1
+ import { jsx as _jsx } from "@sigx/lynx/jsx-runtime";
2
+ import { component } from '@sigx/lynx';
3
+ export const Divider = component(({ props }) => {
4
+ const getClasses = () => {
5
+ const c = [props.vertical ? 'divider-vertical' : 'divider'];
6
+ if (props.class)
7
+ c.push(props.class);
8
+ return c.join(' ');
9
+ };
10
+ const getStyle = () => {
11
+ const style = {};
12
+ if (props.color)
13
+ style.backgroundColor = props.color;
14
+ if (props.margin !== undefined) {
15
+ if (props.vertical) {
16
+ style.marginLeft = props.margin;
17
+ style.marginRight = props.margin;
18
+ }
19
+ else {
20
+ style.marginTop = props.margin;
21
+ style.marginBottom = props.margin;
22
+ }
23
+ }
24
+ return style;
25
+ };
26
+ return () => (_jsx("view", { class: getClasses(), style: getStyle() }));
27
+ });
@@ -1,6 +1,6 @@
1
1
  import { type Define } from '@sigx/lynx';
2
- import { type SpacingValue } from '../shared/styles';
3
- export type RowProps = Define.Prop<'gap', number, false> & Define.Prop<'align', 'flex-start' | 'center' | 'flex-end' | 'stretch' | 'baseline', false> & Define.Prop<'justify', 'flex-start' | 'center' | 'flex-end' | 'space-between' | 'space-around' | 'space-evenly', false> & Define.Prop<'wrap', boolean, false> & Define.Prop<'padding', SpacingValue, false> & Define.Prop<'margin', SpacingValue, false> & Define.Prop<'width', number | string, false> & Define.Prop<'height', number | string, false> & Define.Prop<'flex', number, false> & Define.Prop<'background', string, false> & Define.Prop<'borderRadius', number, false> & Define.Prop<'class', string, false> & Define.Slot<'default'>;
2
+ import { type SpacingValue, type BackgroundValue } from '../shared/styles.js';
3
+ export type RowProps = Define.Prop<'gap', number, false> & Define.Prop<'align', 'flex-start' | 'center' | 'flex-end' | 'stretch' | 'baseline', false> & Define.Prop<'justify', 'flex-start' | 'center' | 'flex-end' | 'space-between' | 'space-around' | 'space-evenly', false> & Define.Prop<'wrap', boolean, false> & Define.Prop<'padding', SpacingValue, false> & Define.Prop<'margin', SpacingValue, false> & Define.Prop<'width', number | string, false> & Define.Prop<'height', number | string, false> & Define.Prop<'flex', number, false> & Define.Prop<'background', BackgroundValue, false> & Define.Prop<'borderRadius', number, false> & Define.Prop<'class', string, false> & Define.Slot<'default'>;
4
4
  export declare const Row: import("@sigx/runtime-core").ComponentFactory<RowProps, void, {
5
5
  default: () => import("@sigx/runtime-core").JSXElement | import("@sigx/runtime-core").JSXElement[] | null;
6
6
  }>;
@@ -0,0 +1,33 @@
1
+ import { jsx as _jsx } from "@sigx/lynx/jsx-runtime";
2
+ import { component } from '@sigx/lynx';
3
+ import { resolveBoxStyle } from '../shared/styles.js';
4
+ export const Row = component(({ props, slots }) => {
5
+ const getStyle = () => {
6
+ const style = {
7
+ display: 'flex',
8
+ flexDirection: 'row',
9
+ };
10
+ if (props.gap !== undefined)
11
+ style.gap = props.gap;
12
+ if (props.align)
13
+ style.alignItems = props.align;
14
+ if (props.justify)
15
+ style.justifyContent = props.justify;
16
+ if (props.wrap)
17
+ style.flexWrap = 'wrap';
18
+ const box = resolveBoxStyle({
19
+ width: props.width,
20
+ height: props.height,
21
+ flex: props.flex,
22
+ background: props.background,
23
+ borderRadius: props.borderRadius,
24
+ padding: props.padding,
25
+ margin: props.margin,
26
+ });
27
+ for (const key in box) {
28
+ style[key] = box[key];
29
+ }
30
+ return style;
31
+ };
32
+ return () => (_jsx("view", { class: props.class, style: getStyle(), children: slots.default?.() }));
33
+ });
@@ -0,0 +1,18 @@
1
+ import { jsx as _jsx } from "@sigx/lynx/jsx-runtime";
2
+ import { component } from '@sigx/lynx';
3
+ export const ScrollView = component(({ props, slots }) => {
4
+ const getStyle = () => {
5
+ const style = {};
6
+ if (props.height !== undefined)
7
+ style.height = props.height;
8
+ if (props.width !== undefined)
9
+ style.width = props.width;
10
+ if (props.flex !== undefined)
11
+ style.flex = props.flex;
12
+ return style;
13
+ };
14
+ return () => {
15
+ const dir = props.direction ?? 'vertical';
16
+ return (_jsx("scroll-view", { class: props.class, style: getStyle(), "scroll-orientation": dir, "scroll-y": dir === 'vertical' ? true : undefined, "scroll-x": dir === 'horizontal' ? true : undefined, "show-scrollbar": props.showScrollbar, bounces: props.bounces, children: slots.default?.() }));
17
+ };
18
+ });
@@ -0,0 +1,11 @@
1
+ import { jsx as _jsx } from "@sigx/lynx/jsx-runtime";
2
+ import { component } from '@sigx/lynx';
3
+ export const Spacer = component(({ props }) => {
4
+ const getStyle = () => {
5
+ if (props.size !== undefined) {
6
+ return { width: props.size, height: props.size };
7
+ }
8
+ return { flex: 1 };
9
+ };
10
+ return () => (_jsx("view", { class: props.class, style: getStyle() }));
11
+ });
@@ -0,0 +1,62 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "@sigx/lynx/jsx-runtime";
2
+ /**
3
+ * `<NavHeader>` — daisy-themed header bar for `@sigx/lynx-navigation`.
4
+ *
5
+ * Pairs with `<Stack>` from `@sigx/lynx-navigation`:
6
+ *
7
+ * ```tsx
8
+ * <Stack initialRoute="tripsHome">
9
+ * <NavHeader />
10
+ * </Stack>
11
+ * ```
12
+ *
13
+ * Reads the focused screen's options + slot fills via
14
+ * `useScreenChrome()`, applies daisy theming (base-200 surface, bottom
15
+ * separator, native-ish horizontal layout with centred title).
16
+ *
17
+ * The navigation package's own `<Header />` is intentionally headless —
18
+ * no flex-row, no padding, no theme — for consumers who want to do all
19
+ * styling themselves. This component is the batteries-included variant
20
+ * for daisyui consumers.
21
+ */
22
+ import { component } from '@sigx/lynx';
23
+ import { Pressable } from '@sigx/lynx-gestures';
24
+ import { useScreenChrome } from '@sigx/lynx-navigation';
25
+ import { PRESSED_SCALE, PRESSED_OPACITY } from '../shared/press.js';
26
+ const backgroundClass = {
27
+ 'base-100': 'bg-base-100',
28
+ 'base-200': 'bg-base-200',
29
+ 'base-300': 'bg-base-300',
30
+ 'transparent': '',
31
+ };
32
+ export const NavHeader = component(({ props }) => {
33
+ const chrome = useScreenChrome();
34
+ return () => {
35
+ if (!chrome.headerShown)
36
+ return null;
37
+ // Full override: <Screen.Header> rendered.
38
+ const override = chrome.header;
39
+ if (override)
40
+ return override();
41
+ const bg = backgroundClass[props.background ?? 'base-200'];
42
+ const bordered = props.bordered ?? true;
43
+ const borderClass = bordered ? 'border-b border-base-300' : '';
44
+ const containerClass = [
45
+ 'flex flex-row items-center px-3',
46
+ 'h-12', // ~48dp / standard nav bar height
47
+ bg,
48
+ borderClass,
49
+ ].filter(Boolean).join(' ');
50
+ const left = chrome.headerLeft?.()
51
+ ?? (chrome.canGoBack
52
+ ? (props.renderBack
53
+ ? props.renderBack({ pop: chrome.pop })
54
+ : _jsx(DefaultBackButton, { onPress: chrome.pop }))
55
+ : null);
56
+ const right = chrome.headerRight?.() ?? null;
57
+ return (_jsxs("view", { class: containerClass, children: [_jsx("view", { class: "flex flex-row items-center", style: { minWidth: 56 }, children: left }), _jsx("view", { class: "flex-1 items-center justify-center", children: _jsx("text", { class: "text-base-content text-base font-semibold", children: chrome.title }) }), _jsx("view", { class: "flex flex-row items-center justify-end", style: { minWidth: 56 }, children: right })] }));
58
+ };
59
+ });
60
+ const DefaultBackButton = component(({ props }) => {
61
+ return () => (_jsx(Pressable, { class: "px-2 py-2", pressedScale: PRESSED_SCALE, pressedOpacity: PRESSED_OPACITY, longPressDuration: 0, "accessibility-element": true, "accessibility-label": "Back", "accessibility-trait": "button", onPress: () => props.onPress(), children: _jsx("text", { class: "text-primary text-base", children: "\u2039 Back" }) }));
62
+ });
@@ -0,0 +1,58 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "@sigx/lynx/jsx-runtime";
2
+ /**
3
+ * `<NavTabBar>` — daisy-themed tab bar for `@sigx/lynx-navigation`.
4
+ *
5
+ * Pairs with `<Tabs>` + `<Tabs.Screen>` from `@sigx/lynx-navigation`:
6
+ * subscribes to `useTabs()` for the active tab + tab list, dispatches
7
+ * tab changes via `setActive`. Pure UI / styling; the navigation
8
+ * package owns state.
9
+ *
10
+ * Default visual treatment: bottom navigation bar — base-200 background,
11
+ * top separator line, active label in primary color.
12
+ *
13
+ * Use the standalone daisy `<Tabs>` / `<Tab>` (also exported from this
14
+ * package) instead when you want generic tab UI not driven by navigation
15
+ * state (e.g. segmented controls inside a settings panel).
16
+ */
17
+ import { component } from '@sigx/lynx';
18
+ import { Pressable } from '@sigx/lynx-gestures';
19
+ import { useTabs } from '@sigx/lynx-navigation';
20
+ import { PRESSED_SCALE, PRESSED_OPACITY } from '../shared/press.js';
21
+ const backgroundClass = {
22
+ 'base-100': 'bg-base-100',
23
+ 'base-200': 'bg-base-200',
24
+ 'base-300': 'bg-base-300',
25
+ 'transparent': '',
26
+ };
27
+ export const NavTabBar = component(({ props }) => {
28
+ const nav = useTabs();
29
+ return () => {
30
+ const tabs = nav.tabs;
31
+ const active = nav.active;
32
+ const renderer = props.renderTab;
33
+ const position = props.position ?? 'bottom';
34
+ const bg = backgroundClass[props.background ?? 'base-200'];
35
+ const bordered = props.bordered ?? true;
36
+ // Bottom tab bar → top border. Top tab bar → bottom border.
37
+ const borderClass = bordered
38
+ ? (position === 'bottom' ? 'border-t border-base-300' : 'border-b border-base-300')
39
+ : '';
40
+ const containerClass = ['flex flex-row', bg, borderClass].filter(Boolean).join(' ');
41
+ return (_jsx("view", { "accessibility-element": false, class: containerClass, children: tabs.map((info) => {
42
+ const isActive = info.name === active;
43
+ const onPress = () => nav.setActive(info.name);
44
+ if (renderer) {
45
+ return renderer(info, { active: isActive, onPress });
46
+ }
47
+ return (_jsx(DefaultNavTab, { info: info, active: isActive, onPress: onPress }));
48
+ }) }));
49
+ };
50
+ });
51
+ const DefaultNavTab = component(({ props }) => {
52
+ return () => {
53
+ const label = props.info.label ?? props.info.name;
54
+ const a11y = props.info.accessibilityLabel ?? label;
55
+ const textColor = props.active ? 'text-primary font-semibold' : 'text-base-content opacity-60';
56
+ return (_jsxs(Pressable, { class: "flex-1 items-center justify-center py-3", pressedScale: PRESSED_SCALE, pressedOpacity: PRESSED_OPACITY, longPressDuration: 0, "accessibility-element": true, "accessibility-label": a11y, "accessibility-trait": "button", "accessibility-status": props.active ? 'selected' : undefined, onPress: () => props.onPress(), children: [props.info.icon ?? null, _jsx("text", { class: `text-sm ${textColor}`, children: label })] }));
57
+ };
58
+ });
@@ -0,0 +1,18 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "@sigx/lynx/jsx-runtime";
2
+ import { component, compound } from '@sigx/lynx';
3
+ import { Pressable } from '@sigx/lynx-gestures';
4
+ import { PRESSED_SCALE, PRESSED_OPACITY } from '../shared/press.js';
5
+ const _Tabs = component(({ props, slots }) => {
6
+ return () => (_jsx("view", { class: `tabs${props.class ? ' ' + props.class : ''}`, children: slots.default?.() }));
7
+ });
8
+ const Tab = component(({ props, slots }) => {
9
+ return () => {
10
+ const isActive = props.active ?? false;
11
+ return (_jsxs(Pressable, { class: `tab${isActive ? ' tab-active' : ''}${props.class ? ' ' + props.class : ''}`, pressedScale: PRESSED_SCALE, pressedOpacity: PRESSED_OPACITY, longPressDuration: 0, onPress: () => {
12
+ props.onPress?.();
13
+ }, children: [slots.default?.(), props.label ? _jsx("text", { children: props.label }) : null] }));
14
+ };
15
+ });
16
+ export const Tabs = compound(_Tabs, {
17
+ Tab,
18
+ });
@@ -1,40 +1,66 @@
1
- import e from "tailwindcss/plugin";
2
- //#region src/preset/index.ts
3
- var t = {
4
- primary: "var(--color-primary)",
5
- "primary-content": "var(--color-primary-content)",
6
- secondary: "var(--color-secondary)",
7
- "secondary-content": "var(--color-secondary-content)",
8
- accent: "var(--color-accent)",
9
- "accent-content": "var(--color-accent-content)",
10
- neutral: "var(--color-neutral)",
11
- "neutral-content": "var(--color-neutral-content)",
12
- "base-100": "var(--color-base-100)",
13
- "base-200": "var(--color-base-200)",
14
- "base-300": "var(--color-base-300)",
15
- "base-content": "var(--color-base-content)",
16
- info: "var(--color-info)",
17
- "info-content": "var(--color-info-content)",
18
- success: "var(--color-success)",
19
- "success-content": "var(--color-success-content)",
20
- warning: "var(--color-warning)",
21
- "warning-content": "var(--color-warning-content)",
22
- error: "var(--color-error)",
23
- "error-content": "var(--color-error-content)"
24
- }, n = e(({ addUtilities: e }) => {
25
- e({ ".flex-fill": {
26
- flexGrow: "1",
27
- flexShrink: "1",
28
- flexBasis: "0",
29
- minHeight: "0",
30
- display: "flex",
31
- flexDirection: "column"
32
- } });
33
- }), r = {
34
- theme: { extend: { colors: t } },
35
- plugins: [n]
36
- }, i = r;
37
- //#endregion
38
- export { r as DaisyLynxPreset, i as daisyuiPreset };
39
-
40
- //# sourceMappingURL=index.js.map
1
+ import plugin from 'tailwindcss/plugin';
2
+ /**
3
+ * DaisyUI Lynx Tailwind Preset
4
+ *
5
+ * Maps DaisyUI semantic color tokens to CSS custom properties
6
+ * defined in @sigx/lynx-daisyui/styles. Consumers add this
7
+ * preset to their tailwind.config.ts so utilities like
8
+ * `bg-primary` and `text-base-content` resolve to our tokens.
9
+ *
10
+ * Also ships a `flex-fill` utility — the Lynx-correct "fill remaining
11
+ * space" class. Why this is in our preset rather than baked into Lynx's
12
+ * own tailwind preset: in Lynx (like React Native) `flex: 1` shorthand
13
+ * expands to `flex: 1 1 auto`, where `flexBasis: 'auto'` sizes the box
14
+ * to its content first, collapsing the layout chain. The browser-CSS
15
+ * intuition that `flex-1` = "fill remaining space" is wrong here, and
16
+ * Tailwind's own `flex-1` class expands to the same broken shorthand.
17
+ * `flex-fill` writes the long-form properties directly so the result
18
+ * actually fills.
19
+ */
20
+ const daisyColors = {
21
+ 'primary': 'var(--color-primary)',
22
+ 'primary-content': 'var(--color-primary-content)',
23
+ 'secondary': 'var(--color-secondary)',
24
+ 'secondary-content': 'var(--color-secondary-content)',
25
+ 'accent': 'var(--color-accent)',
26
+ 'accent-content': 'var(--color-accent-content)',
27
+ 'neutral': 'var(--color-neutral)',
28
+ 'neutral-content': 'var(--color-neutral-content)',
29
+ 'base-100': 'var(--color-base-100)',
30
+ 'base-200': 'var(--color-base-200)',
31
+ 'base-300': 'var(--color-base-300)',
32
+ 'base-content': 'var(--color-base-content)',
33
+ 'info': 'var(--color-info)',
34
+ 'info-content': 'var(--color-info-content)',
35
+ 'success': 'var(--color-success)',
36
+ 'success-content': 'var(--color-success-content)',
37
+ 'warning': 'var(--color-warning)',
38
+ 'warning-content': 'var(--color-warning-content)',
39
+ 'error': 'var(--color-error)',
40
+ 'error-content': 'var(--color-error-content)',
41
+ };
42
+ const lynxLayoutPlugin = plugin(({ addUtilities }) => {
43
+ addUtilities({
44
+ // Long-form flex-fill — the Lynx-correct "take remaining space along
45
+ // the main axis" utility. Default flex direction column; consumers
46
+ // who want a horizontal fill compose with `flex-row` on the parent.
47
+ '.flex-fill': {
48
+ flexGrow: '1',
49
+ flexShrink: '1',
50
+ flexBasis: '0',
51
+ minHeight: '0',
52
+ display: 'flex',
53
+ flexDirection: 'column',
54
+ },
55
+ });
56
+ });
57
+ export const DaisyLynxPreset = {
58
+ theme: {
59
+ extend: {
60
+ colors: daisyColors,
61
+ },
62
+ },
63
+ plugins: [lynxLayoutPlugin],
64
+ };
65
+ /** Alias — preferred consumer name. */
66
+ export const daisyuiPreset = DaisyLynxPreset;
@@ -0,0 +1,2 @@
1
+ export declare const PRESSED_SCALE = 0.97;
2
+ export declare const PRESSED_OPACITY = 0.85;
@@ -0,0 +1,6 @@
1
+ // Shared press-feedback defaults applied across all interactive daisyui
2
+ // components. Lynx has no CSS `:active` support, so press feedback comes from
3
+ // `<Pressable>` (in `@sigx/lynx-gestures`) flipping inline opacity/transform
4
+ // on the main thread.
5
+ export const PRESSED_SCALE = 0.97;
6
+ export const PRESSED_OPACITY = 0.85;
@@ -1,3 +1,25 @@
1
+ /**
2
+ * DaisyUI color tokens — the set of semantic colors exposed by the
3
+ * built-in themes (`daisy-light` / `daisy-dark`) as `--color-<token>`
4
+ * CSS custom properties.
5
+ *
6
+ * Used by layout components' `background` prop so consumers can write
7
+ * `<Col background="base-100">` instead of `<Col class="bg-base-100">`
8
+ * and still get autocomplete + type safety.
9
+ *
10
+ * Single source of truth: both the `DaisyColor` union and the runtime
11
+ * `DAISY_COLOR_TOKENS` Set are derived from this tuple, so adding /
12
+ * removing a token in one place is impossible.
13
+ */
14
+ declare const DAISY_COLOR_TOKEN_LIST: readonly ['primary', 'primary-content', 'secondary', 'secondary-content', 'accent', 'accent-content', 'neutral', 'neutral-content', 'base-100', 'base-200', 'base-300', 'base-content', 'info', 'info-content', 'success', 'success-content', 'warning', 'warning-content', 'error', 'error-content'];
15
+ export type DaisyColor = (typeof DAISY_COLOR_TOKEN_LIST)[number];
16
+ /**
17
+ * Resolve a `background` prop value to a CSS color string.
18
+ *
19
+ * - Known daisyUI tokens (e.g. `'base-100'`) → `var(--color-base-100)`.
20
+ * - Anything else (`'#ffaa00'`, `'rgb(…)'`, `'var(--my-custom)'`) is passed through unchanged.
21
+ */
22
+ export declare function resolveDaisyColor(value: string): string;
1
23
  export type SpacingValue = number | {
2
24
  x?: number;
3
25
  y?: number;
@@ -6,14 +28,20 @@ export type SpacingValue = number | {
6
28
  bottom?: number;
7
29
  left?: number;
8
30
  };
31
+ /**
32
+ * Accepts a daisyUI color token (autocompleted) OR any raw CSS color
33
+ * string (`'#fff'`, `'rgb(…)'`, `'var(--foo)'`).
34
+ */
35
+ export type BackgroundValue = DaisyColor | (string & {});
9
36
  export interface BoxProps {
10
37
  width?: number | string;
11
38
  height?: number | string;
12
39
  flex?: number;
13
- background?: string;
40
+ background?: BackgroundValue;
14
41
  borderRadius?: number;
15
42
  padding?: SpacingValue;
16
43
  margin?: SpacingValue;
17
44
  }
18
45
  export declare function resolveSpacing(value: SpacingValue | undefined, prefix: 'padding' | 'margin'): Record<string, number>;
19
46
  export declare function resolveBoxStyle(props: BoxProps): Record<string, unknown>;
47
+ export {};
@@ -0,0 +1,90 @@
1
+ /**
2
+ * DaisyUI color tokens — the set of semantic colors exposed by the
3
+ * built-in themes (`daisy-light` / `daisy-dark`) as `--color-<token>`
4
+ * CSS custom properties.
5
+ *
6
+ * Used by layout components' `background` prop so consumers can write
7
+ * `<Col background="base-100">` instead of `<Col class="bg-base-100">`
8
+ * and still get autocomplete + type safety.
9
+ *
10
+ * Single source of truth: both the `DaisyColor` union and the runtime
11
+ * `DAISY_COLOR_TOKENS` Set are derived from this tuple, so adding /
12
+ * removing a token in one place is impossible.
13
+ */
14
+ const DAISY_COLOR_TOKEN_LIST = [
15
+ 'primary', 'primary-content',
16
+ 'secondary', 'secondary-content',
17
+ 'accent', 'accent-content',
18
+ 'neutral', 'neutral-content',
19
+ 'base-100', 'base-200', 'base-300', 'base-content',
20
+ 'info', 'info-content',
21
+ 'success', 'success-content',
22
+ 'warning', 'warning-content',
23
+ 'error', 'error-content',
24
+ ];
25
+ const DAISY_COLOR_TOKENS = new Set(DAISY_COLOR_TOKEN_LIST);
26
+ /**
27
+ * Resolve a `background` prop value to a CSS color string.
28
+ *
29
+ * - Known daisyUI tokens (e.g. `'base-100'`) → `var(--color-base-100)`.
30
+ * - Anything else (`'#ffaa00'`, `'rgb(…)'`, `'var(--my-custom)'`) is passed through unchanged.
31
+ */
32
+ export function resolveDaisyColor(value) {
33
+ return DAISY_COLOR_TOKENS.has(value)
34
+ ? `var(--color-${value})`
35
+ : value;
36
+ }
37
+ export function resolveSpacing(value, prefix) {
38
+ if (value === undefined)
39
+ return {};
40
+ if (typeof value === 'number') {
41
+ return {
42
+ [`${prefix}Top`]: value,
43
+ [`${prefix}Right`]: value,
44
+ [`${prefix}Bottom`]: value,
45
+ [`${prefix}Left`]: value,
46
+ };
47
+ }
48
+ const style = {};
49
+ if (value.top !== undefined)
50
+ style[`${prefix}Top`] = value.top;
51
+ else if (value.y !== undefined)
52
+ style[`${prefix}Top`] = value.y;
53
+ if (value.bottom !== undefined)
54
+ style[`${prefix}Bottom`] = value.bottom;
55
+ else if (value.y !== undefined)
56
+ style[`${prefix}Bottom`] = value.y;
57
+ if (value.right !== undefined)
58
+ style[`${prefix}Right`] = value.right;
59
+ else if (value.x !== undefined)
60
+ style[`${prefix}Right`] = value.x;
61
+ if (value.left !== undefined)
62
+ style[`${prefix}Left`] = value.left;
63
+ else if (value.x !== undefined)
64
+ style[`${prefix}Left`] = value.x;
65
+ return style;
66
+ }
67
+ export function resolveBoxStyle(props) {
68
+ const style = {};
69
+ if (props.width !== undefined)
70
+ style.width = props.width;
71
+ if (props.height !== undefined)
72
+ style.height = props.height;
73
+ if (props.flex !== undefined) {
74
+ // Lynx (like React Native) expands `flex: n` shorthand to
75
+ // `flex: n n auto`, where `flexBasis: 'auto'` means "size to content
76
+ // first" — which collapses the layout chain. Write the long-form so
77
+ // `<Center flex={1}>` etc. actually fill remaining space.
78
+ style.flexGrow = props.flex;
79
+ style.flexShrink = 1;
80
+ style.flexBasis = 0;
81
+ style.minHeight = 0;
82
+ }
83
+ if (props.background !== undefined)
84
+ style.backgroundColor = resolveDaisyColor(props.background);
85
+ if (props.borderRadius !== undefined)
86
+ style.borderRadius = props.borderRadius;
87
+ Object.assign(style, resolveSpacing(props.padding, 'padding'));
88
+ Object.assign(style, resolveSpacing(props.margin, 'margin'));
89
+ return style;
90
+ }