@sigx/lynx-daisyui 0.4.0 → 0.4.2

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 (59) hide show
  1. package/README.md +38 -0
  2. package/dist/buttons/Button.js +53 -0
  3. package/dist/data/Avatar.js +46 -0
  4. package/dist/feedback/Alert.js +13 -0
  5. package/dist/feedback/Badge.js +17 -0
  6. package/dist/feedback/Loading.js +16 -0
  7. package/dist/feedback/Modal.js +23 -0
  8. package/dist/feedback/Progress.js +17 -0
  9. package/dist/feedback/Skeleton.js +18 -0
  10. package/dist/feedback/Steps.js +16 -0
  11. package/dist/forms/Checkbox.js +32 -0
  12. package/dist/forms/FormField.js +5 -0
  13. package/dist/forms/Input.js +25 -0
  14. package/dist/forms/Radio.js +28 -0
  15. package/dist/forms/Select.js +33 -0
  16. package/dist/forms/Textarea.js +31 -0
  17. package/dist/forms/Toggle.js +32 -0
  18. package/dist/index.d.ts +66 -58
  19. package/dist/index.js +41 -678
  20. package/dist/layout/Card.js +39 -0
  21. package/dist/layout/Center.d.ts +2 -1
  22. package/dist/layout/Center.js +24 -0
  23. package/dist/layout/Col.d.ts +2 -2
  24. package/dist/layout/Col.js +33 -0
  25. package/dist/layout/Divider.js +27 -0
  26. package/dist/layout/Row.d.ts +2 -2
  27. package/dist/layout/Row.js +33 -0
  28. package/dist/layout/ScrollView.js +18 -0
  29. package/dist/layout/Spacer.js +11 -0
  30. package/dist/navigation/NavDrawer.d.ts +62 -0
  31. package/dist/navigation/NavDrawer.js +205 -0
  32. package/dist/navigation/NavHeader.d.ts +12 -1
  33. package/dist/navigation/NavHeader.js +74 -0
  34. package/dist/navigation/NavTabBar.js +90 -0
  35. package/dist/navigation/SwiperIndicator.d.ts +59 -0
  36. package/dist/navigation/SwiperIndicator.js +232 -0
  37. package/dist/navigation/Tabs.js +18 -0
  38. package/dist/preset/index.js +66 -40
  39. package/dist/shared/press.d.ts +2 -0
  40. package/dist/shared/press.js +6 -0
  41. package/dist/shared/styles.d.ts +29 -1
  42. package/dist/shared/styles.js +90 -0
  43. package/dist/styles/components/typography.css +36 -2
  44. package/dist/styles/index.css +8 -4
  45. package/dist/styles/themes/shapes.css +2 -1
  46. package/dist/styles/themes/{dark.css → tokens.css} +9 -33
  47. package/dist/theme/StatusBarSync.d.ts +41 -0
  48. package/dist/theme/StatusBarSync.js +85 -0
  49. package/dist/theme/ThemeProvider.d.ts +91 -35
  50. package/dist/theme/ThemeProvider.js +183 -0
  51. package/dist/theme/registry.d.ts +101 -0
  52. package/dist/theme/registry.js +185 -0
  53. package/dist/typography/Heading.js +19 -0
  54. package/dist/typography/Text.d.ts +11 -1
  55. package/dist/typography/Text.js +25 -0
  56. package/package.json +12 -10
  57. package/dist/index.js.map +0 -1
  58. package/dist/preset/index.js.map +0 -1
  59. package/dist/styles/themes/light.css +0 -95
package/README.md CHANGED
@@ -143,6 +143,44 @@ For a fully-custom design, build directly on
143
143
  `useScreenChrome()` from `@sigx/lynx-navigation` — `NavHeader` is just
144
144
  one consumer of that hook.
145
145
 
