panelui-native 0.13.0 → 0.16.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.
Files changed (115) hide show
  1. package/README.md +41 -23
  2. package/lib/module/components/button/index.js +12 -9
  3. package/lib/module/components/button/index.js.map +1 -1
  4. package/lib/module/components/chip/index.js +313 -0
  5. package/lib/module/components/chip/index.js.map +1 -0
  6. package/lib/module/components/direction/index.js +86 -0
  7. package/lib/module/components/direction/index.js.map +1 -0
  8. package/lib/module/components/frame/index.js +41 -39
  9. package/lib/module/components/frame/index.js.map +1 -1
  10. package/lib/module/components/heatmap-chart/index.js +772 -0
  11. package/lib/module/components/heatmap-chart/index.js.map +1 -0
  12. package/lib/module/components/input/index.js +4 -0
  13. package/lib/module/components/input/index.js.map +1 -1
  14. package/lib/module/components/message/index.js +16 -1
  15. package/lib/module/components/message/index.js.map +1 -1
  16. package/lib/module/components/scroll-canvas/index.js +175 -0
  17. package/lib/module/components/scroll-canvas/index.js.map +1 -0
  18. package/lib/module/components/scroll-text/index.js +213 -0
  19. package/lib/module/components/scroll-text/index.js.map +1 -0
  20. package/lib/module/components/select/index.js +20 -24
  21. package/lib/module/components/select/index.js.map +1 -1
  22. package/lib/module/components/slider/index.js +2 -5
  23. package/lib/module/components/slider/index.js.map +1 -1
  24. package/lib/module/components/soundwave/index.js +813 -0
  25. package/lib/module/components/soundwave/index.js.map +1 -0
  26. package/lib/module/components/switch/index.js +15 -17
  27. package/lib/module/components/switch/index.js.map +1 -1
  28. package/lib/module/components/thinking-orb/index.js +741 -0
  29. package/lib/module/components/thinking-orb/index.js.map +1 -0
  30. package/lib/module/components/toggle-button/index.js +12 -3
  31. package/lib/module/components/toggle-button/index.js.map +1 -1
  32. package/lib/module/components/typography/index.js +196 -5
  33. package/lib/module/components/typography/index.js.map +1 -1
  34. package/lib/module/hooks/index.js +1 -0
  35. package/lib/module/hooks/index.js.map +1 -1
  36. package/lib/module/hooks/use-keyboard-avoidance.js +99 -59
  37. package/lib/module/hooks/use-keyboard-avoidance.js.map +1 -1
  38. package/lib/module/hooks/use-reveal-progress.js +75 -0
  39. package/lib/module/hooks/use-reveal-progress.js.map +1 -0
  40. package/lib/module/icons/index.js +69 -0
  41. package/lib/module/icons/index.js.map +1 -1
  42. package/lib/module/index.js +9 -1
  43. package/lib/module/index.js.map +1 -1
  44. package/lib/module/native/index.js.map +1 -1
  45. package/lib/module/primitives/keyboard-avoider.js +21 -2
  46. package/lib/module/primitives/keyboard-avoider.js.map +1 -1
  47. package/lib/module/primitives/scroll-progress.js +114 -0
  48. package/lib/module/primitives/scroll-progress.js.map +1 -0
  49. package/lib/typescript/src/components/button/index.d.ts +3 -4
  50. package/lib/typescript/src/components/button/index.d.ts.map +1 -1
  51. package/lib/typescript/src/components/chip/index.d.ts +304 -0
  52. package/lib/typescript/src/components/chip/index.d.ts.map +1 -0
  53. package/lib/typescript/src/components/direction/index.d.ts +64 -0
  54. package/lib/typescript/src/components/direction/index.d.ts.map +1 -0
  55. package/lib/typescript/src/components/frame/index.d.ts +15 -13
  56. package/lib/typescript/src/components/frame/index.d.ts.map +1 -1
  57. package/lib/typescript/src/components/heatmap-chart/index.d.ts +260 -0
  58. package/lib/typescript/src/components/heatmap-chart/index.d.ts.map +1 -0
  59. package/lib/typescript/src/components/input/index.d.ts +19 -4
  60. package/lib/typescript/src/components/input/index.d.ts.map +1 -1
  61. package/lib/typescript/src/components/message/index.d.ts.map +1 -1
  62. package/lib/typescript/src/components/scroll-canvas/index.d.ts +66 -0
  63. package/lib/typescript/src/components/scroll-canvas/index.d.ts.map +1 -0
  64. package/lib/typescript/src/components/scroll-text/index.d.ts +46 -0
  65. package/lib/typescript/src/components/scroll-text/index.d.ts.map +1 -0
  66. package/lib/typescript/src/components/select/index.d.ts.map +1 -1
  67. package/lib/typescript/src/components/slider/index.d.ts.map +1 -1
  68. package/lib/typescript/src/components/soundwave/index.d.ts +91 -0
  69. package/lib/typescript/src/components/soundwave/index.d.ts.map +1 -0
  70. package/lib/typescript/src/components/switch/index.d.ts.map +1 -1
  71. package/lib/typescript/src/components/thinking-orb/index.d.ts +28 -0
  72. package/lib/typescript/src/components/thinking-orb/index.d.ts.map +1 -0
  73. package/lib/typescript/src/components/toggle-button/index.d.ts +12 -0
  74. package/lib/typescript/src/components/toggle-button/index.d.ts.map +1 -1
  75. package/lib/typescript/src/components/typography/index.d.ts +154 -1
  76. package/lib/typescript/src/components/typography/index.d.ts.map +1 -1
  77. package/lib/typescript/src/hooks/index.d.ts +2 -1
  78. package/lib/typescript/src/hooks/index.d.ts.map +1 -1
  79. package/lib/typescript/src/hooks/use-keyboard-avoidance.d.ts +16 -3
  80. package/lib/typescript/src/hooks/use-keyboard-avoidance.d.ts.map +1 -1
  81. package/lib/typescript/src/hooks/use-reveal-progress.d.ts +56 -0
  82. package/lib/typescript/src/hooks/use-reveal-progress.d.ts.map +1 -0
  83. package/lib/typescript/src/icons/index.d.ts +6 -0
  84. package/lib/typescript/src/icons/index.d.ts.map +1 -1
  85. package/lib/typescript/src/index.d.ts +9 -1
  86. package/lib/typescript/src/index.d.ts.map +1 -1
  87. package/lib/typescript/src/native/index.d.ts +15 -7
  88. package/lib/typescript/src/native/index.d.ts.map +1 -1
  89. package/lib/typescript/src/primitives/keyboard-avoider.d.ts +30 -3
  90. package/lib/typescript/src/primitives/keyboard-avoider.d.ts.map +1 -1
  91. package/lib/typescript/src/primitives/scroll-progress.d.ts +61 -0
  92. package/lib/typescript/src/primitives/scroll-progress.d.ts.map +1 -0
  93. package/package.json +1 -1
  94. package/src/components/button/index.tsx +13 -11
  95. package/src/components/direction/index.tsx +90 -0
  96. package/src/components/frame/index.tsx +39 -50
  97. package/src/components/heatmap-chart/index.tsx +1024 -0
  98. package/src/components/input/index.tsx +23 -4
  99. package/src/components/message/index.tsx +17 -1
  100. package/src/components/scroll-canvas/index.tsx +220 -0
  101. package/src/components/scroll-text/index.tsx +277 -0
  102. package/src/components/select/index.tsx +4 -9
  103. package/src/components/slider/index.tsx +4 -7
  104. package/src/components/soundwave/index.tsx +1029 -0
  105. package/src/components/switch/index.tsx +5 -8
  106. package/src/components/thinking-orb/index.tsx +792 -0
  107. package/src/components/typography/index.tsx +231 -10
  108. package/src/hooks/index.ts +6 -0
  109. package/src/hooks/use-keyboard-avoidance.ts +111 -65
  110. package/src/hooks/use-reveal-progress.ts +106 -0
  111. package/src/icons/index.tsx +36 -0
  112. package/src/index.ts +53 -0
  113. package/src/native/index.ts +15 -7
  114. package/src/primitives/keyboard-avoider.tsx +41 -4
  115. package/src/primitives/scroll-progress.tsx +167 -0
