react-outline 2.0.0 → 2.1.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 (3) hide show
  1. package/README.md +1 -1
  2. package/index.d.ts +149 -0
  3. package/package.json +4 -2
package/README.md CHANGED
@@ -8,7 +8,7 @@ react-outline was designed to more easly manage inline styles and better support
8
8
 
9
9
  [![npm version](https://badge.fury.io/js/react-outline.svg)](https://badge.fury.io/js/react-outline)
10
10
  [![Build Status](https://github.com/codemeasandwich/react-outline/actions/workflows/publish.yml/badge.svg)](https://github.com/codemeasandwich/react-outline/actions/workflows/publish.yml)
11
- [![Coverage Status](https://coveralls.io/repos/github/codemeasandwich/react-outline/badge.svg)](https://coveralls.io/github/codemeasandwich/react-outline)
11
+ [![Coverage Status](https://coveralls.io/repos/github/codemeasandwich/react-outline/badge.svg?branch=v2.1.0)](https://coveralls.io/github/codemeasandwich/react-outline?branch=v2.1.0)
12
12
 
13
13
 
14
14
  Feathers:
package/index.d.ts ADDED
@@ -0,0 +1,149 @@
1
+ import * as React from 'react';
2
+
3
+ // CSS style value types
4
+ type CSSValue = string | number;
5
+ type CSSProperties = React.CSSProperties;
6
+
7
+ // Color palette mapping
8
+ type ColorMap = Record<string, string>;
9
+
10
+ // Options for outline configuration
11
+ interface OutlineOptions {
12
+ /** Enable caching of styles (default: false) */
13
+ caching?: boolean;
14
+ /** Color palette mapping for color values */
15
+ colors?: ColorMap;
16
+ /** Add name attribute to DOM elements for debugging (default: true) */
17
+ named?: boolean;
18
+ }
19
+
20
+ // CSS selector styles (for :hover, @media, etc.)
21
+ type CSSSelector = {
22
+ [selector: string]: CSSProperties;
23
+ };
24
+
25
+ // Style definition with optional base and variant styles
26
+ type StyleDefinition = CSSProperties | {
27
+ base?: CSSProperties;
28
+ [variant: string]: CSSProperties | undefined;
29
+ };
30
+
31
+ // Style input object - keys are style names
32
+ type StyleInput = {
33
+ [styleName: string]: StyleDefinition;
34
+ };
35
+
36
+ // Logic function types
37
+ type StyleLogicFn<T = any> = (arg: T) => CSSProperties;
38
+ type StyleModifierFn<T = any> = (baseStyle: CSSProperties, arg: T) => CSSProperties;
39
+
40
+ // Logic functions object - keys are style names
41
+ type LogicInput = {
42
+ [styleName: string]: StyleLogicFn | StyleModifierFn;
43
+ };
44
+
45
+ // Props for generated styled components
46
+ interface StyledComponentProps<T = any> extends React.HTMLAttributes<HTMLElement> {
47
+ /** Style overrides or variant flags */
48
+ style?: CSSProperties | Record<string, boolean> | T;
49
+ /** CSS selector overrides for dynamic styling */
50
+ css?: CSSSelector;
51
+ /** DOM event handlers with direct element access */
52
+ onDomEvent?: {
53
+ [eventName: string]: (element: Element, event: Event) => void;
54
+ };
55
+ children?: React.ReactNode;
56
+ }
57
+
58
+ // Generated styled component
59
+ type StyledComponent = React.ComponentClass<StyledComponentProps>;
60
+
61
+ // Style function that returns inline styles
62
+ interface StyleFunction {
63
+ /** Get the inline styles, optionally with variant flags */
64
+ (variants?: Record<string, boolean>): CSSProperties;
65
+ }
66
+
67
+ // Tagged template literal function for creating styled components
68
+ interface TagCreator {
69
+ (strings: TemplateStringsArray, ...values: any[]): StyledComponent;
70
+ }
71
+
72
+ // Combined style item - both a function and a tag creator
73
+ type StyleItem = StyleFunction & TagCreator & {
74
+ /** Color palette if configured */
75
+ colors?: ColorMap;
76
+ };
77
+
78
+ // Processed styles object
79
+ type ProcessedStyles<T extends StyleInput> = {
80
+ [K in keyof T]: StyleItem;
81
+ } & {
82
+ /** Color palette if configured */
83
+ colors?: ColorMap;
84
+ };
85
+
86
+ // Outline function signature
87
+ interface OutlineFunction {
88
+ /** Process style definitions into usable style functions */
89
+ <T extends StyleInput>(styles: T, logic?: LogicInput): ProcessedStyles<T>;
90
+ /** Color palette if configured via setOptions */
91
+ colors?: ColorMap;
92
+ }
93
+
94
+ // Outline function with options pre-configured
95
+ interface ConfiguredOutlineFunction extends OutlineFunction {
96
+ /** Color palette if configured via withOptions */
97
+ colors?: ColorMap;
98
+ }
99
+
100
+ // Props for the Styles component
101
+ interface StylesProps {
102
+ /** Optional: filter which styles to include */
103
+ [key: string]: any;
104
+ }
105
+
106
+ // Styles component for CSS output (media queries, hover states, etc.)
107
+ interface StylesComponent extends React.FC<StylesProps> {
108
+ /** Get CSS string for server-side rendering */
109
+ toString(): string;
110
+ }
111
+
112
+ // Testing utilities
113
+ interface TestingUtils {
114
+ /** Reset all generated CSS (useful in tests) */
115
+ resetCSS: () => void;
116
+ }
117
+
118
+ // Main outline function
119
+ declare const outline: OutlineFunction;
120
+
121
+ // Create outline function with custom options
122
+ declare function withOptions(options: OutlineOptions): ConfiguredOutlineFunction;
123
+
124
+ // Set global default options
125
+ declare function setOptions(options: OutlineOptions): void;
126
+
127
+ // Styles component for CSS injection
128
+ declare const Styles: StylesComponent;
129
+
130
+ // Testing utilities
131
+ declare const testing: TestingUtils;
132
+
133
+ export default outline;
134
+ export { withOptions, setOptions, Styles, testing };
135
+ export type {
136
+ OutlineOptions,
137
+ StyleInput,
138
+ LogicInput,
139
+ StyleDefinition,
140
+ StyleFunction,
141
+ StyledComponent,
142
+ StyledComponentProps,
143
+ ProcessedStyles,
144
+ ColorMap,
145
+ CSSProperties,
146
+ CSSSelector,
147
+ StylesProps,
148
+ TestingUtils,
149
+ };
package/package.json CHANGED
@@ -1,10 +1,12 @@
1
1
  {
2
2
  "name": "react-outline",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "react styling framework to keep your makeup clean",
5
5
  "main": "./dist/reactOutline.js",
6
+ "types": "./index.d.ts",
6
7
  "files": [
7
- "dist"
8
+ "dist",
9
+ "index.d.ts"
8
10
  ],
9
11
  "scripts": {
10
12
  "prepare": "cp .hooks/* .git/hooks/ 2>/dev/null && chmod +x .git/hooks/* || true",