@butternutbox/pawprint-native 1.1.0 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@butternutbox/pawprint-native",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "type": "module",
5
5
  "description": "ButternutBox Pawprint Design System - React Native Components",
6
6
  "main": "./dist/index.cjs",
@@ -222,7 +222,7 @@ describe("ProductDisplayCard (Native)", () => {
222
222
  expect(screen.queryByText("6")).toBeFalsy()
223
223
  })
224
224
 
225
- it("suppresses the quantity picker when quantityBadge is set (mutually exclusive)", () => {
225
+ it("renders the quantity picker alongside a quantityBadge", () => {
226
226
  renderWithTheme(
227
227
  <ProductDisplayCard
228
228
  title="Test Product"
@@ -239,8 +239,8 @@ describe("ProductDisplayCard (Native)", () => {
239
239
 
240
240
  // The badge shows the quantity...
241
241
  expect(screen.getByText("3")).toBeTruthy()
242
- // ...and the picker input is not rendered.
243
- expect(screen.queryByDisplayValue("3")).toBeFalsy()
242
+ // ...and the picker is rendered independently of it.
243
+ expect(screen.getByDisplayValue("3")).toBeTruthy()
244
244
  })
245
245
 
246
246
  it("renders a thumbnailBadge from BadgeProps", () => {
@@ -259,7 +259,7 @@ describe("ProductDisplayCard (Native)", () => {
259
259
  expect(screen.getByText("New")).toBeTruthy()
260
260
  })
261
261
 
262
- it("suppresses the quantity picker when thumbnailBadge is set", () => {
262
+ it("renders the quantity picker alongside a thumbnailBadge", () => {
263
263
  renderWithTheme(
264
264
  <ProductDisplayCard
265
265
  title="Test Product"
@@ -275,7 +275,7 @@ describe("ProductDisplayCard (Native)", () => {
275
275
  )
276
276
 
277
277
  expect(screen.getByText("New")).toBeTruthy()
278
- expect(screen.queryByDisplayValue("2")).toBeFalsy()
278
+ expect(screen.getByDisplayValue("2")).toBeTruthy()
279
279
  })
280
280
 
281
281
  it("prefers thumbnailBadge over the deprecated quantityBadge when both are set", () => {
@@ -20,16 +20,14 @@ export type ProductDisplayCardProps = ViewProps & {
20
20
  * wins. This prop will be removed in a future major release.
21
21
  *
22
22
  * Show a quantity badge overlaid on the top-right of the image (rendering the
23
- * current `quantity`) instead of the quantity picker. Defaults to `false`.
24
- * The badge and the quantity picker are mutually exclusive — only one shows
25
- * at a time; when `quantityBadge` is true the picker is never rendered.
23
+ * current `quantity`). Defaults to `false`. Independent of the quantity
24
+ * picker — use `showQuantityPicker` to control that separately.
26
25
  */
27
26
  quantityBadge?: boolean
28
27
  /**
29
28
  * Render a `Badge` overlaid on the top-right of the image. Accepts any
30
29
  * `BadgeProps` (variant, size, icon, children, etc.) — pass them as an object.
31
- * Mutually exclusive with the quantity picker: when set, the picker is never
32
- * rendered.
30
+ * Independent of the quantity picker: both can be shown at the same time.
33
31
  *
34
32
  * @example
35
33
  * thumbnailBadge={{ variant: "primary", size: "large", children: "New" }}
@@ -312,7 +310,7 @@ export const ProductDisplayCard = React.forwardRef<
312
310
  )}
313
311
  </StyledTextContainer>
314
312
 
315
- {showQuantityPicker && !resolvedBadgeProps && (
313
+ {showQuantityPicker && (
316
314
  <View style={{ marginLeft: "auto" }}>
317
315
  <NumberField
318
316
  size="sm"
@@ -87,9 +87,11 @@ const StyledSegmentItem = styled(Pressable)<{
87
87
  const StyledIntrinsicClip = styled(View)<{
88
88
  clipBorderRadius: number
89
89
  clipBgColor: string
90
+ clipHeight: number
90
91
  clipWidth?: number
91
- }>(({ clipBorderRadius, clipBgColor, clipWidth }) => ({
92
+ }>(({ clipBorderRadius, clipBgColor, clipHeight, clipWidth }) => ({
92
93
  overflow: "hidden",
94
+ height: clipHeight,
93
95
  borderRadius: clipBorderRadius,
94
96
  backgroundColor: clipBgColor,
95
97
  alignSelf: "flex-start",
@@ -282,12 +284,14 @@ type IntrinsicTrackProps = ViewProps & {
282
284
  scrollIndicatorPaddingOuter: number
283
285
  scrollIndicatorPaddingInner: number
284
286
  }
287
+ trackHeight: number
285
288
  renderItems: () => React.ReactNode
286
289
  forwardedRef: React.Ref<View>
287
290
  }
288
291
 
289
292
  const IntrinsicTrack = ({
290
293
  containerProps,
294
+ trackHeight,
291
295
  renderItems,
292
296
  forwardedRef,
293
297
  ...rest
@@ -325,6 +329,7 @@ const IntrinsicTrack = ({
325
329
  <StyledIntrinsicClip
326
330
  clipBorderRadius={containerProps.containerBorderRadius}
327
331
  clipBgColor={containerProps.containerBgColor}
332
+ clipHeight={trackHeight}
328
333
  clipWidth={
329
334
  containerWidth > 0 && contentWidth > 0
330
335
  ? Math.min(contentWidth, containerWidth)
@@ -426,7 +431,7 @@ const SegmentedControlRoot = React.forwardRef<View, SegmentedControlProps>(
426
431
  ref
427
432
  ) => {
428
433
  const theme = useTheme()
429
- const { spacing, borderRadius, colour } =
434
+ const { spacing, borderRadius, colour, controlItem } =
430
435
  theme.tokens.components.segmentedControl
431
436
  const { dimensions } = theme.tokens.semantics
432
437
 
@@ -505,10 +510,15 @@ const SegmentedControlRoot = React.forwardRef<View, SegmentedControlProps>(
505
510
  scrollIndicatorPaddingInner: parseTokenValue(dimensions.spacing.sm)
506
511
  }
507
512
 
513
+ const trackHeight =
514
+ parseTokenValue(controlItem.size.small.height) +
515
+ parseTokenValue(spacing.verticalPadding) * 2
516
+
508
517
  if (layout === "intrinsic") {
509
518
  return (
510
519
  <IntrinsicTrack
511
520
  containerProps={containerProps}
521
+ trackHeight={trackHeight}
512
522
  renderItems={renderItems}
513
523
  forwardedRef={ref}
514
524
  {...rest}