package/README.md CHANGED
@@ -90,42 +90,60 @@ overlays, and the toast viewport.
90
90
 
91
91
  | Component | What it does |
92
92
  | --- | --- |
93
- | `Accordion` | Collapsible sections — five variants, single or multiple selection |
94
- | `Alert` | Status message with a built-in icon — info, success, warning, destructive |
95
- | `Avatar` | User image with initials fallback, four sizes, `Avatar.Badge` overlay |
96
- | `Badge` | Status label, dot, or a count clamped at 99+ |
97
- | `BottomSheet` | Draggable bottom sheet with swipe-to-dismiss |
98
- | `Button` | Variants (including social sign-in), sizes, loading, theme-aware icon slots |
99
- | `Card` | Content surface with `Header`, `Content` and `Footer` |
100
- | `Checkbox` | Animated checkbox with label, description, and a checkable card variant |
101
- | `Dialog` | Modal dialog with backdrop, title, description and footer actions |
102
- | `EmptyState` | Placeholder for an empty list or screen, with a stacked-icon media slot |
103
- | `Frame` | Widget shell — header row with action, inset panel of rows, caption footer |
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
+ | `Direction` | Reading direction for everything below it |
105
+ | `EmptyState` | Placeholder for a list or screen with no content |
106
+ | `Frame` | Widget shell — a card of rows sitting in a titled tray |
107
+ | `HeatmapChart` | Contribution grid with a themed colour ramp and a readout |
104
108
  | `Input` | Text field with label, description and error message |