146
+ ### `<SwiperIndicator>`
147
+
148
+ Themed wrapper around the headless `useSwiperDot*` hooks from
149
+ [`@sigx/lynx-gestures`](../lynx-gestures#swiper-and-headless-dot-hooks).
150
+ Reads colours from the active daisy theme so the indicator follows light
151
+ / dark mode automatically.
152
+
153
+ ```tsx
154
+ import { Swiper } from '@sigx/lynx-gestures';
155
+ import { SwiperIndicator } from '@sigx/lynx-daisyui';
156
+
157
+ <Swiper offset={offset} index={pageIdx} width={pageWidth}>{pages}</Swiper>
158
+ <SwiperIndicator
159
+ variant="dots"
160
+ count={pages.length}
161
+ offset={offset}
162
+ pageWidth={pageWidth}
163
+ index={pageIdx}
164
+ color="primary"
165
+ onDotPress={(i) => { pageIdx.value = i }}
166
+ />
167
+ ```
168
+
169
+ | Variant | Animated channel | Notes |
170
+ | ------------- | ---------------------------- | ------------------------------------------------------------------ |
171
+ | `dots` | `opacity` crossfade | Default. Two-colour overlay per dot. |
172
+ | `bar` | `translateX` (single thumb) | One MT binding regardless of page count — cheapest for long lists. |
173
+ | `pill` | `scaleX` + `opacity` | Active dot stretches into a pill while overlay fades in. |
174
+ | `scale-pulse` | uniform `scale` | Monochrome pulse — no colour crossfade. |
175
+ | `numbered` | none (BG-thread text) | Renders `n / total`. Requires `index` signal. |
176
+
177
+ Props: `count`, `offset` (`SharedValue<number>`), `pageWidth`, `index`
178
+ (`PrimitiveSignal<number>`, required for `numbered`), `color`, `inactiveColor`
179
+ (daisy tokens), `size` (`'xs' | 'sm' | 'md' | 'lg'`), `onDotPress`.
180
+
181
+ For a non-standard visual, skip this component and call the headless
182
+ hooks directly — they're the same primitives this component composes.
183
+
146
184
  ## Layout primitives
147
185
 
148
186
  Daisy's flex primitives (`Center`, `Col`, `Row`) accept a `flex={n}`
@@ -0,0 +1,53 @@
1
+ import { jsx as _jsx } from "@sigx/lynx/jsx-runtime";
2
+ import { component } from '@sigx/lynx';
3
+ import { Pressable } from '@sigx/lynx-gestures';
4
+ import { Loading } from '../feedback/Loading.js';
5
+ import { PRESSED_SCALE, PRESSED_OPACITY } from '../shared/press.js';
6
+ const variantClasses = {
7
+ primary: 'btn-primary', secondary: 'btn-secondary', accent: 'btn-accent',
8
+ info: 'btn-info', success: 'btn-success', warning: 'btn-warning',
9
+ error: 'btn-error', ghost: 'btn-ghost', link: 'btn-link', neutral: 'btn-neutral',
10
+ };
11
+ const sizeClasses = {
12
+ xs: 'btn-xs', sm: 'btn-sm', md: '', lg: 'btn-lg', xl: 'btn-xl',
13
+ };
14
+ export const Button = component(({ props, slots, emit }) => {
15
+ const getClasses = () => {
16
+ const c = ['btn'];
17
+ if (props.variant)
18
+ c.push(variantClasses[props.variant]);
19
+ if (props.size) {
20
+ const s = sizeClasses[props.size];
21
+ if (s)
22
+ c.push(s);
23
+ }
24
+ if (props.outline)
25
+ c.push('btn-outline');
26
+ if (props.soft)
27
+ c.push('btn-soft');
28
+ if (props.wide)
29
+ c.push('btn-wide');
30
+ if (props.loading)
31
+ c.push('btn-loading');
32
+ if (props.block)
33
+ c.push('btn-block');
34
+ if (props.circle)
35
+ c.push('btn-circle');
36
+ if (props.square)
37
+ c.push('btn-square');
38
+ if (props.active)
39
+ c.push('btn-active');
40
+ if (props.disabled)
41
+ c.push('btn-disabled');
42
+ if (props.class)
43
+ c.push(props.class);
44
+ return c.join(' ');
45
+ };
46
+ return () => {
47
+ const inert = !!(props.disabled || props.loading);
48
+ return (_jsx(Pressable, { class: getClasses(), disabled: inert, pressedScale: PRESSED_SCALE, pressedOpacity: PRESSED_OPACITY, longPressDuration: 0, onPress: () => { if (!inert)
49
+ emit('press'); }, children: props.loading
50
+ ? _jsx(Loading, { type: "spinner", size: "sm" })
51
+ : slots.default?.() }));
52
+ };
53
+ });
@@ -0,0 +1,46 @@
1
+ import { jsx as _jsx } from "@sigx/lynx/jsx-runtime";
2
+ import { component } from '@sigx/lynx';
3
+ const sizeMap = {
4
+ xs: 24,
5
+ sm: 32,
6
+ md: 48,
7
+ lg: 64,
8
+ xl: 96,
9
+ };
10
+ const fontSizeMap = {
11
+ xs: 10,
12
+ sm: 12,
13
+ md: 18,
14
+ lg: 24,
15
+ xl: 36,
16
+ };
17
+ export const Avatar = component(({ props }) => {
18
+ return () => {
19
+ const size = props.size || 'md';
20
+ const dim = sizeMap[size];
21
+ const classes = ['avatar'];
22
+ if (props.online)
23
+ classes.push('online');
24
+ if (props.offline)
25
+ classes.push('offline');
26
+ if (props.placeholder && !props.src)
27
+ classes.push('placeholder');
28
+ if (props.class)
29
+ classes.push(props.class);
30
+ const rounded = props.rounded;
31
+ const borderRadius = rounded === 'full' || rounded === true ? dim / 2 : 8;
32
+ const innerStyle = {
33
+ width: dim,
34
+ height: dim,
35
+ borderRadius,
36
+ overflow: 'hidden',
37
+ alignItems: 'center',
38
+ justifyContent: 'center',
39
+ display: 'flex',
40
+ };
41
+ if (props.src) {
42
+ return (_jsx("view", { class: classes.join(' '), children: _jsx("view", { style: innerStyle, children: _jsx("image", { src: props.src, style: { width: dim, height: dim, borderRadius } }) }) }));
43
+ }
44
+ return (_jsx("view", { class: classes.join(' '), children: _jsx("view", { class: "avatar-placeholder", style: innerStyle, children: _jsx("text", { style: { fontSize: fontSizeMap[size] }, children: props.placeholder || '?' }) }) }));
45
+ };
46
+ });
@@ -0,0 +1,13 @@
1
+ import { jsx as _jsx } from "@sigx/lynx/jsx-runtime";
2
+ import { component } from '@sigx/lynx';
3
+ export const Alert = component(({ props, slots }) => {
4
+ const getClasses = () => {
5
+ const c = ['alert'];
6
+ if (props.variant)
7
+ c.push(`alert-${props.variant}`);
8
+ if (props.class)
9
+ c.push(props.class);
10
+ return c.join(' ');
11
+ };
12
+ return () => _jsx("view", { class: getClasses(), children: slots.default?.() });
13
+ });
@@ -0,0 +1,17 @@
1
+ import { jsx as _jsx } from "@sigx/lynx/jsx-runtime";
2
+ import { component } from '@sigx/lynx';
3
+ export const Badge = component(({ props, slots }) => {
4
+ const getClasses = () => {
5
+ const c = ['badge'];
6
+ if (props.variant)
7
+ c.push(`badge-${props.variant}`);
8
+ if (props.size)
9
+ c.push(`badge-${props.size}`);
10
+ if (props.outline)
11
+ c.push('badge-outline');
12
+ if (props.class)
13
+ c.push(props.class);
14
+ return c.join(' ');
15
+ };
16
+ return () => _jsx("view", { class: getClasses(), children: slots.default?.() });
17
+ });
@@ -0,0 +1,16 @@
1
+ import { jsx as _jsx } from "@sigx/lynx/jsx-runtime";
2
+ import { component } from '@sigx/lynx';
3
+ export const Loading = component(({ props }) => {
4
+ const getClasses = () => {
5
+ const c = ['loading'];
6
+ c.push(`loading-${props.type ?? 'spinner'}`);
7
+ if (props.size)
8
+ c.push(`loading-${props.size}`);
9
+ if (props.color)
10
+ c.push(`text-${props.color}`);
11
+ if (props.class)
12
+ c.push(props.class);
13
+ return c.join(' ');
14
+ };
15
+ return () => _jsx("view", { class: getClasses() });
16
+ });
@@ -0,0 +1,23 @@
1
+ import { jsx as _jsx } from "@sigx/lynx/jsx-runtime";
2
+ import { component, compound } from '@sigx/lynx';
3
+ const _Modal = component(({ props, slots }) => {
4
+ return () => {
5
+ if (!props.open)
6
+ return _jsx("view", { style: { display: 'none' } });
7
+ return (_jsx("view", { class: "modal-overlay", bindtap: () => { props.onClose?.(); }, children: _jsx("view", { class: `modal-box${props.class ? ' ' + props.class : ''}`, bindtap: (e) => { e?.stopPropagation?.(); }, children: slots.default?.() }) }));
8
+ };
9
+ });
10
+ const ModalHeader = component(({ props, slots }) => {
11
+ return () => (_jsx("view", { class: `modal-header${props.class ? ' ' + props.class : ''}`, children: slots.default?.() }));
12
+ });
13
+ const ModalBody = component(({ props, slots }) => {
14
+ return () => (_jsx("view", { class: `modal-body${props.class ? ' ' + props.class : ''}`, children: slots.default?.() }));
15
+ });
16
+ const ModalActions = component(({ props, slots }) => {
17
+ return () => (_jsx("view", { class: `modal-action${props.class ? ' ' + props.class : ''}`, children: slots.default?.() }));
18
+ });
19
+ export const Modal = compound(_Modal, {
20
+ Header: ModalHeader,
21
+ Body: ModalBody,
22
+ Actions: ModalActions,
23
+ });
@@ -0,0 +1,17 @@
1
+ import { jsx as _jsx } from "@sigx/lynx/jsx-runtime";
2
+ import { component } from '@sigx/lynx';
3
+ export const Progress = component(({ props }) => {
4
+ const getClasses = () => {
5
+ const c = ['progress'];
6
+ if (props.color)
7
+ c.push(`progress-${props.color}`);
8
+ if (props.class)
9
+ c.push(props.class);
10
+ return c.join(' ');
11
+ };
12
+ return () => {
13
+ const max = props.max ?? 100;
14
+ const pct = Math.min(Math.max((props.value ?? 0) / max, 0), 1) * 100;
15
+ return (_jsx("view", { class: getClasses(), children: _jsx("view", { class: "progress-bar", style: { width: `${pct}%` } }) }));
16
+ };
17
+ });
@@ -0,0 +1,18 @@
1
+ import { jsx as _jsx } from "@sigx/lynx/jsx-runtime";
2
+ import { component } from '@sigx/lynx';
3
+ export const Skeleton = component(({ props }) => {
4
+ return () => {
5
+ const style = {};
6
+ if (props.width != null)
7
+ style.width = props.width;
8
+ if (props.height != null)
9
+ style.height = props.height;
10
+ if (props.circle) {
11
+ const size = props.width ?? props.height ?? 48;
12
+ style.width = size;
13
+ style.height = size;
14
+ style.borderRadius = typeof size === 'number' ? size / 2 : '50%';
15
+ }
16
+ return (_jsx("view", { class: `skeleton${props.class ? ' ' + props.class : ''}`, style: style }));
17
+ };
18
+ });
@@ -0,0 +1,16 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "@sigx/lynx/jsx-runtime";
2
+ import { component, compound } from '@sigx/lynx';
3
+ const _Steps = component(({ props, slots }) => {
4
+ return () => {
5
+ const isVertical = props.vertical ?? false;
6
+ return (_jsx("view", { class: `steps${isVertical ? ' steps-vertical' : ' steps-horizontal'}${props.class ? ' ' + props.class : ''}`, children: slots.default?.() }));
7
+ };
8
+ });
9
+ const Step = component(({ props, slots }) => {
10
+ return () => {
11
+ const color = props.color;
12
+ const colorClass = color ? ` step-${color}` : '';
13
+ return (_jsxs("view", { class: `step${colorClass}${props.class ? ' ' + props.class : ''}`, children: [_jsx("view", { class: `step-indicator${colorClass}`, children: props.content ? _jsx("text", { style: { fontSize: 14 }, children: props.content }) : null }), slots.default?.()] }));
14
+ };
15
+ });
16
+ export const Steps = compound(_Steps, { Step });
@@ -0,0 +1,32 @@
1
+ import { jsx as _jsx } from "@sigx/lynx/jsx-runtime";
2
+ import { component } from '@sigx/lynx';
3
+ import { Pressable } from '@sigx/lynx-gestures';
4
+ import { PRESSED_SCALE, PRESSED_OPACITY } from '../shared/press.js';
5
+ const checkmarkSizeMap = {
6
+ xs: 10, sm: 12, md: 14, lg: 19,
7
+ };
8
+ export const Checkbox = component(({ props, emit }) => {
9
+ const getClasses = () => {
10
+ const c = ['checkbox'];
11
+ const size = props.size ?? 'md';
12
+ if (size !== 'md')
13
+ c.push(`checkbox-${size}`);
14
+ if (props.color)
15
+ c.push(`checkbox-${props.color}`);
16
+ if (props.checked)
17
+ c.push('checkbox-checked');
18
+ if (props.disabled)
19
+ c.push('checkbox-disabled');
20
+ if (props.class)
21
+ c.push(props.class);
22
+ return c.join(' ');
23
+ };
24
+ return () => {
25
+ const checked = !!props.checked;
26
+ const size = props.size ?? 'md';
27
+ return (_jsx(Pressable, { class: getClasses(), disabled: !!props.disabled, pressedScale: PRESSED_SCALE, pressedOpacity: PRESSED_OPACITY, longPressDuration: 0, onPress: () => {
28
+ if (!props.disabled)
29
+ emit('change', !checked);
30
+ }, children: checked ? (_jsx("text", { class: "checkbox-mark", style: { fontSize: checkmarkSizeMap[size] }, children: "\u2713" })) : null }));
31
+ };
32
+ });
@@ -0,0 +1,5 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "@sigx/lynx/jsx-runtime";
2
+ import { component } from '@sigx/lynx';
3
+ export const FormField = component(({ props, slots }) => {
4
+ return () => (_jsxs("view", { class: ['form-control', props.class].filter(Boolean).join(' '), style: { gap: 4 }, children: [props.label && (_jsx("view", { class: "label", children: _jsx("text", { class: "label-text", children: props.required ? `${props.label} *` : props.label }) })), slots.default?.(), props.error && (_jsx("view", { class: "label", children: _jsx("text", { class: "label-text-error", children: props.error }) }))] }));
5
+ });
@@ -0,0 +1,25 @@
1
+ import { jsx as _jsx } from "@sigx/lynx/jsx-runtime";
2
+ import { component } from '@sigx/lynx';
3
+ const sizeClasses = {
4
+ xs: 'input-xs', sm: 'input-sm', md: '', lg: 'input-lg',
5
+ };
6
+ export const Input = component(({ props }) => {
7
+ const getClasses = () => {
8
+ const c = ['input'];
9
+ if (props.variant === 'bordered')
10
+ c.push('input-bordered');
11
+ if (props.variant === 'ghost')
12
+ c.push('input-ghost');
13
+ if (props.color)
14
+ c.push(`input-${props.color}`);
15
+ if (props.size) {
16
+ const s = sizeClasses[props.size];
17
+ if (s)
18
+ c.push(s);
19
+ }
20
+ if (props.class)
21
+ c.push(props.class);
22
+ return c.join(' ');
23
+ };
24
+ return () => (_jsx("input", { class: getClasses(), placeholder: props.placeholder, type: props.type ?? 'text', disabled: props.disabled, model: props.model }));
25
+ });
@@ -0,0 +1,28 @@
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 RadioItem = component(({ props, emit }) => {
6
+ const getClasses = () => {
7
+ const c = ['radio'];
8
+ if (props.color)
9
+ c.push(`radio-${props.color}`);
10
+ if (props.size)
11
+ c.push(`radio-${props.size}`);
12
+ if (props.checked)
13
+ c.push('radio-checked');
14
+ if (props.class)
15
+ c.push(props.class);
16
+ return c.join(' ');
17
+ };
18
+ return () => (_jsxs(Pressable, { style: { flexDirection: 'row', alignItems: 'center', gap: 8, opacity: props.disabled ? 0.5 : 1 }, disabled: !!props.disabled, pressedScale: PRESSED_SCALE, pressedOpacity: PRESSED_OPACITY, longPressDuration: 0, onPress: () => {
19
+ if (!props.disabled && props.value != null)
20
+ emit('select', props.value);
21
+ }, children: [_jsx("view", { class: getClasses(), children: props.checked && _jsx("view", { class: "radio-mark" }) }), props.label && _jsx("text", { children: props.label })] }));
22
+ });
23
+ const _RadioGroup = component(({ props, slots }) => {
24
+ return () => (_jsx("view", { class: props.class ?? '', style: { gap: 8 }, children: slots.default?.() }));
25
+ });
26
+ export const Radio = compound(_RadioGroup, {
27
+ Item: RadioItem,
28
+ });
@@ -0,0 +1,33 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "@sigx/lynx/jsx-runtime";
2
+ import { component, signal } from '@sigx/lynx';
3
+ import { Pressable } from '@sigx/lynx-gestures';
4
+ import { PRESSED_SCALE, PRESSED_OPACITY } from '../shared/press.js';
5
+ export const Select = component(({ props, emit }) => {
6
+ const state = signal({ open: false });
7
+ const getClasses = () => {
8
+ const c = ['select'];
9
+ if (props.variant === 'bordered')
10
+ c.push('select-bordered');
11
+ if (props.variant === 'ghost')
12
+ c.push('select-ghost');
13
+ if (props.color)
14
+ c.push(`select-${props.color}`);
15
+ if (props.size)
16
+ c.push(`select-${props.size}`);
17
+ if (props.class)
18
+ c.push(props.class);
19
+ return c.join(' ');
20
+ };
21
+ const getSelectedLabel = () => {
22
+ const opts = props.options ?? [];
23
+ const found = opts.find((o) => o.value === props.value);
24
+ return found ? found.label : (props.placeholder ?? 'Select...');
25
+ };
26
+ return () => (_jsxs("view", { style: { position: 'relative', opacity: props.disabled ? 0.5 : 1 }, children: [_jsxs(Pressable, { class: getClasses(), disabled: !!props.disabled, pressedScale: PRESSED_SCALE, pressedOpacity: PRESSED_OPACITY, longPressDuration: 0, onPress: () => {
27
+ if (!props.disabled)
28
+ state.open = !state.open;
29
+ }, children: [_jsx("text", { children: getSelectedLabel() }), _jsx("view", { style: { marginLeft: 'auto' }, children: _jsx("text", { children: state.open ? '▲' : '▼' }) })] }), state.open && !props.disabled && (_jsx("view", { class: "select-dropdown", style: { position: 'absolute', top: '100%', left: 0, right: 0, zIndex: 10 }, children: (props.options ?? []).map((option) => (_jsx(Pressable, { class: `select-option${option.value === props.value ? ' select-option-active' : ''}`, pressedScale: PRESSED_SCALE, pressedOpacity: PRESSED_OPACITY, longPressDuration: 0, onPress: () => {
30
+ emit('change', option.value);
31
+ state.open = false;
32
+ }, children: _jsx("text", { children: option.label }) }))) }))] }));
33
+ });
@@ -0,0 +1,31 @@
1
+ import { jsx as _jsx } from "@sigx/lynx/jsx-runtime";
2
+ import { component } from '@sigx/lynx';
3
+ const sizeClasses = {
4
+ xs: 'textarea-xs', sm: 'textarea-sm', md: '', lg: 'textarea-lg',
5
+ };
6
+ export const Textarea = component(({ props }) => {
7
+ const getClasses = () => {
8
+ const c = ['textarea'];
9
+ if (props.variant === 'bordered')
10
+ c.push('textarea-bordered');
11
+ if (props.variant === 'ghost')
12
+ c.push('textarea-ghost');
13
+ if (props.color)
14
+ c.push(`textarea-${props.color}`);
15
+ if (props.size) {
16
+ const s = sizeClasses[props.size];
17
+ if (s)
18
+ c.push(s);
19
+ }
20
+ if (props.class)
21
+ c.push(props.class);
22
+ return c.join(' ');
23
+ };
24
+ const getHeight = () => {
25
+ const rows = props.rows ?? 3;
26
+ const lineHeight = 20;
27
+ const padding = 16;
28
+ return rows * lineHeight + padding;
29
+ };
30
+ return () => (_jsx("textarea", { class: getClasses(), placeholder: props.placeholder, disabled: props.disabled, model: props.model, style: { height: getHeight() } }));
31
+ });
@@ -0,0 +1,32 @@
1
+ import { jsx as _jsx } from "@sigx/lynx/jsx-runtime";
2
+ import { component } from '@sigx/lynx';
3
+ import { Pressable } from '@sigx/lynx-gestures';
4
+ import { PRESSED_SCALE, PRESSED_OPACITY } from '../shared/press.js';
5
+ const thumbOffsetMap = {
6
+ xs: 10, sm: 16, md: 20, lg: 24,
7
+ };
8
+ export const Toggle = component(({ props, emit }) => {
9
+ const getClasses = () => {
10
+ const c = ['toggle'];
11
+ const size = props.size ?? 'md';
12
+ c.push(`toggle-${size}`);
13
+ if (props.color)
14
+ c.push(`toggle-${props.color}`);
15
+ if (props.checked)
16
+ c.push('toggle-checked');
17
+ if (props.disabled)
18
+ c.push('toggle-disabled');
19
+ if (props.class)
20
+ c.push(props.class);
21
+ return c.join(' ');
22
+ };
23
+ return () => {
24
+ const checked = !!props.checked;
25
+ const size = props.size ?? 'md';
26
+ const offset = checked ? thumbOffsetMap[size] : 0;
27
+ return (_jsx(Pressable, { class: getClasses(), disabled: !!props.disabled, pressedScale: PRESSED_SCALE, pressedOpacity: PRESSED_OPACITY, longPressDuration: 0, onPress: () => {
28
+ if (!props.disabled)
29
+ emit('change', !checked);
30
+ }, children: _jsx("view", { class: "toggle-thumb", style: { transform: `translateX(${offset}px)` } }) }));
31
+ };
32
+ });
package/dist/index.d.ts CHANGED
@@ -1,58 +1,66 @@
1
- export { Button } from './buttons/Button';
2
- export type { ButtonProps, ButtonVariant, ButtonSize } from './buttons/Button';
3
- export { Card } from './layout/Card';
4
- export type { CardProps } from './layout/Card';
5
- export { Row } from './layout/Row';
6
- export type { RowProps } from './layout/Row';
7
- export { Col } from './layout/Col';
8
- export type { ColProps } from './layout/Col';
9
- export { Center } from './layout/Center';
10
- export type { CenterProps } from './layout/Center';
11
- export { Spacer } from './layout/Spacer';
12
- export type { SpacerProps } from './layout/Spacer';
13
- export { ScrollView } from './layout/ScrollView';
14
- export type { ScrollViewProps } from './layout/ScrollView';
15
- export { Divider } from './layout/Divider';
16
- export type { DividerProps } from './layout/Divider';
17
- export { Input } from './forms/Input';
18
- export type { InputProps, InputSize, InputVariant, InputColor } from './forms/Input';
19
- export { Toggle } from './forms/Toggle';
20
- export type { ToggleProps, ToggleColor, ToggleSize } from './forms/Toggle';
21
- export { Checkbox } from './forms/Checkbox';
22
- export type { CheckboxProps, CheckboxColor, CheckboxSize } from './forms/Checkbox';
23
- export { Select } from './forms/Select';
24
- export type { SelectProps, SelectSize, SelectVariant, SelectColor, SelectOption } from './forms/Select';
25
- export { Radio } from './forms/Radio';
26
- export type { RadioGroupProps, RadioItemProps, RadioColor, RadioSize } from './forms/Radio';
27
- export { Textarea } from './forms/Textarea';
28
- export type { TextareaProps, TextareaSize, TextareaVariant, TextareaColor } from './forms/Textarea';
29
- export { FormField } from './forms/FormField';
30
- export type { FormFieldProps } from './forms/FormField';
31
- export { Badge } from './feedback/Badge';
32
- export type { BadgeProps, BadgeVariant, BadgeSize } from './feedback/Badge';
33
- export { Alert } from './feedback/Alert';
34
- export type { AlertProps, AlertVariant } from './feedback/Alert';
35
- export { Loading } from './feedback/Loading';
36
- export type { LoadingProps, LoadingType, LoadingSize, LoadingColor } from './feedback/Loading';
37
- export { Progress } from './feedback/Progress';
38
- export type { ProgressProps, ProgressColor } from './feedback/Progress';
39
- export { Modal } from './feedback/Modal';
40
- export type { ModalProps } from './feedback/Modal';
41
- export { Skeleton } from './feedback/Skeleton';
42
- export type { SkeletonProps } from './feedback/Skeleton';
43
- export { Steps } from './feedback/Steps';
44
- export type { StepsProps, StepProps, StepColor } from './feedback/Steps';
45
- export { Tabs } from './navigation/Tabs';
46
- export type { TabsProps, TabProps } from './navigation/Tabs';
47
- export { NavTabBar } from './navigation/NavTabBar';
48
- export type { NavTabBarProps, NavTabBarPosition, NavTabBarBackground, NavTabRenderContext, } from './navigation/NavTabBar';
49
- export { NavHeader } from './navigation/NavHeader';
50
- export type { NavHeaderProps, NavHeaderBackground, } from './navigation/NavHeader';
51
- export { ThemeProvider, useTheme } from './theme/ThemeProvider';
52
- export type { DaisyTheme, ThemeController, ThemeProviderProps, } from './theme/ThemeProvider';
53
- export { Avatar } from './data/Avatar';
54
- export type { AvatarProps, AvatarSize } from './data/Avatar';
55
- export { Text } from './typography/Text';
56
- export type { TextProps, TextSize, TextWeight, TextColor } from './typography/Text';
57
- export { Heading } from './typography/Heading';
58
- export type { HeadingProps, HeadingLevel } from './typography/Heading';
1
+ export { Button } from './buttons/Button.js';
2
+ export type { ButtonProps, ButtonVariant, ButtonSize } from './buttons/Button.js';
3
+ export { Card } from './layout/Card.js';
4
+ export type { CardProps } from './layout/Card.js';
5
+ export { Row } from './layout/Row.js';
6
+ export type { RowProps } from './layout/Row.js';
7
+ export { Col } from './layout/Col.js';
8
+ export type { ColProps } from './layout/Col.js';
9
+ export { Center } from './layout/Center.js';
10
+ export type { CenterProps } from './layout/Center.js';
11
+ export { Spacer } from './layout/Spacer.js';
12
+ export type { SpacerProps } from './layout/Spacer.js';
13
+ export { ScrollView } from './layout/ScrollView.js';
14
+ export type { ScrollViewProps } from './layout/ScrollView.js';
15
+ export { Divider } from './layout/Divider.js';
16
+ export type { DividerProps } from './layout/Divider.js';
17
+ export type { DaisyColor, BackgroundValue, SpacingValue, BoxProps } from './shared/styles.js';
18
+ export { resolveDaisyColor } from './shared/styles.js';
19
+ export { Input } from './forms/Input.js';
20
+ export type { InputProps, InputSize, InputVariant, InputColor } from './forms/Input.js';
21
+ export { Toggle } from './forms/Toggle.js';
22
+ export type { ToggleProps, ToggleColor, ToggleSize } from './forms/Toggle.js';
23
+ export { Checkbox } from './forms/Checkbox.js';
24
+ export type { CheckboxProps, CheckboxColor, CheckboxSize } from './forms/Checkbox.js';
25
+ export { Select } from './forms/Select.js';
26
+ export type { SelectProps, SelectSize, SelectVariant, SelectColor, SelectOption } from './forms/Select.js';
27
+ export { Radio } from './forms/Radio.js';
28
+ export type { RadioGroupProps, RadioItemProps, RadioColor, RadioSize } from './forms/Radio.js';
29
+ export { Textarea } from './forms/Textarea.js';
30
+ export type { TextareaProps, TextareaSize, TextareaVariant, TextareaColor } from './forms/Textarea.js';
31
+ export { FormField } from './forms/FormField.js';
32
+ export type { FormFieldProps } from './forms/FormField.js';
33
+ export { Badge } from './feedback/Badge.js';
34
+ export type { BadgeProps, BadgeVariant, BadgeSize } from './feedback/Badge.js';
35
+ export { Alert } from './feedback/Alert.js';
36
+ export type { AlertProps, AlertVariant } from './feedback/Alert.js';
37
+ export { Loading } from './feedback/Loading.js';
38
+ export type { LoadingProps, LoadingType, LoadingSize, LoadingColor } from './feedback/Loading.js';
39
+ export { Progress } from './feedback/Progress.js';
40
+ export type { ProgressProps, ProgressColor } from './feedback/Progress.js';
41
+ export { Modal } from './feedback/Modal.js';
42
+ export type { ModalProps } from './feedback/Modal.js';
43
+ export { Skeleton } from './feedback/Skeleton.js';
44
+ export type { SkeletonProps } from './feedback/Skeleton.js';
45
+ export { Steps } from './feedback/Steps.js';
46
+ export type { StepsProps, StepProps, StepColor } from './feedback/Steps.js';
47
+ export { Tabs } from './navigation/Tabs.js';
48
+ export type { TabsProps, TabProps } from './navigation/Tabs.js';
49
+ export { NavTabBar } from './navigation/NavTabBar.js';
50
+ export type { NavTabBarProps, NavTabBarPosition, NavTabBarBackground, NavTabRenderContext, } from './navigation/NavTabBar.js';
51
+ export { NavHeader } from './navigation/NavHeader.js';
52
+ export type { NavHeaderProps, NavHeaderBackground, } from './navigation/NavHeader.js';
53
+ export { NavDrawer } from './navigation/NavDrawer.js';
54
+ export type { NavDrawerProps, NavDrawerSide, } from './navigation/NavDrawer.js';
55
+ export { SwiperIndicator } from './navigation/SwiperIndicator.js';
56
+ export type { SwiperIndicatorProps, SwiperIndicatorVariant, SwiperIndicatorSize, } from './navigation/SwiperIndicator.js';
57
+ export { ThemeProvider, useTheme, listThemes, registerTheme, extendTheme, pickThemeFor, pairOf, variantOf, colorsOf, radiusOf, } from './theme/ThemeProvider.js';
58
+ export type { DaisyTheme, ThemeController, ThemeProviderProps, Theme, ThemePalette, ThemeRadius, ThemeVariant, } from './theme/ThemeProvider.js';
59
+ export { StatusBarSync } from './theme/StatusBarSync.js';
60
+ export type { StatusBarSyncProps } from './theme/StatusBarSync.js';
61
+ export { Avatar } from './data/Avatar.js';
62
+ export type { AvatarProps, AvatarSize } from './data/Avatar.js';
63
+ export { Text } from './typography/Text.js';
64
+ export type { TextProps, TextSize, TextWeight, TextColor } from './typography/Text.js';
65
+ export { Heading } from './typography/Heading.js';
66
+ export type { HeadingProps, HeadingLevel } from './typography/Heading.js';