@manakind/ui-core 0.5.0 → 0.6.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/README.md CHANGED
@@ -57,6 +57,7 @@ separately, so an app can load only what it renders.
57
57
  | Entry | Contents |
58
58
  |---|---|
59
59
  | `@manakind/ui-core` | Everything below, plus every prop type and the `cx` helper |
60
+ | `@manakind/ui-core/alert` | `Alert` |
60
61
  | `@manakind/ui-core/badge` | `Badge` |
61
62
  | `@manakind/ui-core/button` | `Button` + `IconButton` |
62
63
  | `@manakind/ui-core/card` | `Card`, `CardHeader`, `CardTitle`, `CardDescription`, `CardContent`, `CardFooter` |
@@ -67,6 +68,7 @@ separately, so an app can load only what it renders.
67
68
  | `@manakind/ui-core/select` | `Select` |
68
69
  | `@manakind/ui-core/switch` | `Switch` |
69
70
  | `@manakind/ui-core/tabs` | `Tabs`, `TabsList`, `TabsTrigger`, `TabsContent` |
71
+ | `@manakind/ui-core/css/alert` | Alert structural CSS; its icon also needs `css/icon` |
70
72
  | `@manakind/ui-core/css/badge` | Badge structural CSS |
71
73
  | `@manakind/ui-core/css/button` | Button + IconButton structural CSS |
72
74
  | `@manakind/ui-core/css/card` | Card structural CSS |
