@manakind/ui-core 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +81 -0
  3. package/dist/badge/badge.css +147 -0
  4. package/dist/badge/badge.d.ts +90 -0
  5. package/dist/badge/badge.d.ts.map +1 -0
  6. package/dist/badge/badge.js +62 -0
  7. package/dist/badge/badge.js.map +1 -0
  8. package/dist/badge/index.d.ts +3 -0
  9. package/dist/badge/index.d.ts.map +1 -0
  10. package/dist/badge/index.js +2 -0
  11. package/dist/badge/index.js.map +1 -0
  12. package/dist/button/button.css +155 -0
  13. package/dist/button/button.d.ts +41 -0
  14. package/dist/button/button.d.ts.map +1 -0
  15. package/dist/button/button.js +20 -0
  16. package/dist/button/button.js.map +1 -0
  17. package/dist/button/icon-button.d.ts +31 -0
  18. package/dist/button/icon-button.d.ts.map +1 -0
  19. package/dist/button/icon-button.js +18 -0
  20. package/dist/button/icon-button.js.map +1 -0
  21. package/dist/button/index.d.ts +5 -0
  22. package/dist/button/index.d.ts.map +1 -0
  23. package/dist/button/index.js +3 -0
  24. package/dist/button/index.js.map +1 -0
  25. package/dist/card/card.css +79 -0
  26. package/dist/card/card.d.ts +72 -0
  27. package/dist/card/card.d.ts.map +1 -0
  28. package/dist/card/card.js +45 -0
  29. package/dist/card/card.js.map +1 -0
  30. package/dist/card/index.d.ts +3 -0
  31. package/dist/card/index.d.ts.map +1 -0
  32. package/dist/card/index.js +2 -0
  33. package/dist/card/index.js.map +1 -0
  34. package/dist/cx.d.ts +17 -0
  35. package/dist/cx.d.ts.map +1 -0
  36. package/dist/cx.js +17 -0
  37. package/dist/cx.js.map +1 -0
  38. package/dist/icon/icon.css +52 -0
  39. package/dist/icon/icon.d.ts +51 -0
  40. package/dist/icon/icon.d.ts.map +1 -0
  41. package/dist/icon/icon.js +37 -0
  42. package/dist/icon/icon.js.map +1 -0
  43. package/dist/icon/index.d.ts +2 -0
  44. package/dist/icon/index.d.ts.map +1 -0
  45. package/dist/icon/index.js +2 -0
  46. package/dist/icon/index.js.map +1 -0
  47. package/dist/index.d.ts +9 -0
  48. package/dist/index.d.ts.map +1 -0
  49. package/dist/index.js +9 -0
  50. package/dist/index.js.map +1 -0
  51. package/dist/progress/index.d.ts +3 -0
  52. package/dist/progress/index.d.ts.map +1 -0
  53. package/dist/progress/index.js +2 -0
  54. package/dist/progress/index.js.map +1 -0
  55. package/dist/progress/progress.css +95 -0
  56. package/dist/progress/progress.d.ts +55 -0
  57. package/dist/progress/progress.d.ts.map +1 -0
  58. package/dist/progress/progress.js +30 -0
  59. package/dist/progress/progress.js.map +1 -0
  60. package/dist/select/index.d.ts +3 -0
  61. package/dist/select/index.d.ts.map +1 -0
  62. package/dist/select/index.js +2 -0
  63. package/dist/select/index.js.map +1 -0
  64. package/dist/select/select.css +223 -0
  65. package/dist/select/select.d.ts +135 -0
  66. package/dist/select/select.d.ts.map +1 -0
  67. package/dist/select/select.js +89 -0
  68. package/dist/select/select.js.map +1 -0
  69. package/dist/tabs/index.d.ts +3 -0
  70. package/dist/tabs/index.d.ts.map +1 -0
  71. package/dist/tabs/index.js +2 -0
  72. package/dist/tabs/index.js.map +1 -0
  73. package/dist/tabs/tabs.css +145 -0
  74. package/dist/tabs/tabs.d.ts +55 -0
  75. package/dist/tabs/tabs.d.ts.map +1 -0
  76. package/dist/tabs/tabs.js +54 -0
  77. package/dist/tabs/tabs.js.map +1 -0
  78. package/package.json +97 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Humanity Plus Solutions
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,81 @@
1
+ # `@manakind/ui-core`
2
+
3
+ The shared base components of the [Manakind](https://github.com/Humanity-Plus/Manakind)
4
+ design system. These are the product-agnostic primitives — logic, structure,
5
+ accessibility, and token-driven styling — that every product package
6
+ (`@manakind/manuia-ui`, `@manakind/shiptight-ui`, and later Momentus) builds on.
7
+
8
+ Components ship logic + structural CSS only. All visual values come from the
9
+ `--ds-*` CSS-variable contract, which a product's token package
10
+ (e.g. `@manakind/manuia-tokens`) supplies via its `theme.css`. Loading no theme
11
+ means the components render unstyled; loading a product theme is what gives them
12
+ that product's look.
13
+
14
+ ## Install
15
+
16
+ ```bash
17
+ npm install @manakind/ui-core react react-dom
18
+ ```
19
+
20
+ `react` and `react-dom` (`^19`) are peer dependencies.
21
+
22
+ ## Usage
23
+
24
+ ```tsx
25
+ // 1. Load a product theme so the --ds-* contract resolves.
26
+ import '@manakind/manuia-tokens/css/primitives';
27
+ import '@manakind/manuia-tokens/css/semantic';
28
+ import '@manakind/manuia-tokens/css/components';
29
+ import '@manakind/manuia-tokens/css/theme';
30
+
31
+ // Dark theme. Emitted under `:root.dark, :root[data-theme='dark']`, so these
32
+ // are inert until you set the class or attribute — import them even if dark
33
+ // ships later, or switching it on silently does nothing. All three are needed:
34
+ // `manuia-ui` reads --semantic-* and --component-* directly, not only --ds-*.
35
+ import '@manakind/manuia-tokens/css/semantic-dark';
36
+ import '@manakind/manuia-tokens/css/components-dark';
37
+ import '@manakind/manuia-tokens/css/theme-dark';
38
+
39
+ // 2. Load component CSS and import the component.
40
+ import '@manakind/ui-core/css/button';
41
+ import { Button } from '@manakind/ui-core';
42
+
43
+ export function Save() {
44
+ return <Button variant="solid">Save</Button>;
45
+ }
46
+ ```
47
+
48
+ Most consumers use the product surface (`@manakind/manuia-ui`) instead of
49
+ importing `ui-core` directly.
50
+
51
+ ## Exports
52
+
53
+ Every component is available from the root, or on its own subpath when you want to
54
+ import just one. The `./css/*` subpaths carry each component's structural CSS
55
+ separately, so an app can load only what it renders.
56
+
57
+ | Entry | Contents |
58
+ |---|---|
59
+ | `@manakind/ui-core` | Everything below, plus every prop type and the `cx` helper |
60
+ | `@manakind/ui-core/badge` | `Badge` |
61
+ | `@manakind/ui-core/button` | `Button` + `IconButton` |
62
+ | `@manakind/ui-core/card` | `Card`, `CardHeader`, `CardTitle`, `CardDescription`, `CardContent`, `CardFooter` |
63
+ | `@manakind/ui-core/icon` | `Icon` |
64
+ | `@manakind/ui-core/progress` | `Progress` |
65
+ | `@manakind/ui-core/select` | `Select` |
66
+ | `@manakind/ui-core/tabs` | `Tabs`, `TabsList`, `TabsTrigger`, `TabsContent` |
67
+ | `@manakind/ui-core/css/badge` | Badge structural CSS |
68
+ | `@manakind/ui-core/css/button` | Button + IconButton structural CSS |
69
+ | `@manakind/ui-core/css/card` | Card structural CSS |
70
+ | `@manakind/ui-core/css/icon` | Icon structural CSS |
71
+ | `@manakind/ui-core/css/progress` | Progress structural CSS |
72
+ | `@manakind/ui-core/css/select` | Select structural CSS |
73
+ | `@manakind/ui-core/css/tabs` | Tabs structural CSS |
74
+
75
+ Structural CSS is only half of what a component needs — it consumes `--ds-*` custom
76
+ properties that a product's theme supplies. See
77
+ [Installation](https://github.com/Humanity-Plus/Manakind/blob/main/docs/getting-started/installation.mdx).
78
+
79
+ ## License
80
+
81
+ MIT — see [LICENSE](./LICENSE).
@@ -0,0 +1,147 @@
1
+ @layer components {
2
+ .ds-badge {
3
+ /*
4
+ * Explicit, not inherited from a reset: `min-height`/`min-width` must
5
+ * measure the whole box or the padding and border stack on top and the
6
+ * badge silently outgrows its token (24px became 30px).
7
+ */
8
+ box-sizing: border-box;
9
+ display: inline-flex;
10
+ align-items: center;
11
+ justify-content: center;
12
+ width: fit-content;
13
+ /*
14
+ * A badge is almost always placed inside a flex row (a tab trigger, a card
15
+ * header). The default `flex-shrink: 1` let it collapse below its own
16
+ * content, and because the text is `nowrap` that showed up as clipped
17
+ * digits rather than as a wrap — a three-digit count lost its last digit.
18
+ * A badge is a small label; it should never be the thing that gives.
19
+ */
20
+ flex-shrink: 0;
21
+ gap: var(--ds-badge-gap);
22
+ /*
23
+ * An explicit min-height rather than letting the box fall out of the
24
+ * font's `normal` line-height, which produced fractional heights
25
+ * (14px text gave 30.5px). Now the height is a whole number and the
26
+ * circle variant has a size to key off.
27
+ */
28
+ min-height: var(--ds-badge-min-size);
29
+ padding: var(--ds-badge-padding-block) var(--ds-badge-padding-inline);
30
+ /*
31
+ * Tinted badges carry a border derived from their own text colour.
32
+ *
33
+ * The fill alone is a pale tint — measured at 1.18:1 against the tab
34
+ * track — so the badge boundary is not reliably perceivable on its own.
35
+ * The border restores it, and needs no per-variant token because
36
+ * `currentColor` is already the variant's contrast-checked text colour.
37
+ *
38
+ * 75% is not arbitrary: it is the lowest mix that clears the 3:1 non-text
39
+ * threshold (measured 3.05:1 against the track). 35% gave only 1.44:1.
40
+ * For reference the product's own sage-300 border reaches just 1.23:1, so
41
+ * matching it would not have met the bar.
42
+ */
43
+ border: 1px solid color-mix(in srgb, currentColor 75%, transparent);
44
+ border-radius: var(--ds-badge-radius);
45
+ font-size: var(--ds-badge-font-size);
46
+ font-weight: var(--ds-badge-font-weight);
47
+ line-height: inherit;
48
+ white-space: nowrap;
49
+
50
+ /*
51
+ * A circle at one and two digits — the counts this shape is for — and a
52
+ * fixed-height pill beyond that.
53
+ *
54
+ * `aspect-ratio` was tying height to width, so a three-digit count grew in
55
+ * BOTH directions. That made the badge taller than its row, which pushed
56
+ * the whole tab strip up and broke the nested-radius relationship between
57
+ * the track and the triggers inside it: the inner radius is derived from
58
+ * the track, so a taller track changes what "correct" looks like.
59
+ *
60
+ * Pinning the height keeps the row a constant size no matter how large the
61
+ * number gets, and the width still floors at `min-size` so one digit is
62
+ * never a tiny dot.
63
+ */
64
+ &.ds-badge--circle {
65
+ height: var(--ds-badge-min-size);
66
+ min-width: var(--ds-badge-min-size);
67
+ padding-inline: var(--ds-badge-padding-block);
68
+ }
69
+
70
+ /*
71
+ * Icon-only. Square rather than merely narrow: the inline padding drops
72
+ * to the block padding so the glyph sits in an even box, and the min-width
73
+ * floor stops a narrow glyph collapsing the badge to a sliver.
74
+ *
75
+ * `display: none` on the label is deliberate over a visually-hidden
76
+ * class. The badge is `role="img"` with an `aria-label` whenever it is
77
+ * labelled, so its name is already covered; leaving the text in the
78
+ * accessibility tree would announce the status twice.
79
+ */
80
+ &.ds-badge--compact {
81
+ min-width: var(--ds-badge-min-size);
82
+ padding-inline: var(--ds-badge-padding-block);
83
+
84
+ & .ds-badge__label {
85
+ display: none;
86
+ }
87
+ }
88
+
89
+ &.ds-badge--solid {
90
+ background-color: var(--ds-badge-solid-bg);
91
+ color: var(--ds-badge-solid-text);
92
+ /*
93
+ * Solid was the only variant without an edge, which read as an
94
+ * inconsistency next to the others. It is lighter than theirs on
95
+ * purpose: a filled badge already separates itself from the surface, so
96
+ * the border here is for family resemblance rather than perceivability,
97
+ * and the 75% the tinted variants use would sit heavy on a fill.
98
+ */
99
+ border-color: color-mix(in srgb, currentColor 25%, transparent);
100
+ }
101
+
102
+ &.ds-badge--muted {
103
+ background-color: var(--ds-badge-muted-bg);
104
+ color: var(--ds-badge-muted-text);
105
+ }
106
+
107
+ &.ds-badge--outline {
108
+ background-color: transparent;
109
+ border-color: var(--ds-badge-outline-border);
110
+ color: var(--ds-badge-outline-text);
111
+ }
112
+
113
+ &.ds-badge--info {
114
+ background-color: var(--ds-badge-info-bg);
115
+ color: var(--ds-badge-info-text);
116
+ }
117
+
118
+ &.ds-badge--success {
119
+ background-color: var(--ds-badge-success-bg);
120
+ color: var(--ds-badge-success-text);
121
+ }
122
+
123
+ &.ds-badge--warning {
124
+ background-color: var(--ds-badge-warning-bg);
125
+ color: var(--ds-badge-warning-text);
126
+ }
127
+
128
+ &.ds-badge--danger {
129
+ background-color: var(--ds-badge-danger-bg);
130
+ color: var(--ds-badge-danger-text);
131
+ }
132
+
133
+ /*
134
+ * After the variants, `circle` and `compact` on purpose: it has to win at
135
+ * equal specificity while leaving the variant's text colour in place.
136
+ * With no chip there is no box to keep, so the inline padding, the border
137
+ * and the min-width go too, and the glyph and label sit flush with the
138
+ * text around them.
139
+ */
140
+ &.ds-badge--plain {
141
+ min-width: 0;
142
+ padding-inline: 0;
143
+ border-width: 0;
144
+ background-color: transparent;
145
+ }
146
+ }
147
+ }
@@ -0,0 +1,90 @@
1
+ import { ark } from '@ark-ui/react/factory';
2
+ import type { ComponentProps } from 'react';
3
+ import { type IconSource } from '../icon';
4
+ import './badge.css';
5
+ export type BadgeVariant = 'solid' | 'muted' | 'outline' | 'info' | 'success' | 'warning' | 'danger';
6
+ export type BadgeShape = 'pill' | 'circle';
7
+ /**
8
+ * `compact` hides the label, so it may only be used with a glyph to replace it
9
+ * and a name to announce — otherwise the badge is a bare colour chip, and
10
+ * colour alone is never a signal.
11
+ *
12
+ * Expressed as a discriminated union so the pairing is a compile error rather
13
+ * than a convention, mirroring `IconProps`' label/decorative union.
14
+ */
15
+ type BadgeCompact = {
16
+ compact: true;
17
+ icon: IconSource;
18
+ 'aria-label': string;
19
+ } | {
20
+ compact?: false | undefined;
21
+ icon?: IconSource;
22
+ };
23
+ /**
24
+ * `plain` drops the fill, so a variant's text must read on the surface behind
25
+ * it. Every variant's does except `solid`, whose text colour is made for its
26
+ * own dark fill and disappears without it, so that pairing is a compile error.
27
+ */
28
+ type BadgeLook = {
29
+ /**
30
+ * Visual treatment.
31
+ *
32
+ * `solid` is the emphatic one — use it sparingly, at most once in a view.
33
+ * `muted` and `outline` are the neutral workhorses. `info`, `success`,
34
+ * `warning`, and `danger` are tinted status treatments.
35
+ */
36
+ variant?: BadgeVariant;
37
+ /**
38
+ * `filled` (default) draws the variant's fill and border. `plain` drops
39
+ * both and keeps the variant's colour on the glyph and label, for a
40
+ * status that sits inside a busier composition and should not add a
41
+ * chip of its own. Its text is then measured against the surface
42
+ * behind it, not against a tint.
43
+ */
44
+ appearance?: 'filled';
45
+ } | {
46
+ variant?: Exclude<BadgeVariant, 'solid'>;
47
+ appearance: 'plain';
48
+ };
49
+ export type BadgeProps = ComponentProps<typeof ark.span> & BadgeCompact & BadgeLook & {
50
+ /**
51
+ * `pill` is the default. `circle` is for counts: a true circle at one or two
52
+ * digits, and a fixed-height lozenge beyond that.
53
+ *
54
+ * The height is pinned on purpose — see the note in `badge.css`. An earlier
55
+ * `aspect-ratio` grew a three-digit count in both directions, which made the
56
+ * badge taller than its row and broke the nested radius of any track it sat
57
+ * in.
58
+ *
59
+ * Only use it for short numerics. Words in a circle wrap badly, and past two
60
+ * digits the shape stops being a circle anyway.
61
+ */
62
+ shape?: BadgeShape;
63
+ };
64
+ export type BadgeAppearance = NonNullable<BadgeProps['appearance']>;
65
+ /**
66
+ * Small inline label for counts, states, and categories.
67
+ *
68
+ * Renders a `span`, so a badge is decorative text by default. If the badge
69
+ * carries meaning that is not repeated in nearby text — a count, a status —
70
+ * give it an `aria-label` so it is announced usefully rather than as a bare
71
+ * number. Labelling it also switches it to `role="img"`, because `aria-label`
72
+ * on a role-less `span` is prohibited and would not be announced.
73
+ *
74
+ * A badge is not a button. If it needs to be clickable, put it inside one.
75
+ *
76
+ * Colour alone must never be the only signal a badge carries. Pair a status
77
+ * variant with text (or an `aria-label`) that says the same thing.
78
+ *
79
+ * @example Status that survives a narrow card
80
+ * ```tsx
81
+ * <Badge variant="success" icon={CheckIcon} aria-label="Completed">
82
+ * Completed
83
+ * </Badge>
84
+ * ```
85
+ * Reads as "Completed" wide, collapses to the glyph when the container
86
+ * shrinks, and announces the same name at every width.
87
+ */
88
+ export declare function Badge({ variant, shape, appearance, icon, compact, className, children, ...props }: BadgeProps): import("react/jsx-runtime").JSX.Element;
89
+ export {};
90
+ //# sourceMappingURL=badge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"badge.d.ts","sourceRoot":"","sources":["../../src/badge/badge.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAQ,KAAK,UAAU,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,aAAa,CAAC;AAGrB,MAAM,MAAM,YAAY,GACpB,OAAO,GACP,OAAO,GACP,SAAS,GACT,MAAM,GACN,SAAS,GACT,SAAS,GACT,QAAQ,CAAC;AAEb,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,QAAQ,CAAC;AAE3C;;;;;;;GAOG;AACH,KAAK,YAAY,GACb;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,UAAU,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,GACzD;IAAE,OAAO,CAAC,EAAE,KAAK,GAAG,SAAS,CAAC;IAAC,IAAI,CAAC,EAAE,UAAU,CAAA;CAAE,CAAC;AAEvD;;;;GAIG;AACH,KAAK,SAAS,GACV;IACE;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,QAAQ,CAAC;CACvB,GACD;IAAE,OAAO,CAAC,EAAE,OAAO,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IAAC,UAAU,EAAE,OAAO,CAAA;CAAE,CAAC;AAEtE,MAAM,MAAM,UAAU,GAAG,cAAc,CAAC,OAAO,GAAG,CAAC,IAAI,CAAC,GACtD,YAAY,GACZ,SAAS,GAAG;IACV;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,EAAE,UAAU,CAAC;CACpB,CAAC;AAEJ,MAAM,MAAM,eAAe,GAAG,WAAW,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC;AAsBpE;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,KAAK,CAAC,EACpB,OAAiB,EACjB,KAAc,EACd,UAAqB,EACrB,IAAI,EACJ,OAAe,EACf,SAAS,EACT,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,UAAU,2CAmCZ"}
@@ -0,0 +1,62 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { ark } from '@ark-ui/react/factory';
3
+ import { Icon } from '../icon';
4
+ import './badge.css';
5
+ import { cx } from '../cx';
6
+ /*
7
+ * `icon` and `compact` are declared on `BadgeCompact` above rather than here,
8
+ * so their docs live with the union that constrains them:
9
+ *
10
+ * icon — glyph before the label, supplied by the product so this package
11
+ * never imports an icon set. Always decorative; the label beside
12
+ * it says the same thing, and when the label is collapsed the
13
+ * badge's own `aria-label` carries the name. Announcing both would
14
+ * read the status twice.
15
+ *
16
+ * compact — collapse to the glyph alone: square geometry, no visible label.
17
+ * Requires `icon` and `aria-label`, enforced by the union.
18
+ *
19
+ * For a badge that should collapse only when space runs out, leave `compact`
20
+ * off and hide `.ds-badge__label` from a container query — see
21
+ * `mui-goal-card__meta` for a worked example. Scope that rule to badges that
22
+ * actually have a glyph (`:has(.ds-icon)`), or a consumer who passed no icon
23
+ * gets the bare colour chip the union exists to prevent.
24
+ */
25
+ /**
26
+ * Small inline label for counts, states, and categories.
27
+ *
28
+ * Renders a `span`, so a badge is decorative text by default. If the badge
29
+ * carries meaning that is not repeated in nearby text — a count, a status —
30
+ * give it an `aria-label` so it is announced usefully rather than as a bare
31
+ * number. Labelling it also switches it to `role="img"`, because `aria-label`
32
+ * on a role-less `span` is prohibited and would not be announced.
33
+ *
34
+ * A badge is not a button. If it needs to be clickable, put it inside one.
35
+ *
36
+ * Colour alone must never be the only signal a badge carries. Pair a status
37
+ * variant with text (or an `aria-label`) that says the same thing.
38
+ *
39
+ * @example Status that survives a narrow card
40
+ * ```tsx
41
+ * <Badge variant="success" icon={CheckIcon} aria-label="Completed">
42
+ * Completed
43
+ * </Badge>
44
+ * ```
45
+ * Reads as "Completed" wide, collapses to the glyph when the container
46
+ * shrinks, and announces the same name at every width.
47
+ */
48
+ export function Badge({ variant = 'muted', shape = 'pill', appearance = 'filled', icon, compact = false, className, children, ...props }) {
49
+ /*
50
+ * ARIA prohibits `aria-label` on a role-less `span` (it resolves to
51
+ * `role="generic"`), so the label is not reliably announced — axe reports
52
+ * `aria-prohibited-attr`. Since the whole point of the label is to replace
53
+ * the bare text, `role="img"` is the honest role: it makes the element a
54
+ * single labelled node and the label becomes its accessible name.
55
+ *
56
+ * Only applied when a label is actually present. An unlabelled badge is
57
+ * decorative text and should stay a plain `span`.
58
+ */
59
+ const labelled = props['aria-label'] !== undefined || props['aria-labelledby'] !== undefined;
60
+ return (_jsxs(ark.span, { role: labelled ? 'img' : undefined, className: cx('ds-badge', `ds-badge--${variant}`, `ds-badge--${shape}`, appearance === 'plain' && 'ds-badge--plain', compact && 'ds-badge--compact', className), ...props, children: [icon && _jsx(Icon, { source: icon, size: "sm", decorative: true }), icon ? _jsx("span", { className: "ds-badge__label", children: children }) : children] }));
61
+ }
62
+ //# sourceMappingURL=badge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"badge.js","sourceRoot":"","sources":["../../src/badge/badge.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAE5C,OAAO,EAAE,IAAI,EAAmB,MAAM,SAAS,CAAC;AAChD,OAAO,aAAa,CAAC;AACrB,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAuE3B;;;;;;;;;;;;;;;;;;GAkBG;AAEH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,KAAK,CAAC,EACpB,OAAO,GAAG,OAAO,EACjB,KAAK,GAAG,MAAM,EACd,UAAU,GAAG,QAAQ,EACrB,IAAI,EACJ,OAAO,GAAG,KAAK,EACf,SAAS,EACT,QAAQ,EACR,GAAG,KAAK,EACG;IACX;;;;;;;;;OASG;IACH,MAAM,QAAQ,GAAG,KAAK,CAAC,YAAY,CAAC,KAAK,SAAS,IAAI,KAAK,CAAC,iBAAiB,CAAC,KAAK,SAAS,CAAC;IAE7F,OAAO,CACL,MAAC,GAAG,CAAC,IAAI,IACP,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,EAClC,SAAS,EAAE,EAAE,CACX,UAAU,EACV,aAAa,OAAO,EAAE,EACtB,aAAa,KAAK,EAAE,EACpB,UAAU,KAAK,OAAO,IAAI,iBAAiB,EAC3C,OAAO,IAAI,mBAAmB,EAC9B,SAAS,CACV,KACG,KAAK,aAER,IAAI,IAAI,KAAC,IAAI,IAAC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAC,IAAI,EAAC,UAAU,SAAG,EAMnD,IAAI,CAAC,CAAC,CAAC,eAAM,SAAS,EAAC,iBAAiB,YAAE,QAAQ,GAAQ,CAAC,CAAC,CAAC,QAAQ,IAC7D,CACZ,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ export type { BadgeAppearance, BadgeProps, BadgeShape, BadgeVariant } from './badge';
2
+ export { Badge } from './badge';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/badge/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,eAAe,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACrF,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { Badge } from './badge';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/badge/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,155 @@
1
+ @layer components {
2
+ .ds-button {
3
+ display: inline-flex;
4
+ align-items: center;
5
+ justify-content: center;
6
+ border-radius: var(--ds-button-radius);
7
+ font-family: inherit;
8
+ font-weight: var(--ds-button-font-weight);
9
+ line-height: inherit;
10
+ cursor: pointer;
11
+ border: 1px solid transparent;
12
+ transition:
13
+ background-color 150ms cubic-bezier(0, 0, 0.2, 1),
14
+ border-color 150ms cubic-bezier(0, 0, 0.2, 1),
15
+ box-shadow 150ms cubic-bezier(0, 0, 0.2, 1);
16
+
17
+ &.ds-button--sm {
18
+ min-height: var(--ds-button-size-sm-height);
19
+ padding: var(--ds-button-size-sm-padding-block) var(--ds-button-size-sm-padding-inline);
20
+ gap: var(--ds-button-size-sm-gap);
21
+ font-size: var(--ds-button-size-sm-font-size);
22
+ }
23
+
24
+ &.ds-button--md {
25
+ min-height: var(--ds-button-size-md-height);
26
+ padding: var(--ds-button-size-md-padding-block) var(--ds-button-size-md-padding-inline);
27
+ gap: var(--ds-button-size-md-gap);
28
+ font-size: var(--ds-button-size-md-font-size);
29
+ }
30
+
31
+ &.ds-button--lg {
32
+ min-height: var(--ds-button-size-lg-height);
33
+ padding: var(--ds-button-size-lg-padding-block) var(--ds-button-size-lg-padding-inline);
34
+ gap: var(--ds-button-size-lg-gap);
35
+ font-size: var(--ds-button-size-lg-font-size);
36
+ }
37
+
38
+ &.ds-button--primary {
39
+ background-color: var(--ds-button-primary-bg);
40
+ color: var(--ds-button-primary-text);
41
+
42
+ /* Loading sets the button's colour to transparent, so the spinner names its own. */
43
+ & .ds-button__spinner::after {
44
+ color: var(--ds-button-primary-text);
45
+ }
46
+
47
+ &:hover:not(:disabled) {
48
+ background-color: var(--ds-button-primary-bg-hover);
49
+ }
50
+
51
+ &:active:not(:disabled) {
52
+ background-color: var(--ds-button-primary-bg-active);
53
+ }
54
+ }
55
+
56
+ &.ds-button--secondary {
57
+ background-color: var(--ds-button-secondary-bg);
58
+ color: var(--ds-button-secondary-text);
59
+ border-color: var(--ds-button-secondary-border);
60
+
61
+ & .ds-button__spinner::after {
62
+ color: var(--ds-button-secondary-text);
63
+ }
64
+
65
+ &:hover:not(:disabled) {
66
+ background-color: var(--ds-button-secondary-bg-hover);
67
+ }
68
+ }
69
+
70
+ &.ds-button--tertiary {
71
+ background-color: var(--ds-button-tertiary-bg);
72
+ color: var(--ds-button-tertiary-text);
73
+
74
+ & .ds-button__spinner::after {
75
+ color: var(--ds-button-tertiary-text);
76
+ }
77
+
78
+ &:hover:not(:disabled) {
79
+ background-color: var(--ds-button-tertiary-bg-hover);
80
+ }
81
+ }
82
+
83
+ &:focus-visible {
84
+ outline: 2px solid var(--ds-button-focus-ring);
85
+ outline-offset: 3px;
86
+ }
87
+
88
+ &:disabled {
89
+ opacity: var(--ds-opacity-disabled);
90
+ cursor: not-allowed;
91
+ }
92
+
93
+ &.ds-button--loading {
94
+ position: relative;
95
+ color: transparent;
96
+ }
97
+
98
+ & .ds-button__icon {
99
+ display: inline-flex;
100
+ flex-shrink: 0;
101
+ }
102
+
103
+ &.ds-button--icon-only {
104
+ aspect-ratio: 1;
105
+
106
+ /*
107
+ * A circle at every size, rather than inheriting the button radius.
108
+ * `--ds-button-radius` is a fixed 16px while icon buttons are 32/36/40px
109
+ * square, so 16px happened to be exactly half at `sm` and less than half
110
+ * above it — the shape drifted from a circle to a rounded rectangle as
111
+ * the size grew. A percentage tracks the box instead of fighting it.
112
+ */
113
+ border-radius: 50%;
114
+
115
+ &.ds-button--sm {
116
+ padding-inline: var(--ds-button-size-sm-padding-block);
117
+ min-width: var(--ds-button-size-sm-height);
118
+ }
119
+
120
+ &.ds-button--md {
121
+ padding-inline: var(--ds-button-size-md-padding-block);
122
+ min-width: var(--ds-button-size-md-height);
123
+ }
124
+
125
+ &.ds-button--lg {
126
+ padding-inline: var(--ds-button-size-lg-padding-block);
127
+ min-width: var(--ds-button-size-lg-height);
128
+ }
129
+ }
130
+
131
+ & .ds-button__spinner {
132
+ position: absolute;
133
+ inset: 0;
134
+ display: flex;
135
+ align-items: center;
136
+ justify-content: center;
137
+
138
+ &::after {
139
+ content: "";
140
+ width: 1em;
141
+ height: 1em;
142
+ border: 2px solid currentColor;
143
+ border-right-color: transparent;
144
+ border-radius: 50%;
145
+ animation: ds-button-spin 600ms linear infinite;
146
+ }
147
+ }
148
+ }
149
+ }
150
+
151
+ @keyframes ds-button-spin {
152
+ to {
153
+ transform: rotate(360deg);
154
+ }
155
+ }
@@ -0,0 +1,41 @@
1
+ import { ark } from '@ark-ui/react/factory';
2
+ import type { ComponentProps } from 'react';
3
+ import { type IconSource } from '../icon/icon';
4
+ import './button.css';
5
+ export type ButtonVariant = 'primary' | 'secondary' | 'tertiary';
6
+ export type ButtonSize = 'sm' | 'md' | 'lg';
7
+ export interface ButtonProps extends ComponentProps<typeof ark.button> {
8
+ /** Visual style variant. */
9
+ variant?: ButtonVariant;
10
+ /** Size preset. */
11
+ size?: ButtonSize;
12
+ /** Show loading spinner and disable interaction. */
13
+ loading?: boolean;
14
+ /**
15
+ * Decorative icon rendered before the label.
16
+ *
17
+ * Icon size is derived from the button size (1:1 mapping) and the icon
18
+ * inherits the button's text color via `currentColor`. The icon is
19
+ * always rendered as decorative — the accessible name comes from the
20
+ * button's children.
21
+ */
22
+ leadingIcon?: IconSource;
23
+ /**
24
+ * Decorative icon rendered after the label. Same rendering contract as
25
+ * {@link ButtonProps.leadingIcon}.
26
+ */
27
+ trailingIcon?: IconSource;
28
+ }
29
+ /**
30
+ * Shared base button for the Manakind design system.
31
+ *
32
+ * Built on Ark UI for keyboard navigation, focus management, and disabled
33
+ * state handling. Styled exclusively against the `--ds-button-*` token
34
+ * contract; the consuming product is responsible for providing those values
35
+ * via its tokens package (e.g. `@manakind/manuia-tokens/css/theme`).
36
+ *
37
+ * For an icon-only button (no visible label), use `IconButton` instead —
38
+ * it enforces an `aria-label` at the type level.
39
+ */
40
+ export declare function Button({ variant, size, loading, disabled, leadingIcon, trailingIcon, className, children, ...props }: ButtonProps): import("react/jsx-runtime").JSX.Element;
41
+ //# sourceMappingURL=button.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../src/button/button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAQ,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,cAAc,CAAC;AAGtB,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,WAAW,GAAG,UAAU,CAAC;AACjE,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE5C,MAAM,WAAW,WAAY,SAAQ,cAAc,CAAC,OAAO,GAAG,CAAC,MAAM,CAAC;IACpE,4BAA4B;IAC5B,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,mBAAmB;IACnB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,oDAAoD;IACpD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;;;;OAOG;IACH,WAAW,CAAC,EAAE,UAAU,CAAC;IACzB;;;OAGG;IACH,YAAY,CAAC,EAAE,UAAU,CAAC;CAC3B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,MAAM,CAAC,EACrB,OAAmB,EACnB,IAAW,EACX,OAAe,EACf,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,SAAS,EACT,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,WAAW,2CAiCb"}
@@ -0,0 +1,20 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { ark } from '@ark-ui/react/factory';
3
+ import { Icon } from '../icon/icon';
4
+ import './button.css';
5
+ import { cx } from '../cx';
6
+ /**
7
+ * Shared base button for the Manakind design system.
8
+ *
9
+ * Built on Ark UI for keyboard navigation, focus management, and disabled
10
+ * state handling. Styled exclusively against the `--ds-button-*` token
11
+ * contract; the consuming product is responsible for providing those values
12
+ * via its tokens package (e.g. `@manakind/manuia-tokens/css/theme`).
13
+ *
14
+ * For an icon-only button (no visible label), use `IconButton` instead —
15
+ * it enforces an `aria-label` at the type level.
16
+ */
17
+ export function Button({ variant = 'primary', size = 'md', loading = false, disabled, leadingIcon, trailingIcon, className, children, ...props }) {
18
+ return (_jsxs(ark.button, { disabled: disabled || loading, className: cx('ds-button', `ds-button--${variant}`, `ds-button--${size}`, loading && 'ds-button--loading', className), ...props, children: [loading && _jsx("span", { className: "ds-button__spinner", "aria-hidden": "true" }), leadingIcon && (_jsx(Icon, { source: leadingIcon, size: size, decorative: true, className: "ds-button__icon ds-button__icon--leading" })), _jsx("span", { className: "ds-button__label", children: children }), trailingIcon && (_jsx(Icon, { source: trailingIcon, size: size, decorative: true, className: "ds-button__icon ds-button__icon--trailing" }))] }));
19
+ }
20
+ //# sourceMappingURL=button.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"button.js","sourceRoot":"","sources":["../../src/button/button.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAE5C,OAAO,EAAE,IAAI,EAAmB,MAAM,cAAc,CAAC;AACrD,OAAO,cAAc,CAAC;AACtB,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AA4B3B;;;;;;;;;;GAUG;AACH,MAAM,UAAU,MAAM,CAAC,EACrB,OAAO,GAAG,SAAS,EACnB,IAAI,GAAG,IAAI,EACX,OAAO,GAAG,KAAK,EACf,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,SAAS,EACT,QAAQ,EACR,GAAG,KAAK,EACI;IACZ,OAAO,CACL,MAAC,GAAG,CAAC,MAAM,IACT,QAAQ,EAAE,QAAQ,IAAI,OAAO,EAC7B,SAAS,EAAE,EAAE,CACX,WAAW,EACX,cAAc,OAAO,EAAE,EACvB,cAAc,IAAI,EAAE,EACpB,OAAO,IAAI,oBAAoB,EAC/B,SAAS,CACV,KACG,KAAK,aAER,OAAO,IAAI,eAAM,SAAS,EAAC,oBAAoB,iBAAa,MAAM,GAAG,EACrE,WAAW,IAAI,CACd,KAAC,IAAI,IACH,MAAM,EAAE,WAAW,EACnB,IAAI,EAAE,IAAI,EACV,UAAU,QACV,SAAS,EAAC,0CAA0C,GACpD,CACH,EACD,eAAM,SAAS,EAAC,kBAAkB,YAAE,QAAQ,GAAQ,EACnD,YAAY,IAAI,CACf,KAAC,IAAI,IACH,MAAM,EAAE,YAAY,EACpB,IAAI,EAAE,IAAI,EACV,UAAU,QACV,SAAS,EAAC,2CAA2C,GACrD,CACH,IACU,CACd,CAAC;AACJ,CAAC"}