105
- | `InputGroup` | Input with leading and trailing decorators, auto-measured |
109
+ | `InputGroup` | Input with leading and trailing decorators |
110
+ | `Item` | Row of media, text and actions for lists and settings |
106
111
  | `Label` | Form field label with required, invalid and disabled states |
107
- | `Progress` | Determinate and indeterminate progress bar, optionally captioned |
112
+ | `LineChart` | Animated time series, drawn on the UI thread |
113
+ | `Marker` | Inline note between conversation turns |
114
+ | `Message` | Chat turn with avatar, bubble, header and footer |
115
+ | `MessageScroller` | Scroll behaviour a chat transcript needs |
116
+ | `Popover` | Panel anchored to the element that opened it |
117
+ | `Progress` | Determinate and indeterminate progress bar |
108
118
  | `RadioGroup` | Single-select list of options |
119
+ | `ScrollCanvas` | Image frame whose contents move as you scroll |
109
120
  | `ScrollFade` | Fades the edges of a scroll container |
110
- | `SectionRail` | Floating section navigator — bars that expand into a jump list |
111
- | `Select` | Picker shown in a bottom sheet, in place, or floating over the page |
121
+ | `ScrollText` | Text that resolves word by word as you scroll |
122
+ | `SectionRail` | Floating section navigator for a long screen |
123
+ | `Select` | Picker shown in a bottom sheet, expanded in place, or floating over the page |
124
+ | `Separator` | Horizontal or vertical rule between content |
112
125
  | `Shimmer` | Animated highlight sweeping across content |
113
126
  | `Skeleton` | Shimmer placeholder for loading content |
114
127
  | `Slider` | Pick a value by dragging a thumb along a track |
128
+ | `Soundwave` | What a voice looks like while an app listens |
115
129
  | `Spinner` | Indeterminate loading indicator |
116
- | `Steps` | Stepper for multi-step flows, horizontal or vertical |
130
+ | `Steps` | Stepper for multi-step flows |
131
+ | `Surface` | Elevated container with a variant ladder |
117
132
  | `Switch` | Animated on/off toggle |
118
- | `Tabs` | Segmented navigation with animated indicator |
133
+ | `Tabs` | Segmented navigation with an animated indicator |
134
+ | `ThinkingOrb` | Dotted orb saying which kind of busy an agent is |
135
+ | `Timeline` | Vertical sequence of events |
136
+ | `Toast` | Transient notification queue with swipe to dismiss |
119
137
  | `ToggleButton` | A button that stays down, on its own or in a group |
