@ankhorage/zora 1.0.6 → 1.0.8
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/CHANGELOG.md +12 -0
- package/README.md +183 -0
- package/dist/components/media-card/MediaCard.d.ts +4 -0
- package/dist/components/media-card/MediaCard.d.ts.map +1 -0
- package/dist/components/media-card/MediaCard.js +64 -0
- package/dist/components/media-card/MediaCard.js.map +1 -0
- package/dist/components/media-card/index.d.ts +3 -0
- package/dist/components/media-card/index.d.ts.map +1 -0
- package/dist/components/media-card/index.js +2 -0
- package/dist/components/media-card/index.js.map +1 -0
- package/dist/components/media-card/types.d.ts +36 -0
- package/dist/components/media-card/types.d.ts.map +1 -0
- package/dist/components/media-card/types.js +2 -0
- package/dist/components/media-card/types.js.map +1 -0
- package/dist/components/metric-card/MetricCard.d.ts +4 -0
- package/dist/components/metric-card/MetricCard.d.ts.map +1 -0
- package/dist/components/metric-card/MetricCard.js +43 -0
- package/dist/components/metric-card/MetricCard.js.map +1 -0
- package/dist/components/metric-card/index.d.ts +3 -0
- package/dist/components/metric-card/index.d.ts.map +1 -0
- package/dist/components/metric-card/index.js +2 -0
- package/dist/components/metric-card/index.js.map +1 -0
- package/dist/components/metric-card/types.d.ts +17 -0
- package/dist/components/metric-card/types.d.ts.map +1 -0
- package/dist/components/metric-card/types.js +2 -0
- package/dist/components/metric-card/types.js.map +1 -0
- package/dist/components/progress/Progress.d.ts +4 -0
- package/dist/components/progress/Progress.d.ts.map +1 -0
- package/dist/components/progress/Progress.js +28 -0
- package/dist/components/progress/Progress.js.map +1 -0
- package/dist/components/progress/index.d.ts +3 -0
- package/dist/components/progress/index.d.ts.map +1 -0
- package/dist/components/progress/index.js +2 -0
- package/dist/components/progress/index.js.map +1 -0
- package/dist/components/progress/resolveProgressFraction.d.ts +5 -0
- package/dist/components/progress/resolveProgressFraction.d.ts.map +1 -0
- package/dist/components/progress/resolveProgressFraction.js +14 -0
- package/dist/components/progress/resolveProgressFraction.js.map +1 -0
- package/dist/components/progress/types.d.ts +11 -0
- package/dist/components/progress/types.d.ts.map +1 -0
- package/dist/components/progress/types.js +16 -0
- package/dist/components/progress/types.js.map +1 -0
- package/dist/components/rating/Rating.d.ts +4 -0
- package/dist/components/rating/Rating.d.ts.map +1 -0
- package/dist/components/rating/Rating.js +23 -0
- package/dist/components/rating/Rating.js.map +1 -0
- package/dist/components/rating/index.d.ts +3 -0
- package/dist/components/rating/index.d.ts.map +1 -0
- package/dist/components/rating/index.js +2 -0
- package/dist/components/rating/index.js.map +1 -0
- package/dist/components/rating/resolveRatingSegments.d.ts +7 -0
- package/dist/components/rating/resolveRatingSegments.d.ts.map +1 -0
- package/dist/components/rating/resolveRatingSegments.js +22 -0
- package/dist/components/rating/resolveRatingSegments.js.map +1 -0
- package/dist/components/rating/types.d.ts +11 -0
- package/dist/components/rating/types.d.ts.map +1 -0
- package/dist/components/rating/types.js +16 -0
- package/dist/components/rating/types.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/patterns/timeline/Timeline.d.ts +4 -0
- package/dist/patterns/timeline/Timeline.d.ts.map +1 -0
- package/dist/patterns/timeline/Timeline.js +59 -0
- package/dist/patterns/timeline/Timeline.js.map +1 -0
- package/dist/patterns/timeline/index.d.ts +3 -0
- package/dist/patterns/timeline/index.d.ts.map +1 -0
- package/dist/patterns/timeline/index.js +2 -0
- package/dist/patterns/timeline/index.js.map +1 -0
- package/dist/patterns/timeline/types.d.ts +18 -0
- package/dist/patterns/timeline/types.d.ts.map +1 -0
- package/dist/patterns/timeline/types.js +2 -0
- package/dist/patterns/timeline/types.js.map +1 -0
- package/package.json +3 -3
- package/src/components/media-card/MediaCard.tsx +120 -0
- package/src/components/media-card/index.ts +2 -0
- package/src/components/media-card/types.ts +44 -0
- package/src/components/metric-card/MetricCard.tsx +84 -0
- package/src/components/metric-card/index.ts +2 -0
- package/src/components/metric-card/types.ts +18 -0
- package/src/components/progress/Progress.tsx +50 -0
- package/src/components/progress/index.ts +2 -0
- package/src/components/progress/resolveProgressFraction.test.ts +23 -0
- package/src/components/progress/resolveProgressFraction.ts +17 -0
- package/src/components/progress/types.ts +27 -0
- package/src/components/rating/Rating.tsx +38 -0
- package/src/components/rating/index.ts +2 -0
- package/src/components/rating/resolveRatingSegments.test.ts +60 -0
- package/src/components/rating/resolveRatingSegments.ts +34 -0
- package/src/components/rating/types.ts +27 -0
- package/src/index.ts +10 -0
- package/src/patterns/timeline/Timeline.tsx +104 -0
- package/src/patterns/timeline/index.ts +2 -0
- package/src/patterns/timeline/types.ts +20 -0
- package/src/showcaseCoverage.test.ts +5 -0
- package/src/theme/themeScopeStructure.test.ts +10 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.0.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 772236f: Update packages
|
|
8
|
+
|
|
9
|
+
## 1.0.7
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 8795a20: Add common product-facing primitives: `MediaCard`, `MetricCard`, `Progress` (linear v1), `Rating` (readonly v1), and the `Timeline` pattern (vertical-only v1).
|
|
14
|
+
|
|
3
15
|
## 1.0.6
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -442,6 +442,145 @@ Inherits all Surface `CardProps` except `children`, `p`, `radius`, `variant`, an
|
|
|
442
442
|
|
|
443
443
|
</details>
|
|
444
444
|
|
|
445
|
+
### `MediaCard`
|
|
446
|
+
|
|
447
|
+
Media-first card surface for listings, content previews, and catalog items.
|
|
448
|
+
|
|
449
|
+
```tsx
|
|
450
|
+
<MediaCard
|
|
451
|
+
imageSource={require('./cover.png')}
|
|
452
|
+
imageLabel="Cover image"
|
|
453
|
+
title="MediaCard"
|
|
454
|
+
description="Composes an image slot, header content, badges, actions, and footer metadata."
|
|
455
|
+
badges={<Badge tone="primary">Featured</Badge>}
|
|
456
|
+
footer={<Rating value={4.5} />}
|
|
457
|
+
onPress={() => undefined}
|
|
458
|
+
/>
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
<details>
|
|
462
|
+
<summary>Props</summary>
|
|
463
|
+
|
|
464
|
+
ZORA props:
|
|
465
|
+
|
|
466
|
+
| Prop | Type | Default | Notes |
|
|
467
|
+
| ------------------ | --------------------- | ----------- | ---------------------------------------------------------- |
|
|
468
|
+
| `imageSource` | `ImageSourcePropType` | - | Image source (mutually exclusive with `image`). |
|
|
469
|
+
| `imageLabel` | `string` | - | Accessibility label for `imageSource`. |
|
|
470
|
+
| `image` | `React.ReactNode` | - | Custom image slot (mutually exclusive with `imageSource`). |
|
|
471
|
+
| `imageAspectRatio` | `number` | `16 / 9` | Aspect ratio used when rendering `imageSource`. |
|
|
472
|
+
| `title` | `React.ReactNode` | - | Required title. |
|
|
473
|
+
| `description` | `React.ReactNode` | - | Optional description under the title. |
|
|
474
|
+
| `eyebrow` | `React.ReactNode` | - | Optional caption above the title. |
|
|
475
|
+
| `badges` | `React.ReactNode` | - | Optional badge/tags region near the title. |
|
|
476
|
+
| `actions` | `React.ReactNode` | - | Optional trailing action area; disables `onPress`. |
|
|
477
|
+
| `footer` | `React.ReactNode` | - | Optional footer content under the body. |
|
|
478
|
+
| `children` | `React.ReactNode` | - | Optional body content. |
|
|
479
|
+
| `tone` | `ZoraCardTone` | `'default'` | Passed to the underlying `Card`. |
|
|
480
|
+
| `compact` | `boolean` | `false` | Uses tighter spacing. |
|
|
481
|
+
| `onPress` | `() => void` | - | Makes the card pressable when no `actions` are present. |
|
|
482
|
+
| `testID` | `string` | - | Forwarded to the underlying `Card`. |
|
|
483
|
+
|
|
484
|
+
Inherited props:
|
|
485
|
+
|
|
486
|
+
No inherited props. `MediaCardProps` is declared directly by ZORA.
|
|
487
|
+
|
|
488
|
+
</details>
|
|
489
|
+
|
|
490
|
+
### `MetricCard`
|
|
491
|
+
|
|
492
|
+
Compact metric surface for dashboards, stats, and summary cards.
|
|
493
|
+
|
|
494
|
+
```tsx
|
|
495
|
+
<MetricCard
|
|
496
|
+
label="Monthly active users"
|
|
497
|
+
value="14.2k"
|
|
498
|
+
delta="+4.1%"
|
|
499
|
+
deltaTone="success"
|
|
500
|
+
description="Last 30 days"
|
|
501
|
+
/>
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
<details>
|
|
505
|
+
<summary>Props</summary>
|
|
506
|
+
|
|
507
|
+
ZORA props:
|
|
508
|
+
|
|
509
|
+
| Prop | Type | Default | Notes |
|
|
510
|
+
| ------------- | ----------------- | ----------- | ------------------------------------------------------- |
|
|
511
|
+
| `label` | `React.ReactNode` | - | Required label above the value. |
|
|
512
|
+
| `value` | `React.ReactNode` | - | Required metric value. |
|
|
513
|
+
| `description` | `React.ReactNode` | - | Optional supporting copy. |
|
|
514
|
+
| `icon` | `ButtonIconSpec` | - | Optional icon shown next to the label. |
|
|
515
|
+
| `delta` | `React.ReactNode` | - | Optional delta badge content. |
|
|
516
|
+
| `deltaTone` | `ZoraTone` | `'neutral'` | Tone used for the delta `Badge`. |
|
|
517
|
+
| `actions` | `React.ReactNode` | - | Optional trailing action area; disables `onPress`. |
|
|
518
|
+
| `tone` | `ZoraCardTone` | `'default'` | Passed to the underlying `Card`. |
|
|
519
|
+
| `compact` | `boolean` | `false` | Uses tighter spacing. |
|
|
520
|
+
| `onPress` | `() => void` | - | Makes the card pressable when no `actions` are present. |
|
|
521
|
+
| `testID` | `string` | - | Forwarded to the underlying `Card`. |
|
|
522
|
+
|
|
523
|
+
Inherited props:
|
|
524
|
+
|
|
525
|
+
No inherited props. `MetricCardProps` is declared directly by ZORA.
|
|
526
|
+
|
|
527
|
+
</details>
|
|
528
|
+
|
|
529
|
+
### `Progress`
|
|
530
|
+
|
|
531
|
+
Linear progress bar with semantic tone.
|
|
532
|
+
|
|
533
|
+
```tsx
|
|
534
|
+
<Progress value={72} />
|
|
535
|
+
<Progress tone="success" value={38} />
|
|
536
|
+
```
|
|
537
|
+
|
|
538
|
+
<details>
|
|
539
|
+
<summary>Props</summary>
|
|
540
|
+
|
|
541
|
+
ZORA props:
|
|
542
|
+
|
|
543
|
+
| Prop | Type | Default | Notes |
|
|
544
|
+
| -------- | ----------------- | ----------- | ----------------------------- |
|
|
545
|
+
| `value` | `number` | - | Current progress value. |
|
|
546
|
+
| `max` | `number` | `100` | Maximum value for completion. |
|
|
547
|
+
| `tone` | `ZoraTone` | `'primary'` | Fill tone. |
|
|
548
|
+
| `size` | `ZoraControlSize` | `'m'` | Controls bar height. |
|
|
549
|
+
| `testID` | `string` | - | Test id. |
|
|
550
|
+
|
|
551
|
+
Inherited props:
|
|
552
|
+
|
|
553
|
+
No inherited props. `ProgressProps` is declared directly by ZORA.
|
|
554
|
+
|
|
555
|
+
</details>
|
|
556
|
+
|
|
557
|
+
### `Rating`
|
|
558
|
+
|
|
559
|
+
Readonly rating display rendered as star icons.
|
|
560
|
+
|
|
561
|
+
```tsx
|
|
562
|
+
<Rating value={4.5} />
|
|
563
|
+
```
|
|
564
|
+
|
|
565
|
+
<details>
|
|
566
|
+
<summary>Props</summary>
|
|
567
|
+
|
|
568
|
+
ZORA props:
|
|
569
|
+
|
|
570
|
+
| Prop | Type | Default | Notes |
|
|
571
|
+
| -------- | ----------------- | ----------- | ---------------------- |
|
|
572
|
+
| `value` | `number` | - | Current rating value. |
|
|
573
|
+
| `max` | `number` | `5` | Maximum rating value. |
|
|
574
|
+
| `tone` | `ZoraTone` | `'warning'` | Tone for filled icons. |
|
|
575
|
+
| `size` | `ZoraControlSize` | `'m'` | Icon sizing preset. |
|
|
576
|
+
| `testID` | `string` | - | Test id. |
|
|
577
|
+
|
|
578
|
+
Inherited props:
|
|
579
|
+
|
|
580
|
+
No inherited props. `RatingProps` is declared directly by ZORA.
|
|
581
|
+
|
|
582
|
+
</details>
|
|
583
|
+
|
|
445
584
|
### `Input`
|
|
446
585
|
|
|
447
586
|
Text input wrapper with ZORA sizing and optional Surface icon specs.
|
|
@@ -1374,6 +1513,50 @@ No inherited props. `ListSectionProps` is declared directly by ZORA.
|
|
|
1374
1513
|
|
|
1375
1514
|
</details>
|
|
1376
1515
|
|
|
1516
|
+
### `Timeline`
|
|
1517
|
+
|
|
1518
|
+
Vertical-only timeline pattern for onboarding steps, order tracking, and activity sequences.
|
|
1519
|
+
|
|
1520
|
+
```tsx
|
|
1521
|
+
<Timeline
|
|
1522
|
+
items={[
|
|
1523
|
+
{ id: '1', title: 'Order placed', meta: '09:15', status: 'success' },
|
|
1524
|
+
{ id: '2', title: 'In transit', meta: '11:42', status: 'primary' },
|
|
1525
|
+
{ id: '3', title: 'Requires attention', meta: 'Today', status: 'warning' },
|
|
1526
|
+
]}
|
|
1527
|
+
/>
|
|
1528
|
+
```
|
|
1529
|
+
|
|
1530
|
+
<details>
|
|
1531
|
+
<summary>Props</summary>
|
|
1532
|
+
|
|
1533
|
+
ZORA props:
|
|
1534
|
+
|
|
1535
|
+
| Prop | Type | Default | Notes |
|
|
1536
|
+
| --------- | ---------------- | ------- | --------------------------------------------- |
|
|
1537
|
+
| `items` | `TimelineItem[]` | - | Ordered timeline items (vertical-only in v1). |
|
|
1538
|
+
| `compact` | `boolean` | `false` | Uses tighter spacing between items. |
|
|
1539
|
+
| `testID` | `string` | - | Test id. |
|
|
1540
|
+
|
|
1541
|
+
Item shape:
|
|
1542
|
+
|
|
1543
|
+
```ts
|
|
1544
|
+
type TimelineItem = {
|
|
1545
|
+
id: string;
|
|
1546
|
+
title: React.ReactNode;
|
|
1547
|
+
description?: React.ReactNode;
|
|
1548
|
+
meta?: React.ReactNode;
|
|
1549
|
+
status?: ZoraTone;
|
|
1550
|
+
icon?: ButtonIconSpec;
|
|
1551
|
+
};
|
|
1552
|
+
```
|
|
1553
|
+
|
|
1554
|
+
Inherited props:
|
|
1555
|
+
|
|
1556
|
+
No inherited props. `TimelineProps` is declared directly by ZORA.
|
|
1557
|
+
|
|
1558
|
+
</details>
|
|
1559
|
+
|
|
1377
1560
|
### `SettingsRow`
|
|
1378
1561
|
|
|
1379
1562
|
Compact settings row with optional metadata, control, and press handling.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MediaCard.d.ts","sourceRoot":"","sources":["../../../src/components/media-card/MediaCard.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAS1B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AA8G9C,eAAO,MAAM,SAAS,sDAAqC,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Image } from 'react-native';
|
|
3
|
+
import { Box, Stack } from '../../foundation';
|
|
4
|
+
import { useZoraTheme } from '../../theme/useZoraTheme';
|
|
5
|
+
import { withZoraThemeScope } from '../../theme/withZoraThemeScope';
|
|
6
|
+
import { Card } from '../card';
|
|
7
|
+
import { Heading } from '../heading';
|
|
8
|
+
import { Text } from '../text';
|
|
9
|
+
function resolveImageAspectRatio(imageAspectRatio) {
|
|
10
|
+
if (!Number.isFinite(imageAspectRatio) || imageAspectRatio <= 0) {
|
|
11
|
+
return 16 / 9;
|
|
12
|
+
}
|
|
13
|
+
return imageAspectRatio;
|
|
14
|
+
}
|
|
15
|
+
function MediaCardInner({ themeId: _themeId, mode: _mode, testID, imageSource, imageLabel, image, imageAspectRatio = 16 / 9, title, description, eyebrow, badges, actions, footer, children, tone = 'default', compact = false, onPress, }) {
|
|
16
|
+
const { theme } = useZoraTheme();
|
|
17
|
+
const gap = compact ? 's' : 'm';
|
|
18
|
+
const isInteractive = Boolean(onPress) && !actions;
|
|
19
|
+
const resolvedAspectRatio = resolveImageAspectRatio(imageAspectRatio);
|
|
20
|
+
const renderImage = () => {
|
|
21
|
+
if (image) {
|
|
22
|
+
return (<Box radius="m" style={{ overflow: 'hidden' }}>
|
|
23
|
+
{image}
|
|
24
|
+
</Box>);
|
|
25
|
+
}
|
|
26
|
+
if (!imageSource) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
return (<Box bg={theme.semantics.neutral.surface} radius="m" style={{ overflow: 'hidden' }}>
|
|
30
|
+
<Box style={{ aspectRatio: resolvedAspectRatio, width: '100%' }}>
|
|
31
|
+
<Image accessibilityLabel={imageLabel} source={imageSource} style={{ height: '100%', width: '100%' }}/>
|
|
32
|
+
</Box>
|
|
33
|
+
</Box>);
|
|
34
|
+
};
|
|
35
|
+
const hasHeader = [eyebrow, title, description, badges, actions].some((item) => item != null);
|
|
36
|
+
return (<Card compact={compact} onPress={isInteractive ? onPress : undefined} testID={testID} tone={tone}>
|
|
37
|
+
<Stack gap={gap}>
|
|
38
|
+
{renderImage()}
|
|
39
|
+
|
|
40
|
+
{hasHeader ? (<Stack align={{ base: 'flex-start', md: 'center' }} direction={{ base: 'column', md: 'row' }} gap="m" justify="space-between">
|
|
41
|
+
<Box flex={1}>
|
|
42
|
+
<Stack gap="xs">
|
|
43
|
+
{eyebrow ? (<Text tone="muted" variant="caption" weight="semiBold">
|
|
44
|
+
{eyebrow}
|
|
45
|
+
</Text>) : null}
|
|
46
|
+
<Stack gap="xs">
|
|
47
|
+
<Heading level={compact ? 4 : 3}>{title}</Heading>
|
|
48
|
+
{badges ? <Box>{badges}</Box> : null}
|
|
49
|
+
</Stack>
|
|
50
|
+
{description ? (<Text tone="muted" variant="bodySmall">
|
|
51
|
+
{description}
|
|
52
|
+
</Text>) : null}
|
|
53
|
+
</Stack>
|
|
54
|
+
</Box>
|
|
55
|
+
{actions ? <Box>{actions}</Box> : null}
|
|
56
|
+
</Stack>) : null}
|
|
57
|
+
|
|
58
|
+
{children ? <Box>{children}</Box> : null}
|
|
59
|
+
{footer ? <Box pt="xs">{footer}</Box> : null}
|
|
60
|
+
</Stack>
|
|
61
|
+
</Card>);
|
|
62
|
+
}
|
|
63
|
+
export const MediaCard = withZoraThemeScope(MediaCardInner);
|
|
64
|
+
//# sourceMappingURL=MediaCard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MediaCard.js","sourceRoot":"","sources":["../../../src/components/media-card/MediaCard.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAErC,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAG/B,SAAS,uBAAuB,CAC9B,gBAAiE;IAEjE,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAC,IAAI,gBAAgB,IAAI,CAAC,EAAE,CAAC;QAChE,OAAO,EAAE,GAAG,CAAC,CAAC;IAChB,CAAC;IAED,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAED,SAAS,cAAc,CAAC,EACtB,OAAO,EAAE,QAAQ,EACjB,IAAI,EAAE,KAAK,EACX,MAAM,EACN,WAAW,EACX,UAAU,EACV,KAAK,EACL,gBAAgB,GAAG,EAAE,GAAG,CAAC,EACzB,KAAK,EACL,WAAW,EACX,OAAO,EACP,MAAM,EACN,OAAO,EACP,MAAM,EACN,QAAQ,EACR,IAAI,GAAG,SAAS,EAChB,OAAO,GAAG,KAAK,EACf,OAAO,GACQ;IACf,MAAM,EAAE,KAAK,EAAE,GAAG,YAAY,EAAE,CAAC;IACjC,MAAM,GAAG,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;IAChC,MA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CAAC,CAAC,CAAC,CACb,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,CACpC;oBAAA,CAAC,WAAW,CACd;kBAAA,EAAE,IAAI,CAAC,CACR,CAAC,CAAC,CAAC,IAAI,CACV;cAAA,EAAE,KAAK,CACT;YAAA,EAAE,GAAG,CACL;YAAA,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CACxC;UAAA,EAAE,KAAK,CAAC,CACT,CAAC,CAAC,CAAC,IAAI,CAER;;QAAA,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CACxC;QAAA,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAC9C;MAAA,EAAE,KAAK,CACT;IAAA,EAAE,IAAI,CAAC,CACR,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,kBAAkB,CAAC,cAAc,CAAC,CAAC","sourcesContent":["import React from 'react';\nimport { Image } from 'react-native';\n\nimport { Box, Stack } from '../../foundation';\nimport { useZoraTheme } from '../../theme/useZoraTheme';\nimport { withZoraThemeScope } from '../../theme/withZoraThemeScope';\nimport { Card } from '../card';\nimport { Heading } from '../heading';\nimport { Text } from '../text';\nimport type { MediaCardProps } from './types';\n\nfunction resolveImageAspectRatio(\n imageAspectRatio: NonNullable<MediaCardProps['imageAspectRatio']>,\n) {\n if (!Number.isFinite(imageAspectRatio) || imageAspectRatio <= 0) {\n return 16 / 9;\n }\n\n return imageAspectRatio;\n}\n\nfunction MediaCardInner({\n themeId: _themeId,\n mode: _mode,\n testID,\n imageSource,\n imageLabel,\n image,\n imageAspectRatio = 16 / 9,\n title,\n description,\n eyebrow,\n badges,\n actions,\n footer,\n children,\n tone = 'default',\n compact = false,\n onPress,\n}: MediaCardProps) {\n const { theme } = useZoraTheme();\n const gap = compact ? 's' : 'm';\n const isInteractive = Boolean(onPress) && !actions;\n const resolvedAspectRatio = resolveImageAspectRatio(imageAspectRatio);\n\n const renderImage = () => {\n if (image) {\n return (\n <Box radius=\"m\" style={{ overflow: 'hidden' }}>\n {image}\n </Box>\n );\n }\n\n if (!imageSource) {\n return null;\n }\n\n return (\n <Box bg={theme.semantics.neutral.surface} radius=\"m\" style={{ overflow: 'hidden' }}>\n <Box style={{ aspectRatio: resolvedAspectRatio, width: '100%' }}>\n <Image\n accessibilityLabel={imageLabel}\n source={imageSource}\n style={{ height: '100%', width: '100%' }}\n />\n </Box>\n </Box>\n );\n };\n\n const hasHeader = [eyebrow, title, description, badges, actions].some((item) => item != null);\n\n return (\n <Card\n compact={compact}\n onPress={isInteractive ? onPress : undefined}\n testID={testID}\n tone={tone}\n >\n <Stack gap={gap}>\n {renderImage()}\n\n {hasHeader ? (\n <Stack\n align={{ base: 'flex-start', md: 'center' }}\n direction={{ base: 'column', md: 'row' }}\n gap=\"m\"\n justify=\"space-between\"\n >\n <Box flex={1}>\n <Stack gap=\"xs\">\n {eyebrow ? (\n <Text tone=\"muted\" variant=\"caption\" weight=\"semiBold\">\n {eyebrow}\n </Text>\n ) : null}\n <Stack gap=\"xs\">\n <Heading level={compact ? 4 : 3}>{title}</Heading>\n {badges ? <Box>{badges}</Box> : null}\n </Stack>\n {description ? (\n <Text tone=\"muted\" variant=\"bodySmall\">\n {description}\n </Text>\n ) : null}\n </Stack>\n </Box>\n {actions ? <Box>{actions}</Box> : null}\n </Stack>\n ) : null}\n\n {children ? <Box>{children}</Box> : null}\n {footer ? <Box pt=\"xs\">{footer}</Box> : null}\n </Stack>\n </Card>\n );\n}\n\nexport const MediaCard = withZoraThemeScope(MediaCardInner);\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/media-card/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/media-card/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC","sourcesContent":["export { MediaCard } from './MediaCard';\nexport type { MediaCardImageProps, MediaCardProps } from './types';\n"]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import type { ImageSourcePropType } from 'react-native';
|
|
3
|
+
import type { ZoraCardTone } from '../../internal/recipes';
|
|
4
|
+
import type { ZoraBaseProps } from '../../theme/ZoraBaseProps';
|
|
5
|
+
interface MediaCardWithImageSource {
|
|
6
|
+
imageSource: ImageSourcePropType;
|
|
7
|
+
imageLabel?: string;
|
|
8
|
+
image?: never;
|
|
9
|
+
}
|
|
10
|
+
interface MediaCardWithImageSlot {
|
|
11
|
+
image: React.ReactNode;
|
|
12
|
+
imageSource?: never;
|
|
13
|
+
imageLabel?: never;
|
|
14
|
+
}
|
|
15
|
+
interface MediaCardWithoutImage {
|
|
16
|
+
image?: never;
|
|
17
|
+
imageSource?: never;
|
|
18
|
+
imageLabel?: never;
|
|
19
|
+
}
|
|
20
|
+
export type MediaCardImageProps = MediaCardWithImageSource | MediaCardWithImageSlot | MediaCardWithoutImage;
|
|
21
|
+
interface MediaCardBaseProps extends ZoraBaseProps {
|
|
22
|
+
title: React.ReactNode;
|
|
23
|
+
description?: React.ReactNode;
|
|
24
|
+
eyebrow?: React.ReactNode;
|
|
25
|
+
badges?: React.ReactNode;
|
|
26
|
+
actions?: React.ReactNode;
|
|
27
|
+
footer?: React.ReactNode;
|
|
28
|
+
children?: React.ReactNode;
|
|
29
|
+
tone?: ZoraCardTone;
|
|
30
|
+
compact?: boolean;
|
|
31
|
+
onPress?: () => void;
|
|
32
|
+
imageAspectRatio?: number;
|
|
33
|
+
}
|
|
34
|
+
export type MediaCardProps = MediaCardBaseProps & MediaCardImageProps;
|
|
35
|
+
export {};
|
|
36
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/media-card/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAExD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE/D,UAAU,wBAAwB;IAChC,WAAW,EAAE,mBAAmB,CAAC;IACjC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AAED,UAAU,sBAAsB;IAC9B,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,WAAW,CAAC,EAAE,KAAK,CAAC;IACpB,UAAU,CAAC,EAAE,KAAK,CAAC;CACpB;AAED,UAAU,qBAAqB;IAC7B,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,WAAW,CAAC,EAAE,KAAK,CAAC;IACpB,UAAU,CAAC,EAAE,KAAK,CAAC;CACpB;AAED,MAAM,MAAM,mBAAmB,GAC3B,wBAAwB,GACxB,sBAAsB,GACtB,qBAAqB,CAAC;AAE1B,UAAU,kBAAmB,SAAQ,aAAa;IAChD,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC9B,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,MAAM,cAAc,GAAG,kBAAkB,GAAG,mBAAmB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/components/media-card/types.ts"],"names":[],"mappings":"","sourcesContent":["import type React from 'react';\nimport type { ImageSourcePropType } from 'react-native';\n\nimport type { ZoraCardTone } from '../../internal/recipes';\nimport type { ZoraBaseProps } from '../../theme/ZoraBaseProps';\n\ninterface MediaCardWithImageSource {\n imageSource: ImageSourcePropType;\n imageLabel?: string;\n image?: never;\n}\n\ninterface MediaCardWithImageSlot {\n image: React.ReactNode;\n imageSource?: never;\n imageLabel?: never;\n}\n\ninterface MediaCardWithoutImage {\n image?: never;\n imageSource?: never;\n imageLabel?: never;\n}\n\nexport type MediaCardImageProps =\n | MediaCardWithImageSource\n | MediaCardWithImageSlot\n | MediaCardWithoutImage;\n\ninterface MediaCardBaseProps extends ZoraBaseProps {\n title: React.ReactNode;\n description?: React.ReactNode;\n eyebrow?: React.ReactNode;\n badges?: React.ReactNode;\n actions?: React.ReactNode;\n footer?: React.ReactNode;\n children?: React.ReactNode;\n tone?: ZoraCardTone;\n compact?: boolean;\n onPress?: () => void;\n imageAspectRatio?: number;\n}\n\nexport type MediaCardProps = MediaCardBaseProps & MediaCardImageProps;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MetricCard.d.ts","sourceRoot":"","sources":["../../../src/components/metric-card/MetricCard.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAW1B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAwE/C,eAAO,MAAM,UAAU,uDAAsC,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Box, Inline, Stack } from '../../foundation';
|
|
3
|
+
import { resolveBadgeRecipe, resolveIconSize } from '../../internal/recipes';
|
|
4
|
+
import { useZoraTheme } from '../../theme/useZoraTheme';
|
|
5
|
+
import { withZoraThemeScope } from '../../theme/withZoraThemeScope';
|
|
6
|
+
import { Badge } from '../badge';
|
|
7
|
+
import { Card } from '../card';
|
|
8
|
+
import { Heading } from '../heading';
|
|
9
|
+
import { Icon } from '../icon';
|
|
10
|
+
import { Text } from '../text';
|
|
11
|
+
function MetricCardInner({ themeId: _themeId, mode: _mode, testID, label, value, description, icon, delta, deltaTone = 'neutral', actions, tone = 'default', compact = false, onPress, }) {
|
|
12
|
+
const { theme } = useZoraTheme();
|
|
13
|
+
const isInteractive = Boolean(onPress) && !actions;
|
|
14
|
+
const badgeRecipe = resolveBadgeRecipe({ tone: deltaTone, emphasis: 'soft', size: 's' });
|
|
15
|
+
const iconColor = theme.semantics.content.muted;
|
|
16
|
+
return (<Card compact={compact} onPress={isInteractive ? onPress : undefined} testID={testID} tone={tone}>
|
|
17
|
+
<Stack gap={compact ? 's' : 'm'}>
|
|
18
|
+
<Inline align="flex-start" gap="m" justify="space-between">
|
|
19
|
+
<Stack flex={1} gap="xs">
|
|
20
|
+
<Inline align="center" gap="xs" wrap="wrap">
|
|
21
|
+
{icon ? (<Icon color={iconColor} name={icon.name} provider={icon.provider} size={resolveIconSize('s')}/>) : null}
|
|
22
|
+
<Text tone="muted" variant="caption" weight="semiBold">
|
|
23
|
+
{label}
|
|
24
|
+
</Text>
|
|
25
|
+
{delta != null ? (<Badge emphasis={badgeRecipe.variant} size={badgeRecipe.size} tone={badgeRecipe.tone}>
|
|
26
|
+
{delta}
|
|
27
|
+
</Badge>) : null}
|
|
28
|
+
</Inline>
|
|
29
|
+
|
|
30
|
+
<Heading level={compact ? 3 : 2}>{value}</Heading>
|
|
31
|
+
|
|
32
|
+
{description ? (<Text tone="muted" variant="bodySmall">
|
|
33
|
+
{description}
|
|
34
|
+
</Text>) : null}
|
|
35
|
+
</Stack>
|
|
36
|
+
|
|
37
|
+
{actions ? <Box>{actions}</Box> : null}
|
|
38
|
+
</Inline>
|
|
39
|
+
</Stack>
|
|
40
|
+
</Card>);
|
|
41
|
+
}
|
|
42
|
+
export const MetricCard = withZoraThemeScope(MetricCardInner);
|
|
43
|
+
//# sourceMappingURL=MetricCard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MetricCard.js","sourceRoot":"","sources":["../../../src/components/metric-card/MetricCard.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAG/B,SAAS,eAAe,CAAC,EACvB,OAAO,EAAE,QAAQ,EACjB,IAAI,EAAE,KAAK,EACX,MAAM,EACN,KAAK,EACL,KAAK,EACL,WAAW,E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["import React from 'react';\n\nimport { Box, Inline, Stack } from '../../foundation';\nimport { resolveBadgeRecipe, resolveIconSize } from '../../internal/recipes';\nimport { useZoraTheme } from '../../theme/useZoraTheme';\nimport { withZoraThemeScope } from '../../theme/withZoraThemeScope';\nimport { Badge } from '../badge';\nimport { Card } from '../card';\nimport { Heading } from '../heading';\nimport { Icon } from '../icon';\nimport { Text } from '../text';\nimport type { MetricCardProps } from './types';\n\nfunction MetricCardInner({\n themeId: _themeId,\n mode: _mode,\n testID,\n label,\n value,\n description,\n icon,\n delta,\n deltaTone = 'neutral',\n actions,\n tone = 'default',\n compact = false,\n onPress,\n}: MetricCardProps) {\n const { theme } = useZoraTheme();\n const isInteractive = Boolean(onPress) && !actions;\n\n const badgeRecipe = resolveBadgeRecipe({ tone: deltaTone, emphasis: 'soft', size: 's' });\n const iconColor = theme.semantics.content.muted;\n\n return (\n <Card\n compact={compact}\n onPress={isInteractive ? onPress : undefined}\n testID={testID}\n tone={tone}\n >\n <Stack gap={compact ? 's' : 'm'}>\n <Inline align=\"flex-start\" gap=\"m\" justify=\"space-between\">\n <Stack flex={1} gap=\"xs\">\n <Inline align=\"center\" gap=\"xs\" wrap=\"wrap\">\n {icon ? (\n <Icon\n color={iconColor}\n name={icon.name}\n provider={icon.provider}\n size={resolveIconSize('s')}\n />\n ) : null}\n <Text tone=\"muted\" variant=\"caption\" weight=\"semiBold\">\n {label}\n </Text>\n {delta != null ? (\n <Badge\n emphasis={badgeRecipe.variant}\n size={badgeRecipe.size}\n tone={badgeRecipe.tone}\n >\n {delta}\n </Badge>\n ) : null}\n </Inline>\n\n <Heading level={compact ? 3 : 2}>{value}</Heading>\n\n {description ? (\n <Text tone=\"muted\" variant=\"bodySmall\">\n {description}\n </Text>\n ) : null}\n </Stack>\n\n {actions ? <Box>{actions}</Box> : null}\n </Inline>\n </Stack>\n </Card>\n );\n}\n\nexport const MetricCard = withZoraThemeScope(MetricCardInner);\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/metric-card/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/metric-card/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC","sourcesContent":["export { MetricCard } from './MetricCard';\nexport type { MetricCardProps } from './types';\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ButtonIconSpec } from '@ankhorage/surface';
|
|
2
|
+
import type React from 'react';
|
|
3
|
+
import type { ZoraCardTone, ZoraTone } from '../../internal/recipes';
|
|
4
|
+
import type { ZoraBaseProps } from '../../theme/ZoraBaseProps';
|
|
5
|
+
export interface MetricCardProps extends ZoraBaseProps {
|
|
6
|
+
label: React.ReactNode;
|
|
7
|
+
value: React.ReactNode;
|
|
8
|
+
description?: React.ReactNode;
|
|
9
|
+
icon?: ButtonIconSpec;
|
|
10
|
+
delta?: React.ReactNode;
|
|
11
|
+
deltaTone?: ZoraTone;
|
|
12
|
+
actions?: React.ReactNode;
|
|
13
|
+
tone?: ZoraCardTone;
|
|
14
|
+
compact?: boolean;
|
|
15
|
+
onPress?: () => void;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/metric-card/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE/D,MAAM,WAAW,eAAgB,SAAQ,aAAa;IACpD,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC9B,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB,SAAS,CAAC,EAAE,QAAQ,CAAC;IACrB,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/components/metric-card/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ButtonIconSpec } from '@ankhorage/surface';\nimport type React from 'react';\n\nimport type { ZoraCardTone, ZoraTone } from '../../internal/recipes';\nimport type { ZoraBaseProps } from '../../theme/ZoraBaseProps';\n\nexport interface MetricCardProps extends ZoraBaseProps {\n label: React.ReactNode;\n value: React.ReactNode;\n description?: React.ReactNode;\n icon?: ButtonIconSpec;\n delta?: React.ReactNode;\n deltaTone?: ZoraTone;\n actions?: React.ReactNode;\n tone?: ZoraCardTone;\n compact?: boolean;\n onPress?: () => void;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Progress.d.ts","sourceRoot":"","sources":["../../../src/components/progress/Progress.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,EAAE,KAAK,aAAa,EAAuB,MAAM,SAAS,CAAC;AA2ClE,eAAO,MAAM,QAAQ,qDAAoC,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Box } from '../../foundation';
|
|
3
|
+
import { useZoraTheme } from '../../theme/useZoraTheme';
|
|
4
|
+
import { withZoraThemeScope } from '../../theme/withZoraThemeScope';
|
|
5
|
+
import { resolveProgressFraction } from './resolveProgressFraction';
|
|
6
|
+
import { resolveProgressRole } from './types';
|
|
7
|
+
function resolveProgressHeight(size) {
|
|
8
|
+
switch (size) {
|
|
9
|
+
case 's':
|
|
10
|
+
return 4;
|
|
11
|
+
case 'm':
|
|
12
|
+
return 6;
|
|
13
|
+
case 'l':
|
|
14
|
+
default:
|
|
15
|
+
return 8;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function ProgressInner({ themeId: _themeId, mode: _mode, testID, value, max = 100, tone = 'primary', size = 'm', }) {
|
|
19
|
+
const { theme } = useZoraTheme();
|
|
20
|
+
const fraction = resolveProgressFraction({ value, max });
|
|
21
|
+
const height = resolveProgressHeight(size);
|
|
22
|
+
const role = resolveProgressRole(theme, tone);
|
|
23
|
+
return (<Box accessibilityRole="progressbar" bg={theme.semantics.neutral.surface} borderColor={theme.semantics.neutral.divider} borderWidth={1} radius="full" testID={testID} style={{ height, overflow: 'hidden' }}>
|
|
24
|
+
<Box bg={role.base} style={{ height: '100%', width: `${fraction * 100}%` }}/>
|
|
25
|
+
</Box>);
|
|
26
|
+
}
|
|
27
|
+
export const Progress = withZoraThemeScope(ProgressInner);
|
|
28
|
+
//# sourceMappingURL=Progress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Progress.js","sourceRoot":"","sources":["../../../src/components/progress/Progress.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,uBAAu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AE,GAAG,QAAQ,GAAG,GAAG,GAAG,EAAE,CAAC,EAC7E;IAAA,EAAE,GAAG,CAAC,CACP,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,QAAQ,GAAG,kBAAkB,CAAC,aAAa,CAAC,CAAC","sourcesContent":["import React from 'react';\n\nimport { Box } from '../../foundation';\nimport { useZoraTheme } from '../../theme/useZoraTheme';\nimport { withZoraThemeScope } from '../../theme/withZoraThemeScope';\nimport { resolveProgressFraction } from './resolveProgressFraction';\nimport { type ProgressProps, resolveProgressRole } from './types';\n\nfunction resolveProgressHeight(size: NonNullable<ProgressProps['size']>): number {\n switch (size) {\n case 's':\n return 4;\n case 'm':\n return 6;\n case 'l':\n default:\n return 8;\n }\n}\n\nfunction ProgressInner({\n themeId: _themeId,\n mode: _mode,\n testID,\n value,\n max = 100,\n tone = 'primary',\n size = 'm',\n}: ProgressProps) {\n const { theme } = useZoraTheme();\n const fraction = resolveProgressFraction({ value, max });\n const height = resolveProgressHeight(size);\n const role = resolveProgressRole(theme, tone);\n\n return (\n <Box\n accessibilityRole=\"progressbar\"\n bg={theme.semantics.neutral.surface}\n borderColor={theme.semantics.neutral.divider}\n borderWidth={1}\n radius=\"full\"\n testID={testID}\n style={{ height, overflow: 'hidden' }}\n >\n <Box bg={role.base} style={{ height: '100%', width: `${fraction * 100}%` }} />\n </Box>\n );\n}\n\nexport const Progress = withZoraThemeScope(ProgressInner);\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/progress/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/progress/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC","sourcesContent":["export { Progress } from './Progress';\nexport type { ProgressProps } from './types';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveProgressFraction.d.ts","sourceRoot":"","sources":["../../../src/components/progress/resolveProgressFraction.ts"],"names":[],"mappings":"AAAA,wBAAgB,uBAAuB,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAgB9F"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export function resolveProgressFraction({ value, max }) {
|
|
2
|
+
if (!Number.isFinite(value) || !Number.isFinite(max) || max <= 0) {
|
|
3
|
+
return 0;
|
|
4
|
+
}
|
|
5
|
+
const fraction = value / max;
|
|
6
|
+
if (fraction <= 0) {
|
|
7
|
+
return 0;
|
|
8
|
+
}
|
|
9
|
+
if (fraction >= 1) {
|
|
10
|
+
return 1;
|
|
11
|
+
}
|
|
12
|
+
return fraction;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=resolveProgressFraction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveProgressFraction.js","sourceRoot":"","sources":["../../../src/components/progress/resolveProgressFraction.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,uBAAuB,CAAC,EAAE,KAAK,EAAE,GAAG,EAAkC;IACpF,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC;QACjE,OAAO,CAAC,CAAC;IACX,CAAC;IAED,MAAM,QAAQ,GAAG,KAAK,GAAG,GAAG,CAAC;IAE7B,IAAI,QAAQ,IAAI,CAAC,EAAE,CAAC;QAClB,OAAO,CAAC,CAAC;IACX,CAAC;IAED,IAAI,QAAQ,IAAI,CAAC,EAAE,CAAC;QAClB,OAAO,CAAC,CAAC;IACX,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["export function resolveProgressFraction({ value, max }: { value: number; max: number }): number {\n if (!Number.isFinite(value) || !Number.isFinite(max) || max <= 0) {\n return 0;\n }\n\n const fraction = value / max;\n\n if (fraction <= 0) {\n return 0;\n }\n\n if (fraction >= 1) {\n return 1;\n }\n\n return fraction;\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { RoleSemantics, SurfaceTheme } from '@ankhorage/surface';
|
|
2
|
+
import type { ZoraControlSize, ZoraTone } from '../../internal/recipes';
|
|
3
|
+
import type { ZoraBaseProps } from '../../theme/ZoraBaseProps';
|
|
4
|
+
export interface ProgressProps extends ZoraBaseProps {
|
|
5
|
+
value: number;
|
|
6
|
+
max?: number;
|
|
7
|
+
tone?: ZoraTone;
|
|
8
|
+
size?: ZoraControlSize;
|
|
9
|
+
}
|
|
10
|
+
export declare function resolveProgressRole(theme: SurfaceTheme, tone: ZoraTone): RoleSemantics;
|
|
11
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/progress/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEtE,OAAO,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE/D,MAAM,WAAW,aAAc,SAAQ,aAAa;IAClD,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,IAAI,CAAC,EAAE,eAAe,CAAC;CACxB;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,GAAG,aAAa,CActF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export function resolveProgressRole(theme, tone) {
|
|
2
|
+
switch (tone) {
|
|
3
|
+
case 'primary':
|
|
4
|
+
return theme.semantics.action.primary;
|
|
5
|
+
case 'danger':
|
|
6
|
+
return theme.semantics.action.danger;
|
|
7
|
+
case 'success':
|
|
8
|
+
return theme.semantics.success;
|
|
9
|
+
case 'warning':
|
|
10
|
+
return theme.semantics.warning;
|
|
11
|
+
case 'neutral':
|
|
12
|
+
default:
|
|
13
|
+
return theme.semantics.action.neutral;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=types.js.map
|