@pickle-ui/react-native 1.0.0-beta.0 → 1.0.0-beta.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.
- package/README.md +70 -11
- package/dist/components/Badge.d.ts +6 -3
- package/dist/components/Badge.d.ts.map +1 -1
- package/dist/components/Badge.js +36 -7
- package/dist/components/Badge.js.map +1 -1
- package/dist/components/Button.d.ts +11 -4
- package/dist/components/Button.d.ts.map +1 -1
- package/dist/components/Button.js +100 -15
- package/dist/components/Button.js.map +1 -1
- package/dist/components/Card.d.ts +15 -5
- package/dist/components/Card.d.ts.map +1 -1
- package/dist/components/Card.js +28 -10
- package/dist/components/Card.js.map +1 -1
- package/dist/components/Flex.d.ts +25 -0
- package/dist/components/Flex.d.ts.map +1 -0
- package/dist/components/Flex.js +24 -0
- package/dist/components/Flex.js.map +1 -0
- package/dist/components/Grid.d.ts +36 -0
- package/dist/components/Grid.d.ts.map +1 -0
- package/dist/components/Grid.js +68 -0
- package/dist/components/Grid.js.map +1 -0
- package/dist/components/Separator.d.ts +11 -0
- package/dist/components/Separator.d.ts.map +1 -0
- package/dist/components/Separator.js +12 -0
- package/dist/components/Separator.js.map +1 -0
- package/dist/components/Spinner.d.ts +14 -0
- package/dist/components/Spinner.d.ts.map +1 -0
- package/dist/components/Spinner.js +41 -0
- package/dist/components/Spinner.js.map +1 -0
- package/dist/components/Text.d.ts +7 -3
- package/dist/components/Text.d.ts.map +1 -1
- package/dist/components/Text.js +23 -11
- package/dist/components/Text.js.map +1 -1
- package/dist/components/XStack.d.ts +4 -0
- package/dist/components/XStack.d.ts.map +1 -0
- package/dist/components/XStack.js +6 -0
- package/dist/components/XStack.js.map +1 -0
- package/dist/components/YStack.d.ts +4 -0
- package/dist/components/YStack.d.ts.map +1 -0
- package/dist/components/YStack.js +6 -0
- package/dist/components/YStack.js.map +1 -0
- package/dist/components/_internal/InputFrame.d.ts +13 -0
- package/dist/components/_internal/InputFrame.d.ts.map +1 -0
- package/dist/components/_internal/InputFrame.js +14 -0
- package/dist/components/_internal/InputFrame.js.map +1 -0
- package/dist/components/_internal/StoryItem.d.ts +6 -0
- package/dist/components/_internal/StoryItem.d.ts.map +1 -0
- package/dist/components/_internal/StoryItem.js +9 -0
- package/dist/components/_internal/StoryItem.js.map +1 -0
- package/dist/components/_internal/layout.d.ts +79 -0
- package/dist/components/_internal/layout.d.ts.map +1 -0
- package/dist/components/_internal/layout.js +73 -0
- package/dist/components/_internal/layout.js.map +1 -0
- package/dist/components/_internal/useControllableState.d.ts +7 -0
- package/dist/components/_internal/useControllableState.d.ts.map +1 -0
- package/dist/components/_internal/useControllableState.js +17 -0
- package/dist/components/_internal/useControllableState.js.map +1 -0
- package/dist/components/form/Checkbox.d.ts +26 -0
- package/dist/components/form/Checkbox.d.ts.map +1 -0
- package/dist/components/form/Checkbox.js +41 -0
- package/dist/components/form/Checkbox.js.map +1 -0
- package/dist/components/form/Form.context.d.ts +34 -0
- package/dist/components/form/Form.context.d.ts.map +1 -0
- package/dist/components/form/Form.context.js +53 -0
- package/dist/components/form/Form.context.js.map +1 -0
- package/dist/components/form/Form.d.ts +33 -0
- package/dist/components/form/Form.d.ts.map +1 -0
- package/dist/components/form/Form.js +36 -0
- package/dist/components/form/Form.js.map +1 -0
- package/dist/components/form/FormCheckbox.d.ts +7 -0
- package/dist/components/form/FormCheckbox.d.ts.map +1 -0
- package/dist/components/form/FormCheckbox.js +24 -0
- package/dist/components/form/FormCheckbox.js.map +1 -0
- package/dist/components/form/FormDescription.d.ts +4 -0
- package/dist/components/form/FormDescription.d.ts.map +1 -0
- package/dist/components/form/FormDescription.js +7 -0
- package/dist/components/form/FormDescription.js.map +1 -0
- package/dist/components/form/FormError.d.ts +5 -0
- package/dist/components/form/FormError.d.ts.map +1 -0
- package/dist/components/form/FormError.js +8 -0
- package/dist/components/form/FormError.js.map +1 -0
- package/dist/components/form/FormField.d.ts +17 -0
- package/dist/components/form/FormField.d.ts.map +1 -0
- package/dist/components/form/FormField.js +36 -0
- package/dist/components/form/FormField.js.map +1 -0
- package/dist/components/form/FormInput.d.ts +10 -0
- package/dist/components/form/FormInput.d.ts.map +1 -0
- package/dist/components/form/FormInput.js +36 -0
- package/dist/components/form/FormInput.js.map +1 -0
- package/dist/components/form/FormInputGroup.d.ts +8 -0
- package/dist/components/form/FormInputGroup.d.ts.map +1 -0
- package/dist/components/form/FormInputGroup.js +18 -0
- package/dist/components/form/FormInputGroup.js.map +1 -0
- package/dist/components/form/FormLabel.d.ts +4 -0
- package/dist/components/form/FormLabel.d.ts.map +1 -0
- package/dist/components/form/FormLabel.js +7 -0
- package/dist/components/form/FormLabel.js.map +1 -0
- package/dist/components/form/FormRadioGroup.d.ts +11 -0
- package/dist/components/form/FormRadioGroup.d.ts.map +1 -0
- package/dist/components/form/FormRadioGroup.js +24 -0
- package/dist/components/form/FormRadioGroup.js.map +1 -0
- package/dist/components/form/FormRoot.d.ts +13 -0
- package/dist/components/form/FormRoot.d.ts.map +1 -0
- package/dist/components/form/FormRoot.js +19 -0
- package/dist/components/form/FormRoot.js.map +1 -0
- package/dist/components/form/FormTextarea.d.ts +7 -0
- package/dist/components/form/FormTextarea.d.ts.map +1 -0
- package/dist/components/form/FormTextarea.js +27 -0
- package/dist/components/form/FormTextarea.js.map +1 -0
- package/dist/components/form/Input.d.ts +17 -0
- package/dist/components/form/Input.d.ts.map +1 -0
- package/dist/components/form/Input.js +32 -0
- package/dist/components/form/Input.js.map +1 -0
- package/dist/components/form/InputGroup.context.d.ts +10 -0
- package/dist/components/form/InputGroup.context.d.ts.map +1 -0
- package/dist/components/form/InputGroup.context.js +8 -0
- package/dist/components/form/InputGroup.context.js.map +1 -0
- package/dist/components/form/InputGroup.d.ts +31 -0
- package/dist/components/form/InputGroup.d.ts.map +1 -0
- package/dist/components/form/InputGroup.js +123 -0
- package/dist/components/form/InputGroup.js.map +1 -0
- package/dist/components/form/RadioGroup.d.ts +29 -0
- package/dist/components/form/RadioGroup.d.ts.map +1 -0
- package/dist/components/form/RadioGroup.js +42 -0
- package/dist/components/form/RadioGroup.js.map +1 -0
- package/dist/components/form/Textarea.d.ts +19 -0
- package/dist/components/form/Textarea.d.ts.map +1 -0
- package/dist/components/form/Textarea.js +26 -0
- package/dist/components/form/Textarea.js.map +1 -0
- package/dist/entries/card.d.ts +1 -1
- package/dist/entries/card.d.ts.map +1 -1
- package/dist/entries/checkbox.d.ts +3 -0
- package/dist/entries/checkbox.d.ts.map +1 -0
- package/dist/entries/checkbox.js +2 -0
- package/dist/entries/checkbox.js.map +1 -0
- package/dist/entries/flex.d.ts +3 -0
- package/dist/entries/flex.d.ts.map +1 -0
- package/dist/entries/flex.js +2 -0
- package/dist/entries/flex.js.map +1 -0
- package/dist/entries/form.d.ts +3 -0
- package/dist/entries/form.d.ts.map +1 -0
- package/dist/entries/form.js +2 -0
- package/dist/entries/form.js.map +1 -0
- package/dist/entries/grid.d.ts +3 -0
- package/dist/entries/grid.d.ts.map +1 -0
- package/dist/entries/grid.js +2 -0
- package/dist/entries/grid.js.map +1 -0
- package/dist/entries/input-group.d.ts +3 -0
- package/dist/entries/input-group.d.ts.map +1 -0
- package/dist/entries/input-group.js +2 -0
- package/dist/entries/input-group.js.map +1 -0
- package/dist/entries/input.d.ts +3 -0
- package/dist/entries/input.d.ts.map +1 -0
- package/dist/entries/input.js +2 -0
- package/dist/entries/input.js.map +1 -0
- package/dist/entries/radio-group.d.ts +3 -0
- package/dist/entries/radio-group.d.ts.map +1 -0
- package/dist/entries/radio-group.js +2 -0
- package/dist/entries/radio-group.js.map +1 -0
- package/dist/entries/separator.d.ts +3 -0
- package/dist/entries/separator.d.ts.map +1 -0
- package/dist/entries/separator.js +2 -0
- package/dist/entries/separator.js.map +1 -0
- package/dist/entries/spinner.d.ts +3 -0
- package/dist/entries/spinner.d.ts.map +1 -0
- package/dist/entries/spinner.js +2 -0
- package/dist/entries/spinner.js.map +1 -0
- package/dist/entries/textarea.d.ts +3 -0
- package/dist/entries/textarea.d.ts.map +1 -0
- package/dist/entries/textarea.js +2 -0
- package/dist/entries/textarea.js.map +1 -0
- package/dist/entries/theme.d.ts +3 -0
- package/dist/entries/theme.d.ts.map +1 -0
- package/dist/entries/theme.js +2 -0
- package/dist/entries/theme.js.map +1 -0
- package/dist/entries/x-stack.d.ts +3 -0
- package/dist/entries/x-stack.d.ts.map +1 -0
- package/dist/entries/x-stack.js +2 -0
- package/dist/entries/x-stack.js.map +1 -0
- package/dist/entries/y-stack.d.ts +3 -0
- package/dist/entries/y-stack.d.ts.map +1 -0
- package/dist/entries/y-stack.js +2 -0
- package/dist/entries/y-stack.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/cn.d.ts.map +1 -1
- package/dist/lib/cn.js +13 -1
- package/dist/lib/cn.js.map +1 -1
- package/package.json +10 -3
- package/src/base.css +7 -2
- package/src/components/Badge.stories.tsx +51 -6
- package/src/components/Badge.test.tsx +15 -0
- package/src/components/Badge.tsx +73 -17
- package/src/components/Button.stories.tsx +96 -8
- package/src/components/Button.test.tsx +69 -0
- package/src/components/Button.tsx +159 -18
- package/src/components/Card.stories.tsx +17 -4
- package/src/components/Card.test.tsx +24 -1
- package/src/components/Card.tsx +71 -13
- package/src/components/Flex.stories.tsx +58 -0
- package/src/components/Flex.test.tsx +57 -0
- package/src/components/Flex.tsx +52 -0
- package/src/components/Grid.stories.tsx +55 -0
- package/src/components/Grid.test.tsx +140 -0
- package/src/components/Grid.tsx +166 -0
- package/src/components/Separator.stories.tsx +39 -0
- package/src/components/Separator.test.tsx +25 -0
- package/src/components/Separator.tsx +30 -0
- package/src/components/Spinner.stories.tsx +35 -0
- package/src/components/Spinner.test.tsx +30 -0
- package/src/components/Spinner.tsx +75 -0
- package/src/components/Text.stories.tsx +52 -2
- package/src/components/Text.test.tsx +35 -3
- package/src/components/Text.tsx +42 -12
- package/src/components/XStack.stories.tsx +46 -0
- package/src/components/XStack.test.tsx +13 -0
- package/src/components/XStack.tsx +7 -0
- package/src/components/YStack.stories.tsx +46 -0
- package/src/components/YStack.test.tsx +13 -0
- package/src/components/YStack.tsx +7 -0
- package/src/components/_internal/InputFrame.tsx +50 -0
- package/src/components/_internal/Story.tsx +34 -0
- package/src/components/_internal/StoryItem.tsx +24 -0
- package/src/components/_internal/layout.ts +103 -0
- package/src/components/_internal/useControllableState.ts +25 -0
- package/src/components/form/Checkbox.stories.tsx +67 -0
- package/src/components/form/Checkbox.test.tsx +88 -0
- package/src/components/form/Checkbox.tsx +141 -0
- package/src/components/form/Form.context.ts +91 -0
- package/src/components/form/Form.stories.tsx +152 -0
- package/src/components/form/Form.test.tsx +195 -0
- package/src/components/form/Form.tsx +51 -0
- package/src/components/form/FormCheckbox.tsx +42 -0
- package/src/components/form/FormDescription.tsx +14 -0
- package/src/components/form/FormError.tsx +17 -0
- package/src/components/form/FormField.tsx +82 -0
- package/src/components/form/FormInput.tsx +70 -0
- package/src/components/form/FormInputGroup.tsx +30 -0
- package/src/components/form/FormLabel.tsx +17 -0
- package/src/components/form/FormRadioGroup.tsx +48 -0
- package/src/components/form/FormRoot.tsx +41 -0
- package/src/components/form/FormTextarea.tsx +56 -0
- package/src/components/form/Input.stories.tsx +105 -0
- package/src/components/form/Input.test.tsx +76 -0
- package/src/components/form/Input.tsx +81 -0
- package/src/components/form/InputGroup.context.ts +11 -0
- package/src/components/form/InputGroup.stories.tsx +129 -0
- package/src/components/form/InputGroup.test.tsx +95 -0
- package/src/components/form/InputGroup.tsx +266 -0
- package/src/components/form/RadioGroup.stories.tsx +62 -0
- package/src/components/form/RadioGroup.test.tsx +98 -0
- package/src/components/form/RadioGroup.tsx +151 -0
- package/src/components/form/Textarea.stories.tsx +61 -0
- package/src/components/form/Textarea.test.tsx +35 -0
- package/src/components/form/Textarea.tsx +74 -0
- package/src/entries/card.ts +2 -0
- package/src/entries/checkbox.ts +2 -0
- package/src/entries/flex.ts +2 -0
- package/src/entries/form.ts +13 -0
- package/src/entries/grid.ts +2 -0
- package/src/entries/input-group.ts +8 -0
- package/src/entries/input.ts +2 -0
- package/src/entries/radio-group.ts +5 -0
- package/src/entries/separator.ts +2 -0
- package/src/entries/spinner.ts +2 -0
- package/src/entries/textarea.ts +2 -0
- package/src/entries/theme.ts +7 -0
- package/src/entries/x-stack.ts +2 -0
- package/src/entries/y-stack.ts +2 -0
- package/src/index.ts +13 -0
- package/src/lib/cn.test.ts +6 -0
- package/src/lib/cn.ts +14 -1
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Pickle UI components for React Native apps built with Expo, styled with
|
|
4
4
|
Pickle's tokens through [Uniwind](https://uniwind.dev). They reuse the names
|
|
5
5
|
of `@pickle-ui/react` (`variant`, `size`, `tone`, `Card.Header`, …) with
|
|
6
|
-
|
|
6
|
+
the same dimensions, on React Native primitives.
|
|
7
7
|
|
|
8
8
|
Browse them in the [Storybook](https://ugogo.github.io/pickle-ui/react-native/),
|
|
9
9
|
rendered in the browser through react-native-web.
|
|
@@ -42,8 +42,8 @@ after Tailwind and Uniwind, which is why they come from the same file.
|
|
|
42
42
|
|
|
43
43
|
To bring your own token set, import its pieces instead: `tailwindcss`,
|
|
44
44
|
`uniwind`, your tokens as Uniwind themes, then
|
|
45
|
-
`@pickle-ui/react-native/base.css`, which
|
|
46
|
-
|
|
45
|
+
`@pickle-ui/react-native/base.css`, which adds the components to Uniwind's
|
|
46
|
+
content sources and the `Text` type scale.
|
|
47
47
|
|
|
48
48
|
Then use the components:
|
|
49
49
|
|
|
@@ -72,18 +72,57 @@ steps, token overrides and runtime brand colors.
|
|
|
72
72
|
|
|
73
73
|
Each export is also available from its own subpath.
|
|
74
74
|
|
|
75
|
-
| Export | Subpath | Notes
|
|
76
|
-
| --------------- | ----------------------------------------- |
|
|
77
|
-
| `Badge` | `@pickle-ui/react-native/badge` | `variant`: `default`, `secondary`, `success`, `inProgress`, `inReview`
|
|
78
|
-
| `Button` | `@pickle-ui/react-native/button` | `variant`: `default`, `secondary`, `outline`, `ghost`, `
|
|
79
|
-
| `Card` | `@pickle-ui/react-native/card` | Parts: `Card.Header`, `Card.Title`, `Card.Description`, `Card.Content`
|
|
80
|
-
| `
|
|
81
|
-
| `
|
|
82
|
-
| `
|
|
75
|
+
| Export | Subpath | Notes |
|
|
76
|
+
| --------------- | ----------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
77
|
+
| `Badge` | `@pickle-ui/react-native/badge` | `variant`: `default`, `secondary`, `outline`, `destructive`, `info`, `success`, `warning`, `error` and the statuses `pending`, `submitted`, `inProgress`, `inReview`, `failed`, `expired`; `size`: `sm`, `md`, `lg` |
|
|
78
|
+
| `Button` | `@pickle-ui/react-native/button` | `variant`: `default`, `secondary`, `destructive`, `destructive-outline`, `outline`, `ghost`, `link`; `size`: `xs` … `xl`, `icon-xs` … `icon-xl`; `loading` |
|
|
79
|
+
| `Card` | `@pickle-ui/react-native/card` | Parts: `Card.Header`, `Card.Title`, `Card.Description`, `Card.Action`, `Card.Content`, `Card.Footer` |
|
|
80
|
+
| `Checkbox` | `@pickle-ui/react-native/checkbox` | `checked` / `defaultChecked` / `onCheckedChange`, `indeterminate`, `invalid`, `disabled`, `label`; `size`: `md`, `sm`; `classNames`: `field`, `indicator`, `label` |
|
|
81
|
+
| `Flex` | `@pickle-ui/react-native/flex` | A row by default, like the web; `direction`, `wrap`, `align`, `justify`, `gap`, `gapX`, `gapY` |
|
|
82
|
+
| `Form` | `@pickle-ui/react-native/form` | React Hook Form bindings: `Form.Field` (`label`, `description`, `error`), `Form.Input`, `Form.Textarea`, `Form.InputGroup`, `Form.Checkbox`, `Form.RadioGroup`, `Form.Button`, `Form.Label`, `Form.Description`, `Form.Error` |
|
|
83
|
+
| `Grid` | `@pickle-ui/react-native/grid` | Equal columns built from rows of cells (no CSS grid on native): `columns`, `rows`, `flow`, `gap`, `gapX`, `gapY`, `align`, `justify`, `placeContent`, `placeItems`; items can't stretch to their cell's height, give them `flex-1` |
|
|
84
|
+
| `Input` | `@pickle-ui/react-native/input` | `size`: `sm`, `md`, `lg`, the `Button` heights; `invalid`, `disabled`, `unstyled`; `classNames.input` |
|
|
85
|
+
| `InputGroup` | `@pickle-ui/react-native/input-group` | Parts: `InputGroup.Input`, `InputGroup.Addon` (`align`: `inline-start`, `inline-end`, `block-start`, `block-end`), `InputGroup.Button`, `InputGroup.Text` |
|
|
86
|
+
| `RadioGroup` | `@pickle-ui/react-native/radio-group` | `value` / `defaultValue` / `onValueChange`, `disabled`; parts: `RadioGroup.Item` (`value`, `label`, `invalid`, `disabled`, `size`: `md`, `sm`; `classNames`: `field`, `indicator`, `label`) |
|
|
87
|
+
| `Separator` | `@pickle-ui/react-native/separator` | `orientation`: `horizontal`, `vertical`; `role="separator"`, announced on the web only |
|
|
88
|
+
| `Spinner` | `@pickle-ui/react-native/spinner` | Announced as "Loading": `accessibilityLabel` renames it, `aria-hidden` makes it decorative; size it with `size-*` and color it with `text-*` |
|
|
89
|
+
| `Text` | `@pickle-ui/react-native/text` | `variant`: `h1` … `h4`, `lead`, `body`, `small`, `code`; `tone`: `muted`, `primary`, `destructive`; `weight`: `normal`, `bold`; `truncate` |
|
|
90
|
+
| `Textarea` | `@pickle-ui/react-native/textarea` | Grows with its content from three lines; `size`, `invalid`, `disabled`; `classNames.textarea` |
|
|
91
|
+
| `XStack` | `@pickle-ui/react-native/x-stack` | `Flex` as a row |
|
|
92
|
+
| `YStack` | `@pickle-ui/react-native/y-stack` | `Flex` as a column |
|
|
93
|
+
| `createTheme` | `@pickle-ui/react-native/theme` | Derives a theme from a brand color, the same as on the web; apply it with `ScopedVariables` |
|
|
94
|
+
| `cn` | `@pickle-ui/react-native/cn` | Joins class names; later classes win, and `text-h1` … `text-code` count as font sizes |
|
|
95
|
+
| `useColorToken` | `@pickle-ui/react-native/use-color-token` | Reads a token as a color string, for props that don't take a `className` |
|
|
83
96
|
|
|
84
97
|
Every component takes the props of the React Native element it renders,
|
|
85
98
|
`className` included, and merges your `className` last.
|
|
86
99
|
|
|
100
|
+
Form fields take `invalid` and `disabled` props where the web reads the
|
|
101
|
+
`aria-invalid` and `disabled` attributes, and draw the web's focus ring while
|
|
102
|
+
they have focus. Text styles don't cascade on native, so `Checkbox` and
|
|
103
|
+
`RadioGroup.Item` style the row around the control with `classNames.field`
|
|
104
|
+
and the label text with `classNames.label`; pass `label` rather than a
|
|
105
|
+
separate label element, which couldn't toggle the control.
|
|
106
|
+
|
|
107
|
+
`Form` needs `react-hook-form` (a peer dependency). React Native has no
|
|
108
|
+
`<form>`, so `Form` takes `onSubmit` and runs it through `handleSubmit` when
|
|
109
|
+
`Form.Button` is pressed, or when the return key is pressed in a
|
|
110
|
+
`Form.Input`, like Enter on the web. Give `Form.Button` an `onPress` for
|
|
111
|
+
another action. A `Form.Field` label names its control and focuses it when
|
|
112
|
+
pressed.
|
|
113
|
+
|
|
114
|
+
`Button` and `Badge` wrap text children in their label and render other
|
|
115
|
+
children, such as icons, as they are. Icons don't inherit the label's color on
|
|
116
|
+
native, so pass it to the icon, for example with `useColorToken`. Give an
|
|
117
|
+
icon-only button an `icon*` size and an `accessibilityLabel`. Buttons keep the web's dimensions and the text sizes it uses from `sm` up (14px at `md`), and a `hitSlop` stretches each size to a
|
|
118
|
+
44pt touch target, as the web's `pointer-coarse` hit area does. Headings (`h1` … `h4`)
|
|
119
|
+
are announced as headers.
|
|
120
|
+
|
|
121
|
+
`Text` sizes come from the shared type scale (`--text-h1` … `--text-code` in
|
|
122
|
+
`@pickle-ui/tokens/typography.css`); override them like any token. Fonts are
|
|
123
|
+
not set yet: text uses the platform's system font, and `code` its monospace
|
|
124
|
+
font.
|
|
125
|
+
|
|
87
126
|
## Theming
|
|
88
127
|
|
|
89
128
|
The tokens are Uniwind themes. Override them in `global.css` inside
|
|
@@ -91,3 +130,23 @@ The tokens are Uniwind themes. Override them in `global.css` inside
|
|
|
91
130
|
themes, or at runtime with Uniwind's `ScopedVariables` and
|
|
92
131
|
`Uniwind.updateCSSVariables`. See the
|
|
93
132
|
[`@pickle-ui/tokens` README](../tokens/README.md#react-native).
|
|
133
|
+
|
|
134
|
+
To brand an app at runtime, derive the tokens from one color with
|
|
135
|
+
`createTheme` and apply the set for the active theme:
|
|
136
|
+
|
|
137
|
+
```tsx
|
|
138
|
+
import { createTheme } from '@pickle-ui/react-native/theme';
|
|
139
|
+
import { ScopedVariables, useUniwind } from 'uniwind';
|
|
140
|
+
|
|
141
|
+
const brand = createTheme({ primary: '#2563eb' });
|
|
142
|
+
|
|
143
|
+
export function Branded({ children }: { children: React.ReactNode }) {
|
|
144
|
+
const { theme } = useUniwind();
|
|
145
|
+
return <ScopedVariables variables={brand[theme]}>{children}</ScopedVariables>;
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
The values are `oklch()` colors: Uniwind resolves them in `className`
|
|
150
|
+
utilities (`bg-primary`), but React Native can't read them from a `style`
|
|
151
|
+
prop, so draw with the tokens rather than the raw values. Fonts from
|
|
152
|
+
`createTheme` don't apply on native.
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { type VariantProps } from 'class-variance-authority';
|
|
2
2
|
import { View } from 'react-native';
|
|
3
3
|
declare const badgeVariants: (props?: ({
|
|
4
|
-
|
|
4
|
+
size?: "md" | "lg" | "sm" | null | undefined;
|
|
5
|
+
variant?: "default" | "destructive" | "error" | "expired" | "failed" | "info" | "inProgress" | "inReview" | "outline" | "pending" | "secondary" | "submitted" | "success" | "warning" | null | undefined;
|
|
5
6
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
6
7
|
export type BadgeProps = React.ComponentProps<typeof View> & VariantProps<typeof badgeVariants> & {
|
|
7
|
-
children
|
|
8
|
+
/** Text is wrapped in the label; other children, such as icons, render as they are. */
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
labelClassName?: string;
|
|
8
11
|
};
|
|
9
|
-
export declare function Badge({ children, className, variant, ...props }: BadgeProps): import("react").JSX.Element;
|
|
12
|
+
export declare function Badge({ children, className, labelClassName, size, variant, ...props }: BadgeProps): import("react").JSX.Element;
|
|
10
13
|
export {};
|
|
11
14
|
//# sourceMappingURL=Badge.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Badge.d.ts","sourceRoot":"","sources":["../../src/components/Badge.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"Badge.d.ts","sourceRoot":"","sources":["../../src/components/Badge.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAElE,OAAO,EAAQ,IAAI,EAAE,MAAM,cAAc,CAAC;AAK1C,QAAA,MAAM,aAAa;;;8EA4BlB,CAAC;AA6BF,MAAM,MAAM,UAAU,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,IAAI,CAAC,GACxD,YAAY,CAAC,OAAO,aAAa,CAAC,GAAG;IACnC,uFAAuF;IACvF,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEJ,wBAAgB,KAAK,CAAC,EACpB,QAAQ,EACR,SAAS,EACT,cAAc,EACd,IAAW,EACX,OAAmB,EACnB,GAAG,KAAK,EACT,EAAE,UAAU,+BAmBZ"}
|
package/dist/components/Badge.js
CHANGED
|
@@ -1,33 +1,62 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { cva } from 'class-variance-authority';
|
|
3
|
+
import { Children, isValidElement } from 'react';
|
|
3
4
|
import { Text, View } from 'react-native';
|
|
4
5
|
import { cn } from '../lib/cn';
|
|
5
|
-
//
|
|
6
|
-
const badgeVariants = cva('self-start rounded-sm
|
|
7
|
-
defaultVariants: { variant: 'default' },
|
|
6
|
+
// Same variants and sizes as `Badge` in @pickle-ui/react.
|
|
7
|
+
const badgeVariants = cva('flex-row items-center justify-center gap-1 self-start rounded-sm border border-transparent', {
|
|
8
|
+
defaultVariants: { size: 'md', variant: 'default' },
|
|
8
9
|
variants: {
|
|
10
|
+
size: {
|
|
11
|
+
lg: 'h-5.5 min-w-5.5 px-1.5',
|
|
12
|
+
md: 'h-4.5 min-w-4.5 px-1',
|
|
13
|
+
sm: 'h-4 min-w-4 rounded px-1',
|
|
14
|
+
},
|
|
9
15
|
variant: {
|
|
10
16
|
default: 'bg-primary',
|
|
17
|
+
destructive: 'bg-destructive',
|
|
18
|
+
error: 'bg-destructive-subtle',
|
|
19
|
+
expired: 'bg-secondary',
|
|
20
|
+
failed: 'bg-destructive-subtle',
|
|
21
|
+
info: 'bg-info-subtle',
|
|
11
22
|
inProgress: 'bg-info-subtle',
|
|
12
23
|
inReview: 'bg-warning-subtle',
|
|
24
|
+
outline: 'border-input bg-background dark:bg-input/32',
|
|
25
|
+
pending: 'bg-warning-subtle',
|
|
13
26
|
secondary: 'bg-secondary',
|
|
27
|
+
submitted: 'bg-info-subtle',
|
|
14
28
|
success: 'bg-success-subtle',
|
|
29
|
+
warning: 'bg-warning-subtle',
|
|
15
30
|
},
|
|
16
31
|
},
|
|
17
32
|
});
|
|
18
|
-
const labelVariants = cva('
|
|
19
|
-
defaultVariants: { variant: 'default' },
|
|
33
|
+
const labelVariants = cva('font-medium', {
|
|
34
|
+
defaultVariants: { size: 'md', variant: 'default' },
|
|
20
35
|
variants: {
|
|
36
|
+
size: {
|
|
37
|
+
lg: 'text-sm',
|
|
38
|
+
md: 'text-xs',
|
|
39
|
+
sm: 'text-[10px]',
|
|
40
|
+
},
|
|
21
41
|
variant: {
|
|
22
42
|
default: 'text-primary-foreground',
|
|
43
|
+
destructive: 'text-destructive-foreground',
|
|
44
|
+
error: 'text-destructive-subtle-foreground',
|
|
45
|
+
expired: 'text-secondary-foreground',
|
|
46
|
+
failed: 'text-destructive-subtle-foreground',
|
|
47
|
+
info: 'text-info-subtle-foreground',
|
|
23
48
|
inProgress: 'text-info-subtle-foreground',
|
|
24
49
|
inReview: 'text-warning-subtle-foreground',
|
|
50
|
+
outline: 'text-foreground',
|
|
51
|
+
pending: 'text-warning-subtle-foreground',
|
|
25
52
|
secondary: 'text-secondary-foreground',
|
|
53
|
+
submitted: 'text-info-subtle-foreground',
|
|
26
54
|
success: 'text-success-subtle-foreground',
|
|
55
|
+
warning: 'text-warning-subtle-foreground',
|
|
27
56
|
},
|
|
28
57
|
},
|
|
29
58
|
});
|
|
30
|
-
export function Badge({ children, className, variant, ...props }) {
|
|
31
|
-
return (_jsx(View, { className: cn(badgeVariants({ variant }), className), ...props, children: _jsx(Text, { className: labelVariants({ variant }), children:
|
|
59
|
+
export function Badge({ children, className, labelClassName, size = 'md', variant = 'default', ...props }) {
|
|
60
|
+
return (_jsx(View, { className: cn(badgeVariants({ size, variant }), className), ...props, children: Children.map(children, (child) => typeof child === 'string' || typeof child === 'number' ? (_jsx(Text, { className: cn(labelVariants({ size, variant }), labelClassName), children: child })) : isValidElement(child) ? (child) : null) }));
|
|
32
61
|
}
|
|
33
62
|
//# sourceMappingURL=Badge.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Badge.js","sourceRoot":"","sources":["../../src/components/Badge.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAqB,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AAE/B,
|
|
1
|
+
{"version":3,"file":"Badge.js","sourceRoot":"","sources":["../../src/components/Badge.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAqB,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MA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BAAiB;YAC1B,OAAO,EAAE,gCAAgC;YACzC,SAAS,EAAE,2BAA2B;YACtC,SAAS,EAAE,6BAA6B;YACxC,OAAO,EAAE,gCAAgC;YACzC,OAAO,EAAE,gCAAgC;SAC1C;KACF;CACF,CAAC,CAAC;AASH,MAAM,UAAU,KAAK,CAAC,EACpB,QAAQ,EACR,SAAS,EACT,cAAc,EACd,IAAI,GAAG,IAAI,EACX,OAAO,GAAG,SAAS,EACnB,GAAG,KAAK,EACG;IACX,OAAO,CACL,KAAC,IAAI,IACH,SAAS,EAAE,EAAE,CAAC,aAAa,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,SAAS,CAAC,KACtD,KAAK,YAER,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAChC,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,CACvD,KAAC,IAAI,IACH,SAAS,EAAE,EAAE,CAAC,aAAa,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,cAAc,CAAC,YAE9D,KAAK,GACD,CACR,CAAC,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAC1B,KAAK,CACN,CAAC,CAAC,CAAC,IAAI,CACT,GACI,CACR,CAAC;AACJ,CAAC"}
|
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
import { type VariantProps } from 'class-variance-authority';
|
|
2
2
|
import { Pressable } from 'react-native';
|
|
3
3
|
declare const buttonVariants: (props?: ({
|
|
4
|
-
size?: "md" | "lg" | "sm" | null | undefined;
|
|
5
|
-
variant?: "default" | "
|
|
4
|
+
size?: "md" | "lg" | "sm" | "icon" | "icon-lg" | "icon-sm" | "icon-xl" | "icon-xs" | "xl" | "xs" | null | undefined;
|
|
5
|
+
variant?: "default" | "destructive" | "outline" | "secondary" | "link" | "destructive-outline" | "ghost" | null | undefined;
|
|
6
6
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
7
7
|
export type ButtonProps = Omit<React.ComponentProps<typeof Pressable>, 'children'> & VariantProps<typeof buttonVariants> & {
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Text is wrapped in the label; other children, such as icons, render as
|
|
10
|
+
* they are. Icon-only buttons need an `icon*` size and an
|
|
11
|
+
* `accessibilityLabel`.
|
|
12
|
+
*/
|
|
13
|
+
children: React.ReactNode;
|
|
9
14
|
labelClassName?: string;
|
|
15
|
+
/** Shows a spinner in place of the content and disables the button. */
|
|
16
|
+
loading?: boolean;
|
|
10
17
|
};
|
|
11
|
-
export declare function Button({ children, className, labelClassName, size, variant, ...props }: ButtonProps): import("react").JSX.Element;
|
|
18
|
+
export declare function Button({ accessibilityState, children, className, disabled, labelClassName, loading, size, variant, ...props }: ButtonProps): import("react").JSX.Element;
|
|
12
19
|
export {};
|
|
13
20
|
//# sourceMappingURL=Button.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../src/components/Button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../src/components/Button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAElE,OAAO,EAAe,SAAS,EAAc,MAAM,cAAc,CAAC;AAQlE,QAAA,MAAM,cAAc;;;8EAgCnB,CAAC;AAuFF,MAAM,MAAM,WAAW,GAAG,IAAI,CAC5B,KAAK,CAAC,cAAc,CAAC,OAAO,SAAS,CAAC,EACtC,UAAU,CACX,GACC,YAAY,CAAC,OAAO,cAAc,CAAC,GAAG;IACpC;;;;OAIG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,uEAAuE;IACvE,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEJ,wBAAgB,MAAM,CAAC,EACrB,kBAAkB,EAClB,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,cAAc,EACd,OAAe,EACf,IAAW,EACX,OAAmB,EACnB,GAAG,KAAK,EACT,EAAE,WAAW,+BAuDb"}
|
|
@@ -1,39 +1,124 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { cva } from 'class-variance-authority';
|
|
3
|
-
import {
|
|
3
|
+
import { Children, isValidElement } from 'react';
|
|
4
|
+
import { Pressable, Text, View } from 'react-native';
|
|
4
5
|
import { cn } from '../lib/cn';
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
import { Spinner } from './Spinner';
|
|
7
|
+
// Same variants, sizes and dimensions as `Button` in @pickle-ui/react on a
|
|
8
|
+
// phone, with its text sizes from `sm` up. Like the web's `pointer-coarse` hit area, `hitSlop` stretches every
|
|
9
|
+
// size to a 44pt touch target. Paddings leave room for the 1pt border.
|
|
10
|
+
const buttonVariants = cva('flex-row items-center justify-center gap-2 rounded-lg border disabled:opacity-64', {
|
|
7
11
|
defaultVariants: { size: 'md', variant: 'default' },
|
|
8
12
|
variants: {
|
|
9
13
|
size: {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
sm: '
|
|
14
|
+
icon: 'size-8',
|
|
15
|
+
'icon-lg': 'size-9',
|
|
16
|
+
'icon-sm': 'size-7',
|
|
17
|
+
'icon-xl': 'size-10',
|
|
18
|
+
'icon-xs': 'size-6 rounded-md',
|
|
19
|
+
lg: 'h-9 px-[13px]',
|
|
20
|
+
md: 'h-8 px-[11px]',
|
|
21
|
+
sm: 'h-7 gap-1.5 px-[9px]',
|
|
22
|
+
xl: 'h-10 px-[15px]',
|
|
23
|
+
xs: 'h-6 gap-1 rounded-md px-[7px]',
|
|
13
24
|
},
|
|
14
25
|
variant: {
|
|
15
|
-
default: 'border-primary bg-primary',
|
|
16
|
-
destructive: 'border-destructive bg-destructive',
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
26
|
+
default: 'border-primary bg-primary shadow-primary/24 shadow-xs active:bg-primary/90 disabled:shadow-none',
|
|
27
|
+
destructive: 'border-destructive bg-destructive shadow-destructive/24 shadow-xs active:bg-destructive/90 disabled:shadow-none',
|
|
28
|
+
'destructive-outline': 'border-input bg-popover active:border-destructive/32 active:bg-destructive/4 dark:bg-input/32 shadow-xs shadow-black/5 disabled:shadow-none',
|
|
29
|
+
ghost: 'active:bg-accent border-transparent',
|
|
30
|
+
link: 'border-transparent',
|
|
31
|
+
outline: 'border-input bg-popover active:bg-accent/50 dark:bg-input/32 dark:active:bg-input/64 shadow-xs shadow-black/5 disabled:shadow-none',
|
|
32
|
+
secondary: 'bg-secondary active:bg-secondary/80 border-transparent',
|
|
20
33
|
},
|
|
21
34
|
},
|
|
22
35
|
});
|
|
23
36
|
const labelVariants = cva('font-medium', {
|
|
37
|
+
compoundVariants: [
|
|
38
|
+
{ className: 'underline', pressed: true, variant: 'link' },
|
|
39
|
+
],
|
|
24
40
|
defaultVariants: { size: 'md', variant: 'default' },
|
|
25
41
|
variants: {
|
|
26
|
-
|
|
42
|
+
pressed: { false: '', true: '' },
|
|
43
|
+
// The web's sizes from `sm` up, not its larger phone sizes, which only
|
|
44
|
+
// stop iOS Safari zooming into focused fields.
|
|
45
|
+
size: {
|
|
46
|
+
icon: 'text-sm',
|
|
47
|
+
'icon-lg': 'text-sm',
|
|
48
|
+
'icon-sm': 'text-sm',
|
|
49
|
+
'icon-xl': 'text-sm',
|
|
50
|
+
'icon-xs': 'text-sm',
|
|
51
|
+
lg: 'text-sm',
|
|
52
|
+
md: 'text-sm',
|
|
53
|
+
sm: 'text-sm',
|
|
54
|
+
xl: 'text-base',
|
|
55
|
+
xs: 'text-xs',
|
|
56
|
+
},
|
|
27
57
|
variant: {
|
|
28
58
|
default: 'text-primary-foreground',
|
|
29
59
|
destructive: 'text-destructive-foreground',
|
|
60
|
+
'destructive-outline': 'text-destructive-subtle-foreground',
|
|
30
61
|
ghost: 'text-foreground',
|
|
62
|
+
link: 'text-foreground',
|
|
31
63
|
outline: 'text-foreground',
|
|
32
64
|
secondary: 'text-secondary-foreground',
|
|
33
65
|
},
|
|
34
66
|
},
|
|
35
67
|
});
|
|
36
|
-
|
|
37
|
-
|
|
68
|
+
// Sized and dimmed like the web button's icons, in the label's color.
|
|
69
|
+
const spinnerVariants = cva('size-4 opacity-80', {
|
|
70
|
+
variants: {
|
|
71
|
+
variant: {
|
|
72
|
+
default: 'text-primary-foreground',
|
|
73
|
+
destructive: 'text-destructive-foreground',
|
|
74
|
+
'destructive-outline': 'text-foreground',
|
|
75
|
+
ghost: 'text-foreground',
|
|
76
|
+
link: 'text-foreground',
|
|
77
|
+
outline: 'text-foreground',
|
|
78
|
+
secondary: 'text-secondary-foreground',
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
// The web's 1px inner highlight on solid buttons. Uniwind draws
|
|
83
|
+
// `inset-shadow` outside the view, so a top border on an overlay stands in.
|
|
84
|
+
const highlightVariants = cva('absolute inset-0 rounded-lg border-t', {
|
|
85
|
+
variants: {
|
|
86
|
+
pressed: { false: 'border-white/16', true: 'border-black/8' },
|
|
87
|
+
size: {
|
|
88
|
+
icon: '',
|
|
89
|
+
'icon-lg': '',
|
|
90
|
+
'icon-sm': '',
|
|
91
|
+
'icon-xl': '',
|
|
92
|
+
'icon-xs': 'rounded-md',
|
|
93
|
+
lg: '',
|
|
94
|
+
md: '',
|
|
95
|
+
sm: '',
|
|
96
|
+
xl: '',
|
|
97
|
+
xs: 'rounded-md',
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
// Half the gap between each size and a 44pt touch target, vertical only for
|
|
102
|
+
// buttons with a label, whose width already reaches it.
|
|
103
|
+
const HIT_SLOP = {
|
|
104
|
+
icon: 6,
|
|
105
|
+
'icon-lg': 4,
|
|
106
|
+
'icon-sm': 8,
|
|
107
|
+
'icon-xl': 2,
|
|
108
|
+
'icon-xs': 10,
|
|
109
|
+
lg: { bottom: 4, top: 4 },
|
|
110
|
+
md: { bottom: 6, top: 6 },
|
|
111
|
+
sm: { bottom: 8, top: 8 },
|
|
112
|
+
xl: { bottom: 2, top: 2 },
|
|
113
|
+
xs: { bottom: 10, top: 10 },
|
|
114
|
+
};
|
|
115
|
+
export function Button({ accessibilityState, children, className, disabled, labelClassName, loading = false, size = 'md', variant = 'default', ...props }) {
|
|
116
|
+
const isDisabled = Boolean(disabled || loading);
|
|
117
|
+
const isSolid = variant === 'default' || variant === 'destructive';
|
|
118
|
+
return (_jsx(Pressable, { accessibilityRole: "button", accessibilityState: {
|
|
119
|
+
...accessibilityState,
|
|
120
|
+
busy: loading,
|
|
121
|
+
disabled: isDisabled,
|
|
122
|
+
}, className: cn(buttonVariants({ size, variant }), className), disabled: isDisabled, hitSlop: size ? HIT_SLOP[size] : undefined, ...props, children: ({ pressed }) => (_jsxs(_Fragment, { children: [isSolid && !isDisabled ? (_jsx(View, { className: highlightVariants({ pressed, size }), pointerEvents: "none" })) : null, Children.map(children, (child) => typeof child === 'string' || typeof child === 'number' ? (_jsx(Text, { className: cn(labelVariants({ pressed, size, variant }), loading && 'opacity-0', labelClassName), children: child })) : isValidElement(child) ? (loading ? (_jsx(View, { className: "opacity-0", children: child })) : (child)) : null), loading ? (_jsx(View, { className: "absolute", children: _jsx(Spinner, { "aria-hidden": true, className: spinnerVariants({ variant }) }) })) : null] })) }));
|
|
38
123
|
}
|
|
39
124
|
//# sourceMappingURL=Button.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","sourceRoot":"","sources":["../../src/components/Button.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAqB,MAAM,0BAA0B,CAAC;AAClE,OAA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AC,CAAC,CAAC,IAAI,IACP,CACJ,GACS,CACb,CAAC;AACJ,CAAC"}
|
|
@@ -1,20 +1,30 @@
|
|
|
1
1
|
import { View } from 'react-native';
|
|
2
|
-
import {
|
|
2
|
+
import { type TextProps } from './Text';
|
|
3
|
+
export type CardActionProps = React.ComponentProps<typeof View>;
|
|
3
4
|
export type CardContentProps = React.ComponentProps<typeof View>;
|
|
4
|
-
export type CardDescriptionProps =
|
|
5
|
+
export type CardDescriptionProps = Omit<TextProps, 'tone' | 'variant'>;
|
|
6
|
+
export type CardFooterProps = React.ComponentProps<typeof View>;
|
|
5
7
|
export type CardHeaderProps = React.ComponentProps<typeof View>;
|
|
6
8
|
export type CardProps = React.ComponentProps<typeof View>;
|
|
7
|
-
export type CardTitleProps =
|
|
9
|
+
export type CardTitleProps = Omit<TextProps, 'tone' | 'variant'>;
|
|
10
|
+
declare function CardAction({ className, ...props }: CardActionProps): import("react").JSX.Element;
|
|
8
11
|
declare function CardContent({ className, ...props }: CardContentProps): import("react").JSX.Element;
|
|
9
12
|
declare function CardDescription({ className, ...props }: CardDescriptionProps): import("react").JSX.Element;
|
|
10
|
-
declare function
|
|
13
|
+
declare function CardFooter({ className, ...props }: CardFooterProps): import("react").JSX.Element;
|
|
14
|
+
/**
|
|
15
|
+
* Lays a `Card.Action` out beside the title and description, top-aligned,
|
|
16
|
+
* like the web header's grid.
|
|
17
|
+
*/
|
|
18
|
+
declare function CardHeader({ children, className, ...props }: CardHeaderProps): import("react").JSX.Element;
|
|
11
19
|
declare function CardRoot({ className, ...props }: CardProps): import("react").JSX.Element;
|
|
12
20
|
declare function CardTitle({ className, ...props }: CardTitleProps): import("react").JSX.Element;
|
|
13
21
|
declare const Card: typeof CardRoot & {
|
|
22
|
+
Action: typeof CardAction;
|
|
14
23
|
Content: typeof CardContent;
|
|
15
24
|
Description: typeof CardDescription;
|
|
25
|
+
Footer: typeof CardFooter;
|
|
16
26
|
Header: typeof CardHeader;
|
|
17
27
|
Title: typeof CardTitle;
|
|
18
28
|
};
|
|
19
|
-
export { Card, CardContent, CardDescription, CardHeader, CardTitle };
|
|
29
|
+
export { Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, };
|
|
20
30
|
//# sourceMappingURL=Card.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Card.d.ts","sourceRoot":"","sources":["../../src/components/Card.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Card.d.ts","sourceRoot":"","sources":["../../src/components/Card.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAGpC,OAAO,EAAQ,KAAK,SAAS,EAAE,MAAM,QAAQ,CAAC;AAE9C,MAAM,MAAM,eAAe,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,IAAI,CAAC,CAAC;AAChE,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,IAAI,CAAC,CAAC;AACjE,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;AACvE,MAAM,MAAM,eAAe,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,IAAI,CAAC,CAAC;AAChE,MAAM,MAAM,eAAe,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,IAAI,CAAC,CAAC;AAChE,MAAM,MAAM,SAAS,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,IAAI,CAAC,CAAC;AAC1D,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;AAKjE,iBAAS,UAAU,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,eAAe,+BAE3D;AAED,iBAAS,WAAW,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,gBAAgB,+BAE7D;AAED,iBAAS,eAAe,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,oBAAoB,+BASrE;AAED,iBAAS,UAAU,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,eAAe,+BAI3D;AAED;;;GAGG;AACH,iBAAS,UAAU,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,eAAe,+BAyBrE;AAED,iBAAS,QAAQ,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,SAAS,+BAUnD;AAED,iBAAS,SAAS,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,cAAc,+BAQzD;AAED,QAAA,MAAM,IAAI;;;;;;;CAOR,CAAC;AAEH,OAAO,EACL,IAAI,EACJ,UAAU,EACV,WAAW,EACX,eAAe,EACf,UAAU,EACV,UAAU,EACV,SAAS,GACV,CAAC"}
|
package/dist/components/Card.js
CHANGED
|
@@ -1,29 +1,47 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Children, isValidElement } from 'react';
|
|
2
3
|
import { View } from 'react-native';
|
|
3
4
|
import { cn } from '../lib/cn';
|
|
4
5
|
import { Text } from './Text';
|
|
6
|
+
// The parts sit in a column with `gap-4` and their own side padding, which
|
|
7
|
+
// reproduces the web's spacing between header, content and footer.
|
|
8
|
+
function CardAction({ className, ...props }) {
|
|
9
|
+
return _jsx(View, { className: cn('self-start', className), ...props });
|
|
10
|
+
}
|
|
5
11
|
function CardContent({ className, ...props }) {
|
|
6
|
-
return _jsx(View, { className: cn('
|
|
12
|
+
return _jsx(View, { className: cn('px-6', className), ...props });
|
|
7
13
|
}
|
|
8
14
|
function CardDescription({ className, ...props }) {
|
|
9
|
-
return _jsx(Text, { className: className, tone: "muted", ...props });
|
|
15
|
+
return (_jsx(Text, { className: cn('text-sm', className), tone: "muted", variant: "body", ...props }));
|
|
16
|
+
}
|
|
17
|
+
function CardFooter({ className, ...props }) {
|
|
18
|
+
return (_jsx(View, { className: cn('flex-row items-center px-6', className), ...props }));
|
|
10
19
|
}
|
|
11
|
-
|
|
12
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Lays a `Card.Action` out beside the title and description, top-aligned,
|
|
22
|
+
* like the web header's grid.
|
|
23
|
+
*/
|
|
24
|
+
function CardHeader({ children, className, ...props }) {
|
|
25
|
+
const parts = Children.toArray(children);
|
|
26
|
+
const actions = parts.filter((child) => isValidElement(child) && child.type === CardAction);
|
|
27
|
+
if (actions.length === 0) {
|
|
28
|
+
return (_jsx(View, { className: cn('gap-1.5 px-6', className), ...props, children: children }));
|
|
29
|
+
}
|
|
30
|
+
return (_jsxs(View, { className: cn('flex-row items-start gap-4 px-6', className), ...props, children: [_jsx(View, { className: "flex-1 gap-1.5", children: parts.filter((child) => !actions.includes(child)) }), actions] }));
|
|
13
31
|
}
|
|
14
32
|
function CardRoot({ className, ...props }) {
|
|
15
|
-
return (_jsx(View, { className: cn('border-border bg-card gap-4 rounded-
|
|
33
|
+
return (_jsx(View, { className: cn('border-border bg-card gap-4 rounded-2xl border py-6 shadow-xs shadow-black/5', className), ...props }));
|
|
16
34
|
}
|
|
17
35
|
function CardTitle({ className, ...props }) {
|
|
18
|
-
return (_jsx(Text, { className: cn('text-card-foreground', className), variant: "
|
|
36
|
+
return (_jsx(Text, { className: cn('text-card-foreground leading-none', className), variant: "h3", ...props }));
|
|
19
37
|
}
|
|
20
|
-
// Same compound shape as `Card` in @pickle-ui/react. The parts are exported
|
|
21
|
-
// so Fast Refresh keeps their state; the public entry only exports `Card`.
|
|
22
38
|
const Card = Object.assign(CardRoot, {
|
|
39
|
+
Action: CardAction,
|
|
23
40
|
Content: CardContent,
|
|
24
41
|
Description: CardDescription,
|
|
42
|
+
Footer: CardFooter,
|
|
25
43
|
Header: CardHeader,
|
|
26
44
|
Title: CardTitle,
|
|
27
45
|
});
|
|
28
|
-
export { Card, CardContent, CardDescription, CardHeader, CardTitle };
|
|
46
|
+
export { Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, };
|
|
29
47
|
//# sourceMappingURL=Card.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Card.js","sourceRoot":"","sources":["../../src/components/Card.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,OAAO,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AAC/B,OAAO,EAAE,IAAI,
|
|
1
|
+
{"version":3,"file":"Card.js","sourceRoot":"","sources":["../../src/components/Card.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,OAAO,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAkB,MAAM,QAAQ,CAAC;AAU9C,2EAA2E;AAC3E,mEAAmE;AAEnE,SAAS,UAAU,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAmB;IAC1D,OAAO,KAAC,IAAI,IAAC,SAAS,EAAE,EAAE,CAAC,YAAY,EAAE,SAAS,CAAC,KAAM,KAAK,GAAI,CAAC;AACrE,CAAC;AAED,SAAS,WAAW,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAoB;IAC5D,OAAO,KAAC,IAAI,IAAC,SAAS,EAAE,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC,KAAM,KAAK,GAAI,CAAC;AAC/D,CAAC;AAED,SAAS,eAAe,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAwB;IACpE,OAAO,CACL,KAAC,IAAI,IACH,SAAS,EAAE,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC,EACnC,IAAI,EAAC,OAAO,EACZ,OAAO,EAAC,MAAM,KACV,KAAK,GACT,CACH,CAAC;AACJ,CAAC;AAED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O,CACL,KAAC,IAAI,IACH,SAAS,EAAE,EAAE,CAAC,mCAAmC,EAAE,SAAS,CAAC,EAC7D,OAAO,EAAC,IAAI,KACR,KAAK,GACT,CACH,CAAC;AACJ,CAAC;AAED,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE;IACnC,MAAM,EAAE,UAAU;IAClB,OAAO,EAAE,WAAW;IACpB,WAAW,EAAE,eAAe;IAC5B,MAAM,EAAE,UAAU;IAClB,MAAM,EAAE,UAAU;IAClB,KAAK,EAAE,SAAS;CACjB,CAAC,CAAC;AAEH,OAAO,EACL,IAAI,EACJ,UAAU,EACV,WAAW,EACX,eAAe,EACf,UAAU,EACV,UAAU,EACV,SAAS,GACV,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { View } from 'react-native';
|
|
2
|
+
import { type LayoutStyleProps } from './_internal/layout';
|
|
3
|
+
declare const directionClasses: {
|
|
4
|
+
readonly column: "flex-col";
|
|
5
|
+
readonly 'column-reverse': "flex-col-reverse";
|
|
6
|
+
readonly row: "flex-row";
|
|
7
|
+
readonly 'row-reverse': "flex-row-reverse";
|
|
8
|
+
};
|
|
9
|
+
declare const wrapClasses: {
|
|
10
|
+
readonly nowrap: "flex-nowrap";
|
|
11
|
+
readonly wrap: "flex-wrap";
|
|
12
|
+
readonly 'wrap-reverse': "flex-wrap-reverse";
|
|
13
|
+
};
|
|
14
|
+
export type FlexProps = LayoutStyleProps & Omit<React.ComponentProps<typeof View>, keyof LayoutStyleProps> & {
|
|
15
|
+
direction?: keyof typeof directionClasses;
|
|
16
|
+
wrap?: keyof typeof wrapClasses;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* A `View` laid out with flexbox props, like `Flex` in @pickle-ui/react. It
|
|
20
|
+
* defaults to a row, as on the web, where React Native's `View` stacks its
|
|
21
|
+
* children in a column.
|
|
22
|
+
*/
|
|
23
|
+
export declare function Flex({ align, className, direction, gap, gapX, gapY, justify, wrap, ...props }: FlexProps): import("react").JSX.Element;
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=Flex.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Flex.d.ts","sourceRoot":"","sources":["../../src/components/Flex.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAGpC,OAAO,EAAoB,KAAK,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE7E,QAAA,MAAM,gBAAgB;;;;;CAKZ,CAAC;AAEX,QAAA,MAAM,WAAW;;;;CAIP,CAAC;AAEX,MAAM,MAAM,SAAS,GAAG,gBAAgB,GACtC,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,IAAI,CAAC,EAAE,MAAM,gBAAgB,CAAC,GAAG;IAChE,SAAS,CAAC,EAAE,MAAM,OAAO,gBAAgB,CAAC;IAC1C,IAAI,CAAC,EAAE,MAAM,OAAO,WAAW,CAAC;CACjC,CAAC;AAEJ;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,EACnB,KAAK,EACL,SAAS,EACT,SAAiB,EACjB,GAAG,EACH,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,IAAI,EACJ,GAAG,KAAK,EACT,EAAE,SAAS,+BAYX"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import { cn } from '../lib/cn';
|
|
4
|
+
import { getLayoutClasses } from './_internal/layout';
|
|
5
|
+
const directionClasses = {
|
|
6
|
+
column: 'flex-col',
|
|
7
|
+
'column-reverse': 'flex-col-reverse',
|
|
8
|
+
row: 'flex-row',
|
|
9
|
+
'row-reverse': 'flex-row-reverse',
|
|
10
|
+
};
|
|
11
|
+
const wrapClasses = {
|
|
12
|
+
nowrap: 'flex-nowrap',
|
|
13
|
+
wrap: 'flex-wrap',
|
|
14
|
+
'wrap-reverse': 'flex-wrap-reverse',
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* A `View` laid out with flexbox props, like `Flex` in @pickle-ui/react. It
|
|
18
|
+
* defaults to a row, as on the web, where React Native's `View` stacks its
|
|
19
|
+
* children in a column.
|
|
20
|
+
*/
|
|
21
|
+
export function Flex({ align, className, direction = 'row', gap, gapX, gapY, justify, wrap, ...props }) {
|
|
22
|
+
return (_jsx(View, { className: cn(getLayoutClasses({ align, gap, gapX, gapY, justify }), directionClasses[direction], wrap === undefined ? undefined : wrapClasses[wrap], className), ...props }));
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=Flex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Flex.js","sourceRoot":"","sources":["../../src/components/Flex.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,OAAO,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AAC/B,OAAO,EAAE,gBAAgB,EAAyB,MAAM,oBAAoB,CAAC;AAE7E,MAAM,gBAAgB,GAAG;IACvB,MAAM,EAAE,UAAU;IAClB,gBAAgB,EAAE,kBAAkB;IACpC,GAAG,EAAE,UAAU;IACf,aAAa,EAAE,kBAAkB;CACzB,CAAC;AAEX,MAAM,WAAW,GAAG;IAClB,MAAM,EAAE,aAAa;IACrB,IAAI,EAAE,WAAW;IACjB,cAAc,EAAE,mBAAmB;CAC3B,CAAC;AAQX;;;;GAIG;AACH,MAAM,UAAU,IAAI,CAAC,EACnB,KAAK,EACL,SAAS,EACT,SAAS,GAAG,KAAK,EACjB,GAAG,EACH,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,IAAI,EACJ,GAAG,KAAK,EACE;IACV,OAAO,CACL,KAAC,IAAI,IACH,SAAS,EAAE,EAAE,CACX,gBAAgB,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EACrD,gBAAgB,CAAC,SAAS,CAAC,EAC3B,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,EAClD,SAAS,CACV,KACG,KAAK,GACT,CACH,CAAC;AACJ,CAAC"}
|