@musecat/uikit 0.1.1 → 0.1.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 (56) hide show
  1. package/.agents/references/Components/Box.md +60 -0
  2. package/.agents/references/Components/Button.md +49 -0
  3. package/.agents/references/Components/Card.md +67 -0
  4. package/.agents/references/Components/Checkbox.md +48 -0
  5. package/.agents/references/Components/CodeBox.md +31 -0
  6. package/.agents/references/Components/ContextMenu.md +82 -0
  7. package/.agents/references/Components/ContributionGraph.md +61 -0
  8. package/.agents/references/Components/DatePicker.md +92 -0
  9. package/.agents/references/Components/Divider.md +56 -0
  10. package/.agents/references/Components/Header.md +52 -0
  11. package/.agents/references/Components/Icon.md +82 -0
  12. package/.agents/references/Components/Input.md +60 -0
  13. package/.agents/references/Components/Label.md +78 -0
  14. package/.agents/references/Components/Layout.md +102 -0
  15. package/.agents/references/Components/Maps.md +63 -0
  16. package/.agents/references/Components/Nav.md +68 -0
  17. package/.agents/references/Components/Pagination.md +67 -0
  18. package/.agents/references/Components/Pill.md +75 -0
  19. package/.agents/references/Components/Profile.md +76 -0
  20. package/.agents/references/Components/Progress.md +72 -0
  21. package/.agents/references/Components/Radio.md +68 -0
  22. package/.agents/references/Components/Select.md +80 -0
  23. package/.agents/references/Components/Skeleton.md +48 -0
  24. package/.agents/references/Components/Spinner.md +62 -0
  25. package/.agents/references/Components/Text.md +73 -0
  26. package/.agents/references/Components/TimePicker.md +72 -0
  27. package/.agents/references/Components/Timeline.md +97 -0
  28. package/.agents/references/Components/Title.md +108 -0
  29. package/.agents/references/Components/Toggle.md +53 -0
  30. package/.agents/references/Components/Tooltip.md +62 -0
  31. package/.agents/references/Frameworks/DNDView.md +82 -0
  32. package/.agents/references/Frameworks/Dialog.md +109 -0
  33. package/.agents/references/Frameworks/EdgeEffect.md +64 -0
  34. package/.agents/references/Frameworks/HScrollView.md +76 -0
  35. package/.agents/references/Frameworks/ImageView.md +67 -0
  36. package/.agents/references/Frameworks/Motion.md +62 -0
  37. package/.agents/references/Frameworks/Pressable.md +79 -0
  38. package/.agents/references/Frameworks/Squircle.md +50 -0
  39. package/.agents/references/Frameworks/Theme.md +68 -0
  40. package/.agents/references/Frameworks/Toaster.md +67 -0
  41. package/.agents/references/Frameworks/View.md +81 -0
  42. package/.agents/references/Frameworks/_shared.md +74 -0
  43. package/.agents/references/Styles/Animation.md +43 -0
  44. package/.agents/references/Styles/Color.md +45 -0
  45. package/.agents/references/Styles/Font.md +37 -0
  46. package/.agents/references/Styles/Icon.md +43 -0
  47. package/.agents/references/Styles/Importer.md +19 -0
  48. package/.agents/references/Styles/System.md +27 -0
  49. package/.agents/references/Styles/Textstyle.md +45 -0
  50. package/.agents/references/Styles/Theme.md +51 -0
  51. package/.agents/references/Styles/Viewport-global.md +42 -0
  52. package/.agents/references/Styles/Viewport.md +42 -0
  53. package/README.md +4 -0
  54. package/package.json +2 -1
  55. package/packages/Styles/_icon.scss +2 -0
  56. package/packages/Styles/_importer.scss +0 -1