120
- | `Timeline` | Vertical sequence of events — dot, icon, numbered, card or compact, with per-item tones |
121
- | `Toast` | Transient notification queue with swipe-to-dismiss |
122
- | `Typography` | Semantic text presets — `h1`–`h6`, body sizes, inline code |
138
+ | `Typography` | Semantic text presets |
123
139
 
124
- Plus `PanelUIProvider`, `Portal`, `AnimatedPressable`, `Text`, a set of SVG icons (with brand
125
- marks for Google, Facebook and Apple), and the `cn` class-merging helper.
140
+ Plus `PanelUIProvider`, `Portal`, `AnimatedPressable`, `KeyboardAvoider`, `ScrollProgress`,
141
+ `Text`, a set of SVG icons (with brand marks for Google, Facebook and Apple), and the `cn`
142
+ class-merging helper.
126
143
 
127
144
  **Hooks:** `useTheme`, `useThemeMode`, `useToast`, `useCopyToClipboard`, `useDisclosure`,
128
- `useBreakpoint`, `useKeyboard`, `useDebouncedValue`, `usePrevious`.
145
+ `useBreakpoint`, `useKeyboard`, `useKeyboardAvoidance`, `useScrollSections`,
146
+ `useRevealProgress`, `useDebouncedValue`, `usePrevious`.
129
147
 
130
148
  Icons inside a coloured surface inherit a readable colour automatically — `Button` provides the
131
149
  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 native host, matching the styled scale above.
107
+ * Height given to the platform button, matching the styled scale above.
108
108
  *
