@lodado/sdui-template-component 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/LICENCE +8 -0
- package/README.md +50 -0
- package/dist/cjs/client/index.cjs +1 -0
- package/dist/es/client/_virtual/_tslib.mjs +1 -0
- package/dist/es/client/src/features/button/ui/Button.mjs +1 -0
- package/dist/es/client/src/index.mjs +1 -0
- package/dist/es/client/src/shared/lib/button-variants.mjs +1 -0
- package/dist/es/client/src/shared/lib/cn.mjs +1 -0
- package/dist/types/app/index.d.ts +3 -0
- package/dist/types/features/button/index.d.ts +2 -0
- package/dist/types/features/button/model/types.d.ts +62 -0
- package/dist/types/features/button/ui/Button.d.ts +25 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/shared/lib/button-variants.d.ts +14 -0
- package/dist/types/shared/lib/cn.d.ts +8 -0
- package/package.json +95 -0
package/LICENCE
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
Copyright (c) 2024 lodado
|
|
3
|
+
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
5
|
+
|
|
6
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
7
|
+
|
|
8
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# @lodado/sdui-template-component
|
|
2
|
+
|
|
3
|
+
SDUI Component Library - Radix UI-based components for Server-Driven UI.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @lodado/sdui-template-component
|
|
9
|
+
# or
|
|
10
|
+
pnpm add @lodado/sdui-template-component
|
|
11
|
+
# or
|
|
12
|
+
yarn add @lodado/sdui-template-component
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import { Button } from '@lodado/sdui-template-component'
|
|
19
|
+
|
|
20
|
+
function App() {
|
|
21
|
+
return <Button variant="primary">Click me</Button>
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Components
|
|
26
|
+
|
|
27
|
+
### Button
|
|
28
|
+
|
|
29
|
+
A flexible button component built with Radix UI primitives.
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
import { Button } from '@lodado/sdui-template-component'
|
|
33
|
+
|
|
34
|
+
<Button variant="primary" size="md" onClick={handleClick}>
|
|
35
|
+
Submit
|
|
36
|
+
</Button>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Architecture
|
|
40
|
+
|
|
41
|
+
This library follows Feature-Sliced Design (FSD) architecture:
|
|
42
|
+
|
|
43
|
+
- `app/` - Entry point and exports
|
|
44
|
+
- `features/` - Component features (Button, etc.)
|
|
45
|
+
- `shared/` - Shared utilities, hooks, and UI primitives
|
|
46
|
+
|
|
47
|
+
## License
|
|
48
|
+
|
|
49
|
+
MIT
|
|
50
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("react/jsx-runtime"),r=require("react"),i=require("clsx"),t=require("tailwind-merge"),a=require("class-variance-authority");function n(...e){return t.twMerge(i.clsx(e))}"function"==typeof SuppressedError&&SuppressedError;const s=a.cva("inline-flex items-center justify-center rounded-md font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{primary:"bg-blue-600 text-white hover:bg-blue-700 focus-visible:ring-blue-600",secondary:"bg-gray-200 text-gray-900 hover:bg-gray-300 focus-visible:ring-gray-400",outline:"border border-gray-300 bg-transparent hover:bg-gray-100 focus-visible:ring-gray-400",ghost:"hover:bg-gray-100 focus-visible:ring-gray-400"},size:{sm:"h-8 px-3 text-sm",md:"h-10 px-4 text-base",lg:"h-12 px-6 text-lg"}},defaultVariants:{variant:"primary",size:"md"}}),o=r.forwardRef((r,i)=>{var{variant:t="primary",size:a="md",disabled:o=!1,children:l,onClick:c,className:d,nodeId:b,eventId:u,"aria-label":y,"aria-describedby":g}=r,v=function(e,r){var i={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&r.indexOf(t)<0&&(i[t]=e[t]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(t=Object.getOwnPropertySymbols(e);a<t.length;a++)r.indexOf(t[a])<0&&Object.prototype.propertyIsEnumerable.call(e,t[a])&&(i[t[a]]=e[t[a]])}return i}(r,["variant","size","disabled","children","onClick","className","nodeId","eventId","aria-label","aria-describedby"]);const p=s({variant:t,size:a});return e.jsx("button",Object.assign({ref:i,type:"button",disabled:o,onClick:e=>{o?e.preventDefault():null==c||c(e)},onKeyDown:e=>{var r;!o||"Enter"!==e.key&&" "!==e.key?null===(r=v.onKeyDown)||void 0===r||r.call(v,e):e.preventDefault()},className:n(p,d),"aria-label":y,"aria-describedby":g,"aria-disabled":o},v,{children:l}))});o.displayName="Button",exports.Button=o,exports.cn=n;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function r(r,e){var t={};for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&e.indexOf(o)<0&&(t[o]=r[o]);if(null!=r&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(o=Object.getOwnPropertySymbols(r);n<o.length;n++)e.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(r,o[n])&&(t[o[n]]=r[o[n]])}return t}"function"==typeof SuppressedError&&SuppressedError;export{r as __rest};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__rest as e}from"../../../../_virtual/_tslib.mjs";import{jsx as a}from"react/jsx-runtime";import r from"react";import{cn as i}from"../../../shared/lib/cn.mjs";import{buttonVariants as t}from"../../../shared/lib/button-variants.mjs";const n=r.forwardRef((r,n)=>{var{variant:l="primary",size:d="md",disabled:s=!1,children:o,onClick:b,className:m,nodeId:c,eventId:v,"aria-label":p,"aria-describedby":u}=r,f=e(r,["variant","size","disabled","children","onClick","className","nodeId","eventId","aria-label","aria-describedby"]);const y=t({variant:l,size:d});return a("button",Object.assign({ref:n,type:"button",disabled:s,onClick:e=>{s?e.preventDefault():null==b||b(e)},onKeyDown:e=>{var a;!s||"Enter"!==e.key&&" "!==e.key?null===(a=f.onKeyDown)||void 0===a||a.call(f,e):e.preventDefault()},className:i(y,m),"aria-label":p,"aria-describedby":u,"aria-disabled":s},f,{children:o}))});n.displayName="Button";export{n as Button};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{Button}from"./features/button/ui/Button.mjs";export{cn}from"./shared/lib/cn.mjs";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{cva as e}from"class-variance-authority";const i=e("inline-flex items-center justify-center rounded-md font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{primary:"bg-blue-600 text-white hover:bg-blue-700 focus-visible:ring-blue-600",secondary:"bg-gray-200 text-gray-900 hover:bg-gray-300 focus-visible:ring-gray-400",outline:"border border-gray-300 bg-transparent hover:bg-gray-100 focus-visible:ring-gray-400",ghost:"hover:bg-gray-100 focus-visible:ring-gray-400"},size:{sm:"h-8 px-3 text-sm",md:"h-10 px-4 text-base",lg:"h-12 px-6 text-lg"}},defaultVariants:{variant:"primary",size:"md"}});export{i as buttonVariants};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{clsx as r}from"clsx";import{twMerge as o}from"tailwind-merge";function t(...t){return o(r(t))}export{t as cn};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Button component variant styles
|
|
3
|
+
*/
|
|
4
|
+
export type ButtonVariant = 'primary' | 'secondary' | 'outline' | 'ghost';
|
|
5
|
+
/**
|
|
6
|
+
* Button component size options
|
|
7
|
+
*/
|
|
8
|
+
export type ButtonSize = 'sm' | 'md' | 'lg';
|
|
9
|
+
/**
|
|
10
|
+
* Button component props
|
|
11
|
+
*
|
|
12
|
+
* @description
|
|
13
|
+
* - Supports multiple variants and sizes for flexible styling
|
|
14
|
+
* - Integrates with SDUI via nodeId prop
|
|
15
|
+
* - Supports event emission via eventId prop
|
|
16
|
+
* - Full keyboard navigation support (Enter, Space)
|
|
17
|
+
* - Accessible by default (ARIA attributes)
|
|
18
|
+
*
|
|
19
|
+
* @param variant - Visual style variant (default: 'primary')
|
|
20
|
+
* @param size - Size of the button (default: 'md')
|
|
21
|
+
* @param disabled - Whether button is disabled (default: false)
|
|
22
|
+
* @param children - Button content
|
|
23
|
+
* @param onClick - Click event handler
|
|
24
|
+
* @param className - Additional CSS classes (merged with defaults)
|
|
25
|
+
* @param nodeId - SDUI node ID for integration (optional)
|
|
26
|
+
* @param eventId - Event ID for event emission (optional)
|
|
27
|
+
* @param 'aria-label' - Accessible label (optional, uses children if not provided)
|
|
28
|
+
* @param 'aria-describedby' - Element ID that describes button (optional)
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```tsx
|
|
32
|
+
* <Button variant="primary" size="md" onClick={handleClick}>
|
|
33
|
+
* Submit
|
|
34
|
+
* </Button>
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```tsx
|
|
39
|
+
* // SDUI integration
|
|
40
|
+
* <Button nodeId="button-1" eventId="submit-click">
|
|
41
|
+
* Submit
|
|
42
|
+
* </Button>
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
46
|
+
/** Visual style variant */
|
|
47
|
+
variant?: ButtonVariant;
|
|
48
|
+
/** Size of the button */
|
|
49
|
+
size?: ButtonSize;
|
|
50
|
+
/** Whether button is disabled */
|
|
51
|
+
disabled?: boolean;
|
|
52
|
+
/** Button content */
|
|
53
|
+
children: React.ReactNode;
|
|
54
|
+
/** Click event handler */
|
|
55
|
+
onClick?: (event: React.MouseEvent<HTMLButtonElement>) => void;
|
|
56
|
+
/** Additional CSS classes */
|
|
57
|
+
className?: string;
|
|
58
|
+
/** SDUI node ID for integration */
|
|
59
|
+
nodeId?: string;
|
|
60
|
+
/** Event ID for event emission */
|
|
61
|
+
eventId?: string;
|
|
62
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ButtonProps } from '../model/types';
|
|
3
|
+
/**
|
|
4
|
+
* Button component
|
|
5
|
+
*
|
|
6
|
+
* @description
|
|
7
|
+
* A flexible, accessible button component built with Radix UI primitives.
|
|
8
|
+
* Supports multiple variants, sizes, and integrates with SDUI template system.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* <Button variant="primary" size="md" onClick={handleClick}>
|
|
13
|
+
* Submit
|
|
14
|
+
* </Button>
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```tsx
|
|
19
|
+
* // SDUI integration
|
|
20
|
+
* <Button nodeId="button-1" eventId="submit-click">
|
|
21
|
+
* Submit
|
|
22
|
+
* </Button>
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './app/index';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type VariantProps } from 'class-variance-authority';
|
|
2
|
+
import type { ButtonVariant, ButtonSize } from '../../features/button/model/types';
|
|
3
|
+
/**
|
|
4
|
+
* Button variant configuration using class-variance-authority
|
|
5
|
+
*
|
|
6
|
+
* @description
|
|
7
|
+
* Defines the visual variants and sizes for the Button component.
|
|
8
|
+
* Uses Tailwind CSS classes for styling.
|
|
9
|
+
*/
|
|
10
|
+
export declare const buttonVariants: (props?: ({
|
|
11
|
+
variant?: ButtonVariant | null | undefined;
|
|
12
|
+
size?: ButtonSize | null | undefined;
|
|
13
|
+
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
14
|
+
export type ButtonVariants = VariantProps<typeof buttonVariants>;
|
package/package.json
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lodado/sdui-template-component",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "SDUI Component Library - Radix UI-based components for Server-Driven UI",
|
|
5
|
+
"author": "lodado",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"main": "./dist/cjs/client/index.cjs",
|
|
8
|
+
"module": "./dist/es/client/index.mjs",
|
|
9
|
+
"types": "./dist/types/index.d.ts",
|
|
10
|
+
"source": "./src/index.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"import": {
|
|
14
|
+
"default": "./dist/es/client/index.mjs",
|
|
15
|
+
"types": "./dist/types/index.d.ts"
|
|
16
|
+
},
|
|
17
|
+
"require": {
|
|
18
|
+
"default": "./dist/cjs/client/index.cjs",
|
|
19
|
+
"types": "./dist/types/index.d.ts"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist/**",
|
|
25
|
+
"README.md"
|
|
26
|
+
],
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public",
|
|
29
|
+
"source": "./src/index.ts"
|
|
30
|
+
},
|
|
31
|
+
"sideEffects": false,
|
|
32
|
+
"keywords": [
|
|
33
|
+
"react",
|
|
34
|
+
"sdui",
|
|
35
|
+
"server-driven-ui",
|
|
36
|
+
"components",
|
|
37
|
+
"radix-ui",
|
|
38
|
+
"ui-library",
|
|
39
|
+
"typescript"
|
|
40
|
+
],
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"react": "^18.0",
|
|
43
|
+
"react-dom": "^18.0",
|
|
44
|
+
"@lodado/sdui-template": "^1.0.0"
|
|
45
|
+
},
|
|
46
|
+
"peerDependenciesMeta": {
|
|
47
|
+
"@types/react": {
|
|
48
|
+
"optional": true
|
|
49
|
+
},
|
|
50
|
+
"@types/react-dom": {
|
|
51
|
+
"optional": true
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"@radix-ui/react-slot": "^1.0.2",
|
|
56
|
+
"class-variance-authority": "^0.7.0",
|
|
57
|
+
"clsx": "^2.1.1",
|
|
58
|
+
"tailwind-merge": "^2.2.1"
|
|
59
|
+
},
|
|
60
|
+
"devDependencies": {
|
|
61
|
+
"@testing-library/jest-dom": "^6.1.5",
|
|
62
|
+
"@testing-library/react": "^14.1.2",
|
|
63
|
+
"@testing-library/user-event": "^14.5.2",
|
|
64
|
+
"@types/node": "^20.12.7",
|
|
65
|
+
"@types/react": "^18.3.5",
|
|
66
|
+
"@types/react-dom": "^18.3.0",
|
|
67
|
+
"babel-jest": "29.5.0",
|
|
68
|
+
"eslint": "^8.57.0",
|
|
69
|
+
"react": "^18.3.1",
|
|
70
|
+
"react-dom": "^18.3.1",
|
|
71
|
+
"ts-jest": "29.0.5",
|
|
72
|
+
"typescript": "^5.4.5",
|
|
73
|
+
"vitest": "^1.6.0",
|
|
74
|
+
"eslint-config-sdui-template": "0.0.0",
|
|
75
|
+
"jest-config": "0.0.0",
|
|
76
|
+
"rollup-config": "0.0.1",
|
|
77
|
+
"tsconfig": "0.0.0"
|
|
78
|
+
},
|
|
79
|
+
"repository": {
|
|
80
|
+
"type": "git",
|
|
81
|
+
"url": "https://github.com/lodado/sdui-template.git",
|
|
82
|
+
"directory": "apps/sdui-template-component"
|
|
83
|
+
},
|
|
84
|
+
"homepage": "https://github.com/lodado/sdui-template#readme",
|
|
85
|
+
"bugs": {
|
|
86
|
+
"url": "https://github.com/lodado/sdui-template/issues"
|
|
87
|
+
},
|
|
88
|
+
"scripts": {
|
|
89
|
+
"build": "rollup -c && tsc --emitDeclarationOnly --declarationMap false --declaration --declarationDir dist/types",
|
|
90
|
+
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
|
|
91
|
+
"lint": "eslint \"src/**/*.ts*\"",
|
|
92
|
+
"test": "jest --passWithNoTests",
|
|
93
|
+
"manual-release": "pnpm run build && pnpm publish --no-git-checks"
|
|
94
|
+
}
|
|
95
|
+
}
|