@@ -0,0 +1,90 @@
1
+ @layer components {
2
+ .ds-alert {
3
+ box-sizing: border-box;
4
+ display: flex;
5
+ align-items: center;
6
+ /*
7
+ * The gap between the plate and the text is the padding, so the plate
8
+ * sits the same distance from the alert's edge as from the text: one
9
+ * value, not two tokens that can drift apart.
10
+ */
11
+ gap: var(--ds-alert-padding);
12
+ padding: var(--ds-alert-padding);
13
+ /*
14
+ * The border is the variant's text colour, not a lighter tint of it: the
15
+ * fills are pale washes in both products, so the text colour is what
16
+ * bounds the box against the page, and it is already the contrast-checked
17
+ * colour of the variant.
18
+ */
19
+ border: 1px solid var(--_alert-border);
20
+ border-radius: var(--ds-alert-radius);
21
+ background-color: var(--_alert-bg);
22
+ color: var(--_alert-text);
23
+ font-size: var(--ds-alert-font-size);
24
+ line-height: var(--ds-alert-line-height);
25
+
26
+ /*
27
+ * The icon has a column of its own, centred against the text beside it in
28
+ * both directions, on a round plate of the raised surface. Its size is the
29
+ * alert's, not the icon scale's: the glyph names the variant at a glance,
30
+ * so it is drawn larger than an inline icon, and the plate lifts it off the
31
+ * wash.
32
+ */
33
+ & .ds-alert__icon {
34
+ display: flex;
35
+ flex: 0 0 auto;
36
+ align-items: center;
37
+ justify-content: center;
38
+ padding: var(--ds-alert-icon-padding);
39
+ border: var(--ds-alert-icon-border-width) solid currentColor;
40
+ border-radius: var(--ds-alert-icon-radius);
41
+ background-color: var(--ds-alert-icon-bg);
42
+
43
+ & .ds-icon {
44
+ width: var(--ds-alert-icon-size);
45
+ height: var(--ds-alert-icon-size);
46
+ }
47
+ }
48
+
49
+ & .ds-alert__body {
50
+ display: flex;
51
+ flex: 1 1 auto;
52
+ flex-direction: column;
53
+ gap: var(--ds-alert-body-gap);
54
+ min-width: 0;
55
+ }
56
+
57
+ & .ds-alert__title {
58
+ margin: 0;
59
+ font-weight: var(--ds-alert-title-font-weight);
60
+ }
61
+
62
+ & .ds-alert__description {
63
+ margin: 0;
64
+ }
65
+
66
+ &.ds-alert--info {
67
+ --_alert-bg: var(--ds-alert-info-bg);
68
+ --_alert-border: var(--ds-alert-info-border);
69
+ --_alert-text: var(--ds-alert-info-text);
70
+ }
71
+
72
+ &.ds-alert--success {
73
+ --_alert-bg: var(--ds-alert-success-bg);
74
+ --_alert-border: var(--ds-alert-success-border);
75
+ --_alert-text: var(--ds-alert-success-text);
76
+ }
77
+
78
+ &.ds-alert--warning {
79
+ --_alert-bg: var(--ds-alert-warning-bg);
80
+ --_alert-border: var(--ds-alert-warning-border);
81
+ --_alert-text: var(--ds-alert-warning-text);
82
+ }
83
+
84
+ &.ds-alert--danger {
85
+ --_alert-bg: var(--ds-alert-danger-bg);
86
+ --_alert-border: var(--ds-alert-danger-border);
87
+ --_alert-text: var(--ds-alert-danger-text);
88
+ }
89
+ }
90
+ }
@@ -0,0 +1,2 @@
1
+ /* AUTOGENERATED: types for the stylesheet beside it. */
2
+ export {};
@@ -0,0 +1,45 @@
1
+ import type { ComponentProps, ReactNode } from 'react';
2
+ import './alert.css';
3
+ import { type IconSource } from '../icon';
4
+ export type AlertVariant = 'info' | 'success' | 'warning' | 'danger';
5
+ /**
6
+ * `alert` interrupts, and is announced when the element is inserted. `status`
7
+ * waits until the reader is idle, and assistive tech announces only changes
8
+ * inside a region it already knows about: a `status` alert mounted with its
9
+ * content may go unannounced, so keep it mounted and change its text, or use
10
+ * `alert`. Warnings and failures interrupt by default, the other two do not.
11
+ */
12
+ export type AlertRole = 'status' | 'alert';
13
+ export type AlertProps = Omit<ComponentProps<'div'>, 'role' | 'title'> & {
14
+ /**
15
+ * Tone and colour. `info` is the default; `warning` and `danger` also change
16
+ * the live-region role (see {@link AlertRole}).
17
+ */
18
+ variant?: AlertVariant;
19
+ /**
20
+ * Live-region role. Leave it unset and the variant picks one.
21
+ */
22
+ role?: AlertRole;
23
+ /** The one-line headline. Keep it to what happened. */
24
+ title?: ReactNode;
25
+ /**
26
+ * Glyph before the text. Decorative: the variant's role and text say what
27
+ * kind of message this is. `ui-core` ships no icons, so a product passes
28
+ * one of its own.
29
+ */
30
+ icon?: IconSource;
31
+ /** The message body: what to do about it. */
32
+ children?: ReactNode;
33
+ };
34
+ /**
35
+ * An inline message about the surrounding content: a failed save, a setting
36
+ * that needs attention, a result worth confirming. It stays in the flow of the
37
+ * page; a message about the whole app is a toast, and a question is a Dialog.
38
+ *
39
+ * Give it a `title`, `children`, or both. A title alone is a short notice; a
40
+ * body alone is a sentence of explanation. The variant's text colour clears
41
+ * 4.5:1 on its own fill in both themes, and the border is that same colour,
42
+ * so the box is bounded on any surface.
43
+ */
44
+ export declare function Alert({ variant, role, title, icon, children, className, ...rest }: AlertProps): import("react/jsx-runtime").JSX.Element;
45
+ //# sourceMappingURL=alert.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alert.d.ts","sourceRoot":"","sources":["../../src/alert/alert.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,aAAa,CAAC;AAErB,OAAO,EAAQ,KAAK,UAAU,EAAE,MAAM,SAAS,CAAC;AAEhD,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;AAErE;;;;;;GAMG;AACH,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAC;AAS3C,MAAM,MAAM,UAAU,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG;IACvE;;;OAGG;IACH,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB;;OAEG;IACH,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,uDAAuD;IACvD,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;;;OAIG;IACH,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAgB,KAAK,CAAC,EACpB,OAAgB,EAChB,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,SAAS,EACT,GAAG,IAAI,EACR,EAAE,UAAU,2CAkBZ"}
@@ -0,0 +1,24 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import './alert.css';
3
+ import { cx } from '../cx';
4
+ import { Icon } from '../icon';
5
+ const DEFAULT_ROLE = {
6
+ info: 'status',
7
+ success: 'status',
8
+ warning: 'alert',
9
+ danger: 'alert',
10
+ };
11
+ /**
12
+ * An inline message about the surrounding content: a failed save, a setting
13
+ * that needs attention, a result worth confirming. It stays in the flow of the
14
+ * page; a message about the whole app is a toast, and a question is a Dialog.
15
+ *
16
+ * Give it a `title`, `children`, or both. A title alone is a short notice; a
17
+ * body alone is a sentence of explanation. The variant's text colour clears
18
+ * 4.5:1 on its own fill in both themes, and the border is that same colour,
19
+ * so the box is bounded on any surface.
20
+ */
21
+ export function Alert({ variant = 'info', role, title, icon, children, className, ...rest }) {
22
+ return (_jsxs("div", { role: role ?? DEFAULT_ROLE[variant], className: cx('ds-alert', `ds-alert--${variant}`, className), ...rest, children: [icon && (_jsx("span", { className: "ds-alert__icon", children: _jsx(Icon, { source: icon, decorative: true }) })), _jsxs("div", { className: "ds-alert__body", children: [title != null && _jsx("p", { className: "ds-alert__title", children: title }), children != null && _jsx("div", { className: "ds-alert__description", children: children })] })] }));
23
+ }
24
+ //# sourceMappingURL=alert.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alert.js","sourceRoot":"","sources":["../../src/alert/alert.tsx"],"names":[],"mappings":";AACA,OAAO,aAAa,CAAC;AACrB,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAC3B,OAAO,EAAE,IAAI,EAAmB,MAAM,SAAS,CAAC;AAahD,MAAM,YAAY,GAAoC;IACpD,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE,QAAQ;IACjB,OAAO,EAAE,OAAO;IAChB,MAAM,EAAE,OAAO;CAChB,CAAC;AAwBF;;;;;;;;;GASG;AACH,MAAM,UAAU,KAAK,CAAC,EACpB,OAAO,GAAG,MAAM,EAChB,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,SAAS,EACT,GAAG,IAAI,EACI;IACX,OAAO,CACL,eACE,IAAI,EAAE,IAAI,IAAI,YAAY,CAAC,OAAO,CAAC,EACnC,SAAS,EAAE,EAAE,CAAC,UAAU,EAAE,aAAa,OAAO,EAAE,EAAE,SAAS,CAAC,KACxD,IAAI,aAEP,IAAI,IAAI,CACP,eAAM,SAAS,EAAC,gBAAgB,YAC9B,KAAC,IAAI,IAAC,MAAM,EAAE,IAAI,EAAE,UAAU,SAAG,GAC5B,CACR,EACD,eAAK,SAAS,EAAC,gBAAgB,aAC5B,KAAK,IAAI,IAAI,IAAI,YAAG,SAAS,EAAC,iBAAiB,YAAE,KAAK,GAAK,EAC3D,QAAQ,IAAI,IAAI,IAAI,cAAK,SAAS,EAAC,uBAAuB,YAAE,QAAQ,GAAO,IACxE,IACF,CACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ export type { AlertProps, AlertRole, AlertVariant } from './alert';
2
+ export { Alert } from './alert';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/alert/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnE,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { Alert } from './alert';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/alert/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export * from './alert';
1
2
  export * from './badge';
