@dnanpm/ui-components 0.0.3 → 0.0.5
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 +15 -0
- package/README.md +45 -3
- package/dist/components/Box/Box.d.ts +0 -22
- package/dist/components/Box/Box.d.ts.map +1 -1
- package/dist/components/Button/Button.d.ts.map +1 -1
- package/dist/components/Dialog/Dialog.d.ts +3 -0
- package/dist/components/Dialog/Dialog.d.ts.map +1 -0
- package/dist/components/Dialog/Dialog.types.d.ts +45 -0
- package/dist/components/Dialog/Dialog.types.d.ts.map +1 -0
- package/dist/components/Dialog/index.d.ts +3 -0
- package/dist/components/Dialog/index.d.ts.map +1 -0
- package/dist/components/Tooltip/Tooltip.d.ts +3 -0
- package/dist/components/Tooltip/Tooltip.d.ts.map +1 -0
- package/dist/components/Tooltip/Tooltip.types.d.ts +39 -0
- package/dist/components/Tooltip/Tooltip.types.d.ts.map +1 -0
- package/dist/components/Tooltip/index.d.ts +3 -0
- package/dist/components/Tooltip/index.d.ts.map +1 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/index.cjs +9962 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9946 -30
- package/dist/index.js.map +1 -1
- package/dist/styles.css +247 -18
- package/dist/utils/cn/cn.d.ts +13 -3
- package/dist/utils/cn/cn.d.ts.map +1 -1
- package/dist/utils/cn/index.d.ts +3 -0
- package/dist/utils/cn/index.d.ts.map +1 -0
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/package.json +16 -6
package/LICENSE
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) DNA Online Services
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
10
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
12
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
14
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
15
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# UI Components
|
|
1
|
+
# DNA UI Components
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/@dnanpm/ui-components)
|
|
4
4
|
|
|
5
5
|
> ⚠️ **Under Heavy Development** — This package is actively being developed. Breaking changes may occur between minor versions during the 0.x release cycle.
|
|
6
6
|
|
|
@@ -12,10 +12,13 @@ React component library for the DNA Design System. Built with TypeScript, CSS Mo
|
|
|
12
12
|
## Features
|
|
13
13
|
|
|
14
14
|
- Accessible, responsive, and customizable components
|
|
15
|
+
- Canonical DNA component APIs with swappable internal implementations
|
|
15
16
|
- Built with TypeScript and CSS Modules
|
|
16
17
|
- Themed with design tokens from `@dnanpm/design-tokens`
|
|
17
18
|
- Supports server-side rendering and tree-shaking
|
|
18
19
|
- Comprehensive documentation and examples
|
|
20
|
+
- Single CSS file for easier consumption
|
|
21
|
+
- Selective exports for optimal bundle sizes
|
|
19
22
|
|
|
20
23
|
## Installation
|
|
21
24
|
|
|
@@ -26,7 +29,7 @@ pnpm add @dnanpm/ui-components @dnanpm/design-tokens
|
|
|
26
29
|
## Usage
|
|
27
30
|
|
|
28
31
|
```tsx
|
|
29
|
-
import { Button,
|
|
32
|
+
import { Box, Button, Dialog, Tooltip } from '@dnanpm/ui-components';
|
|
30
33
|
import '@dnanpm/ui-components/styles.css';
|
|
31
34
|
|
|
32
35
|
function App() {
|
|
@@ -41,13 +44,52 @@ function App() {
|
|
|
41
44
|
<Box elevation="high">
|
|
42
45
|
<h2>Elevated Content</h2>
|
|
43
46
|
</Box>
|
|
47
|
+
|
|
48
|
+
<Tooltip content="Additional context lives behind the same DNA API.">
|
|
49
|
+
<Button aria-label="Show more information" variant="secondary">
|
|
50
|
+
Hover me
|
|
51
|
+
</Button>
|
|
52
|
+
</Tooltip>
|
|
53
|
+
|
|
54
|
+
<Dialog
|
|
55
|
+
trigger={<Button>Open dialog</Button>}
|
|
56
|
+
title="Project details"
|
|
57
|
+
description="Implementation stays internal to the design system."
|
|
58
|
+
footer={<Button>Done</Button>}
|
|
59
|
+
>
|
|
60
|
+
<p>
|
|
61
|
+
Consumers use the same component contract regardless of what powers it
|
|
62
|
+
underneath.
|
|
63
|
+
</p>
|
|
64
|
+
</Dialog>
|
|
44
65
|
</div>
|
|
45
66
|
);
|
|
46
67
|
}
|
|
47
68
|
```
|
|
48
69
|
|
|
70
|
+
## Implementation Model
|
|
71
|
+
|
|
72
|
+
This package now supports two contributor paths under one public API surface:
|
|
73
|
+
|
|
74
|
+
- `Plain React` components, written entirely in-house.
|
|
75
|
+
- `Base UI` components, where the public DNA API is built on top of a headless library primitive directly in the component file.
|
|
76
|
+
|
|
77
|
+
Consumers should not need to know which path a component uses. Public names, props, and behavior belong to DNA; implementation choices stay internal.
|
|
78
|
+
|
|
49
79
|
Design tokens are available as CSS custom properties: `var(--colors-primitive-pink-500)`, `var(--spacing-ui-md)`, etc.
|
|
50
80
|
|
|
81
|
+
### Tree-shaking
|
|
82
|
+
|
|
83
|
+
This package uses selective exports to optimize bundle sizes. Import only what you need:
|
|
84
|
+
|
|
85
|
+
```tsx
|
|
86
|
+
// ✅ Good: Named imports (tree-shakeable)
|
|
87
|
+
import { Button, Box } from '@dnanpm/ui-components';
|
|
88
|
+
|
|
89
|
+
// ❌ Avoid: Wildcard imports (larger bundle)
|
|
90
|
+
import * as UI from '@dnanpm/ui-components';
|
|
91
|
+
```
|
|
92
|
+
|
|
51
93
|
## Contributing
|
|
52
94
|
|
|
53
95
|
See [CONTRIBUTING.md](./CONTRIBUTING.md) for contribution guidelines.
|
|
@@ -1,24 +1,2 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Box Component
|
|
3
|
-
*
|
|
4
|
-
* A versatile container component with elevation (shadow) variants.
|
|
5
|
-
* Can be rendered as any HTML element using the polymorphic `as` prop.
|
|
6
|
-
*
|
|
7
|
-
* Features:
|
|
8
|
-
* - Polymorphic: Render as any element (div, section, article, etc.)
|
|
9
|
-
* - Elevation: Four shadow depth levels (none, low, high, extraHigh)
|
|
10
|
-
* - Ref forwarding supported
|
|
11
|
-
* - Uses design tokens for consistent shadows
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* // Basic box with no elevation
|
|
15
|
-
* <Box>Content</Box>
|
|
16
|
-
*
|
|
17
|
-
* // Box with elevation
|
|
18
|
-
* <Box elevation="high">Elevated content</Box>
|
|
19
|
-
*
|
|
20
|
-
* // Box as section element
|
|
21
|
-
* <Box as="section" elevation="low">Section content</Box>
|
|
22
|
-
*/
|
|
23
1
|
export declare const Box: import('react').ForwardRefExoticComponent<import('./Box.types').BaseBoxProps & import('react').HTMLAttributes<HTMLElement> & import('react').RefAttributes<HTMLElement>>;
|
|
24
2
|
//# sourceMappingURL=Box.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Box.d.ts","sourceRoot":"","sources":["../../../src/components/Box/Box.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Box.d.ts","sourceRoot":"","sources":["../../../src/components/Box/Box.tsx"],"names":[],"mappings":"AAKA,eAAO,MAAM,GAAG,0KAUf,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../src/components/Button/Button.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../src/components/Button/Button.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAGlD,eAAO,MAAM,MAAM,+HAoDlB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Dialog.d.ts","sourceRoot":"","sources":["../../../src/components/Dialog/Dialog.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,eAAO,MAAM,MAAM,wGAsDjB,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { DialogPortalProps, DialogRootProps } from '@base-ui/react/dialog';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
export type DialogSize = 'sm' | 'md' | 'lg';
|
|
4
|
+
export interface DialogProps extends Omit<DialogRootProps, 'children' | 'disablePointerDismissal'>, Pick<DialogPortalProps, 'keepMounted'> {
|
|
5
|
+
/**
|
|
6
|
+
* Optional trigger element composed without changing its public API.
|
|
7
|
+
*/
|
|
8
|
+
readonly trigger?: React.ReactElement;
|
|
9
|
+
/**
|
|
10
|
+
* Dialog title announced by assistive technology.
|
|
11
|
+
*/
|
|
12
|
+
readonly title: React.ReactNode;
|
|
13
|
+
/**
|
|
14
|
+
* Optional supporting copy below the title.
|
|
15
|
+
*/
|
|
16
|
+
readonly description?: React.ReactNode;
|
|
17
|
+
/**
|
|
18
|
+
* Main dialog content.
|
|
19
|
+
*/
|
|
20
|
+
readonly children?: React.ReactNode;
|
|
21
|
+
/**
|
|
22
|
+
* Optional footer actions.
|
|
23
|
+
*/
|
|
24
|
+
readonly footer?: React.ReactNode;
|
|
25
|
+
/**
|
|
26
|
+
* Whether clicking the backdrop should close the dialog.
|
|
27
|
+
* @default true
|
|
28
|
+
*/
|
|
29
|
+
readonly closeOnOutsideClick?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Accessible label for the close button.
|
|
32
|
+
* @default 'Close dialog'
|
|
33
|
+
*/
|
|
34
|
+
readonly closeLabel?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Width preset for the popup.
|
|
37
|
+
* @default 'md'
|
|
38
|
+
*/
|
|
39
|
+
readonly size?: DialogSize;
|
|
40
|
+
/**
|
|
41
|
+
* Optional popup className.
|
|
42
|
+
*/
|
|
43
|
+
readonly className?: string;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=Dialog.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Dialog.types.d.ts","sourceRoot":"","sources":["../../../src/components/Dialog/Dialog.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAEhF,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE5C,MAAM,WAAW,WACb,SACI,IAAI,CAAC,eAAe,EAAE,UAAU,GAAG,yBAAyB,CAAC,EAC7D,IAAI,CAAC,iBAAiB,EAAE,aAAa,CAAC;IAC1C;;OAEG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC;IACtC;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC;IAChC;;OAEG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACvC;;OAEG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACpC;;OAEG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAClC;;;OAGG;IACH,QAAQ,CAAC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IACvC;;;OAGG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B;;;OAGG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC;IAC3B;;OAEG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC/B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Dialog/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../../src/components/Tooltip/Tooltip.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD,eAAO,MAAM,OAAO,yGAqClB,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { TooltipPortalProps, TooltipPositionerProps, TooltipRootProps, TooltipTriggerProps } from '@base-ui/react/tooltip';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
export type TooltipSide = 'top' | 'right' | 'bottom' | 'left';
|
|
4
|
+
export type TooltipAlign = 'start' | 'center' | 'end';
|
|
5
|
+
export interface TooltipProps extends Omit<TooltipRootProps, 'children'>, Pick<TooltipTriggerProps, 'delay' | 'closeDelay'>, Pick<TooltipPortalProps, 'keepMounted'>, Pick<TooltipPositionerProps, 'side' | 'align' | 'sideOffset'> {
|
|
6
|
+
/**
|
|
7
|
+
* Visual tooltip content rendered in the popup.
|
|
8
|
+
*/
|
|
9
|
+
readonly content: React.ReactNode;
|
|
10
|
+
/**
|
|
11
|
+
* Trigger element composed without changing its public API.
|
|
12
|
+
*/
|
|
13
|
+
readonly children: React.ReactElement;
|
|
14
|
+
/**
|
|
15
|
+
* Preferred tooltip side.
|
|
16
|
+
* @default 'top'
|
|
17
|
+
*/
|
|
18
|
+
readonly side?: TooltipSide;
|
|
19
|
+
/**
|
|
20
|
+
* Popup alignment relative to the trigger.
|
|
21
|
+
* @default 'center'
|
|
22
|
+
*/
|
|
23
|
+
readonly align?: TooltipAlign;
|
|
24
|
+
/**
|
|
25
|
+
* Space between trigger and popup.
|
|
26
|
+
* @default 8
|
|
27
|
+
*/
|
|
28
|
+
readonly sideOffset?: number;
|
|
29
|
+
/**
|
|
30
|
+
* Whether to render the arrow.
|
|
31
|
+
* @default true
|
|
32
|
+
*/
|
|
33
|
+
readonly showArrow?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Optional popup className.
|
|
36
|
+
*/
|
|
37
|
+
readonly className?: string;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=Tooltip.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tooltip.types.d.ts","sourceRoot":"","sources":["../../../src/components/Tooltip/Tooltip.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EACR,kBAAkB,EAClB,sBAAsB,EACtB,gBAAgB,EAChB,mBAAmB,EACtB,MAAM,wBAAwB,CAAC;AAEhC,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;AAC9D,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;AAEtD,MAAM,WAAW,YACb,SACI,IAAI,CAAC,gBAAgB,EAAE,UAAU,CAAC,EAClC,IAAI,CAAC,mBAAmB,EAAE,OAAO,GAAG,YAAY,CAAC,EACjD,IAAI,CAAC,kBAAkB,EAAE,aAAa,CAAC,EACvC,IAAI,CAAC,sBAAsB,EAAE,MAAM,GAAG,OAAO,GAAG,YAAY,CAAC;IACjE;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC;IAClC;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,YAAY,CAAC;IACtC;;;OAGG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,WAAW,CAAC;IAC5B;;;OAGG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,YAAY,CAAC;IAC9B;;;OAGG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B;;;OAGG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAC7B;;OAEG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC/B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Tooltip/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC"}
|