-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add @openlabs/system module (#332)
- Loading branch information
1 parent
51cf3b3
commit 3b71d59
Showing
20 changed files
with
438 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{ | ||
"name": "@openlabs/system", | ||
"version": "0.1.0", | ||
"description": "Open UI System primitives", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"author": "Open Labs", | ||
"license": "MIT", | ||
"homepage": "https://github.com/OpenLabs-dev/openui#readme", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/OpenLabs-dev/openui.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/OpenLabs-dev/openui/issues" | ||
}, | ||
"keywords": [ | ||
"ui", | ||
"design system", | ||
"open", | ||
"theme", | ||
"system" | ||
], | ||
"sideEffects": false, | ||
"exports": { | ||
".": { | ||
"types": "./dist/index.d.ts", | ||
"import": "./dist/index.mjs", | ||
"require": "./dist/index.js" | ||
}, | ||
"./package.json": "./package.json" | ||
}, | ||
"scripts": { | ||
"build": "tsup --dts", | ||
"compile": "tsup --dts --watch" | ||
}, | ||
"peerDependencies": { | ||
"react": ">=18", | ||
"react-dom": ">=18" | ||
}, | ||
"devDependencies": { | ||
"@openlabs/tsconfig": "workspace:*", | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0", | ||
"tsup": "^8.0.2", | ||
"typescript": "^5.4.5" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export type { | ||
As, | ||
DOMElement, | ||
DOMElements, | ||
CapitalizedDOMElements, | ||
DOMAttributes, | ||
OmitCommonProps, | ||
RightJoinProps, | ||
MergeWithAs, | ||
InternalForwardRefRenderFunction, | ||
PropsOf, | ||
Merge, | ||
HTMLOpenUIProps, | ||
PropGetter, | ||
} from '@system/types' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"extends": "@openlabs/tsconfig/base.json", | ||
"compilerOptions": { | ||
"baseUrl": ".", | ||
"paths": { | ||
"@system/types": ["types/index.d.ts"] | ||
} | ||
}, | ||
"include": ["."], | ||
"exclude": ["dist", "build", "node_modules"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { defineConfig } from 'tsup' | ||
|
||
export default defineConfig({ | ||
name: 'system', | ||
entry: ['src/index.ts'], | ||
clean: true, | ||
target: 'es2019', | ||
format: ['cjs', 'esm'], | ||
banner: { js: '"use client";' }, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
export type As<Props = any> = React.ElementType<Props> | ||
export type DOMElements = keyof JSX.IntrinsicElements | ||
export type CapitalizedDOMElements = Capitalize<DOMElements> | ||
|
||
export interface DOMElement extends Element, HTMLOrSVGElement {} | ||
|
||
interface DataAttributes { | ||
[dataAttr: string]: any | ||
} | ||
|
||
export type DOMAttributes<T = DOMElement> = React.AriaAttributes & React.DOMAttributes<T> & DataAttributes & { | ||
id?: string | ||
role?: React.AriaRole | ||
tabIndex?: number | ||
style?: React.CSSProperties | ||
} | ||
|
||
export type OmitCommonProps<Target, OmitAdditionalProps extends keyof any = never> = Omit<Target, 'transition' | 'as' | 'color' | OmitAdditionalProps> | ||
|
||
export type RightJoinProps<SourceProps extends object = object, OverrideProps extends object = object> = OmitCommonProps<SourceProps, keyof OverrideProps> & OverrideProps | ||
|
||
export type MergeWithAs< | ||
ComponentProps extends object, | ||
AsProps extends object, | ||
AdditionalProps extends object = object, | ||
AsComponent extends As = As, | ||
> = (RightJoinProps<ComponentProps, AdditionalProps> | RightJoinProps<AsProps, AdditionalProps>) & { | ||
as?: AsComponent | ||
} | ||
|
||
export interface InternalForwardRefRenderFunction< | ||
Component extends As, | ||
Props extends object = object, | ||
OmitKeys extends keyof any = never, | ||
> { | ||
<AsComponent extends As = Component>( | ||
props: MergeWithAs< | ||
React.ComponentPropsWithoutRef<Component>, | ||
Omit<React.ComponentPropsWithoutRef<AsComponent>, OmitKeys>, | ||
Props, | ||
AsComponent | ||
>, | ||
): React.ReactElement | null | ||
readonly $$typeof: symbol | ||
defaultProps?: Partial<Props> | undefined | ||
propTypes?: React.WeakValidationMap<Props> | undefined | ||
displayName?: string | undefined | ||
} | ||
|
||
/** | ||
* Extract the props of a React element or component | ||
*/ | ||
export type PropsOf<T extends As> = React.ComponentPropsWithoutRef<T> & { | ||
as?: As | ||
} | ||
|
||
export type Merge<M, N> = N extends Record<string, unknown> ? M : Omit<M, keyof N> & N | ||
|
||
export type HTMLOpenUIProps<T extends As = 'div', OmitKeys extends keyof any = never> = Omit< | ||
PropsOf<T>, | ||
'ref' | 'color' | 'slot' | 'size' | 'defaultChecked' | 'defaultValue' | OmitKeys | ||
> & { | ||
as?: As | ||
} | ||
|
||
export type PropGetter<P = Record<string, unknown>, R = DOMAttributes> = ( | ||
props?: Merge<DOMAttributes, P>, | ||
ref?: React.Ref<any>, | ||
) => R & React.RefAttributes<any> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,12 @@ | ||
{ | ||
"extends": "@openlabs/tsconfig/base.json", | ||
"compilerOptions": { | ||
"baseUrl": ".", | ||
"paths": { | ||
"@/*": ["./src/*"], | ||
"@theme/types": ["./types/index.d.ts"] | ||
} | ||
}, | ||
"include": ["."], | ||
"exclude": ["dist", "build", "node_modules"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 29 additions & 29 deletions
58
packages/theme/src/interfaces/config.d.ts → packages/theme/types/config.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,29 @@ | ||
import type { ConfigThemes } from '../tailwindcss' | ||
import type { LayoutTheme } from './theme' | ||
import type { DefaultThemeType } from './utils' | ||
|
||
export interface OpenUIPluginConfig { | ||
/** | ||
* The prefix for the css variables. | ||
* @default "openui" | ||
*/ | ||
prefix?: string | ||
/** | ||
* Common layout definitions. These definitions are applied to all themes. | ||
*/ | ||
layout?: LayoutTheme | ||
/** | ||
* The theme definitions. | ||
*/ | ||
themes?: ConfigThemes | ||
/** | ||
* The default theme to use is light | ||
* @default "light" | ||
*/ | ||
defaultTheme?: DefaultThemeType | ||
/** | ||
* The default theme to extend. | ||
* @default "light" | ||
*/ | ||
defaultExtendTheme?: DefaultThemeType | ||
} | ||
import type { LayoutTheme } from './theme' | ||
import type { DefaultThemeType } from './utils' | ||
import type { ConfigThemes } from '@/tailwindcss' | ||
|
||
export interface OpenUIPluginConfig { | ||
/** | ||
* The prefix for the css variables. | ||
* @default "openui" | ||
*/ | ||
prefix?: string | ||
/** | ||
* Common layout definitions. These definitions are applied to all themes. | ||
*/ | ||
layout?: LayoutTheme | ||
/** | ||
* The theme definitions. | ||
*/ | ||
themes?: ConfigThemes | ||
/** | ||
* The default theme to use is light | ||
* @default "light" | ||
*/ | ||
defaultTheme?: DefaultThemeType | ||
/** | ||
* The default theme to extend. | ||
* @default "light" | ||
*/ | ||
defaultExtendTheme?: DefaultThemeType | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
export type { | ||
DefaultThemeType, | ||
Color, | ||
Colors, | ||
BaseColors, | ||
BaseUnit, | ||
OpacityValue, | ||
OpacityColor, | ||
Resolved, | ||
} from './utils' | ||
|
||
export type { ConfigTheme, LayoutTheme } from './theme' | ||
|
||
export type { OpenUIPluginConfig } from './config' |
Oops, something went wrong.