2
3
  export * from './button';
3
4
  export * from './card';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC"}
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ export * from './alert';
1
2
  export * from './badge';
2
3
  export * from './button';
3
4
  export * from './card';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@manakind/ui-core",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -24,6 +24,10 @@
24
24
  "types": "./dist/index.d.ts",
25
25
  "import": "./dist/index.js"
26
26
  },
27
+ "./alert": {
28
+ "types": "./dist/alert/index.d.ts",
29
+ "import": "./dist/alert/index.js"
30
+ },
27
31
  "./badge": {
28
32
  "types": "./dist/badge/index.d.ts",
29
33
  "import": "./dist/badge/index.js"
@@ -40,6 +44,10 @@
40
44
  "types": "./dist/dialog/index.d.ts",
41
45
  "import": "./dist/dialog/index.js"
42
46
  },
47
+ "./css/alert": {
48
+ "types": "./dist/alert/alert.css.d.ts",
49
+ "default": "./dist/alert/alert.css"
50
+ },
43
51
  "./css/badge": {
44
52
  "types": "./dist/badge/badge.css.d.ts",
45
53
  "default": "./dist/badge/badge.css"
@@ -122,7 +130,7 @@
122
130
  },
123
131
  "devDependencies": {
124
132
  "@manakind/ds-config": "*",
125
- "@manakind/manuia-tokens": "0.5.0",
133
+ "@manakind/manuia-tokens": "0.6.0",
126
134
  "@testing-library/jest-dom": "^6.9.1",
127
135
  "@testing-library/react": "^16.3.2",
128
136
  "@testing-library/user-event": "^14.6.1",