@molecule/app-status-badge-react 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +115 -0
- package/README.md +187 -0
- package/dist/StatusBadge.d.ts +41 -0
- package/dist/StatusBadge.d.ts.map +1 -0
- package/dist/StatusBadge.js +29 -0
- package/dist/StatusPill.d.ts +23 -0
- package/dist/StatusPill.d.ts.map +1 -0
- package/dist/StatusPill.js +21 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +45 -0
- package/package.json +47 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work.
|
|
38
|
+
|
|
39
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
40
|
+
form, that is based on (or derived from) the Work and for which the
|
|
41
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
42
|
+
represent, as a whole, an original work of authorship.
|
|
43
|
+
|
|
44
|
+
"Contribution" shall mean any work of authorship, including the
|
|
45
|
+
original version of the Work and any modifications or additions
|
|
46
|
+
to that Work, that is intentionally submitted to the Licensor for
|
|
47
|
+
inclusion in the Work by the copyright owner or by an individual or
|
|
48
|
+
Legal Entity authorized to submit on behalf of the copyright owner.
|
|
49
|
+
|
|
50
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
51
|
+
on behalf of whom a Contribution has been received by the Licensor and
|
|
52
|
+
subsequently incorporated within the Work.
|
|
53
|
+
|
|
54
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
55
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
56
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
57
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
58
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
59
|
+
Work and such Derivative Works in Source or Object form.
|
|
60
|
+
|
|
61
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
62
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
63
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
64
|
+
patent license to make, have made, use, offer to sell, sell, import,
|
|
65
|
+
and otherwise transfer the Work.
|
|
66
|
+
|
|
67
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
68
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
69
|
+
modifications, and in Source or Object form, provided that You
|
|
70
|
+
meet the following conditions:
|
|
71
|
+
|
|
72
|
+
(a) You must give any other recipients of the Work or
|
|
73
|
+
Derivative Works a copy of this License; and
|
|
74
|
+
|
|
75
|
+
(b) You must cause any modified files to carry prominent notices
|
|
76
|
+
stating that You changed the files; and
|
|
77
|
+
|
|
78
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
79
|
+
that You distribute, all copyright, patent, trademark, and
|
|
80
|
+
attribution notices from the Source form of the Work,
|
|
81
|
+
excluding those notices that do not pertain to any part of
|
|
82
|
+
the Derivative Works; and
|
|
83
|
+
|
|
84
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
85
|
+
distribution, then any Derivative Works that You distribute must
|
|
86
|
+
include a readable copy of the attribution notices contained
|
|
87
|
+
within such NOTICE file.
|
|
88
|
+
|
|
89
|
+
5. Submission of Contributions.
|
|
90
|
+
|
|
91
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
92
|
+
names, trademarks, service marks, or product names of the Licensor.
|
|
93
|
+
|
|
94
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
95
|
+
agreed to in writing, Licensor provides the Work on an "AS IS" BASIS,
|
|
96
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND.
|
|
97
|
+
|
|
98
|
+
8. Limitation of Liability. In no event and under no legal theory shall
|
|
99
|
+
any Contributor be liable to You for damages.
|
|
100
|
+
|
|
101
|
+
9. Accepting Warranty or Additional Liability.
|
|
102
|
+
|
|
103
|
+
Copyright 2026 Molecule Dev, Inc.
|
|
104
|
+
|
|
105
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
106
|
+
you may not use this file except in compliance with the License.
|
|
107
|
+
You may obtain a copy of the License at
|
|
108
|
+
|
|
109
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
110
|
+
|
|
111
|
+
Unless required by applicable law or agreed to in writing, software
|
|
112
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
113
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
114
|
+
See the License for the specific language governing permissions and
|
|
115
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
AUTO-GENERATED — DO NOT EDIT THIS FILE.
|
|
3
|
+
Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
|
|
4
|
+
Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
|
|
5
|
+
To change this document, edit the module-level JSDoc in src/index.ts.
|
|
6
|
+
Generated: 2026-08-04T00:41:12.819Z
|
|
7
|
+
-->
|
|
8
|
+
|
|
9
|
+
# @molecule/app-status-badge-react
|
|
10
|
+
|
|
11
|
+
> **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
|
|
12
|
+
> It is written to be read by coding agents as much as by people, and is generated from this
|
|
13
|
+
> package's source — edit `src/index.ts` JSDoc, not this file.
|
|
14
|
+
|
|
15
|
+
React status-badge and status-pill components.
|
|
16
|
+
|
|
17
|
+
Both components map a small `StatusKind` union (`success`/`warning`/
|
|
18
|
+
`error`/`info`/`neutral`) to ClassMap-driven styling so apps can
|
|
19
|
+
restyle by swapping the ClassMap bond rather than rewriting
|
|
20
|
+
components.
|
|
21
|
+
|
|
22
|
+
`<StatusBadge kind children icon? appearance? className?>` — the
|
|
23
|
+
contract is `kind` + `children` (there are NO `label`/`color` props).
|
|
24
|
+
`appearance='ui'` (default) wraps `<Badge>` from
|
|
25
|
+
`@molecule/app-ui-react` and works with any ClassMap bond.
|
|
26
|
+
`<StatusPill kind children dot? className?>` adds a small colored
|
|
27
|
+
status dot before the label.
|
|
28
|
+
|
|
29
|
+
## Quick Start
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
import { StatusBadge, StatusPill } from '@molecule/app-status-badge-react'
|
|
33
|
+
|
|
34
|
+
<StatusBadge kind="success">Open</StatusBadge>
|
|
35
|
+
|
|
36
|
+
<StatusBadge kind="warning" icon={<span aria-hidden>!</span>}>Pending</StatusBadge>
|
|
37
|
+
|
|
38
|
+
<StatusPill kind="error">Overdue</StatusPill>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Type
|
|
42
|
+
|
|
43
|
+
`feature`
|
|
44
|
+
|
|
45
|
+
## Installation
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npm install @molecule/app-status-badge-react @molecule/app-react @molecule/app-ui @molecule/app-ui-react react
|
|
49
|
+
npm install -D @types/react
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## API
|
|
53
|
+
|
|
54
|
+
### Interfaces
|
|
55
|
+
|
|
56
|
+
#### `StatusBadgeProps`
|
|
57
|
+
|
|
58
|
+
Props for the {@link StatusBadge} component.
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
interface StatusBadgeProps {
|
|
62
|
+
/** Semantic kind — maps to ClassMap badge color variants. */
|
|
63
|
+
kind?: StatusKind
|
|
64
|
+
/** Badge label (usually `t('...')`). */
|
|
65
|
+
children: ReactNode
|
|
66
|
+
/** Optional leading icon (e.g. a dot or check). */
|
|
67
|
+
icon?: ReactNode
|
|
68
|
+
/**
|
|
69
|
+
* Visual appearance variant.
|
|
70
|
+
* - `'ui'` (default) — wraps `<Badge>` from `@molecule/app-ui-react` with
|
|
71
|
+
* ClassMap-driven coloring. Honors the active ClassMap bond's badge
|
|
72
|
+
* styling and works with any theme.
|
|
73
|
+
* - `'uppercase-pill'` — a compact uppercase pill that colors itself with
|
|
74
|
+
* the SAME ClassMap `badge` tokens as the `'ui'` variant
|
|
75
|
+
* (`cm.badge({ variant })` → real, theme-backed `bg-*` / `text-*`
|
|
76
|
+
* utilities), then layers `cm.uppercase` + `cm.trackingWide` for the
|
|
77
|
+
* uppercase treatment. Every kind is visibly colored in both light and
|
|
78
|
+
* dark themes.
|
|
79
|
+
*/
|
|
80
|
+
appearance?: 'ui' | 'uppercase-pill'
|
|
81
|
+
/** Extra classes passed through to the rendered element. */
|
|
82
|
+
className?: string
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
#### `StatusPillProps`
|
|
87
|
+
|
|
88
|
+
Props for the {@link StatusPill} component.
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
interface StatusPillProps {
|
|
92
|
+
/** Semantic kind. */
|
|
93
|
+
kind?: StatusKind
|
|
94
|
+
/** Pill label. */
|
|
95
|
+
children: ReactNode
|
|
96
|
+
/** Render a leading dot indicator. Defaults to true. */
|
|
97
|
+
dot?: boolean
|
|
98
|
+
/** Extra classes. */
|
|
99
|
+
className?: string
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Types
|
|
104
|
+
|
|
105
|
+
#### `StatusKind`
|
|
106
|
+
|
|
107
|
+
Semantic status kind used to select badge color variants.
|
|
108
|
+
|
|
109
|
+
```typescript
|
|
110
|
+
type StatusKind = 'success' | 'warning' | 'error' | 'info' | 'neutral'
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Functions
|
|
114
|
+
|
|
115
|
+
#### `StatusBadge(props)`
|
|
116
|
+
|
|
117
|
+
Semantic status badge — maps status kinds to ClassMap color variants.
|
|
118
|
+
Use for "Open / Closed / Pending / Archived" row labels, deal stages,
|
|
119
|
+
ticket priorities, etc.
|
|
120
|
+
|
|
121
|
+
Both appearances resolve their color through the ClassMap `badge` tokens,
|
|
122
|
+
so they stay theme-correct: `appearance="ui"` (default) renders the
|
|
123
|
+
framework `<Badge>`, and `'uppercase-pill'` renders a compact uppercase
|
|
124
|
+
pill with the same per-kind `bg-*` / `text-*` colors.
|
|
125
|
+
|
|
126
|
+
```typescript
|
|
127
|
+
function StatusBadge({
|
|
128
|
+
kind = 'neutral',
|
|
129
|
+
children,
|
|
130
|
+
icon,
|
|
131
|
+
appearance = 'ui',
|
|
132
|
+
className,
|
|
133
|
+
}: StatusBadgeProps): JSX.Element
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
- `props` — Component props (see {@link StatusBadgeProps}).
|
|
137
|
+
|
|
138
|
+
#### `StatusPill(props)`
|
|
139
|
+
|
|
140
|
+
Rounded status pill with an optional leading colored dot. The pill has
|
|
141
|
+
NO background surface of its own — only the dot carries color — so add
|
|
142
|
+
a surface via `className` if you need a filled pill. The `neutral` dot
|
|
143
|
+
uses `bg-outline`, which is only visible in themes that define an
|
|
144
|
+
`outline` color token.
|
|
145
|
+
|
|
146
|
+
```typescript
|
|
147
|
+
function StatusPill({
|
|
148
|
+
kind = 'neutral',
|
|
149
|
+
children,
|
|
150
|
+
dot = true,
|
|
151
|
+
className,
|
|
152
|
+
}: StatusPillProps): JSX.Element
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
- `props` — Component props (see {@link StatusPillProps}).
|
|
156
|
+
|
|
157
|
+
## Injection Notes
|
|
158
|
+
|
|
159
|
+
### Requirements
|
|
160
|
+
|
|
161
|
+
Peer dependencies:
|
|
162
|
+
|
|
163
|
+
- `@molecule/app-react` ^1.0.0
|
|
164
|
+
- `@molecule/app-ui` ^1.0.0
|
|
165
|
+
- `@molecule/app-ui-react` ^1.0.0
|
|
166
|
+
- `react` ^18.0.0 || ^19.0.0
|
|
167
|
+
|
|
168
|
+
### Runtime Dependencies
|
|
169
|
+
|
|
170
|
+
- `@molecule/app-react`
|
|
171
|
+
- `@molecule/app-ui`
|
|
172
|
+
- `@molecule/app-ui-react`
|
|
173
|
+
- `react`
|
|
174
|
+
|
|
175
|
+
- Requires a wired ClassMap bond (e.g. `@molecule/app-ui-tailwind`) —
|
|
176
|
+
`getClassMap()` throws before bonding.
|
|
177
|
+
- Both `appearance` variants color through the ClassMap `badge` tokens
|
|
178
|
+
(`cm.badge({ variant })` → real `bg-*` / `text-*` theme utilities), so
|
|
179
|
+
the `'uppercase-pill'` variant is visibly colored per kind in every
|
|
180
|
+
theme — it just adds `cm.uppercase` + `cm.trackingWide` on top of the
|
|
181
|
+
same colors the `'ui'` variant uses.
|
|
182
|
+
- `<StatusPill>` has no background surface of its own — only the dot
|
|
183
|
+
is colored; add a surface via `className` if you need a filled pill.
|
|
184
|
+
Its `neutral` dot uses `bg-outline`, which also needs a theme
|
|
185
|
+
`outline` color token to be visible.
|
|
186
|
+
- Labels are `children` — pass already-translated strings
|
|
187
|
+
(`t('...')`); the components render no text of their own.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { JSX, ReactNode } from 'react';
|
|
2
|
+
/** Semantic status kind used to select badge color variants. */
|
|
3
|
+
export type StatusKind = 'success' | 'warning' | 'error' | 'info' | 'neutral';
|
|
4
|
+
/** Props for the {@link StatusBadge} component. */
|
|
5
|
+
export interface StatusBadgeProps {
|
|
6
|
+
/** Semantic kind — maps to ClassMap badge color variants. */
|
|
7
|
+
kind?: StatusKind;
|
|
8
|
+
/** Badge label (usually `t('...')`). */
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
/** Optional leading icon (e.g. a dot or check). */
|
|
11
|
+
icon?: ReactNode;
|
|
12
|
+
/**
|
|
13
|
+
* Visual appearance variant.
|
|
14
|
+
* - `'ui'` (default) — wraps `<Badge>` from `@molecule/app-ui-react` with
|
|
15
|
+
* ClassMap-driven coloring. Honors the active ClassMap bond's badge
|
|
16
|
+
* styling and works with any theme.
|
|
17
|
+
* - `'uppercase-pill'` — a compact uppercase pill that colors itself with
|
|
18
|
+
* the SAME ClassMap `badge` tokens as the `'ui'` variant
|
|
19
|
+
* (`cm.badge({ variant })` → real, theme-backed `bg-*` / `text-*`
|
|
20
|
+
* utilities), then layers `cm.uppercase` + `cm.trackingWide` for the
|
|
21
|
+
* uppercase treatment. Every kind is visibly colored in both light and
|
|
22
|
+
* dark themes.
|
|
23
|
+
*/
|
|
24
|
+
appearance?: 'ui' | 'uppercase-pill';
|
|
25
|
+
/** Extra classes passed through to the rendered element. */
|
|
26
|
+
className?: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Semantic status badge — maps status kinds to ClassMap color variants.
|
|
30
|
+
* Use for "Open / Closed / Pending / Archived" row labels, deal stages,
|
|
31
|
+
* ticket priorities, etc.
|
|
32
|
+
*
|
|
33
|
+
* Both appearances resolve their color through the ClassMap `badge` tokens,
|
|
34
|
+
* so they stay theme-correct: `appearance="ui"` (default) renders the
|
|
35
|
+
* framework `<Badge>`, and `'uppercase-pill'` renders a compact uppercase
|
|
36
|
+
* pill with the same per-kind `bg-*` / `text-*` colors.
|
|
37
|
+
*
|
|
38
|
+
* @param props - Component props (see {@link StatusBadgeProps}).
|
|
39
|
+
*/
|
|
40
|
+
export declare function StatusBadge({ kind, children, icon, appearance, className, }: StatusBadgeProps): JSX.Element;
|
|
41
|
+
//# sourceMappingURL=StatusBadge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StatusBadge.d.ts","sourceRoot":"","sources":["../src/StatusBadge.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAK3C,gEAAgE;AAChE,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAA;AAE7E,mDAAmD;AACnD,MAAM,WAAW,gBAAgB;IAC/B,6DAA6D;IAC7D,IAAI,CAAC,EAAE,UAAU,CAAA;IACjB,wCAAwC;IACxC,QAAQ,EAAE,SAAS,CAAA;IACnB,mDAAmD;IACnD,IAAI,CAAC,EAAE,SAAS,CAAA;IAChB;;;;;;;;;;;OAWG;IACH,UAAU,CAAC,EAAE,IAAI,GAAG,gBAAgB,CAAA;IACpC,4DAA4D;IAC5D,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAUD;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CAAC,EAC1B,IAAgB,EAChB,QAAQ,EACR,IAAI,EACJ,UAAiB,EACjB,SAAS,GACV,EAAE,gBAAgB,GAAG,GAAG,CAAC,OAAO,CAuBhC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { getClassMap } from '@molecule/app-ui';
|
|
3
|
+
import { Badge } from '@molecule/app-ui-react';
|
|
4
|
+
const KIND_TO_COLOR = {
|
|
5
|
+
success: 'success',
|
|
6
|
+
warning: 'warning',
|
|
7
|
+
error: 'error',
|
|
8
|
+
info: 'info',
|
|
9
|
+
neutral: 'secondary',
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Semantic status badge — maps status kinds to ClassMap color variants.
|
|
13
|
+
* Use for "Open / Closed / Pending / Archived" row labels, deal stages,
|
|
14
|
+
* ticket priorities, etc.
|
|
15
|
+
*
|
|
16
|
+
* Both appearances resolve their color through the ClassMap `badge` tokens,
|
|
17
|
+
* so they stay theme-correct: `appearance="ui"` (default) renders the
|
|
18
|
+
* framework `<Badge>`, and `'uppercase-pill'` renders a compact uppercase
|
|
19
|
+
* pill with the same per-kind `bg-*` / `text-*` colors.
|
|
20
|
+
*
|
|
21
|
+
* @param props - Component props (see {@link StatusBadgeProps}).
|
|
22
|
+
*/
|
|
23
|
+
export function StatusBadge({ kind = 'neutral', children, icon, appearance = 'ui', className, }) {
|
|
24
|
+
const cm = getClassMap();
|
|
25
|
+
if (appearance === 'uppercase-pill') {
|
|
26
|
+
return (_jsxs("span", { className: cm.cn(cm.badge({ variant: KIND_TO_COLOR[kind] }), cm.uppercase, cm.trackingWide, className), children: [icon && _jsx("span", { className: cm.sp('mr', 1), children: icon }), children] }));
|
|
27
|
+
}
|
|
28
|
+
return (_jsxs(Badge, { color: KIND_TO_COLOR[kind], className: className, children: [icon && _jsx("span", { className: cm.sp('mr', 1), children: icon }), children] }));
|
|
29
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { JSX, ReactNode } from 'react';
|
|
2
|
+
import type { StatusKind } from './StatusBadge.js';
|
|
3
|
+
/** Props for the {@link StatusPill} component. */
|
|
4
|
+
export interface StatusPillProps {
|
|
5
|
+
/** Semantic kind. */
|
|
6
|
+
kind?: StatusKind;
|
|
7
|
+
/** Pill label. */
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
/** Render a leading dot indicator. Defaults to true. */
|
|
10
|
+
dot?: boolean;
|
|
11
|
+
/** Extra classes. */
|
|
12
|
+
className?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Rounded status pill with an optional leading colored dot. The pill has
|
|
16
|
+
* NO background surface of its own — only the dot carries color — so add
|
|
17
|
+
* a surface via `className` if you need a filled pill. The `neutral` dot
|
|
18
|
+
* uses `bg-outline`, which is only visible in themes that define an
|
|
19
|
+
* `outline` color token.
|
|
20
|
+
* @param props - Component props (see {@link StatusPillProps}).
|
|
21
|
+
*/
|
|
22
|
+
export declare function StatusPill({ kind, children, dot, className, }: StatusPillProps): JSX.Element;
|
|
23
|
+
//# sourceMappingURL=StatusPill.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StatusPill.d.ts","sourceRoot":"","sources":["../src/StatusPill.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAI3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAElD,kDAAkD;AAClD,MAAM,WAAW,eAAe;IAC9B,qBAAqB;IACrB,IAAI,CAAC,EAAE,UAAU,CAAA;IACjB,kBAAkB;IAClB,QAAQ,EAAE,SAAS,CAAA;IACnB,wDAAwD;IACxD,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,qBAAqB;IACrB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAUD;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,EACzB,IAAgB,EAChB,QAAQ,EACR,GAAU,EACV,SAAS,GACV,EAAE,eAAe,GAAG,GAAG,CAAC,OAAO,CAoB/B"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { getClassMap } from '@molecule/app-ui';
|
|
3
|
+
const DOT_COLOR = {
|
|
4
|
+
success: 'bg-success',
|
|
5
|
+
warning: 'bg-warning',
|
|
6
|
+
error: 'bg-error',
|
|
7
|
+
info: 'bg-info',
|
|
8
|
+
neutral: 'bg-outline',
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Rounded status pill with an optional leading colored dot. The pill has
|
|
12
|
+
* NO background surface of its own — only the dot carries color — so add
|
|
13
|
+
* a surface via `className` if you need a filled pill. The `neutral` dot
|
|
14
|
+
* uses `bg-outline`, which is only visible in themes that define an
|
|
15
|
+
* `outline` color token.
|
|
16
|
+
* @param props - Component props (see {@link StatusPillProps}).
|
|
17
|
+
*/
|
|
18
|
+
export function StatusPill({ kind = 'neutral', children, dot = true, className, }) {
|
|
19
|
+
const cm = getClassMap();
|
|
20
|
+
return (_jsxs("span", { className: cm.cn(cm.flex({ align: 'center', gap: 'xs' }), cm.sp('px', 3), cm.sp('py', 1), cm.roundedFull, cm.textSize('xs'), cm.fontWeight('medium'), className), children: [dot && (_jsx("span", { className: cm.cn(cm.w(2), cm.h(2), cm.roundedFull, DOT_COLOR[kind]), "aria-hidden": true })), children] }));
|
|
21
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React status-badge and status-pill components.
|
|
3
|
+
*
|
|
4
|
+
* Both components map a small `StatusKind` union (`success`/`warning`/
|
|
5
|
+
* `error`/`info`/`neutral`) to ClassMap-driven styling so apps can
|
|
6
|
+
* restyle by swapping the ClassMap bond rather than rewriting
|
|
7
|
+
* components.
|
|
8
|
+
*
|
|
9
|
+
* `<StatusBadge kind children icon? appearance? className?>` — the
|
|
10
|
+
* contract is `kind` + `children` (there are NO `label`/`color` props).
|
|
11
|
+
* `appearance='ui'` (default) wraps `<Badge>` from
|
|
12
|
+
* `@molecule/app-ui-react` and works with any ClassMap bond.
|
|
13
|
+
* `<StatusPill kind children dot? className?>` adds a small colored
|
|
14
|
+
* status dot before the label.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* import { StatusBadge, StatusPill } from '@molecule/app-status-badge-react'
|
|
19
|
+
*
|
|
20
|
+
* <StatusBadge kind="success">Open</StatusBadge>
|
|
21
|
+
*
|
|
22
|
+
* <StatusBadge kind="warning" icon={<span aria-hidden>!</span>}>Pending</StatusBadge>
|
|
23
|
+
*
|
|
24
|
+
* <StatusPill kind="error">Overdue</StatusPill>
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @remarks
|
|
28
|
+
* - Requires a wired ClassMap bond (e.g. `@molecule/app-ui-tailwind`) —
|
|
29
|
+
* `getClassMap()` throws before bonding.
|
|
30
|
+
* - Both `appearance` variants color through the ClassMap `badge` tokens
|
|
31
|
+
* (`cm.badge({ variant })` → real `bg-*` / `text-*` theme utilities), so
|
|
32
|
+
* the `'uppercase-pill'` variant is visibly colored per kind in every
|
|
33
|
+
* theme — it just adds `cm.uppercase` + `cm.trackingWide` on top of the
|
|
34
|
+
* same colors the `'ui'` variant uses.
|
|
35
|
+
* - `<StatusPill>` has no background surface of its own — only the dot
|
|
36
|
+
* is colored; add a surface via `className` if you need a filled pill.
|
|
37
|
+
* Its `neutral` dot uses `bg-outline`, which also needs a theme
|
|
38
|
+
* `outline` color token to be visible.
|
|
39
|
+
* - Labels are `children` — pass already-translated strings
|
|
40
|
+
* (`t('...')`); the components render no text of their own.
|
|
41
|
+
*
|
|
42
|
+
* @module
|
|
43
|
+
*/
|
|
44
|
+
export * from './StatusBadge.js';
|
|
45
|
+
export * from './StatusPill.js';
|
|
46
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAEH,cAAc,kBAAkB,CAAA;AAChC,cAAc,iBAAiB,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React status-badge and status-pill components.
|
|
3
|
+
*
|
|
4
|
+
* Both components map a small `StatusKind` union (`success`/`warning`/
|
|
5
|
+
* `error`/`info`/`neutral`) to ClassMap-driven styling so apps can
|
|
6
|
+
* restyle by swapping the ClassMap bond rather than rewriting
|
|
7
|
+
* components.
|
|
8
|
+
*
|
|
9
|
+
* `<StatusBadge kind children icon? appearance? className?>` — the
|
|
10
|
+
* contract is `kind` + `children` (there are NO `label`/`color` props).
|
|
11
|
+
* `appearance='ui'` (default) wraps `<Badge>` from
|
|
12
|
+
* `@molecule/app-ui-react` and works with any ClassMap bond.
|
|
13
|
+
* `<StatusPill kind children dot? className?>` adds a small colored
|
|
14
|
+
* status dot before the label.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* import { StatusBadge, StatusPill } from '@molecule/app-status-badge-react'
|
|
19
|
+
*
|
|
20
|
+
* <StatusBadge kind="success">Open</StatusBadge>
|
|
21
|
+
*
|
|
22
|
+
* <StatusBadge kind="warning" icon={<span aria-hidden>!</span>}>Pending</StatusBadge>
|
|
23
|
+
*
|
|
24
|
+
* <StatusPill kind="error">Overdue</StatusPill>
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @remarks
|
|
28
|
+
* - Requires a wired ClassMap bond (e.g. `@molecule/app-ui-tailwind`) —
|
|
29
|
+
* `getClassMap()` throws before bonding.
|
|
30
|
+
* - Both `appearance` variants color through the ClassMap `badge` tokens
|
|
31
|
+
* (`cm.badge({ variant })` → real `bg-*` / `text-*` theme utilities), so
|
|
32
|
+
* the `'uppercase-pill'` variant is visibly colored per kind in every
|
|
33
|
+
* theme — it just adds `cm.uppercase` + `cm.trackingWide` on top of the
|
|
34
|
+
* same colors the `'ui'` variant uses.
|
|
35
|
+
* - `<StatusPill>` has no background surface of its own — only the dot
|
|
36
|
+
* is colored; add a surface via `className` if you need a filled pill.
|
|
37
|
+
* Its `neutral` dot uses `bg-outline`, which also needs a theme
|
|
38
|
+
* `outline` color token to be visible.
|
|
39
|
+
* - Labels are `children` — pass already-translated strings
|
|
40
|
+
* (`t('...')`); the components render no text of their own.
|
|
41
|
+
*
|
|
42
|
+
* @module
|
|
43
|
+
*/
|
|
44
|
+
export * from './StatusBadge.js';
|
|
45
|
+
export * from './StatusPill.js';
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@molecule/app-status-badge-react",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "React status badge / pill with semantic kinds",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "tsc",
|
|
10
|
+
"test": "vitest run",
|
|
11
|
+
"test:watch": "vitest"
|
|
12
|
+
},
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"import": "./dist/index.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"README.md"
|
|
22
|
+
],
|
|
23
|
+
"keywords": [
|
|
24
|
+
"molecule",
|
|
25
|
+
"status-badge",
|
|
26
|
+
"react"
|
|
27
|
+
],
|
|
28
|
+
"license": "Apache-2.0",
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"@molecule/app-react": "^1.0.0",
|
|
31
|
+
"@molecule/app-ui": "^1.0.0",
|
|
32
|
+
"@molecule/app-ui-react": "^1.0.0",
|
|
33
|
+
"react": "^18.0.0 || ^19.0.0"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@molecule/app-react": "1.0.0",
|
|
37
|
+
"@molecule/app-ui": "1.0.0",
|
|
38
|
+
"@molecule/app-ui-react": "1.0.0",
|
|
39
|
+
"@types/node": "26.1.2",
|
|
40
|
+
"@types/react": "19.2.17",
|
|
41
|
+
"@types/react-dom": "19.2.3",
|
|
42
|
+
"react": "19.2.8",
|
|
43
|
+
"react-dom": "19.2.8",
|
|
44
|
+
"typescript": "6.0.3",
|
|
45
|
+
"vitest": "4.1.10"
|
|
46
|
+
}
|
|
47
|
+
}
|