@@ -0,0 +1,68 @@
1
+ # Radio
2
+
3
+ ## Purpose
4
+
5
+ The `Radio` component provides a radio button UI that lets the user select a single option among multiple choices. It supports custom theming, controlled/uncontrolled state management, and labels.
6
+
7
+ ## Usage Logic
8
+
9
+ - **Controlled/Uncontrolled**: Depending on the presence of the `checked` prop, it acts as a controlled or uncontrolled component.
10
+ - **Grouped State**: `Radio` components with the same `name` synchronize their state via the native `change` event.
11
+ - **Styling**: Combined with the theme system (`ThemeSystemProps`), allowing various presets, background, color, and size (`UIKitSizeValue`) adjustments. Providing a `title` renders a text label together, and `titleSpaceBetween` or `reversed` adjusts the layout.
12
+
13
+ ## Type Signatures
14
+
15
+ ```typescript
16
+ import type { RadiusProps } from "@/packages/Frameworks/Theme/Radius.types";
17
+ import type { UIKitSizeValue } from "../../Frameworks/_shared/sizing";
18
+ import type {
19
+ BorderProps,
20
+ ThemeSystemProps,
21
+ } from "../../Frameworks/Theme/Theme.types";
22
+ import type { TextProps } from "../Text/Text.types";
23
+
24
+ export interface RadioProps
25
+ extends
26
+ Omit<React.InputHTMLAttributes<HTMLInputElement>, "size" | "color">,
27
+ BorderProps,
28
+ RadiusProps,
29
+ ThemeSystemProps {
30
+ title?: string;
31
+ titleType?: TextProps["type"];
32
+ titleSpaceBetween?: boolean;
33
+ reversed?: boolean;
34
+ readOnly?: boolean;
35
+ size?: UIKitSizeValue;
36
+ }
37
+ ```
38
+
39
+ ## Example Code
40
+
41
+ ```tsx
42
+ import Radio from "@/packages/Components/Radio/Radio";
43
+ import { useState } from "react";
44
+
45
+ export default function RadioExample() {
46
+ const [selected, setSelected] = useState("apple");
47
+
48
+ return (
49
+ <div style={{ display: "flex", flexDirection: "column", gap: "10px" }}>
50
+ <Radio
51
+ name="fruit"
52
+ value="apple"
53
+ title="Apple"
54
+ checked={selected === "apple"}
55
+ onChange={(e) => setSelected(e.target.value)}
56
+ />
57
+ <Radio
58
+ name="fruit"
59
+ value="banana"
60
+ title="Banana"
61
+ checked={selected === "banana"}
62
+ onChange={(e) => setSelected(e.target.value)}
63
+ />
64
+ <Radio name="fruit" value="cherry" title="Cherry" disabled />
65
+ </div>
66
+ );
67
+ }
68
+ ```
@@ -0,0 +1,80 @@
1
+ # Select
2
+
3
+ ## Purpose
4
+
5
+ The `Select` component provides a dropdown menu for receiving single or multiple item selection from the user. It natively supports accessibility and keyboard navigation, and is provided as a custom UI wrapping the native `<select>` element.
6
+
7
+ ## Usage Logic
8
+
9
+ - **Single/Multiple Selection**: The type signature and return value differ based on the `multiple` prop value (`string` or `string[]`). Generics are used so the value type received in `onChange` is automatically inferred.
10
+ - **Option structure**: Uses `Option` (value, label, description, icon) objects or `OptGroup` object arrays rather than a simple string array. Internally composed of `Select.trigger.tsx` (control Pressable), `select.control.tsx` (control + combobox orchestration), and `select.inner.tsx` (ContextMenu integration).
11
+ - **Combobox/Search**: The `combobox` prop allows composing a searchable select box.
12
+
13
+ ## Type Signatures
14
+
15
+ ```typescript
16
+ export interface Option {
17
+ value: string | number;
18
+ label: string;
19
+ description?: string;
20
+ icon?: string;
21
+ disabled?: boolean;
22
+ }
23
+
24
+ export interface OptGroup {
25
+ label: string;
26
+ options: Option[];
27
+ }
28
+
29
+ export type SelectValue<Multiple extends boolean = false> =
30
+ Multiple extends true ? string[] : string;
31
+
32
+ export type SelectChangeEvent<Multiple extends boolean = false> =
33
+ | React.ChangeEvent<HTMLSelectElement>
34
+ | { target: { value: SelectValue<Multiple> } };
35
+
36
+ export interface SelectProps<
37
+ Multiple extends boolean = false,
38
+ > extends LabelSharedProps {
39
+ id?: string;
40
+ value?: SelectValue<Multiple>;
41
+ defaultValue?: SelectValue<Multiple>;
42
+ onChange?: (e: SelectChangeEvent<Multiple>) => void;
43
+ onInputChange?: (value: string) => void;
44
+ options?: (Option | OptGroup)[];
45
+ required?: boolean;
46
+ placeholder?: string;
47
+ lockAncestorScrollOnOpen?: boolean;
48
+ multiple?: Multiple;
49
+ combobox?: boolean | "inline" | "search";
50
+ disabled?: boolean;
51
+ readOnly?: boolean;
52
+ }
53
+ ```
54
+
55
+ ## Example Code
56
+
57
+ ```tsx
58
+ import Select from "@/packages/Components/Select/Select";
59
+ import { useState } from "react";
60
+
61
+ export default function SelectExample() {
62
+ const [value, setValue] = useState<string>("");
63
+
64
+ const options = [
65
+ { label: "Apple", value: "apple" },
66
+ { label: "Banana", value: "banana" },
67
+ { label: "Cherry", value: "cherry", disabled: true },
68
+ ];
69
+
70
+ return (
71
+ <Select
72
+ title="Select Fruit"
73
+ placeholder="Please select a fruit"
74
+ value={value}
75
+ onChange={(e) => setValue(e.target.value as string)}
76
+ options={options}
77
+ />
78
+ );
79
+ }
80
+ ```
@@ -0,0 +1,48 @@
1
+ # Skeleton
2
+
3
+ ## Purpose
4
+
5
+ The `Skeleton` component provides a visual placeholder to the user while data is loading, naturally conveying the loading state.
6
+
7
+ ## Usage Logic
8
+
9
+ - **Sizing**: Specify `width`, `height`, or pass a font typography type (`Title1`, `Body`, etc.) to the `type` prop to automatically adjust the height to match the text size.
10
+ - **Multiple Slots**: The `count` prop easily renders multiple lines of skeleton UI at once. Concise code without array mapping.
11
+
12
+ ## Type Signatures
13
+
14
+ ```typescript
15
+ import type { UIKitSizeValue } from "../../Frameworks/_shared/sizing";
16
+ import type { TextProps } from "../Text/Text.types";
17
+
18
+ export interface SkeletonProps {
19
+ "data-color-mode"?: string;
20
+ className?: string;
21
+ style?: React.CSSProperties;
22
+ width?: UIKitSizeValue;
23
+ height?: UIKitSizeValue;
24
+ count?: number;
25
+ type?: TextProps["type"];
26
+ }
27
+ ```
28
+
29
+ ## Example Code
30
+
31
+ ```tsx
32
+ import Skeleton from "@/packages/Components/Skeleton/Skeleton";
33
+
34
+ export default function SkeletonExample() {
35
+ return (
36
+ <div style={{ display: "flex", flexDirection: "column", gap: "8px" }}>
37
+ {/* Single-line skeleton matching 'Headline' text height */}
38
+ <Skeleton type="Headline" width="50%" />
39
+
40
+ {/* Three-line skeleton matching 'Body' text height */}
41
+ <Skeleton type="Body" count={3} />
42
+
43
+ {/* Arbitrary-size skeleton */}
44
+ <Skeleton width="100px" height="100px" />
45
+ </div>
46
+ );
47
+ }
48
+ ```
@@ -0,0 +1,62 @@
1
+ # Spinner
2
+
3
+ ## Purpose
4
+
5
+ The `Spinner` component is a rotating animation icon that visually represents an in-progress process or loading state. It supports three different designs (`apple`, `material`, `wheel`).
6
+
7
+ ## Usage Logic
8
+
9
+ - **Visual Type**: Choose one of `apple` (segmented), `material` (SVG track), or `wheel` (default rotating) designs via the `type` prop.
10
+ - **Customization**: Fine-tune the spinner's appearance and rotation speed via `size`, `color`, `strokeWidth`, `duration`, etc.
11
+ - **Accessibility**: Automatically sets `role="progressbar"` or appropriate `aria-label`, `aria-hidden` to indicate progress, ensuring screen reader accessibility.
12
+
13
+ ## Type Signatures
14
+
15
+ ```typescript
16
+ import type { AriaRole, CSSProperties, SVGAttributes } from "react";
17
+ import type { UIKitSizeValue } from "../../Frameworks/_shared/sizing";
18
+ import type { ThemePaint } from "../../Frameworks/Theme/Theme.types";
19
+
20
+ export interface SpinnerProps {
21
+ "data-color-mode"?: string;
22
+ "aria-hidden"?: boolean | "true" | "false";
23
+ "aria-label"?: string;
24
+ role?: AriaRole;
25
+ type?: "apple" | "material" | "wheel";
26
+ className?: string;
27
+ style?: CSSProperties;
28
+ size?: UIKitSizeValue;
29
+ strokeWidth?: number;
30
+ color?: ThemePaint;
31
+ opacity?: number;
32
+ duration?: number;
33
+ linecap?: SVGAttributes<SVGElement>["strokeLinecap"];
34
+ }
35
+ ```
36
+
37
+ ## Example Code
38
+
39
+ ```tsx
40
+ import Spinner from "@/packages/Components/Spinner/Spinner";
41
+
42
+ export default function SpinnerExample() {
43
+ return (
44
+ <div style={{ display: "flex", gap: "20px", alignItems: "center" }}>
45
+ {/* Default Wheel spinner */}
46
+ <Spinner size={32} color="Blue" />
47
+
48
+ {/* Material Design style spinner */}
49
+ <Spinner
50
+ type="material"
51
+ size={32}
52
+ color="Red"
53
+ strokeWidth={3}
54
+ duration={1.5}
55
+ />
56
+
57
+ {/* Apple style spinner */}
58
+ <Spinner type="apple" size={32} color="Gray" />
59
+ </div>
60
+ );
61
+ }
62
+ ```
@@ -0,0 +1,73 @@
1
+ # Text
2
+
3
+ ## Purpose
4
+
5
+ The `Text` component is a text element for applying a unified typography system across the project. It allows applying consistent font sizes, heights, and styles.
6
+
7
+ ## Usage Logic
8
+
9
+ - **Typography Tokens**: Pass a UIKit typography hierarchy (`LargeTitle`, `Body`, `Caption1`, etc.) to `type` to easily apply predefined formatting.
10
+ - **Styling Details**: Override `weight`, `color`, `textAlign`, `opacity`, `lineHeight`, etc.
11
+ - **Vertical Trim**: With `verticalTrim={true}`, `lineHeight: 1` is applied, removing top/bottom text margins for precise layout calculation.
12
+
13
+ ## Type Signatures
14
+
15
+ ```typescript
16
+ import type { UIKitSizeValue } from "../../Frameworks/_shared/sizing";
17
+ import type { ThemePaint } from "../../Frameworks/Theme/Theme.types";
18
+
19
+ export interface TextProps {
20
+ "data-color-mode"?: string;
21
+ children?: React.ReactNode;
22
+ className?: string;
23
+ style?: React.CSSProperties;
24
+ type?:
25
+ | "LargeTitle"
26
+ | "Title1"
27
+ | "Title2"
28
+ | "Title3"
29
+ | "Headline"
30
+ | "Callout"
31
+ | "Body"
32
+ | "Subheadline"
33
+ | "Footnote"
34
+ | "Caption1"
35
+ | "Caption2"
36
+ | "Coding"
37
+ | "Pre";
38
+ color?: ThemePaint;
39
+ lineHeight?: number;
40
+ weight?: 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900;
41
+ letterSpacing?: number;
42
+ size?: UIKitSizeValue;
43
+ verticalTrim?: boolean;
44
+ fontType?: "serif" | "code";
45
+ textAlign?: "left" | "center" | "right";
46
+ id?: string;
47
+ opacity?: number;
48
+ }
49
+ ```
50
+
51
+ ## Example Code
52
+
53
+ ```tsx
54
+ import Text from "@/packages/Components/Text/Text";
55
+
56
+ export default function TextExample() {
57
+ return (
58
+ <div style={{ display: "flex", flexDirection: "column", gap: "10px" }}>
59
+ <Text type="LargeTitle" weight={700} color="Base1">
60
+ Page Title
61
+ </Text>
62
+
63
+ <Text type="Body" color="Base2">
64
+ This is a standard body text that describes the contents of the page.
65
+ </Text>
66
+
67
+ <Text type="Caption1" color="Base3" textAlign="center">
68
+ Footer description
69
+ </Text>
70
+ </div>
71
+ );
72
+ }
73
+ ```
@@ -0,0 +1,72 @@
1
+ # TimePicker
2
+
3
+ ## Purpose
4
+
5
+ The `TimePicker` component is an input field that lets users select a time by directly entering hours, minutes, (optionally seconds and AM/PM) or adjusting via arrow keys.
6
+
7
+ ## Usage Logic
8
+
9
+ - **Interaction**: Supports precise keyboard navigation within the input field via number keys, arrow keys (`ArrowUp`, `ArrowDown`, `ArrowLeft`, `ArrowRight`), tab key, etc.
10
+ - **Time Format**: `showSeconds` determines whether to display seconds, and `use12h` selects between 12-hour (AM/PM display) and 24-hour formats.
11
+ - **Component Architecture**: Composed of `TimePicker.core.tsx` (managing input and state) and `TimePicker.tsx` (handling layout/styling), abstracting complex focus-movement logic to improve usability. Covered in a single document integrated with the core logic.
12
+ - **Controlled/Uncontrolled**: State is controlled via `value` and `defaultValue`. Time is handled as a string in `HH:mm` or `HH:mm:ss` format.
13
+
14
+ ## Type Signatures
15
+
16
+ ```typescript
17
+ import type { LabelProps } from "../Label/Label.types";
18
+
19
+ export interface TimePickerProps {
20
+ "data-color-mode"?: string;
21
+ className?: string;
22
+ style?: React.CSSProperties;
23
+ title?: string;
24
+ required?: boolean;
25
+ readOnly?: boolean;
26
+ disabled?: boolean;
27
+ hint?: LabelProps["hint"];
28
+
29
+ value?: string;
30
+ defaultValue?: string;
31
+
32
+ showSeconds?: boolean;
33
+ use12h?: boolean;
34
+
35
+ placeholder?: string;
36
+ onChange?: (value: string) => void;
37
+ onHourOverflow?: (params: { input: number; normalized: number }) => void;
38
+ }
39
+ ```
40
+
41
+ ## Example Code
42
+
43
+ ```tsx
44
+ import TimePicker from "@/packages/Components/TimePicker/TimePicker";
45
+ import { useState } from "react";
46
+
47
+ export default function TimePickerExample() {
48
+ const [time, setTime] = useState("14:30");
49
+
50
+ return (
51
+ <div
52
+ style={{
53
+ display: "flex",
54
+ flexDirection: "column",
55
+ gap: "20px",
56
+ maxWidth: "300px",
57
+ }}
58
+ >
59
+ {/* Default 24-hour */}
60
+ <TimePicker title="Meeting Time" value={time} onChange={setTime} />
61
+
62
+ {/* 12-hour and with seconds */}
63
+ <TimePicker
64
+ title="Timer Setting"
65
+ use12h
66
+ showSeconds
67
+ defaultValue="02:15:30"
68
+ />
69
+ </div>
70
+ );
71
+ }
72
+ ```
@@ -0,0 +1,97 @@
1
+ # Timeline
2
+
3
+ ## Purpose
4
+
5
+ The `Timeline` component is a layout component that visualizes a series of events, states, or records as a time-ordered or sequential list.
6
+
7
+ ## Usage Logic
8
+
9
+ - **Items structure**: Receives an array of `TimelineItemProps` structure via `items`. Each item includes text content (`children`), an icon (`icon`), or a custom node (`node`).
10
+ - **Custom Nodes**: The node (dot) color or design can be customized globally (`nodePreset`, `nodeBackground`, `nodeColor`) or per item.
11
+ - **Interactivity**: The inside of each item is wrapped with the `Pressable` component, so click/touch events can be easily bound via the `pressable` prop.
12
+
13
+ ## Type Signatures
14
+
15
+ ```typescript
16
+ import type { IconProps } from "../Icon/Icon.types";
17
+ import type { PressableProps } from "../../Frameworks/Pressable/Pressable.types";
18
+ import type { ThemeSystemProps } from "../../Frameworks/Theme/Theme.types";
19
+
20
+ export interface TimelineItemProps {
21
+ children?: React.ReactNode;
22
+ id?: string | number;
23
+ icon?: IconProps;
24
+ node?: React.ReactNode;
25
+ nodePreset?: ThemeSystemProps["themePreset"];
26
+ nodeBackground?: ThemeSystemProps["background"];
27
+ nodeColor?: ThemeSystemProps["color"];
28
+ pressable?: PressableProps;
29
+ }
30
+
31
+ export interface TimelineProps {
32
+ className?: string;
33
+ style?: React.CSSProperties;
34
+ items: TimelineItemProps[];
35
+ nodePreset?: ThemeSystemProps["themePreset"];
36
+ nodeBackground?: ThemeSystemProps["background"];
37
+ nodeColor?: ThemeSystemProps["color"];
38
+ }
39
+ ```
40
+
41
+ ## Example Code
42
+
43
+ ```tsx
44
+ import Timeline from "@/packages/Components/Timeline/Timeline";
45
+ import Text from "@/packages/Components/Text/Text";
46
+
47
+ export default function TimelineExample() {
48
+ const events = [
49
+ {
50
+ id: "1",
51
+ icon: { icon: "iCheck", size: 12 },
52
+ nodePreset: "UIPrimary",
53
+ children: (
54
+ <>
55
+ <Text type="Subheadline" weight={600}>
56
+ Order Completed
57
+ </Text>
58
+ <Text type="Caption1" color="Base3">
59
+ 10:30 AM
60
+ </Text>
61
+ </>
62
+ ),
63
+ },
64
+ {
65
+ id: "2",
66
+ icon: { icon: "iTruck", size: 12 },
67
+ nodePreset: "UINeutral",
68
+ children: (
69
+ <>
70
+ <Text type="Subheadline" weight={600}>
71
+ In Delivery
72
+ </Text>
73
+ <Text type="Caption1" color="Base3">
74
+ 2:15 PM
75
+ </Text>
76
+ </>
77
+ ),
78
+ pressable: {
79
+ onClick: () => alert("Go to delivery tracking page"),
80
+ },
81
+ },
82
+ {
83
+ id: "3",
84
+ nodePreset: "UISecondary", // gray dot indicating waiting state
85
+ children: (
86
+ <>
87
+ <Text type="Subheadline" weight={600} color="Base3">
88
+ Delivery Completed (Scheduled)
89
+ </Text>
90
+ </>
91
+ ),
92
+ },
93
+ ];
94
+
95
+ return <Timeline items={events as any} />;
96
+ }
97
+ ```
@@ -0,0 +1,108 @@
1
+ # Title
2
+
3
+ ## 1. Purpose
4
+
5
+ A component for composing a UI title and related information (metadata, caption, action buttons, etc.). Used to render a header role or a section's main heading, and provides a `Title.ContextBar` sub-component that displays auxiliary actions and information to manage them integrally.
6
+
7
+ ## 2. Usage Logic
8
+
9
+ - The `title` prop receives a single or multiple texts and elements.
10
+ - Text-related styling options such as `titleType`, `fontType` can manipulate the title's appearance.
11
+ - The `meta`, `caption`, `actions` props can arrange subtitles, additional info, and action buttons (icon groups).
12
+ - `Title.ContextBar` (assign a `ContextBar` object) can place left/right-aligned context buttons and icons inside the title component or independently.
13
+
14
+ ## 3. Type Signatures
15
+
16
+ ```tsx
17
+ export interface TitleProps {
18
+ "data-color-mode"?: string;
19
+ className?: string;
20
+ style?: React.CSSProperties;
21
+ title?: TitleItemProps[] | TitleItemProps;
22
+ titleType?: TextProps["type"];
23
+ titleClassName?: TextProps["className"];
24
+ titleGap?: ViewProps["gap"];
25
+ leftGap?: ViewProps["gap"];
26
+ rightGap?: ViewProps["gap"];
27
+ fontType?: TextProps["fontType"];
28
+ titleLineHeight?: number;
29
+ titleVerticalTrim?: boolean;
30
+ suffix?: PillProps;
31
+ meta?: React.ReactNode;
32
+ actions?: IconGroupProps["icons"];
33
+ caption?: React.ReactNode;
34
+ captionOpacity?: TextProps["opacity"];
35
+ context?: React.ReactNode;
36
+ }
37
+
38
+ interface TitleItemProps {
39
+ "data-color-mode"?: string;
40
+ text?: React.ReactNode;
41
+ active?: boolean;
42
+ pressable?: PressableProps;
43
+ }
44
+
45
+ export interface TitleContextProps {
46
+ className?: string;
47
+ style?: React.CSSProperties;
48
+ start?: TitleContextItem | TitleContextItem[];
49
+ end?: TitleContextItem | TitleContextItem[];
50
+ startGap?: ViewProps["gap"];
51
+ endGap?: ViewProps["gap"];
52
+ }
53
+
54
+ export type TitleContextItem = Pick<
55
+ PressableProps,
56
+ | "className"
57
+ | "style"
58
+ | "themePreset"
59
+ | "background"
60
+ | "color"
61
+ | "themeInteractive"
62
+ | "selected"
63
+ | "border"
64
+ | "data-color-mode"
65
+ > & {
66
+ key?: React.Key;
67
+ content: React.ReactNode;
68
+ leadingIcon?: IconProps["icon"];
69
+ trailingIcon?: IconProps["icon"];
70
+ leadingIconProps?: Omit<IconProps, "icon" | "pressable">;
71
+ trailingIconProps?: Omit<IconProps, "icon" | "pressable">;
72
+ pressable?: PressableProps;
73
+ };
74
+ ```
75
+
76
+ ## 4. Example Code
77
+
78
+ ```tsx
79
+ import Title from "./Title";
80
+ import { IconBell, IconArrowLeft } from "lucide-react";
81
+
82
+ function Example() {
83
+ return (
84
+ <Title
85
+ title={{ text: "Settings" }}
86
+ titleType="Title2"
87
+ caption="Manage your account settings"
88
+ meta="User Profile"
89
+ actions={[
90
+ {
91
+ icon: <IconBell />,
92
+ pressable: { onPress: () => alert("Notifications") },
93
+ },
94
+ ]}
95
+ context={
96
+ <Title.ContextBar
97
+ start={{
98
+ content: "Back",
99
+ leadingIcon: <IconArrowLeft />,
100
+ pressable: {},
101
+ }}
102
+ end={{ content: "Save", pressable: {} }}
103
+ />
104
+ }
105
+ />
106
+ );
107
+ }
108
+ ```
@@ -0,0 +1,53 @@
1
+ # Toggle
2
+
3
+ ## 1. Purpose
4
+
5
+ A toggle (switch) component that lets the user switch between two states (on/off). Smoothly supports drag gestures and click animations.
6
+
7
+ ## 2. Usage Logic
8
+
9
+ - Maintains accessibility by linking with the native HTML `input[type="checkbox"]`.
10
+ - Supports both controlled and uncontrolled rendering via the `checked`, `defaultChecked` props.
11
+ - Uses Framer Motion to naturally control the toggle button's drag (`drag="x"`) and spring animation.
12
+ - Supports `loading`, `disabled`, `readOnly` states, displaying an internal spinner while loading.
13
+ - Rendered together with a `title`, and the `titleSpaceBetween` prop easily sets the spacing layout between the toggle and title.
14
+
15
+ ## 3. Type Signatures
16
+
17
+ ```tsx
18
+ export interface ToggleProps
19
+ extends
20
+ Omit<React.InputHTMLAttributes<HTMLInputElement>, "size" | "color">,
21
+ ThemeSystemProps {
22
+ title?: string;
23
+ titleType?: TextProps["type"];
24
+ titleSpaceBetween?: boolean;
25
+ reversed?: boolean;
26
+ readOnly?: boolean;
27
+ loading?: boolean;
28
+ size?: UIKitSizeValue;
29
+ width?: UIKitSizeValue;
30
+ height?: UIKitSizeValue;
31
+ }
32
+ ```
33
+
34
+ ## 4. Example Code
35
+
36
+ ```tsx
37
+ import { useState } from "react";
38
+ import Toggle from "./Toggle";
39
+
40
+ function Example() {
41
+ const [isEnabled, setIsEnabled] = useState(false);
42
+
43
+ return (
44
+ <Toggle
45
+ checked={isEnabled}
46
+ onChange={(e) => setIsEnabled(e.target.checked)}
47
+ title="Enable Feature"
48
+ titleSpaceBetween
49
+ size={24}
50
+ />
51
+ );
52
+ }
53
+ ```