109
- * The host is told its size rather than asked to work it out. `matchContents`
110
- * measures the platform's own content a frame late and again when that content
111
- * changes — so the button renders at nothing, collapses against whatever sits
112
- * above it, and jolts into place on the first press. Width comes from ordinary
113
- * layout instead, which is why a native button fills its container.
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
- style: {
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","matchContents","color","accessibilityRole","accessibilityState","busy","displayName"],"sourceRoot":"../../../../src","sources":["components/button/index.tsx"],"mappings":";;AAAA,SAASA,UAAU,QAAwB,OAAO;AAElD,SAASC,EAAE,QAA2B,mB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AAA,CAAC8C,UAAU;UAACK,aAAa;UAAArB,QAAA,eACvB9B,IAAA,CAAAF,SAAA;YAAAgC,QAAA,EAAGA;UAAQ,CAAG;QAAC,CACL;MACb,CACW;IAAC,CACX,CAAC;EAEX;EAEA,oBACE9B,IAAA,CAACN,iBAAiB;IAAC0D,KAAK,EAAEV,YAAa;IAAAZ,QAAA,eACrC5B,KAAA,CAACV,iBAAiB;MAChB8C,GAAG,EAAEA,GAAI;MACTe,iBAAiB,EAAC,QAAQ;MAC1BC,kBAAkB,EAAE;QAAE/B,QAAQ,EAAEgB,UAAU;QAAEgB,IAAI,EAAEtB;MAAQ,CAAE;MAC5DV,QAAQ,EAAEgB,UAAW;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":[]}
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,EAAE;IACRC,OAAO,EAAE;MACPC,OAAO,EAAE;QACPL,IAAI,EAAE,qCAAqC;QAC3CC,KAAK,EAAE,yBAAyB;QAChCC,OAAO,EAAE;MACX,CAAC;MACDI,SAAS,EAAE;QACTN,IAAI,EAAE,cAAc;QACpBC,KAAK,EAAE,2BAA2B;QAClCC,OAAO,EAAE;MACX,CAAC;MACDK,OAAO,EAAE;QACPP,IAAI,EAAE,mCAAmC;QACzCC,KAAK,EAAE,iBAAiB;QACxBC,OAAO,EAAE;MACX,CAAC;MACDM,KAAK,EAAE;QACLR,IAAI,EAAE,gBAAgB;QACtBC,KAAK,EAAE,iBAAiB;QACxBC,OAAO,EAAE;MACX,CAAC;MACDO,WAAW,EAAE;QACXT,IAAI,EAAE,6CAA6C;QACnDC,KAAK,EAAE,YAAY;QACnBC,OAAO,EAAE;MAC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2B,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;AAC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6C,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":[]}
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Direction — reading direction for everything below it.
5
+ *
6
+ * ```tsx
7
+ * <Direction dir="rtl">
8
+ * <App />
9
+ * </Direction>
10
+ * ```
11
+ *
12
+ * The layout flip is Yoga's, not ours: the wrapper carries the `direction`
13
+ * style, and every row, `start`/`end` inset and horizontal padding underneath
14
+ * it mirrors natively. That is the whole reason this is a component and not a
15
+ * bare context — `direction` is a *style*, so a subtree is the unit it applies
16
+ * to.
17
+ *
18
+ * It is also the reason to prefer it over flipping the process with
19
+ * `I18nManager.forceRTL`, which needs an app restart to take effect, cannot be
20
+ * scoped to part of a screen, and cannot be previewed side by side. Here the
21
+ * value is a prop: change it and the next frame is mirrored.
22
+ *
23
+ * ## What Yoga does not flip
24
+ *
25
+ * Anything measured in raw pixels rather than laid out — a drag translation, an
26
+ * indicator offset, the direction a sweep travels. Those have to consult the
27
+ * value and negate it themselves, which is what `useDirection()` is for:
28
+ *
29
+ * ```tsx
30
+ * const dir = useDirection();
31
+ * const delta = (dir === 'rtl' ? -event.translationX : event.translationX) / width;
32
+ * ```
33
+ *
34
+ * With no provider mounted, and for a `<Direction>` given no `dir`, the value
35
+ * comes from the device — so an app that did force RTL the old way still reads
36
+ * back the truth.
37
+ */
38
+ import { createContext, useContext, useMemo } from 'react';
39
+ import { I18nManager, View } from 'react-native';
40
+ import { cn } from "../../utils/cn.js";
41
+ import { jsx as _jsx } from "react/jsx-runtime";
42
+ /** What the device is set to, for anything outside a provider. */
43
+ const deviceDirection = () => I18nManager.isRTL ? 'rtl' : 'ltr';
44
+ const DirectionContext = /*#__PURE__*/createContext(null);
45
+ /**
46
+ * Provider. Renders one `View` — it has to, since the flip is a style — which
47
+ * fills its parent by default so it can wrap an app. Pass `className` to change
48
+ * that: `flex-none` or a width class both win over the default.
49
+ */
50
+ export function Direction({
51
+ className,
52
+ children,
53
+ dir,
54
+ style,
55
+ ...props
56
+ }) {
57
+ const inherited = useContext(DirectionContext);
58
+ const value = dir ?? inherited ?? deviceDirection();
59
+
60
+ // The style object is memoised because it is the thing that invalidates
61
+ // layout for the entire subtree — a fresh one each render would re-run Yoga
62
+ // on every parent render, for a value that almost never changes.
63
+ const directionStyle = useMemo(() => ({
64
+ direction: value
65
+ }), [value]);
66
+ return /*#__PURE__*/_jsx(DirectionContext.Provider, {
67
+ value: value,
68
+ children: /*#__PURE__*/_jsx(View, {
69
+ className: cn('flex-1', className),
70
+ style: [directionStyle, style],
71
+ ...props,
72
+ children: children
73
+ })
74
+ });
75
+ }
76
+ Direction.displayName = 'Direction';
77
+
78
+ /**
79
+ * The reading direction in force, for a component that has to flip maths Yoga
80
+ * cannot flip for it. Safe with no provider mounted: it falls back to the
81
+ * device's own setting.
82
+ */
83
+ export function useDirection() {
84
+ return useContext(DirectionContext) ?? deviceDirection();
85
+ }
86
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createContext","useContext","useMemo","I18nManager","View","cn","jsx","_jsx","deviceDirection","isRTL","DirectionContext","Direction","className","children","dir","style","props","inherited","value","directionStyle","direction","Provider","displayName","useDirection"],"sourceRoot":"../../../../src","sources":["components/direction/index.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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