panelui-native 0.12.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -23
- package/lib/module/components/button/index.js +12 -9
- package/lib/module/components/button/index.js.map +1 -1
- package/lib/module/components/chip/index.js +313 -0
- package/lib/module/components/chip/index.js.map +1 -0
- package/lib/module/components/frame/index.js +41 -39
- package/lib/module/components/frame/index.js.map +1 -1
- package/lib/module/components/heatmap-chart/index.js +772 -0
- package/lib/module/components/heatmap-chart/index.js.map +1 -0
- package/lib/module/components/input/index.js +4 -0
- package/lib/module/components/input/index.js.map +1 -1
- package/lib/module/components/scroll-canvas/index.js +175 -0
- package/lib/module/components/scroll-canvas/index.js.map +1 -0
- package/lib/module/components/scroll-text/index.js +213 -0
- package/lib/module/components/scroll-text/index.js.map +1 -0
- package/lib/module/components/select/index.js +20 -24
- package/lib/module/components/select/index.js.map +1 -1
- package/lib/module/components/slider/index.js +2 -5
- package/lib/module/components/slider/index.js.map +1 -1
- package/lib/module/components/switch/index.js +15 -17
- package/lib/module/components/switch/index.js.map +1 -1
- package/lib/module/components/thinking-orb/index.js +741 -0
- package/lib/module/components/thinking-orb/index.js.map +1 -0
- package/lib/module/components/toggle-button/index.js +12 -3
- package/lib/module/components/toggle-button/index.js.map +1 -1
- package/lib/module/hooks/index.js +1 -0
- package/lib/module/hooks/index.js.map +1 -1
- package/lib/module/hooks/use-keyboard-avoidance.js +99 -59
- package/lib/module/hooks/use-keyboard-avoidance.js.map +1 -1
- package/lib/module/hooks/use-reveal-progress.js +75 -0
- package/lib/module/hooks/use-reveal-progress.js.map +1 -0
- package/lib/module/index.js +6 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/native/index.js.map +1 -1
- package/lib/module/primitives/keyboard-avoider.js +21 -2
- package/lib/module/primitives/keyboard-avoider.js.map +1 -1
- package/lib/module/primitives/scroll-progress.js +114 -0
- package/lib/module/primitives/scroll-progress.js.map +1 -0
- package/lib/typescript/src/components/button/index.d.ts +3 -4
- package/lib/typescript/src/components/button/index.d.ts.map +1 -1
- package/lib/typescript/src/components/chip/index.d.ts +304 -0
- package/lib/typescript/src/components/chip/index.d.ts.map +1 -0
- package/lib/typescript/src/components/frame/index.d.ts +15 -13
- package/lib/typescript/src/components/frame/index.d.ts.map +1 -1
- package/lib/typescript/src/components/heatmap-chart/index.d.ts +260 -0
- package/lib/typescript/src/components/heatmap-chart/index.d.ts.map +1 -0
- package/lib/typescript/src/components/input/index.d.ts +19 -4
- package/lib/typescript/src/components/input/index.d.ts.map +1 -1
- package/lib/typescript/src/components/scroll-canvas/index.d.ts +66 -0
- package/lib/typescript/src/components/scroll-canvas/index.d.ts.map +1 -0
- package/lib/typescript/src/components/scroll-text/index.d.ts +46 -0
- package/lib/typescript/src/components/scroll-text/index.d.ts.map +1 -0
- package/lib/typescript/src/components/select/index.d.ts.map +1 -1
- package/lib/typescript/src/components/slider/index.d.ts.map +1 -1
- package/lib/typescript/src/components/switch/index.d.ts.map +1 -1
- package/lib/typescript/src/components/thinking-orb/index.d.ts +28 -0
- package/lib/typescript/src/components/thinking-orb/index.d.ts.map +1 -0
- package/lib/typescript/src/components/toggle-button/index.d.ts +12 -0
- package/lib/typescript/src/components/toggle-button/index.d.ts.map +1 -1
- package/lib/typescript/src/hooks/index.d.ts +2 -1
- package/lib/typescript/src/hooks/index.d.ts.map +1 -1
- package/lib/typescript/src/hooks/use-keyboard-avoidance.d.ts +16 -3
- package/lib/typescript/src/hooks/use-keyboard-avoidance.d.ts.map +1 -1
- package/lib/typescript/src/hooks/use-reveal-progress.d.ts +56 -0
- package/lib/typescript/src/hooks/use-reveal-progress.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +6 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/native/index.d.ts +15 -7
- package/lib/typescript/src/native/index.d.ts.map +1 -1
- package/lib/typescript/src/primitives/keyboard-avoider.d.ts +30 -3
- package/lib/typescript/src/primitives/keyboard-avoider.d.ts.map +1 -1
- package/lib/typescript/src/primitives/scroll-progress.d.ts +61 -0
- package/lib/typescript/src/primitives/scroll-progress.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/components/button/index.tsx +13 -11
- package/src/components/chip/index.tsx +333 -0
- package/src/components/frame/index.tsx +39 -50
- package/src/components/heatmap-chart/index.tsx +1024 -0
- package/src/components/input/index.tsx +23 -4
- package/src/components/scroll-canvas/index.tsx +220 -0
- package/src/components/scroll-text/index.tsx +277 -0
- package/src/components/select/index.tsx +4 -9
- package/src/components/slider/index.tsx +4 -7
- package/src/components/switch/index.tsx +5 -8
- package/src/components/thinking-orb/index.tsx +792 -0
- package/src/components/toggle-button/index.tsx +24 -2
- package/src/hooks/index.ts +6 -0
- package/src/hooks/use-keyboard-avoidance.ts +111 -65
- package/src/hooks/use-reveal-progress.ts +106 -0
- package/src/index.ts +46 -0
- package/src/native/index.ts +15 -7
- package/src/primitives/keyboard-avoider.tsx +41 -4
- package/src/primitives/scroll-progress.tsx +167 -0
package/README.md
CHANGED
|
@@ -90,42 +90,58 @@ overlays, and the toast viewport.
|
|
|
90
90
|
|
|
91
91
|
| Component | What it does |
|
|
92
92
|
| --- | --- |
|
|
93
|
-
| `Accordion` | Collapsible sections
|
|
94
|
-
| `Alert` | Status message with a built-in icon
|
|
95
|
-
| `
|
|
96
|
-
| `
|
|
97
|
-
| `
|
|
98
|
-
| `
|
|
99
|
-
| `
|
|
100
|
-
| `
|
|
101
|
-
| `
|
|
102
|
-
| `
|
|
103
|
-
| `
|
|
93
|
+
| `Accordion` | Collapsible sections with single or multiple selection |
|
|
94
|
+
| `Alert` | Status message with a built-in icon |
|
|
95
|
+
| `Attachment` | File row with upload states, built on Item |
|
|
96
|
+
| `Avatar` | User image with an initials fallback and an optional badge overlay |
|
|
97
|
+
| `Badge` | Compact status label, dot, or notification count |
|
|
98
|
+
| `BottomSheet` | Draggable sheet anchored to the bottom of the screen |
|
|
99
|
+
| `Button` | Pressable action with variants, sizes, loading state and icon slots |
|
|
100
|
+
| `Card` | Content surface with header, body and footer |
|
|
101
|
+
| `Checkbox` | Animated checkbox, as a row or a selectable card |
|
|
102
|
+
| `Chip` | Interactive pill — a filter, a tag, or a removable token |
|
|
103
|
+
| `Dialog` | Modal dialog with a backdrop and footer actions |
|
|
104
|
+
| `EmptyState` | Placeholder for a list or screen with no content |
|
|
105
|
+
| `Frame` | Widget shell — a card of rows sitting in a titled tray |
|
|
106
|
+
| `HeatmapChart` | Contribution grid with a themed colour ramp and a readout |
|
|
104
107
|
| `Input` | Text field with label, description and error message |
|
|
105
|
-
| `InputGroup` | Input with leading and trailing decorators
|
|
108
|
+
| `InputGroup` | Input with leading and trailing decorators |
|
|
109
|
+
| `Item` | Row of media, text and actions for lists and settings |
|
|
106
110
|
| `Label` | Form field label with required, invalid and disabled states |
|
|
107
|
-
| `
|
|
111
|
+
| `LineChart` | Animated time series, drawn on the UI thread |
|
|
112
|
+
| `Marker` | Inline note between conversation turns |
|
|
113
|
+
| `Message` | Chat turn with avatar, bubble, header and footer |
|
|
114
|
+
| `MessageScroller` | Scroll behaviour a chat transcript needs |
|
|
115
|
+
| `Popover` | Panel anchored to the element that opened it |
|
|
116
|
+
| `Progress` | Determinate and indeterminate progress bar |
|
|
108
117
|
| `RadioGroup` | Single-select list of options |
|
|
118
|
+
| `ScrollCanvas` | Image frame whose contents move as you scroll |
|
|
109
119
|
| `ScrollFade` | Fades the edges of a scroll container |
|
|
110
|
-
| `
|
|
111
|
-
| `
|
|
120
|
+
| `ScrollText` | Text that resolves word by word as you scroll |
|
|
121
|
+
| `SectionRail` | Floating section navigator for a long screen |
|
|
122
|
+
| `Select` | Picker shown in a bottom sheet, expanded in place, or floating over the page |
|
|
123
|
+
| `Separator` | Horizontal or vertical rule between content |
|
|
112
124
|
| `Shimmer` | Animated highlight sweeping across content |
|
|
113
125
|
| `Skeleton` | Shimmer placeholder for loading content |
|
|
114
126
|
| `Slider` | Pick a value by dragging a thumb along a track |
|
|
115
127
|
| `Spinner` | Indeterminate loading indicator |
|
|
116
|
-
| `Steps` | Stepper for multi-step flows
|
|
128
|
+
| `Steps` | Stepper for multi-step flows |
|
|
129
|
+
| `Surface` | Elevated container with a variant ladder |
|
|
117
130
|
| `Switch` | Animated on/off toggle |
|
|
118
|
-
| `Tabs` | Segmented navigation with animated indicator |
|
|
131
|
+
| `Tabs` | Segmented navigation with an animated indicator |
|
|
132
|
+
| `ThinkingOrb` | Dotted orb saying which kind of busy an agent is |
|
|
133
|
+
| `Timeline` | Vertical sequence of events |
|
|
134
|
+
| `Toast` | Transient notification queue with swipe to dismiss |
|
|
119
135
|
| `ToggleButton` | A button that stays down, on its own or in a group |
|
|
120
|
-
| `
|
|
121
|
-
| `Toast` | Transient notification queue with swipe-to-dismiss |
|
|
122
|
-
| `Typography` | Semantic text presets — `h1`–`h6`, body sizes, inline code |
|
|
136
|
+
| `Typography` | Semantic text presets |
|
|
123
137
|
|
|
124
|
-
Plus `PanelUIProvider`, `Portal`, `AnimatedPressable`, `
|
|
125
|
-
marks for Google, Facebook and Apple), and the `cn`
|
|
138
|
+
Plus `PanelUIProvider`, `Portal`, `AnimatedPressable`, `KeyboardAvoider`, `ScrollProgress`,
|
|
139
|
+
`Text`, a set of SVG icons (with brand marks for Google, Facebook and Apple), and the `cn`
|
|
140
|
+
class-merging helper.
|
|
126
141
|
|
|
127
142
|
**Hooks:** `useTheme`, `useThemeMode`, `useToast`, `useCopyToClipboard`, `useDisclosure`,
|
|
128
|
-
`useBreakpoint`, `useKeyboard`, `
|
|
143
|
+
`useBreakpoint`, `useKeyboard`, `useKeyboardAvoidance`, `useScrollSections`,
|
|
144
|
+
`useRevealProgress`, `useDebouncedValue`, `usePrevious`.
|
|
129
145
|
|
|
130
146
|
Icons inside a coloured surface inherit a readable colour automatically — `Button` provides the
|
|
131
147
|
foreground its variant reads against, so an icon in `startContent` follows the theme without a
|
|
@@ -104,13 +104,15 @@ const CONTENT_COLOR_VAR = {
|
|
|
104
104
|
social: '--color-foreground'
|
|
105
105
|
};
|
|
106
106
|
/**
|
|
107
|
-
* Height given to the
|
|
107
|
+
* Height given to the platform button, matching the styled scale above.
|
|
108
108
|
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
109
|
+
* It goes on the button rather than on the host, and that distinction is the
|
|
110
|
+
* whole fix for the jump. A host sized to a number with an unsized control
|
|
111
|
+
* inside it hands the platform a box the control never agreed to: SwiftUI and
|
|
112
|
+
* Compose both lay out against their own intrinsic size and only settle into
|
|
113
|
+
* the box when something forces a second pass — which for a button is the
|
|
114
|
+
* first press. Given a definite height of its own, the button has nothing left
|
|
115
|
+
* to recompute, and the host follows it with `matchContents`.
|
|
114
116
|
*/
|
|
115
117
|
const NATIVE_HEIGHT = {
|
|
116
118
|
sm: 36,
|
|
@@ -168,13 +170,14 @@ export const Button = /*#__PURE__*/forwardRef(({
|
|
|
168
170
|
} = nativeUI;
|
|
169
171
|
const isStringLabel = typeof children === 'string';
|
|
170
172
|
return /*#__PURE__*/_jsx(Host, {
|
|
171
|
-
|
|
172
|
-
height: NATIVE_HEIGHT[size ?? 'md']
|
|
173
|
-
},
|
|
173
|
+
matchContents: true,
|
|
174
174
|
children: /*#__PURE__*/_jsx(NativeButton, {
|
|
175
175
|
label: isStringLabel ? children : undefined,
|
|
176
176
|
variant: NATIVE_VARIANT[variant ?? 'primary'],
|
|
177
177
|
disabled: isDisabled,
|
|
178
|
+
style: {
|
|
179
|
+
height: NATIVE_HEIGHT[size ?? 'md']
|
|
180
|
+
},
|
|
178
181
|
onPress: props.onPress,
|
|
179
182
|
children: isStringLabel ? undefined : /*#__PURE__*/_jsx(RNHostView, {
|
|
180
183
|
matchContents: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["forwardRef","tv","useCSSVariable","AnimatedPressable","Text","IconColorProvider","getNativeUI","Spinner","Fragment","_Fragment","jsx","_jsx","jsxs","_jsxs","buttonVariants","slots","root","label","spinner","variants","variant","primary","secondary","outline","ghost","destructive","social","size","sm","md","lg","icon","fullWidth","true","disabled","defaultVariants","SPINNER_SIZE","CONTENT_COLOR_VAR","NATIVE_HEIGHT","NATIVE_VARIANT","Button","children","className","labelClassName","loading","startContent","endContent","native","props","ref","isDisabled","nativeUI","themedColor","contentColor","undefined","Host","NativeButton","RNHostView","isStringLabel","style","height","onPress","
|
|
1
|
+
{"version":3,"names":["forwardRef","tv","useCSSVariable","AnimatedPressable","Text","IconColorProvider","getNativeUI","Spinner","Fragment","_Fragment","jsx","_jsx","jsxs","_jsxs","buttonVariants","slots","root","label","spinner","variants","variant","primary","secondary","outline","ghost","destructive","social","size","sm","md","lg","icon","fullWidth","true","disabled","defaultVariants","SPINNER_SIZE","CONTENT_COLOR_VAR","NATIVE_HEIGHT","NATIVE_VARIANT","Button","children","className","labelClassName","loading","startContent","endContent","native","props","ref","isDisabled","nativeUI","themedColor","contentColor","undefined","Host","NativeButton","RNHostView","isStringLabel","matchContents","style","height","onPress","color","accessibilityRole","accessibilityState","busy","displayName"],"sourceRoot":"../../../../src","sources":["components/button/index.tsx"],"mappings":";;AAAA,SAASA,UAAU,QAAwB,OAAO;AAElD,SAASC,EAAE,QAA2B,mBAAmB;AACzD,SAASC,cAAc,QAAQ,SAAS;AACxC,SACEC,iBAAiB,QAEZ,wCAAqC;AAC5C,SAASC,IAAI,QAAQ,0BAAuB;AAC5C,SAASC,iBAAiB,QAAQ,sBAAa;AAC/C,SAASC,WAAW,QAAQ,uBAAc;AAC1C,SAASC,OAAO,QAAQ,qBAAY;AAAC,SAAAC,QAAA,IAAAC,SAAA,EAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAErC,MAAMC,cAAc,GAAGb,EAAE,CAAC;EACxBc,KAAK,EAAE;IACLC,IAAI,EAAE,iFAAiF;IACvFC,KAAK,EAAE,aAAa;IACpBC,OAAO,EAAE;EACX,CAAC;EACDC,QAAQ,EAA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AAW;MACrBR,SAAS,EAAE1B,IAAI,CAAC;QAAE0B;MAAU,CAAC,CAAE;MAAA,GAC3BM,KAAK;MAAAP,QAAA,GAERG,OAAO,gBACNjC,IAAA,CAACJ,OAAO;QAACoB,IAAI,EAAES,YAAY,CAACT,IAAI,IAAI,IAAI,CAAE;QAACe,SAAS,EAAExB,OAAO,CAAC;MAAE,CAAE,CAAC,GAEnE2B,YACD,EACA,OAAOJ,QAAQ,KAAK,QAAQ,gBAC3B9B,IAAA,CAACP,IAAI;QAACsC,SAAS,EAAEzB,KAAK,CAAC;UAAEyB,SAAS,EAAEC;QAAe,CAAC,CAAE;QAAAF,QAAA,EAAEA;MAAQ,CAAO,CAAC,GAExEA,QACD,EACAK,UAAU;IAAA,CACM;EAAC,CACH,CAAC;AAExB,CACF,CAAC;AAEDN,MAAM,CAAC2B,WAAW,GAAG,QAAQ","ignoreList":[]}
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Chip — a compact, interactive token.
|
|
5
|
+
*
|
|
6
|
+
* Where Badge only shows and ToggleButton owns a stateful toolbar, Chip is the
|
|
7
|
+
* thing in between: a small pill you can *press*, mark as *selected*, or
|
|
8
|
+
* *remove*. It is the filter in a filter bar, the tag on a photo, the removable
|
|
9
|
+
* recipient in a "To:" field — small, dense, and touchable.
|
|
10
|
+
*
|
|
11
|
+
* The close button is its own hit target nested inside the pill, so tapping the
|
|
12
|
+
* ✕ removes the chip without also firing the chip's own `onPress`. That split
|
|
13
|
+
* is the whole reason a removable chip needs a component and not just a styled
|
|
14
|
+
* Badge.
|
|
15
|
+
*
|
|
16
|
+
* ```tsx
|
|
17
|
+
* <Chip>Design</Chip>
|
|
18
|
+
*
|
|
19
|
+
* <Chip variant="info" onClose={() => remove('design')}>Design</Chip>
|
|
20
|
+
*
|
|
21
|
+
* <Chip selected={on} onPress={() => setOn(!on)}>
|
|
22
|
+
* <CheckIcon size={14} />
|
|
23
|
+
* <Chip.Label>Available</Chip.Label>
|
|
24
|
+
* </Chip>
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
import { createContext, forwardRef, useCallback, useContext, useMemo } from 'react';
|
|
28
|
+
import { Pressable, View } from 'react-native';
|
|
29
|
+
import { tv } from 'tailwind-variants';
|
|
30
|
+
import { useCSSVariable } from 'uniwind';
|
|
31
|
+
import { IconColorProvider, XIcon } from "../../icons/index.js";
|
|
32
|
+
import { AnimatedPressable } from "../../primitives/animated-pressable.js";
|
|
33
|
+
import { Text } from "../../primitives/text.js";
|
|
34
|
+
import { cn } from "../../utils/cn.js";
|
|
35
|
+
import { selectionTick } from "../../utils/haptics.js";
|
|
36
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
37
|
+
const chipVariants = tv({
|
|
38
|
+
slots: {
|
|
39
|
+
root: 'flex-row items-center self-start rounded-full border border-transparent',
|
|
40
|
+
label: 'font-medium',
|
|
41
|
+
close: 'items-center justify-center rounded-full -mr-1 aspect-square opacity-70'
|
|
42
|
+
},
|
|
43
|
+
variants: {
|
|
44
|
+
variant: {
|
|
45
|
+
/** The resting tag — a quiet neutral fill. */
|
|
46
|
+
default: {
|
|
47
|
+
root: 'bg-secondary',
|
|
48
|
+
label: 'text-secondary-foreground'
|
|
49
|
+
},
|
|
50
|
+
/** The accent fill, for the one chip that leads. */
|
|
51
|
+
primary: {
|
|
52
|
+
root: 'bg-primary',
|
|
53
|
+
label: 'text-primary-foreground'
|
|
54
|
+
},
|
|
55
|
+
/** Just an outline — the lightest a chip gets while still being a shape. */
|
|
56
|
+
outline: {
|
|
57
|
+
root: 'border-border bg-transparent',
|
|
58
|
+
label: 'text-foreground'
|
|
59
|
+
},
|
|
60
|
+
success: {
|
|
61
|
+
root: 'bg-success-subtle',
|
|
62
|
+
label: 'text-success-foreground'
|
|
63
|
+
},
|
|
64
|
+
warning: {
|
|
65
|
+
root: 'bg-warning-subtle',
|
|
66
|
+
label: 'text-warning-foreground'
|
|
67
|
+
},
|
|
68
|
+
info: {
|
|
69
|
+
root: 'bg-info-subtle',
|
|
70
|
+
label: 'text-info-foreground'
|
|
71
|
+
},
|
|
72
|
+
destructive: {
|
|
73
|
+
root: 'bg-destructive-subtle',
|
|
74
|
+
label: 'text-destructive-foreground'
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
size: {
|
|
78
|
+
sm: {
|
|
79
|
+
root: 'h-6 gap-1 px-2',
|
|
80
|
+
label: 'text-xs'
|
|
81
|
+
},
|
|
82
|
+
md: {
|
|
83
|
+
root: 'h-7 gap-1.5 px-2.5',
|
|
84
|
+
label: 'text-sm'
|
|
85
|
+
},
|
|
86
|
+
lg: {
|
|
87
|
+
root: 'h-9 gap-2 px-3.5',
|
|
88
|
+
label: 'text-base'
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
/**
|
|
92
|
+
* The filter "on" state — a loud accent surface that wins over the resting
|
|
93
|
+
* variant, so any chip can be a filter without picking a second colour.
|
|
94
|
+
*/
|
|
95
|
+
selected: {
|
|
96
|
+
true: {
|
|
97
|
+
root: 'border-primary/24 bg-accent',
|
|
98
|
+
label: 'text-accent-foreground'
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
/** Trims the trailing padding so the close target hugs the right edge. */
|
|
102
|
+
closable: {
|
|
103
|
+
true: {
|
|
104
|
+
root: 'pr-1'
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
disabled: {
|
|
108
|
+
true: {
|
|
109
|
+
root: 'opacity-[0.56]'
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
compoundVariants: [{
|
|
114
|
+
size: 'sm',
|
|
115
|
+
closable: true,
|
|
116
|
+
class: {
|
|
117
|
+
close: 'h-4'
|
|
118
|
+
}
|
|
119
|
+
}, {
|
|
120
|
+
size: 'md',
|
|
121
|
+
closable: true,
|
|
122
|
+
class: {
|
|
123
|
+
close: 'h-5'
|
|
124
|
+
}
|
|
125
|
+
}, {
|
|
126
|
+
size: 'lg',
|
|
127
|
+
closable: true,
|
|
128
|
+
class: {
|
|
129
|
+
close: 'h-6'
|
|
130
|
+
}
|
|
131
|
+
}],
|
|
132
|
+
defaultVariants: {
|
|
133
|
+
variant: 'default',
|
|
134
|
+
size: 'md'
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
/** Which foreground token each variant paints its icons and ✕ with. */
|
|
138
|
+
const TINT_VAR = {
|
|
139
|
+
default: '--color-secondary-foreground',
|
|
140
|
+
primary: '--color-primary-foreground',
|
|
141
|
+
outline: '--color-foreground',
|
|
142
|
+
success: '--color-success-foreground',
|
|
143
|
+
warning: '--color-warning-foreground',
|
|
144
|
+
info: '--color-info-foreground',
|
|
145
|
+
destructive: '--color-destructive-foreground'
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
/** The ✕ scales with the pill so it never looks stranded in a large chip. */
|
|
149
|
+
const CLOSE_ICON = {
|
|
150
|
+
sm: 11,
|
|
151
|
+
md: 13,
|
|
152
|
+
lg: 15
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
/* -------------------------------------------------------------------------- */
|
|
156
|
+
/* State context */
|
|
157
|
+
/* -------------------------------------------------------------------------- */
|
|
158
|
+
|
|
159
|
+
const ChipContext = /*#__PURE__*/createContext(null);
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* The chip's own state, for anything rendered inside it — an icon that swaps
|
|
163
|
+
* when the chip is selected, a count that only shows when it is on.
|
|
164
|
+
*/
|
|
165
|
+
export function useChip() {
|
|
166
|
+
const ctx = useContext(ChipContext);
|
|
167
|
+
if (!ctx) {
|
|
168
|
+
throw new Error('useChip must be used within a <Chip>');
|
|
169
|
+
}
|
|
170
|
+
return {
|
|
171
|
+
selected: ctx.selected,
|
|
172
|
+
disabled: ctx.disabled
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/* -------------------------------------------------------------------------- */
|
|
177
|
+
/* Chip */
|
|
178
|
+
/* -------------------------------------------------------------------------- */
|
|
179
|
+
|
|
180
|
+
const ChipRoot = /*#__PURE__*/forwardRef(({
|
|
181
|
+
children,
|
|
182
|
+
className,
|
|
183
|
+
labelClassName,
|
|
184
|
+
variant = 'default',
|
|
185
|
+
size = 'md',
|
|
186
|
+
selected,
|
|
187
|
+
disabled = false,
|
|
188
|
+
start,
|
|
189
|
+
onClose,
|
|
190
|
+
closeLabel = 'Remove',
|
|
191
|
+
haptics = false,
|
|
192
|
+
onPress,
|
|
193
|
+
...props
|
|
194
|
+
}, ref) => {
|
|
195
|
+
const isToggle = selected !== undefined;
|
|
196
|
+
const isSelected = selected ?? false;
|
|
197
|
+
const closable = onClose !== undefined;
|
|
198
|
+
// Only the whole chip becoming pressable warrants the press animation; a
|
|
199
|
+
// static attribute tag stays a plain View so it does not invite a tap.
|
|
200
|
+
const pressable = onPress !== undefined || isToggle;
|
|
201
|
+
const slots = chipVariants({
|
|
202
|
+
variant,
|
|
203
|
+
size,
|
|
204
|
+
selected: isSelected,
|
|
205
|
+
closable,
|
|
206
|
+
disabled
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
// Icons and the ✕ inherit this, so they track the surface they sit on
|
|
210
|
+
// instead of every caller hardcoding a hex that is wrong in one theme.
|
|
211
|
+
const tint = useCSSVariable(isSelected ? '--color-accent-foreground' : TINT_VAR[variant]);
|
|
212
|
+
const handlePress = useCallback(event => {
|
|
213
|
+
if (haptics) selectionTick();
|
|
214
|
+
onPress?.(event);
|
|
215
|
+
}, [haptics, onPress]);
|
|
216
|
+
const handleClose = useCallback(() => {
|
|
217
|
+
if (haptics) selectionTick();
|
|
218
|
+
onClose?.();
|
|
219
|
+
}, [haptics, onClose]);
|
|
220
|
+
const labelClasses = slots.label();
|
|
221
|
+
const state = useMemo(() => ({
|
|
222
|
+
selected: isSelected,
|
|
223
|
+
disabled,
|
|
224
|
+
labelClasses
|
|
225
|
+
}), [isSelected, disabled, labelClasses]);
|
|
226
|
+
const body = /*#__PURE__*/_jsxs(_Fragment, {
|
|
227
|
+
children: [start, typeof children === 'string' ? /*#__PURE__*/_jsx(Text, {
|
|
228
|
+
className: slots.label({
|
|
229
|
+
className: labelClassName
|
|
230
|
+
}),
|
|
231
|
+
children: children
|
|
232
|
+
}) : children, closable ? /*#__PURE__*/_jsx(Pressable, {
|
|
233
|
+
accessibilityRole: "button",
|
|
234
|
+
accessibilityLabel: closeLabel
|
|
235
|
+
// A small pill leaves little room for the ✕; the slop gives the
|
|
236
|
+
// finger the target the pixels do not.
|
|
237
|
+
,
|
|
238
|
+
hitSlop: 8,
|
|
239
|
+
disabled: disabled,
|
|
240
|
+
onPress: handleClose,
|
|
241
|
+
className: slots.close(),
|
|
242
|
+
children: /*#__PURE__*/_jsx(XIcon, {
|
|
243
|
+
size: CLOSE_ICON[size]
|
|
244
|
+
})
|
|
245
|
+
}) : null]
|
|
246
|
+
});
|
|
247
|
+
const sharedProps = {
|
|
248
|
+
accessibilityRole: 'button',
|
|
249
|
+
// A toggle chip is read out as checked/unchecked; a plain pressable one
|
|
250
|
+
// as a button. A static tag gets neither, so it is not announced as
|
|
251
|
+
// something to press.
|
|
252
|
+
accessibilityState: {
|
|
253
|
+
disabled,
|
|
254
|
+
...(isToggle ? {
|
|
255
|
+
selected: isSelected
|
|
256
|
+
} : {})
|
|
257
|
+
},
|
|
258
|
+
'aria-pressed': isToggle ? isSelected : undefined,
|
|
259
|
+
disabled,
|
|
260
|
+
className: slots.root({
|
|
261
|
+
className
|
|
262
|
+
})
|
|
263
|
+
};
|
|
264
|
+
return /*#__PURE__*/_jsx(ChipContext.Provider, {
|
|
265
|
+
value: state,
|
|
266
|
+
children: /*#__PURE__*/_jsx(IconColorProvider, {
|
|
267
|
+
color: typeof tint === 'string' ? tint : undefined,
|
|
268
|
+
children: pressable ? /*#__PURE__*/_jsx(AnimatedPressable, {
|
|
269
|
+
ref: ref,
|
|
270
|
+
onPress: handlePress,
|
|
271
|
+
...sharedProps,
|
|
272
|
+
...props,
|
|
273
|
+
children: body
|
|
274
|
+
}) : /*#__PURE__*/_jsx(View, {
|
|
275
|
+
ref: ref,
|
|
276
|
+
className: slots.root({
|
|
277
|
+
className
|
|
278
|
+
}),
|
|
279
|
+
...props,
|
|
280
|
+
children: body
|
|
281
|
+
})
|
|
282
|
+
})
|
|
283
|
+
});
|
|
284
|
+
});
|
|
285
|
+
ChipRoot.displayName = 'Chip';
|
|
286
|
+
|
|
287
|
+
/* -------------------------------------------------------------------------- */
|
|
288
|
+
/* Chip.Label */
|
|
289
|
+
/* -------------------------------------------------------------------------- */
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* The label, when the chip holds more than a string — an icon beside text. It
|
|
293
|
+
* reads the selected state itself, so composing the two does not mean threading
|
|
294
|
+
* the colour through by hand.
|
|
295
|
+
*/
|
|
296
|
+
function ChipLabel({
|
|
297
|
+
className,
|
|
298
|
+
children
|
|
299
|
+
}) {
|
|
300
|
+
const ctx = useContext(ChipContext);
|
|
301
|
+
if (!ctx) {
|
|
302
|
+
throw new Error('Chip.Label must be used within a <Chip>');
|
|
303
|
+
}
|
|
304
|
+
return /*#__PURE__*/_jsx(Text, {
|
|
305
|
+
className: cn(ctx.labelClasses, className),
|
|
306
|
+
children: children
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
ChipLabel.displayName = 'Chip.Label';
|
|
310
|
+
export const Chip = Object.assign(ChipRoot, {
|
|
311
|
+
Label: ChipLabel
|
|
312
|
+
});
|
|
313
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createContext","forwardRef","useCallback","useContext","useMemo","Pressable","View","tv","useCSSVariable","IconColorProvider","XIcon","AnimatedPressable","Text","cn","selectionTick","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","chipVariants","slots","root","label","close","variants","variant","default","primary","outline","success","warning","info","destructive","size","sm","md","lg","selected","true","closable","disabled","compoundVariants","class","defaultVariants","TINT_VAR","CLOSE_ICON","ChipContext","useChip","ctx","Error","ChipRoot","children","className","labelClassName","start","onClose","closeLabel","haptics","onPress","props","ref","isToggle","undefined","isSelected","pressable","tint","handlePress","event","handleClose","labelClasses","state","body","accessibilityRole","accessibilityLabel","hitSlop","sharedProps","accessibilityState","Provider","value","color","displayName","ChipLabel","Chip","Object","assign","Label"],"sourceRoot":"../../../../src","sources":["components/chip/index.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SACEA,aAAa,EACbC,UAAU,EACVC,WAAW,EACXC,UAAU,EACVC,OAAO,QAEF,OAAO;AACd,SAASC,SAAS,EAAEC,IAAI,QAAwB,cAAc;AAC9D,SAASC,EAAE,QAA2B,mBAAmB;AACzD,SAASC,cAAc,QAAQ,SAAS;AACxC,SAASC,iBAAiB,EAAEC,KAAK,QAAQ,sBAAa;AACtD,SACEC,iBAAiB,QAEZ,wCAAqC;AAC5C,SAASC,IAAI,QAAQ,0BAAuB;AAC5C,SAASC,EAAE,QAAQ,mBAAgB;AACnC,SAASC,aAAa,QAAQ,wBAAqB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,QAAA,IAAAC,SAAA,EAAAC,IAAA,IAAAC,KAAA;AAEpD,MAAMC,YAAY,GAAGd,EAAE,CAAC;EACtBe,KAAK,EAAE;IACLC,IAAI,EAAE,yEAAyE;IAC/EC,KAAK,EAAE,aAAa;IACpBC,KAAK,EACH;EACJ,CAAC;EACDC,QAAQ,EAAE;IACRC,OAAO,EAAE;MACP;MACAC,OAAO,EAAE;QAAEL,IAAI,EAAE,cAAc;QAAEC,KAAK,EAAE;MAA4B,CAAC;MACrE;MACAK,OAAO,EAAE;QAAEN,IAAI,EAAE,YAAY;QAAEC,KAAK,EAAE;MAA0B,CAAC;MACjE;MACAM,OAAO,EAAE;QAA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K,CAACC,IAAI,CAAC;UAAE+B;QAAU,CAAC,CAAE;QAAA,GAAMO,KAAK;QAAAR,QAAA,EAC7DoB;MAAI,CACD;IACP,CACgB;EAAC,CACA,CAAC;AAE3B,CACF,CAAC;AACDrB,QAAQ,CAAC8B,WAAW,GAAG,MAAM;;AAE7B;AACA;AACA;;AAOA;AACA;AACA;AACA;AACA;AACA,SAASC,SAASA,CAAC;EAAE7B,SAAS;EAAED;AAAyB,CAAC,EAAE;EAC1D,MAAMH,GAAG,GAAG/C,UAAU,CAAC6C,WAAW,CAAC;EACnC,IAAI,CAACE,GAAG,EAAE;IACR,MAAM,IAAIC,KAAK,CAAC,yCAAyC,CAAC;EAC5D;EACA,oBAAOnC,IAAA,CAACJ,IAAI;IAAC0C,SAAS,EAAEzC,EAAE,CAACqC,GAAG,CAACqB,YAAY,EAAEjB,SAAS,CAAE;IAAAD,QAAA,EAAEA;EAAQ,CAAO,CAAC;AAC5E;AACA8B,SAAS,CAACD,WAAW,GAAG,YAAY;AAEpC,OAAO,MAAME,IAAI,GAAGC,MAAM,CAACC,MAAM,CAAClC,QAAQ,EAAE;EAC1CmC,KAAK,EAAEJ;AACT,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,25 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Frame — a widget shell: a
|
|
5
|
-
*
|
|
4
|
+
* Frame — a widget shell: a card of rows sitting in a tray, with the tray's
|
|
5
|
+
* one exposed strip along the top carrying the title.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* The two surfaces are nested rather than stacked, and only one edge of the
|
|
8
|
+
* outer one is ever visible. The panel is flush to the shell's left, right and
|
|
9
|
+
* bottom, so the shell reads as something the card is *sitting in* rather than
|
|
10
|
+
* as a border around it — and the strip left at the top is the header, which
|
|
11
|
+
* is why the header needs no rule under it and no background of its own.
|
|
12
|
+
*
|
|
13
|
+
* The shell's radius is the larger of the two, and the panel's top corners are
|
|
14
|
+
* tighter. That is the reverse of the usual nested-radius rule, and it is
|
|
15
|
+
* deliberate: with only the top corners free, matching them would make the two
|
|
16
|
+
* surfaces read as one misdrawn shape. The panel's bottom corners are not set
|
|
17
|
+
* at all — the shell clips them, so they take its radius exactly.
|
|
11
18
|
*
|
|
12
19
|
* ```tsx
|
|
13
20
|
* <Frame>
|
|
14
21
|
* <Frame.Header>
|
|
15
|
-
* <Frame.Title>
|
|
16
|
-
* <Frame.Action>
|
|
22
|
+
* <Frame.Title>Agent monitor</Frame.Title>
|
|
23
|
+
* <Frame.Action>All agents under 25% token limit</Frame.Action>
|
|
17
24
|
* </Frame.Header>
|
|
18
25
|
* <Frame.Panel>
|
|
19
26
|
* <Frame.Row>…</Frame.Row>
|
|
20
27
|
* <Frame.Row>…</Frame.Row>
|
|
21
28
|
* </Frame.Panel>
|
|
22
|
-
* <Frame.Footer>Updated 2 minutes ago</Frame.Footer>
|
|
23
29
|
* </Frame>
|
|
24
30
|
* ```
|
|
25
31
|
*
|
|
@@ -37,19 +43,26 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
37
43
|
const frameVariants = tv({
|
|
38
44
|
slots: {
|
|
39
45
|
root: '',
|
|
40
|
-
|
|
46
|
+
// Flush left, right and bottom: no side or bottom border, because the
|
|
47
|
+
// shell's own edge is already there, and no bottom radius, because the
|
|
48
|
+
// shell clips it. Only the top corners and the rule under the header are
|
|
49
|
+
// the panel's to draw.
|
|
50
|
+
panel: 'overflow-hidden rounded-t-2xl border-t border-border bg-card'
|
|
41
51
|
},
|
|
42
52
|
variants: {
|
|
43
53
|
variant: {
|
|
54
|
+
// `overflow-hidden` is load-bearing — it is what makes the panel's
|
|
55
|
+
// bottom corners take the shell's radius instead of squaring off
|
|
56
|
+
// against it.
|
|
44
57
|
default: {
|
|
45
|
-
root: 'rounded-
|
|
58
|
+
root: 'overflow-hidden rounded-3xl border border-border bg-surface'
|
|
46
59
|
},
|
|
47
60
|
// No shell: the panel is the whole widget. For a Frame nested inside a
|
|
48
61
|
// card that already draws a border, where the shell's own edge sitting
|
|
49
62
|
// just inside it reads as a double line.
|
|
50
63
|
plain: {
|
|
51
64
|
root: '',
|
|
52
|
-
panel: 'rounded-
|
|
65
|
+
panel: 'rounded-3xl border border-border'
|
|
53
66
|
}
|
|
54
67
|
}
|
|
55
68
|
},
|
|
@@ -72,26 +85,32 @@ const FrameRoot = /*#__PURE__*/forwardRef(({
|
|
|
72
85
|
}));
|
|
73
86
|
FrameRoot.displayName = 'Frame';
|
|
74
87
|
/**
|
|
75
|
-
* The header row
|
|
76
|
-
* `className="flex-col items-start"`
|
|
88
|
+
* The header row — the strip of shell left exposed above the panel. Title on
|
|
89
|
+
* the left, `Frame.Action` on the right. Add `className="flex-col items-start"`
|
|
90
|
+
* when you want a description underneath.
|
|
77
91
|
*/
|
|
78
92
|
const FrameHeader = /*#__PURE__*/forwardRef(({
|
|
79
93
|
className,
|
|
80
94
|
...props
|
|
81
95
|
}, ref) => /*#__PURE__*/_jsx(View, {
|
|
82
96
|
ref: ref,
|
|
83
|
-
className: cn('flex-row items-center justify-between gap-3 px-
|
|
97
|
+
className: cn('flex-row items-center justify-between gap-3 px-4 pb-3 pt-2.5', className),
|
|
84
98
|
...props
|
|
85
99
|
}));
|
|
86
100
|
FrameHeader.displayName = 'Frame.Header';
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Muted by default. The header is a caption on the tray the card sits in, not
|
|
104
|
+
* a heading over a section — the card's own rows carry the weight.
|
|
105
|
+
*/
|
|
87
106
|
const FrameTitle = /*#__PURE__*/forwardRef(({
|
|
88
107
|
className,
|
|
89
108
|
...props
|
|
90
109
|
}, ref) => /*#__PURE__*/_jsx(Text, {
|
|
91
110
|
ref: ref,
|
|
92
|
-
size: "
|
|
93
|
-
|
|
94
|
-
className:
|
|
111
|
+
size: "sm",
|
|
112
|
+
muted: true,
|
|
113
|
+
className: className,
|
|
95
114
|
...props
|
|
96
115
|
}));
|
|
97
116
|
FrameTitle.displayName = 'Frame.Title';
|
|
@@ -108,7 +127,7 @@ const FrameAction = /*#__PURE__*/forwardRef(({
|
|
|
108
127
|
className: cn('flex-row items-center gap-2', className),
|
|
109
128
|
...props,
|
|
110
129
|
children: typeof children === 'string' ? /*#__PURE__*/_jsx(Text, {
|
|
111
|
-
size: "
|
|
130
|
+
size: "sm",
|
|
112
131
|
muted: true,
|
|
113
132
|
children: children
|
|
114
133
|
}) : children
|
|
@@ -151,8 +170,8 @@ function divideChildren(children) {
|
|
|
151
170
|
});
|
|
152
171
|
}
|
|
153
172
|
/**
|
|
154
|
-
* The
|
|
155
|
-
*
|
|
173
|
+
* The card holding the frame's content — flush to the shell on three sides,
|
|
174
|
+
* with the header strip above it.
|
|
156
175
|
*/
|
|
157
176
|
const FramePanel = /*#__PURE__*/forwardRef(({
|
|
158
177
|
className,
|
|
@@ -235,22 +254,6 @@ FrameSection.displayName = 'Frame.Section';
|
|
|
235
254
|
|
|
236
255
|
/** Parts the panel divides. Declared after them, since it holds references. */
|
|
237
256
|
const DIVIDABLE = new Set([FrameRow, FrameSection]);
|
|
238
|
-
/** Muted caption under the panel. Strings are wrapped for you. */
|
|
239
|
-
const FrameFooter = /*#__PURE__*/forwardRef(({
|
|
240
|
-
className,
|
|
241
|
-
children,
|
|
242
|
-
...props
|
|
243
|
-
}, ref) => /*#__PURE__*/_jsx(View, {
|
|
244
|
-
ref: ref,
|
|
245
|
-
className: cn('flex-row items-center gap-2 px-3 pb-1.5 pt-2.5', className),
|
|
246
|
-
...props,
|
|
247
|
-
children: typeof children === 'string' ? /*#__PURE__*/_jsx(Text, {
|
|
248
|
-
size: "sm",
|
|
249
|
-
muted: true,
|
|
250
|
-
children: children
|
|
251
|
-
}) : children
|
|
252
|
-
}));
|
|
253
|
-
FrameFooter.displayName = 'Frame.Footer';
|
|
254
257
|
export const Frame = Object.assign(FrameRoot, {
|
|
255
258
|
Header: FrameHeader,
|
|
256
259
|
Title: FrameTitle,
|
|
@@ -258,7 +261,6 @@ export const Frame = Object.assign(FrameRoot, {
|
|
|
258
261
|
Description: FrameDescription,
|
|
259
262
|
Panel: FramePanel,
|
|
260
263
|
Section: FrameSection,
|
|
261
|
-
Row: FrameRow
|
|
262
|
-
Footer: FrameFooter
|
|
264
|
+
Row: FrameRow
|
|
263
265
|
});
|
|
264
266
|
//# sourceMappingURL=index.js.map
|