react-mnt 1.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.
- package/LICENSE +21 -0
- package/README.md +166 -0
- package/dist/cjs/index.js +90 -0
- package/dist/cjs/react-props-check/src/index.js +12 -0
- package/dist/cjs/react-props-check/src/react_props.js +6 -0
- package/dist/esm/index.js +91 -0
- package/dist/esm/react-props-check/src/index.js +13 -0
- package/dist/esm/react-props-check/src/react_props.js +6 -0
- package/dist/types/index.d.ts +44 -0
- package/package.json +59 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Marco Antonio Ghiani
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
# react-mnt
|
|
2
|
+
|
|
3
|
+
[](https://github.com/tonyghiani/mnt/actions)
|
|
4
|
+
[](https://github.com/tonyghiani/mnt/blob/main/LICENSE)
|
|
5
|
+
|
|
6
|
+
`react-mnt` is a versatile utility library designed to enhance the capabilities of React components. It exposes a powerful `mnt` function that allows you to create component factory functions. With `mnt`, you can easily customize and extend the behavior of your React components, making it an invaluable tool for building flexible and dynamic UIs.
|
|
7
|
+
|
|
8
|
+
## Key Features
|
|
9
|
+
|
|
10
|
+
- 💡 **Polymorphism**: Achieve polymorphism by dynamically changing the component's underlying HTML element. This allows you to easily adapt your component to different use cases.
|
|
11
|
+
|
|
12
|
+
**Usage Example**:
|
|
13
|
+
|
|
14
|
+
```javascript
|
|
15
|
+
import mnt from 'react-mnt';
|
|
16
|
+
|
|
17
|
+
// Create a link-like button using the 'as' property
|
|
18
|
+
const LinkButton = mnt('button').params({ as: 'a' })`text-blue`;
|
|
19
|
+
|
|
20
|
+
function App() {
|
|
21
|
+
// Change the underline HTML element also on site
|
|
22
|
+
return <LinkButton as='input' type='submit' />;
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
- 🔄 **Forwarded Ref**: `react-mnt` ensures that your enhanced components maintain support for forwarded refs, making them seamlessly integrate with other libraries and components that rely on refs.
|
|
27
|
+
|
|
28
|
+
**Usage Example**:
|
|
29
|
+
|
|
30
|
+
```javascript
|
|
31
|
+
import mnt from 'react-mnt';
|
|
32
|
+
|
|
33
|
+
// Create an enhanced button component that forwards refs
|
|
34
|
+
const EnhancedButton = mnt('button')``;
|
|
35
|
+
|
|
36
|
+
// Usage in a parent component
|
|
37
|
+
function ParentComponent() {
|
|
38
|
+
const buttonRef = React.createRef();
|
|
39
|
+
return <EnhancedButton ref={buttonRef}>Click me!</EnhancedButton>;
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
- 🚀 **Extend Existing Components**: You can enhance and build upon existing components, making it easy to extend the functionality of your favorite libraries or your own components.
|
|
44
|
+
|
|
45
|
+
**Usage Example**:
|
|
46
|
+
|
|
47
|
+
```javascript
|
|
48
|
+
import mnt from 'react-mnt';
|
|
49
|
+
|
|
50
|
+
// Extend a base typography component with custom styles
|
|
51
|
+
const BaseTypography = /* your base typography component */;
|
|
52
|
+
const EnhancedTypography = mnt(BaseTypography)`text-blue`;
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
- 📚 **Strong Typing for Rendered Component**: `react-mnt` ensures strong typing for the rendered component, helping you catch type-related errors early in the development process.
|
|
56
|
+
|
|
57
|
+
**Usage Example**:
|
|
58
|
+
|
|
59
|
+
```javascript
|
|
60
|
+
import mnt from 'react-mnt';
|
|
61
|
+
|
|
62
|
+
interface ButtonProps {
|
|
63
|
+
variant?: 'primary' | 'secondary'
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Create an enhanced button component with strong typing
|
|
67
|
+
const EnhancedButton = mnt('button')<ButtonProps>`text-blue`;
|
|
68
|
+
|
|
69
|
+
// Usage with TypeScript
|
|
70
|
+
function App() {
|
|
71
|
+
// Suggests values for optional `variant` property
|
|
72
|
+
return <LinkButton variant="primary" />;
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
These highlighted features, accompanied by usage examples, showcase the power and flexibility of `react-mnt` for building robust and dynamic React components.
|
|
77
|
+
|
|
78
|
+
## Installation
|
|
79
|
+
|
|
80
|
+
You can install `react-mnt` via npm or yarn. Make sure you have Node.js and npm (or yarn) installed in your project before proceeding.
|
|
81
|
+
|
|
82
|
+
### Using npm
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
npm install react-mnt
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Using yarn
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
yarn add react-mnt
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Once the package is installed, you can import it into your React application and start using the `mnt` function to create enhanced components.
|
|
95
|
+
|
|
96
|
+
## Usage
|
|
97
|
+
|
|
98
|
+
`react-mnt` introduces the `mnt` function, which provides a seamless way to enhance the capabilities of your React components. It allows you to modify component behavior and style by applying tagged styles and additional props.
|
|
99
|
+
|
|
100
|
+
### Basic Usage
|
|
101
|
+
|
|
102
|
+
```javascript
|
|
103
|
+
import mnt from 'react-mnt';
|
|
104
|
+
|
|
105
|
+
const EnhancedButton = mnt('button')`
|
|
106
|
+
text-blue
|
|
107
|
+
${props => props.disabled && 'text-disabled'}
|
|
108
|
+
`;
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
In the example above, `mnt` is used to enhance a `button` element by applying CSS classes based on tagged styles and props. This creates a more versatile and customized button component.
|
|
112
|
+
|
|
113
|
+
### Enhanced Component with Base Component
|
|
114
|
+
|
|
115
|
+
You can also use `mnt` with a base component to further extend its functionality.
|
|
116
|
+
|
|
117
|
+
```javascript
|
|
118
|
+
import mnt from 'react-mnt';
|
|
119
|
+
|
|
120
|
+
const BaseTypography = /* your base typography component */;
|
|
121
|
+
const EnhancedTypography = mnt(BaseTypography)`
|
|
122
|
+
text-blue
|
|
123
|
+
${props => props.disabled && 'text-disabled'}
|
|
124
|
+
`;
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Here, the `mnt` function is applied to a base typography component, allowing you to add custom styles and behavior.
|
|
128
|
+
|
|
129
|
+
### Advanced Usage with Parameters
|
|
130
|
+
|
|
131
|
+
`mnt` supports advanced usage where you can define parameters for your enhanced components.
|
|
132
|
+
|
|
133
|
+
```javascript
|
|
134
|
+
import mnt from 'react-mnt';
|
|
135
|
+
|
|
136
|
+
const EnhancedButton = mnt('button').params({ as: 'a' })`
|
|
137
|
+
text-blue
|
|
138
|
+
${props => props.disabled && 'text-disabled'}
|
|
139
|
+
`;
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
In this example, the `params` method is used to specify additional parameters, such as changing the element type to 'a'. This is useful for creating link-like buttons with custom styles.
|
|
143
|
+
|
|
144
|
+
## API Reference
|
|
145
|
+
|
|
146
|
+
### `mnt<TElement, TElementHtmlProps>(elementType: TElement): MntComponent`
|
|
147
|
+
|
|
148
|
+
- `elementType` (TElement): The target element or component to enhance.
|
|
149
|
+
|
|
150
|
+
Returns a factory function for creating enhanced components.
|
|
151
|
+
|
|
152
|
+
Creates an enhanced component using the provided tagged styles.
|
|
153
|
+
|
|
154
|
+
### `mnt.params<Props>(params: MntParamsOrFactory<Props>)`
|
|
155
|
+
|
|
156
|
+
- `params` (MntParamsOrFactory): Additional parameters or a factory function to modify the component's behavior.
|
|
157
|
+
|
|
158
|
+
Returns an enhanced component with the specified parameters.
|
|
159
|
+
|
|
160
|
+
### Other Types and Utility Functions
|
|
161
|
+
|
|
162
|
+
- Various types and utility functions are exported, allowing you to work with component parameters, classes, and tagged styles.
|
|
163
|
+
|
|
164
|
+
## License
|
|
165
|
+
|
|
166
|
+
This project is licensed under the MIT License - see the [LICENSE.md](https://github.com/tonyghiani/mnt/blob/main/LICENSE) file for details. You are free to use and distribute this package under the terms of the MIT License.
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
3
|
+
const React = require("react");
|
|
4
|
+
const index = require("./react-props-check/src/index.js");
|
|
5
|
+
const isMnt = (arg) => arg._isMnt === true;
|
|
6
|
+
const mnt = (element, params = {}) => {
|
|
7
|
+
const builder = (...taggedStyles) => {
|
|
8
|
+
const classesFactory = getClasses(...taggedStyles);
|
|
9
|
+
const paramsFactory = isFunction(params) ? params : () => params;
|
|
10
|
+
if (isMnt(element)) {
|
|
11
|
+
return mnt(element._element, (props) => ({
|
|
12
|
+
...element._paramsFactory(props),
|
|
13
|
+
...paramsFactory(props)
|
|
14
|
+
}))`
|
|
15
|
+
${(props) => element._classesFactory(props)}
|
|
16
|
+
${(props) => classesFactory(props)}
|
|
17
|
+
`;
|
|
18
|
+
}
|
|
19
|
+
return componentTemplate(element, classesFactory, paramsFactory);
|
|
20
|
+
};
|
|
21
|
+
builder.params = (params2) => {
|
|
22
|
+
return mnt(element, params2);
|
|
23
|
+
};
|
|
24
|
+
return builder;
|
|
25
|
+
};
|
|
26
|
+
const componentTemplate = (element, classesFactory, paramsFactory) => {
|
|
27
|
+
function Component(componentProps, ref) {
|
|
28
|
+
const {
|
|
29
|
+
as: As,
|
|
30
|
+
className,
|
|
31
|
+
...props
|
|
32
|
+
} = componentProps;
|
|
33
|
+
const params = paramsFactory(componentProps);
|
|
34
|
+
const {
|
|
35
|
+
as: paramsAs,
|
|
36
|
+
...paramsRest
|
|
37
|
+
} = params;
|
|
38
|
+
const taggedClasses = classesFactory({
|
|
39
|
+
...params,
|
|
40
|
+
...componentProps
|
|
41
|
+
});
|
|
42
|
+
const classes = [taggedClasses, className].filter(Boolean).join(" ").trim() || void 0;
|
|
43
|
+
const cleanedParams = cleanProps(paramsRest);
|
|
44
|
+
const cleanedProps = cleanProps(props);
|
|
45
|
+
const TagName = As ?? paramsAs ?? element;
|
|
46
|
+
return /* @__PURE__ */ jsxRuntime.jsx(TagName, { ...cleanedParams, ...cleanedProps, ref, className: classes });
|
|
47
|
+
}
|
|
48
|
+
if (hasStaticProperty(element, "displayName")) {
|
|
49
|
+
Component.displayName = element.displayName || element.name;
|
|
50
|
+
}
|
|
51
|
+
const MntComponent = React.forwardRef(Component);
|
|
52
|
+
MntComponent._classesFactory = classesFactory;
|
|
53
|
+
MntComponent._paramsFactory = paramsFactory;
|
|
54
|
+
MntComponent._element = element;
|
|
55
|
+
MntComponent._isMnt = true;
|
|
56
|
+
return MntComponent;
|
|
57
|
+
};
|
|
58
|
+
function getClasses(...taggedStyles) {
|
|
59
|
+
return (props) => {
|
|
60
|
+
const [statics, ...dynamics] = taggedStyles;
|
|
61
|
+
const chunks = [];
|
|
62
|
+
for (let i = 0; i < statics.length; i++) {
|
|
63
|
+
const staticChunk = statics[i].trim();
|
|
64
|
+
if (staticChunk)
|
|
65
|
+
chunks.push(staticChunk);
|
|
66
|
+
if (i < dynamics.length) {
|
|
67
|
+
const classBuilder = dynamics[i];
|
|
68
|
+
const dynamicClass = isFunction(classBuilder) ? classBuilder(props) : classBuilder;
|
|
69
|
+
if (dynamicClass)
|
|
70
|
+
chunks.push(dynamicClass.trim());
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return chunks.join(" ");
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function cleanProps(props) {
|
|
77
|
+
const cleanedProps = {};
|
|
78
|
+
for (const prop in props) {
|
|
79
|
+
if (index.default(prop))
|
|
80
|
+
cleanedProps[prop] = props[prop];
|
|
81
|
+
}
|
|
82
|
+
return cleanedProps;
|
|
83
|
+
}
|
|
84
|
+
function hasStaticProperty(input, propertyName) {
|
|
85
|
+
return isFunction(input) && propertyName in input;
|
|
86
|
+
}
|
|
87
|
+
function isFunction(arg) {
|
|
88
|
+
return typeof arg === "function";
|
|
89
|
+
}
|
|
90
|
+
module.exports = mnt;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const react_props = require("./react_props.js");
|
|
4
|
+
function isValidProp(property) {
|
|
5
|
+
return react_props.reactAcceptedPropertiesSet.has(property) || isDataAttribute(property);
|
|
6
|
+
}
|
|
7
|
+
function isDataAttribute(property) {
|
|
8
|
+
return property.startsWith("data-");
|
|
9
|
+
}
|
|
10
|
+
exports.reactAcceptedProperties = react_props.reactAcceptedProperties;
|
|
11
|
+
exports.reactAcceptedPropertiesSet = react_props.reactAcceptedPropertiesSet;
|
|
12
|
+
exports.default = isValidProp;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const reactAcceptedProperties = ["abbr", "about", "accentHeight", "accept", "acceptCharset", "accessKey", "accumulate", "action", "additive", "alignmentBaseline", "allow", "allowFullScreen", "allowPaymentRequest", "allowReorder", "allowTransparency", "allowUserMedia", "alphabetic", "alt", "amplitude", "arabicForm", "aria-activedescendant", "aria-atomic", "aria-autocomplete", "aria-braillelabel", "aria-brailleroledescription", "aria-busy", "aria-checked", "aria-colcount", "aria-colindex", "aria-colindextext", "aria-colspan", "aria-controls", "aria-current", "aria-describedby", "aria-description", "aria-details", "aria-disabled", "aria-dropeffect", "aria-errormessage", "aria-expanded", "aria-flowto", "aria-grabbed", "aria-haspopup", "aria-hidden", "aria-invalid", "aria-keyshortcuts", "aria-label", "aria-labelledby", "aria-level", "aria-live", "aria-modal", "aria-multiline", "aria-multiselectable", "aria-orientation", "aria-owns", "aria-placeholder", "aria-posinset", "aria-pressed", "aria-readonly", "aria-relevant", "aria-required", "aria-roledescription", "aria-rowcount", "aria-rowindex", "aria-rowindextext", "aria-rowspan", "aria-selected", "aria-setsize", "aria-sort", "aria-valuemax", "aria-valuemin", "aria-valuenow", "aria-valuetext", "as", "ascent", "async", "attributeName", "attributeType", "autoCapitalize", "autoComplete", "autoCorrect", "autofocus", "autoFocus", "autoPlay", "autoReverse", "autoSave", "azimuth", "baseFrequency", "baselineShift", "baseProfile", "bbox", "begin", "bias", "by", "calcMode", "capHeight", "capture", "cellPadding", "cellSpacing", "challenge", "charSet", "checked", "children", "cite", "class", "classID", "className", "clip", "clipPath", "clipPathUnits", "clipRule", "color", "colorInterpolation", "colorInterpolationFilters", "colorProfile", "colorRendering", "cols", "colSpan", "content", "contentEditable", "contentScriptType", "contentStyleType", "contextMenu", "controls", "controlsList", "coords", "crossOrigin", "cursor", "cx", "cy", "d", "dangerouslySetInnerHTML", "data", "datatype", "dateTime", "decelerate", "decoding", "default", "defaultChecked", "defaultValue", "defer", "descent", "diffuseConstant", "dir", "direction", "disabled", "disablePictureInPicture", "display", "divisor", "dominantBaseline", "download", "draggable", "dur", "dx", "dy", "edgeMode", "elevation", "enableBackground", "encType", "end", "enterKeyHint", "exponent", "externalResourcesRequired", "fallback", "fill", "fillOpacity", "fillRule", "filter", "filterRes", "filterUnits", "floodColor", "floodOpacity", "focusable", "fontFamily", "fontSize", "fontSizeAdjust", "fontStretch", "fontStyle", "fontVariant", "fontWeight", "for", "form", "formAction", "format", "formEncType", "formMethod", "formNoValidate", "formTarget", "fr", "frameBorder", "from", "fx", "fy", "g1", "g2", "glyphName", "glyphOrientationHorizontal", "glyphOrientationVertical", "glyphRef", "gradientTransform", "gradientUnits", "hanging", "headers", "height", "hidden", "high", "horizAdvX", "horizOriginX", "href", "hrefLang", "htmlFor", "httpEquiv", "id", "ideographic", "imageRendering", "in", "in2", "incremental", "inert", "inlist", "innerHTML", "inputMode", "integrity", "intercept", "is", "itemID", "itemProp", "itemRef", "itemScope", "itemType", "k", "k1", "k2", "k3", "k4", "kernelMatrix", "kernelUnitLength", "kerning", "key", "keyParams", "keyPoints", "keySplines", "keyTimes", "keyType", "kind", "label", "lang", "lengthAdjust", "letterSpacing", "lightingColor", "limitingConeAngle", "list", "loading", "local", "loop", "low", "manifest", "marginHeight", "marginWidth", "markerEnd", "markerHeight", "markerMid", "markerStart", "markerUnits", "markerWidth", "mask", "maskContentUnits", "maskUnits", "mathematical", "max", "maxLength", "media", "mediaGroup", "method", "min", "minLength", "mode", "multiple", "muted", "name", "nonce", "noValidate", "numOctaves", "offset", "on", "onAbort", "onAbortCapture", "onAnimationEnd", "onAnimationEndCapture", "onAnimationIteration", "onAnimationIterationCapture", "onAnimationStart", "onAnimationStartCapture", "onAuxClick", "onAuxClickCapture", "onBeforeInput", "onBeforeInputCapture", "onBlur", "onBlurCapture", "onCanPlay", "onCanPlayCapture", "onCanPlayThrough", "onCanPlayThroughCapture", "onChange", "onChangeCapture", "onClick", "onClickCapture", "onCompositionEnd", "onCompositionEndCapture", "onCompositionStart", "onCompositionStartCapture", "onCompositionUpdate", "onCompositionUpdateCapture", "onContextMenu", "onContextMenuCapture", "onCopy", "onCopyCapture", "onCut", "onCutCapture", "onDoubleClick", "onDoubleClickCapture", "onDrag", "onDragCapture", "onDragEnd", "onDragEndCapture", "onDragEnter", "onDragEnterCapture", "onDragExit", "onDragExitCapture", "onDragLeave", "onDragLeaveCapture", "onDragOver", "onDragOverCapture", "onDragStart", "onDragStartCapture", "onDrop", "onDropCapture", "onDurationChange", "onDurationChangeCapture", "onEmptied", "onEmptiedCapture", "onEncrypted", "onEncryptedCapture", "onEnded", "onEndedCapture", "onError", "onErrorCapture", "onFocus", "onFocusCapture", "onGotPointerCapture", "onGotPointerCaptureCapture", "onInput", "onInputCapture", "onInvalid", "onInvalidCapture", "onKeyDown", "onKeyDownCapture", "onKeyPress", "onKeyPressCapture", "onKeyUp", "onKeyUpCapture", "onLoad", "onLoadCapture", "onLoadedData", "onLoadedDataCapture", "onLoadedMetadata", "onLoadedMetadataCapture", "onLoadStart", "onLoadStartCapture", "onLostPointerCapture", "onLostPointerCaptureCapture", "onMouseDown", "onMouseDownCapture", "onMouseEnter", "onMouseLeave", "onMouseMove", "onMouseMoveCapture", "onMouseOut", "onMouseOutCapture", "onMouseOver", "onMouseOverCapture", "onMouseUp", "onMouseUpCapture", "onPaste", "onPasteCapture", "onPause", "onPauseCapture", "onPlay", "onPlayCapture", "onPlaying", "onPlayingCapture", "onPointerCancel", "onPointerCancelCapture", "onPointerDown", "onPointerDownCapture", "onPointerEnter", "onPointerEnterCapture", "onPointerLeave", "onPointerLeaveCapture", "onPointerMove", "onPointerMoveCapture", "onPointerOut", "onPointerOutCapture", "onPointerOver", "onPointerOverCapture", "onPointerUp", "onPointerUpCapture", "onProgress", "onProgressCapture", "onRateChange", "onRateChangeCapture", "onReset", "onResetCapture", "onResize", "onResizeCapture", "onScroll", "onScrollCapture", "onSeeked", "onSeekedCapture", "onSeeking", "onSeekingCapture", "onSelect", "onSelectCapture", "onStalled", "onStalledCapture", "onSubmit", "onSubmitCapture", "onSuspend", "onSuspendCapture", "onTimeUpdate", "onTimeUpdateCapture", "onTouchCancel", "onTouchCancelCapture", "onTouchEnd", "onTouchEndCapture", "onTouchMove", "onTouchMoveCapture", "onTouchStart", "onTouchStartCapture", "onTransitionEnd", "onTransitionEndCapture", "onVolumeChange", "onVolumeChangeCapture", "onWaiting", "onWaitingCapture", "onWheel", "onWheelCapture", "opacity", "open", "operator", "optimum", "option", "order", "orient", "orientation", "origin", "overflow", "overlinePosition", "overlineThickness", "paintOrder", "panose1", "pathLength", "pattern", "patternContentUnits", "patternTransform", "patternUnits", "placeholder", "playsInline", "pointerEvents", "points", "pointsAtX", "pointsAtY", "pointsAtZ", "poster", "prefix", "preload", "preserveAlpha", "preserveAspectRatio", "primitiveUnits", "profile", "property", "r", "radioGroup", "radius", "readOnly", "ref", "referrerPolicy", "refX", "refY", "rel", "renderingIntent", "repeatCount", "repeatDur", "required", "requiredExtensions", "requiredFeatures", "resource", "restart", "result", "results", "rev", "reversed", "role", "rotate", "rows", "rowSpan", "rx", "ry", "sandbox", "scale", "scope", "scoped", "scrolling", "seamless", "security", "seed", "selected", "shape", "shapeRendering", "size", "sizes", "slope", "slot", "spacing", "span", "specularConstant", "specularExponent", "speed", "spellCheck", "spreadMethod", "src", "srcDoc", "srcLang", "srcSet", "start", "startOffset", "stdDeviation", "stemh", "stemv", "step", "stitchTiles", "stopColor", "stopOpacity", "strikethroughPosition", "strikethroughThickness", "string", "stroke", "strokeDasharray", "strokeDashoffset", "strokeLinecap", "strokeLinejoin", "strokeMiterlimit", "strokeOpacity", "strokeWidth", "style", "summary", "suppressContentEditableWarning", "suppressHydrationWarning", "surfaceScale", "systemLanguage", "tabIndex", "tableValues", "target", "targetX", "targetY", "textAnchor", "textDecoration", "textLength", "textRendering", "title", "to", "transform", "translate", "type", "typeof", "u1", "u2", "underlinePosition", "underlineThickness", "unicode", "unicodeBidi", "unicodeRange", "unitsPerEm", "unselectable", "useMap", "vAlphabetic", "value", "valueLink", "values", "vectorEffect", "version", "vertAdvY", "vertOriginX", "vertOriginY", "vHanging", "vIdeographic", "viewBox", "viewTarget", "visibility", "vMathematical", "vocab", "width", "widths", "wmode", "wordSpacing", "wrap", "writingMode", "x", "x1", "x2", "xChannelSelector", "xHeight", "xlinkActuate", "xlinkArcrole", "xlinkHref", "xlinkRole", "xlinkShow", "xlinkTitle", "xlinkType", "xmlBase", "xmlLang", "xmlns", "xmlnsXlink", "xmlSpace", "y", "y1", "y2", "yChannelSelector", "z", "zoomAndPan"];
|
|
4
|
+
const reactAcceptedPropertiesSet = new Set(reactAcceptedProperties);
|
|
5
|
+
exports.reactAcceptedProperties = reactAcceptedProperties;
|
|
6
|
+
exports.reactAcceptedPropertiesSet = reactAcceptedPropertiesSet;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import isValidProp from "./react-props-check/src/index.js";
|
|
4
|
+
const isMnt = (arg) => arg._isMnt === true;
|
|
5
|
+
const mnt = (element, params = {}) => {
|
|
6
|
+
const builder = (...taggedStyles) => {
|
|
7
|
+
const classesFactory = getClasses(...taggedStyles);
|
|
8
|
+
const paramsFactory = isFunction(params) ? params : () => params;
|
|
9
|
+
if (isMnt(element)) {
|
|
10
|
+
return mnt(element._element, (props) => ({
|
|
11
|
+
...element._paramsFactory(props),
|
|
12
|
+
...paramsFactory(props)
|
|
13
|
+
}))`
|
|
14
|
+
${(props) => element._classesFactory(props)}
|
|
15
|
+
${(props) => classesFactory(props)}
|
|
16
|
+
`;
|
|
17
|
+
}
|
|
18
|
+
return componentTemplate(element, classesFactory, paramsFactory);
|
|
19
|
+
};
|
|
20
|
+
builder.params = (params2) => {
|
|
21
|
+
return mnt(element, params2);
|
|
22
|
+
};
|
|
23
|
+
return builder;
|
|
24
|
+
};
|
|
25
|
+
const componentTemplate = (element, classesFactory, paramsFactory) => {
|
|
26
|
+
function Component(componentProps, ref) {
|
|
27
|
+
const {
|
|
28
|
+
as: As,
|
|
29
|
+
className,
|
|
30
|
+
...props
|
|
31
|
+
} = componentProps;
|
|
32
|
+
const params = paramsFactory(componentProps);
|
|
33
|
+
const {
|
|
34
|
+
as: paramsAs,
|
|
35
|
+
...paramsRest
|
|
36
|
+
} = params;
|
|
37
|
+
const taggedClasses = classesFactory({
|
|
38
|
+
...params,
|
|
39
|
+
...componentProps
|
|
40
|
+
});
|
|
41
|
+
const classes = [taggedClasses, className].filter(Boolean).join(" ").trim() || void 0;
|
|
42
|
+
const cleanedParams = cleanProps(paramsRest);
|
|
43
|
+
const cleanedProps = cleanProps(props);
|
|
44
|
+
const TagName = As ?? paramsAs ?? element;
|
|
45
|
+
return /* @__PURE__ */ jsx(TagName, { ...cleanedParams, ...cleanedProps, ref, className: classes });
|
|
46
|
+
}
|
|
47
|
+
if (hasStaticProperty(element, "displayName")) {
|
|
48
|
+
Component.displayName = element.displayName || element.name;
|
|
49
|
+
}
|
|
50
|
+
const MntComponent = React.forwardRef(Component);
|
|
51
|
+
MntComponent._classesFactory = classesFactory;
|
|
52
|
+
MntComponent._paramsFactory = paramsFactory;
|
|
53
|
+
MntComponent._element = element;
|
|
54
|
+
MntComponent._isMnt = true;
|
|
55
|
+
return MntComponent;
|
|
56
|
+
};
|
|
57
|
+
function getClasses(...taggedStyles) {
|
|
58
|
+
return (props) => {
|
|
59
|
+
const [statics, ...dynamics] = taggedStyles;
|
|
60
|
+
const chunks = [];
|
|
61
|
+
for (let i = 0; i < statics.length; i++) {
|
|
62
|
+
const staticChunk = statics[i].trim();
|
|
63
|
+
if (staticChunk)
|
|
64
|
+
chunks.push(staticChunk);
|
|
65
|
+
if (i < dynamics.length) {
|
|
66
|
+
const classBuilder = dynamics[i];
|
|
67
|
+
const dynamicClass = isFunction(classBuilder) ? classBuilder(props) : classBuilder;
|
|
68
|
+
if (dynamicClass)
|
|
69
|
+
chunks.push(dynamicClass.trim());
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return chunks.join(" ");
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function cleanProps(props) {
|
|
76
|
+
const cleanedProps = {};
|
|
77
|
+
for (const prop in props) {
|
|
78
|
+
if (isValidProp(prop))
|
|
79
|
+
cleanedProps[prop] = props[prop];
|
|
80
|
+
}
|
|
81
|
+
return cleanedProps;
|
|
82
|
+
}
|
|
83
|
+
function hasStaticProperty(input, propertyName) {
|
|
84
|
+
return isFunction(input) && propertyName in input;
|
|
85
|
+
}
|
|
86
|
+
function isFunction(arg) {
|
|
87
|
+
return typeof arg === "function";
|
|
88
|
+
}
|
|
89
|
+
export {
|
|
90
|
+
mnt as default
|
|
91
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { reactAcceptedPropertiesSet } from "./react_props.js";
|
|
2
|
+
import { reactAcceptedProperties } from "./react_props.js";
|
|
3
|
+
function isValidProp(property) {
|
|
4
|
+
return reactAcceptedPropertiesSet.has(property) || isDataAttribute(property);
|
|
5
|
+
}
|
|
6
|
+
function isDataAttribute(property) {
|
|
7
|
+
return property.startsWith("data-");
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
isValidProp as default,
|
|
11
|
+
reactAcceptedProperties,
|
|
12
|
+
reactAcceptedPropertiesSet
|
|
13
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
const reactAcceptedProperties = ["abbr", "about", "accentHeight", "accept", "acceptCharset", "accessKey", "accumulate", "action", "additive", "alignmentBaseline", "allow", "allowFullScreen", "allowPaymentRequest", "allowReorder", "allowTransparency", "allowUserMedia", "alphabetic", "alt", "amplitude", "arabicForm", "aria-activedescendant", "aria-atomic", "aria-autocomplete", "aria-braillelabel", "aria-brailleroledescription", "aria-busy", "aria-checked", "aria-colcount", "aria-colindex", "aria-colindextext", "aria-colspan", "aria-controls", "aria-current", "aria-describedby", "aria-description", "aria-details", "aria-disabled", "aria-dropeffect", "aria-errormessage", "aria-expanded", "aria-flowto", "aria-grabbed", "aria-haspopup", "aria-hidden", "aria-invalid", "aria-keyshortcuts", "aria-label", "aria-labelledby", "aria-level", "aria-live", "aria-modal", "aria-multiline", "aria-multiselectable", "aria-orientation", "aria-owns", "aria-placeholder", "aria-posinset", "aria-pressed", "aria-readonly", "aria-relevant", "aria-required", "aria-roledescription", "aria-rowcount", "aria-rowindex", "aria-rowindextext", "aria-rowspan", "aria-selected", "aria-setsize", "aria-sort", "aria-valuemax", "aria-valuemin", "aria-valuenow", "aria-valuetext", "as", "ascent", "async", "attributeName", "attributeType", "autoCapitalize", "autoComplete", "autoCorrect", "autofocus", "autoFocus", "autoPlay", "autoReverse", "autoSave", "azimuth", "baseFrequency", "baselineShift", "baseProfile", "bbox", "begin", "bias", "by", "calcMode", "capHeight", "capture", "cellPadding", "cellSpacing", "challenge", "charSet", "checked", "children", "cite", "class", "classID", "className", "clip", "clipPath", "clipPathUnits", "clipRule", "color", "colorInterpolation", "colorInterpolationFilters", "colorProfile", "colorRendering", "cols", "colSpan", "content", "contentEditable", "contentScriptType", "contentStyleType", "contextMenu", "controls", "controlsList", "coords", "crossOrigin", "cursor", "cx", "cy", "d", "dangerouslySetInnerHTML", "data", "datatype", "dateTime", "decelerate", "decoding", "default", "defaultChecked", "defaultValue", "defer", "descent", "diffuseConstant", "dir", "direction", "disabled", "disablePictureInPicture", "display", "divisor", "dominantBaseline", "download", "draggable", "dur", "dx", "dy", "edgeMode", "elevation", "enableBackground", "encType", "end", "enterKeyHint", "exponent", "externalResourcesRequired", "fallback", "fill", "fillOpacity", "fillRule", "filter", "filterRes", "filterUnits", "floodColor", "floodOpacity", "focusable", "fontFamily", "fontSize", "fontSizeAdjust", "fontStretch", "fontStyle", "fontVariant", "fontWeight", "for", "form", "formAction", "format", "formEncType", "formMethod", "formNoValidate", "formTarget", "fr", "frameBorder", "from", "fx", "fy", "g1", "g2", "glyphName", "glyphOrientationHorizontal", "glyphOrientationVertical", "glyphRef", "gradientTransform", "gradientUnits", "hanging", "headers", "height", "hidden", "high", "horizAdvX", "horizOriginX", "href", "hrefLang", "htmlFor", "httpEquiv", "id", "ideographic", "imageRendering", "in", "in2", "incremental", "inert", "inlist", "innerHTML", "inputMode", "integrity", "intercept", "is", "itemID", "itemProp", "itemRef", "itemScope", "itemType", "k", "k1", "k2", "k3", "k4", "kernelMatrix", "kernelUnitLength", "kerning", "key", "keyParams", "keyPoints", "keySplines", "keyTimes", "keyType", "kind", "label", "lang", "lengthAdjust", "letterSpacing", "lightingColor", "limitingConeAngle", "list", "loading", "local", "loop", "low", "manifest", "marginHeight", "marginWidth", "markerEnd", "markerHeight", "markerMid", "markerStart", "markerUnits", "markerWidth", "mask", "maskContentUnits", "maskUnits", "mathematical", "max", "maxLength", "media", "mediaGroup", "method", "min", "minLength", "mode", "multiple", "muted", "name", "nonce", "noValidate", "numOctaves", "offset", "on", "onAbort", "onAbortCapture", "onAnimationEnd", "onAnimationEndCapture", "onAnimationIteration", "onAnimationIterationCapture", "onAnimationStart", "onAnimationStartCapture", "onAuxClick", "onAuxClickCapture", "onBeforeInput", "onBeforeInputCapture", "onBlur", "onBlurCapture", "onCanPlay", "onCanPlayCapture", "onCanPlayThrough", "onCanPlayThroughCapture", "onChange", "onChangeCapture", "onClick", "onClickCapture", "onCompositionEnd", "onCompositionEndCapture", "onCompositionStart", "onCompositionStartCapture", "onCompositionUpdate", "onCompositionUpdateCapture", "onContextMenu", "onContextMenuCapture", "onCopy", "onCopyCapture", "onCut", "onCutCapture", "onDoubleClick", "onDoubleClickCapture", "onDrag", "onDragCapture", "onDragEnd", "onDragEndCapture", "onDragEnter", "onDragEnterCapture", "onDragExit", "onDragExitCapture", "onDragLeave", "onDragLeaveCapture", "onDragOver", "onDragOverCapture", "onDragStart", "onDragStartCapture", "onDrop", "onDropCapture", "onDurationChange", "onDurationChangeCapture", "onEmptied", "onEmptiedCapture", "onEncrypted", "onEncryptedCapture", "onEnded", "onEndedCapture", "onError", "onErrorCapture", "onFocus", "onFocusCapture", "onGotPointerCapture", "onGotPointerCaptureCapture", "onInput", "onInputCapture", "onInvalid", "onInvalidCapture", "onKeyDown", "onKeyDownCapture", "onKeyPress", "onKeyPressCapture", "onKeyUp", "onKeyUpCapture", "onLoad", "onLoadCapture", "onLoadedData", "onLoadedDataCapture", "onLoadedMetadata", "onLoadedMetadataCapture", "onLoadStart", "onLoadStartCapture", "onLostPointerCapture", "onLostPointerCaptureCapture", "onMouseDown", "onMouseDownCapture", "onMouseEnter", "onMouseLeave", "onMouseMove", "onMouseMoveCapture", "onMouseOut", "onMouseOutCapture", "onMouseOver", "onMouseOverCapture", "onMouseUp", "onMouseUpCapture", "onPaste", "onPasteCapture", "onPause", "onPauseCapture", "onPlay", "onPlayCapture", "onPlaying", "onPlayingCapture", "onPointerCancel", "onPointerCancelCapture", "onPointerDown", "onPointerDownCapture", "onPointerEnter", "onPointerEnterCapture", "onPointerLeave", "onPointerLeaveCapture", "onPointerMove", "onPointerMoveCapture", "onPointerOut", "onPointerOutCapture", "onPointerOver", "onPointerOverCapture", "onPointerUp", "onPointerUpCapture", "onProgress", "onProgressCapture", "onRateChange", "onRateChangeCapture", "onReset", "onResetCapture", "onResize", "onResizeCapture", "onScroll", "onScrollCapture", "onSeeked", "onSeekedCapture", "onSeeking", "onSeekingCapture", "onSelect", "onSelectCapture", "onStalled", "onStalledCapture", "onSubmit", "onSubmitCapture", "onSuspend", "onSuspendCapture", "onTimeUpdate", "onTimeUpdateCapture", "onTouchCancel", "onTouchCancelCapture", "onTouchEnd", "onTouchEndCapture", "onTouchMove", "onTouchMoveCapture", "onTouchStart", "onTouchStartCapture", "onTransitionEnd", "onTransitionEndCapture", "onVolumeChange", "onVolumeChangeCapture", "onWaiting", "onWaitingCapture", "onWheel", "onWheelCapture", "opacity", "open", "operator", "optimum", "option", "order", "orient", "orientation", "origin", "overflow", "overlinePosition", "overlineThickness", "paintOrder", "panose1", "pathLength", "pattern", "patternContentUnits", "patternTransform", "patternUnits", "placeholder", "playsInline", "pointerEvents", "points", "pointsAtX", "pointsAtY", "pointsAtZ", "poster", "prefix", "preload", "preserveAlpha", "preserveAspectRatio", "primitiveUnits", "profile", "property", "r", "radioGroup", "radius", "readOnly", "ref", "referrerPolicy", "refX", "refY", "rel", "renderingIntent", "repeatCount", "repeatDur", "required", "requiredExtensions", "requiredFeatures", "resource", "restart", "result", "results", "rev", "reversed", "role", "rotate", "rows", "rowSpan", "rx", "ry", "sandbox", "scale", "scope", "scoped", "scrolling", "seamless", "security", "seed", "selected", "shape", "shapeRendering", "size", "sizes", "slope", "slot", "spacing", "span", "specularConstant", "specularExponent", "speed", "spellCheck", "spreadMethod", "src", "srcDoc", "srcLang", "srcSet", "start", "startOffset", "stdDeviation", "stemh", "stemv", "step", "stitchTiles", "stopColor", "stopOpacity", "strikethroughPosition", "strikethroughThickness", "string", "stroke", "strokeDasharray", "strokeDashoffset", "strokeLinecap", "strokeLinejoin", "strokeMiterlimit", "strokeOpacity", "strokeWidth", "style", "summary", "suppressContentEditableWarning", "suppressHydrationWarning", "surfaceScale", "systemLanguage", "tabIndex", "tableValues", "target", "targetX", "targetY", "textAnchor", "textDecoration", "textLength", "textRendering", "title", "to", "transform", "translate", "type", "typeof", "u1", "u2", "underlinePosition", "underlineThickness", "unicode", "unicodeBidi", "unicodeRange", "unitsPerEm", "unselectable", "useMap", "vAlphabetic", "value", "valueLink", "values", "vectorEffect", "version", "vertAdvY", "vertOriginX", "vertOriginY", "vHanging", "vIdeographic", "viewBox", "viewTarget", "visibility", "vMathematical", "vocab", "width", "widths", "wmode", "wordSpacing", "wrap", "writingMode", "x", "x1", "x2", "xChannelSelector", "xHeight", "xlinkActuate", "xlinkArcrole", "xlinkHref", "xlinkRole", "xlinkShow", "xlinkTitle", "xlinkType", "xmlBase", "xmlLang", "xmlns", "xmlnsXlink", "xmlSpace", "y", "y1", "y2", "yChannelSelector", "z", "zoomAndPan"];
|
|
2
|
+
const reactAcceptedPropertiesSet = new Set(reactAcceptedProperties);
|
|
3
|
+
export {
|
|
4
|
+
reactAcceptedProperties,
|
|
5
|
+
reactAcceptedPropertiesSet
|
|
6
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React, { ElementType } from 'react';
|
|
2
|
+
export interface MntProps<TAs = MntComponentType> {
|
|
3
|
+
as?: TAs;
|
|
4
|
+
}
|
|
5
|
+
export type AnyFunction = (..._args: any) => any;
|
|
6
|
+
export type ParamsResult<Params extends MntParamsOrFactory> = Params extends AnyFunction ? ReturnType<AnyFunction> : Params;
|
|
7
|
+
export type ParamsTarget<Params extends MntParamsOrFactory, TDefault extends MntComponentType> = ParamsResult<Params> extends {
|
|
8
|
+
as: infer PAs;
|
|
9
|
+
} ? PAs extends MntComponentType ? PAs : TDefault : TDefault;
|
|
10
|
+
export interface Mnt<TElement extends MntComponentType, TElementHtmlProps extends object> {
|
|
11
|
+
<Props extends object = BaseObject>(..._taggedStyle: TaggedStyle<Merge<TElementHtmlProps, Props>>): MntComponent<TElement, Merge<TElementHtmlProps, Props>>;
|
|
12
|
+
params<Props extends object = BaseObject, _MergedProps extends object = Merge<TElementHtmlProps, Props>, _ParamsArg extends MntParamsOrFactory<_MergedProps> = MntParamsOrFactory<_MergedProps>, _ResolvedElement extends MntComponentType = ParamsTarget<_ParamsArg, TElement>>(_paramsFactory: _ParamsArg): Mnt<_ResolvedElement, _ResolvedElement extends MntComponentType ? Merge<React.ComponentPropsWithRef<_ResolvedElement>, Props> : _MergedProps>;
|
|
13
|
+
}
|
|
14
|
+
export interface MntComponent<TElement extends MntComponentType = any, Props extends object = BaseObject> extends React.ForwardRefExoticComponent<React.PropsWithoutRef<Props> & React.RefAttributes<unknown>> {
|
|
15
|
+
<TAs extends MntComponentType>(_props: MntComponentProps<TAs, Props>): React.ReactNode;
|
|
16
|
+
_classesFactory: ClassesFactory<Props>;
|
|
17
|
+
_paramsFactory: MntParamsFactory<Props>;
|
|
18
|
+
_element: TElement;
|
|
19
|
+
_isMnt: boolean;
|
|
20
|
+
}
|
|
21
|
+
export type MntParamsFactory<Props> = (_props: MntProps & Props) => MntProps & Partial<Props>;
|
|
22
|
+
export type MntParamsOrFactory<Props extends object = BaseObject> = ReturnType<MntParamsFactory<Props>> | MntParamsFactory<Props>;
|
|
23
|
+
export type ClassesFactory<Props extends object> = (_props: Merge<Props, MntProps>) => string;
|
|
24
|
+
export type ClassesFactoryOrString<Props extends object> = ClassesFactory<Props> | string;
|
|
25
|
+
export type TaggedStyle<Props extends object> = [
|
|
26
|
+
TemplateStringsArray,
|
|
27
|
+
...ClassesFactoryOrString<Props>[]
|
|
28
|
+
];
|
|
29
|
+
export type MntComponentType = ElementType | MntComponent;
|
|
30
|
+
export type MntComponentProps<TAs extends MntComponentType = MntComponentType, Props extends object = BaseObject, TAsProps extends object = MntComponentType extends TAs ? BaseObject : React.ComponentPropsWithRef<TAs>> = Merge<Merge<Props, TAsProps>, MntProps<TAs>>;
|
|
31
|
+
export type Merge<A extends object, B extends object> = Omit<A, keyof B> & B;
|
|
32
|
+
export type BaseObject = {};
|
|
33
|
+
/**
|
|
34
|
+
* Creates a component factory function to enhance basic capabilities of a passed component.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* // Usage example:
|
|
38
|
+
* const Button = mnt('button')`text-blue ${props => props.disabled && text-disabled}`;
|
|
39
|
+
* const Button = mnt(BaseTypography)`text-blue ${props => props.disabled && text-disabled}`;
|
|
40
|
+
* const Button = mnt(BaseTypography).params({as: 'a'})`text-blue ${props => props.disabled && text-disabled}`;
|
|
41
|
+
* const Button = mnt(BaseTypography).params((props) => ({as: props.variant}))`text-blue ${props => props.disabled && text-disabled}`;
|
|
42
|
+
*/
|
|
43
|
+
declare const mnt: <TElement extends MntComponentType, TElementHtmlProps extends object = TElement extends MntComponentType ? React.ComponentPropsWithRef<TElement> : BaseObject>(element: TElement, params?: MntParamsOrFactory<BaseObject>) => Mnt<TElement, TElementHtmlProps>;
|
|
44
|
+
export default mnt;
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "react-mnt",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "Create strongly typed React components, including essential features such as polymorphism and ref handling.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"components",
|
|
7
|
+
"css",
|
|
8
|
+
"mnt",
|
|
9
|
+
"react component",
|
|
10
|
+
"react",
|
|
11
|
+
"styles",
|
|
12
|
+
"typescript"
|
|
13
|
+
],
|
|
14
|
+
"homepage": "https://github.com/tonyghiani/mnt/tree/main/packages/react-mnt#readme",
|
|
15
|
+
"repository": "https://github.com/tonyghiani/mnt",
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"author": "Marco Antonio Ghiani <marcoantonio.ghiani01@gmail.com>",
|
|
18
|
+
"sideEffects": false,
|
|
19
|
+
"main": "dist/cjs/index.js",
|
|
20
|
+
"module": "dist/esm/index.js",
|
|
21
|
+
"types": "dist/types/index.d.ts",
|
|
22
|
+
"files": [
|
|
23
|
+
"dist"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "yarn clean:build && yarn build:vite && yarn build:types",
|
|
27
|
+
"build:types": "tsc --project ./tsconfig.types.json",
|
|
28
|
+
"build:vite": "vite build",
|
|
29
|
+
"clean:build": "rimraf dist *.tsbuildinfo",
|
|
30
|
+
"commit": "git cz",
|
|
31
|
+
"lint": "eslint",
|
|
32
|
+
"lint:package": "sort-package-json",
|
|
33
|
+
"release": "semantic-release",
|
|
34
|
+
"test": "NODE_ENV=testing jest --passWithNoTests"
|
|
35
|
+
},
|
|
36
|
+
"config": {
|
|
37
|
+
"commitizen": {
|
|
38
|
+
"path": "git-cz"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"react-props-check": "^1.1.0"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@testing-library/react": "^14.0.0",
|
|
46
|
+
"@types/react": "^18.2.36",
|
|
47
|
+
"@types/react-dom": "^18.2.14",
|
|
48
|
+
"react": "^18.2.0",
|
|
49
|
+
"react-dom": "^18.2.0"
|
|
50
|
+
},
|
|
51
|
+
"peerDependencies": {
|
|
52
|
+
"react": ">=17",
|
|
53
|
+
"react-dom": ">=17"
|
|
54
|
+
},
|
|
55
|
+
"publishConfig": {
|
|
56
|
+
"access": "public"
|
|
57
|
+
},
|
|
58
|
+
"gitHead": "bb73a6fcd36ec512bba0da9ccf28dbcc7c040c2e"
|
|
59
|
+
}
|