@stylix/core 3.1.3 → 4.0.1
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/dist/index.js +853 -28
- package/dist/index.js.map +1 -1
- package/dist/module.mjs +828 -0
- package/dist/module.mjs.map +1 -0
- package/dist/types.d.ts +163 -27
- package/dist/types.d.ts.map +1 -0
- package/package.json +19 -31
- package/dist/Stylix.d.ts +0 -3
- package/dist/Stylix.js +0 -66
- package/dist/Stylix.js.map +0 -1
- package/dist/StylixProvider.d.ts +0 -52
- package/dist/StylixProvider.js +0 -143
- package/dist/StylixProvider.js.map +0 -1
- package/dist/applyRules.d.ts +0 -5
- package/dist/applyRules.js +0 -31
- package/dist/applyRules.js.map +0 -1
- package/dist/classifyProps.d.ts +0 -7
- package/dist/classifyProps.js +0 -35
- package/dist/classifyProps.js.map +0 -1
- package/dist/css-props.json +0 -413
- package/dist/html-tags.json +0 -119
- package/dist/index.d.ts +0 -8
- package/dist/plugins/cleanStyles.d.ts +0 -5
- package/dist/plugins/cleanStyles.js +0 -28
- package/dist/plugins/cleanStyles.js.map +0 -1
- package/dist/plugins/customProps.d.ts +0 -2
- package/dist/plugins/customProps.js +0 -61
- package/dist/plugins/customProps.js.map +0 -1
- package/dist/plugins/defaultUnits.d.ts +0 -7
- package/dist/plugins/defaultUnits.js +0 -41
- package/dist/plugins/defaultUnits.js.map +0 -1
- package/dist/plugins/flattenNestedStyles.d.ts +0 -5
- package/dist/plugins/flattenNestedStyles.js +0 -47
- package/dist/plugins/flattenNestedStyles.js.map +0 -1
- package/dist/plugins/index.d.ts +0 -30
- package/dist/plugins/index.js +0 -44
- package/dist/plugins/index.js.map +0 -1
- package/dist/plugins/mediaArrays.d.ts +0 -5
- package/dist/plugins/mediaArrays.js +0 -56
- package/dist/plugins/mediaArrays.js.map +0 -1
- package/dist/plugins/merge$css.d.ts +0 -6
- package/dist/plugins/merge$css.js +0 -45
- package/dist/plugins/merge$css.js.map +0 -1
- package/dist/plugins/propCasing.d.ts +0 -5
- package/dist/plugins/propCasing.js +0 -21
- package/dist/plugins/propCasing.js.map +0 -1
- package/dist/plugins/replace$$class.d.ts +0 -5
- package/dist/plugins/replace$$class.js +0 -20
- package/dist/plugins/replace$$class.js.map +0 -1
- package/dist/plugins/themeFunctions.d.ts +0 -5
- package/dist/plugins/themeFunctions.js +0 -20
- package/dist/plugins/themeFunctions.js.map +0 -1
- package/dist/styleCollector.d.ts +0 -8
- package/dist/styleCollector.js +0 -40
- package/dist/styleCollector.js.map +0 -1
- package/dist/stylesToRuleArray.d.ts +0 -5
- package/dist/stylesToRuleArray.js +0 -41
- package/dist/stylesToRuleArray.js.map +0 -1
- package/dist/types.js +0 -3
- package/dist/types.js.map +0 -1
- package/dist/useStyles.d.ts +0 -16
- package/dist/useStyles.js +0 -115
- package/dist/useStyles.js.map +0 -1
- package/dist/util/cloneDeep.d.ts +0 -4
- package/dist/util/cloneDeep.js +0 -28
- package/dist/util/cloneDeep.js.map +0 -1
- package/dist/util/flatten.d.ts +0 -4
- package/dist/util/flatten.js +0 -19
- package/dist/util/flatten.js.map +0 -1
- package/dist/util/hashString.d.ts +0 -4
- package/dist/util/hashString.js +0 -15
- package/dist/util/hashString.js.map +0 -1
- package/dist/util/isPlainObject.d.ts +0 -4
- package/dist/util/isPlainObject.js +0 -11
- package/dist/util/isPlainObject.js.map +0 -1
- package/dist/util/mapObjectRecursive.d.ts +0 -8
- package/dist/util/mapObjectRecursive.js +0 -37
- package/dist/util/mapObjectRecursive.js.map +0 -1
- package/dist/util/merge.d.ts +0 -5
- package/dist/util/merge.js +0 -31
- package/dist/util/merge.js.map +0 -1
- package/dist/util/useIsoLayoutEffect.d.ts +0 -2
- package/dist/util/useIsoLayoutEffect.js +0 -8
- package/dist/util/useIsoLayoutEffect.js.map +0 -1
- package/dist/util/walkRecursive.d.ts +0 -8
- package/dist/util/walkRecursive.js +0 -26
- package/dist/util/walkRecursive.js.map +0 -1
- package/exports.mjs +0 -8
package/dist/StylixProvider.d.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { StylixPlugin } from './plugins';
|
|
3
|
-
/**
|
|
4
|
-
* Stylix context
|
|
5
|
-
*
|
|
6
|
-
* The <StylixProvider> wrapper represents an "instance" of Stylix - a configuration, set of plugins, and reference to
|
|
7
|
-
* the <style> element where css is output. All nodes contained within a <StylixProvider> element will share this
|
|
8
|
-
* Stylix instance's configuration.
|
|
9
|
-
*
|
|
10
|
-
* A StylixProvider internally contains a <StylixTheme>, so you can conveniently provide a theme object and media query
|
|
11
|
-
* array with a single element.
|
|
12
|
-
*
|
|
13
|
-
* See the README for more details.
|
|
14
|
-
*/
|
|
15
|
-
type StylixProviderProps<Theme = any> = StylixThemeProps<Theme> & {
|
|
16
|
-
id?: string;
|
|
17
|
-
devMode?: boolean;
|
|
18
|
-
plugins?: StylixPlugin[] | StylixPlugin[][];
|
|
19
|
-
styleElement?: HTMLStyleElement;
|
|
20
|
-
children: any;
|
|
21
|
-
};
|
|
22
|
-
type StylixThemeProps<Theme = any> = {
|
|
23
|
-
theme?: Theme;
|
|
24
|
-
media?: string[];
|
|
25
|
-
children: any;
|
|
26
|
-
};
|
|
27
|
-
export type StylixContext<Theme = any> = {
|
|
28
|
-
id: string;
|
|
29
|
-
devMode: boolean;
|
|
30
|
-
theme: Theme;
|
|
31
|
-
media: string[];
|
|
32
|
-
plugins: StylixPlugin[];
|
|
33
|
-
stylesheet: CSSStyleSheet;
|
|
34
|
-
styleElement: HTMLStyleElement;
|
|
35
|
-
styleCollector?: string[];
|
|
36
|
-
rules: {
|
|
37
|
-
[key: string]: {
|
|
38
|
-
hash: string;
|
|
39
|
-
rules: string[];
|
|
40
|
-
refs: number;
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
styleProps: Record<string, string>;
|
|
44
|
-
cleanupRequest: number;
|
|
45
|
-
requestApply: boolean;
|
|
46
|
-
};
|
|
47
|
-
export type StylixPublicContext = Pick<StylixContext, 'id' | 'devMode' | 'theme' | 'media' | 'stylesheet' | 'styleElement' | 'styleProps'>;
|
|
48
|
-
export declare function useStylixContext<Theme = any>(): StylixContext<Theme>;
|
|
49
|
-
export declare function useStylixTheme<Theme = any>(): Theme;
|
|
50
|
-
export declare function StylixProvider({ id, devMode, plugins, styleElement, children, ...themeProps }: StylixProviderProps): React.ReactElement;
|
|
51
|
-
export declare function StylixTheme({ children, media, theme }: StylixThemeProps): JSX.Element;
|
|
52
|
-
export {};
|
package/dist/StylixProvider.js
DELETED
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
26
|
-
var t = {};
|
|
27
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
28
|
-
t[p] = s[p];
|
|
29
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
30
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
31
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
32
|
-
t[p[i]] = s[p[i]];
|
|
33
|
-
}
|
|
34
|
-
return t;
|
|
35
|
-
};
|
|
36
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
-
};
|
|
39
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
-
exports.StylixTheme = exports.StylixProvider = exports.useStylixTheme = exports.useStylixContext = void 0;
|
|
41
|
-
const react_1 = __importStar(require("react"));
|
|
42
|
-
const classifyProps_1 = require("./classifyProps");
|
|
43
|
-
const css_props_json_1 = __importDefault(require("./css-props.json"));
|
|
44
|
-
const plugins_1 = require("./plugins");
|
|
45
|
-
const styleCollector_1 = require("./styleCollector");
|
|
46
|
-
const flatten_1 = require("./util/flatten");
|
|
47
|
-
const merge_1 = require("./util/merge");
|
|
48
|
-
const useIsoLayoutEffect_1 = __importDefault(require("./util/useIsoLayoutEffect"));
|
|
49
|
-
const IS_DEV_ENV = process.env.NODE_ENV !== 'production';
|
|
50
|
-
const defaultStyleProps = {};
|
|
51
|
-
for (const value of css_props_json_1.default) {
|
|
52
|
-
defaultStyleProps[(0, classifyProps_1.simplifyStylePropName)(value)] = value;
|
|
53
|
-
}
|
|
54
|
-
function createStylixContext(userValues = {}) {
|
|
55
|
-
var _a, _b;
|
|
56
|
-
const ctx = {
|
|
57
|
-
id: userValues.id || Math.round(Math.random() * 10000).toString(10),
|
|
58
|
-
devMode: (_a = userValues.devMode) !== null && _a !== void 0 ? _a : IS_DEV_ENV,
|
|
59
|
-
styleProps: defaultStyleProps,
|
|
60
|
-
theme: userValues.theme || null,
|
|
61
|
-
media: userValues.media || null,
|
|
62
|
-
styleElement: userValues.styleElement,
|
|
63
|
-
plugins: (0, flatten_1.flatten)(Object.values(plugins_1.defaultPlugins)),
|
|
64
|
-
rules: {},
|
|
65
|
-
cleanupRequest: undefined,
|
|
66
|
-
};
|
|
67
|
-
if (!ctx.styleElement && typeof document !== 'undefined') {
|
|
68
|
-
ctx.styleElement = document.createElement('style');
|
|
69
|
-
if (ctx.id)
|
|
70
|
-
ctx.styleElement.id = 'stylix-' + ctx.id;
|
|
71
|
-
ctx.styleElement.className = 'stylix';
|
|
72
|
-
document.head.appendChild(ctx.styleElement);
|
|
73
|
-
}
|
|
74
|
-
if (ctx.styleElement)
|
|
75
|
-
ctx.stylesheet = ctx.styleElement.sheet;
|
|
76
|
-
if ((_b = userValues.plugins) === null || _b === void 0 ? void 0 : _b.length) {
|
|
77
|
-
const flatPlugins = (0, flatten_1.flatten)(userValues.plugins);
|
|
78
|
-
for (const i in flatPlugins) {
|
|
79
|
-
const plugin = flatPlugins[i];
|
|
80
|
-
let pluginIndex = -1;
|
|
81
|
-
if (plugin.before && ctx.plugins.includes(plugin.before))
|
|
82
|
-
pluginIndex = ctx.plugins.indexOf(plugin.before);
|
|
83
|
-
if (plugin.after && ctx.plugins.includes(plugin.after))
|
|
84
|
-
pluginIndex = ctx.plugins.indexOf(plugin.after) + 1;
|
|
85
|
-
if ('atIndex' in plugin)
|
|
86
|
-
pluginIndex = plugin.atIndex;
|
|
87
|
-
if (pluginIndex === -1)
|
|
88
|
-
ctx.plugins.push(plugin);
|
|
89
|
-
else
|
|
90
|
-
ctx.plugins.splice(pluginIndex, 0, plugin);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
(0, plugins_1.applyPlugins)('initialize', null, null, ctx);
|
|
94
|
-
return ctx;
|
|
95
|
-
}
|
|
96
|
-
// The React context object
|
|
97
|
-
const stylixContext = react_1.default.createContext(createStylixContext());
|
|
98
|
-
// Convenience wrapper hook that returns the current Stylix context
|
|
99
|
-
function useStylixContext() {
|
|
100
|
-
return (0, react_1.useContext)(stylixContext);
|
|
101
|
-
}
|
|
102
|
-
exports.useStylixContext = useStylixContext;
|
|
103
|
-
// Convenience wrapper hook that returns just the current Stylix theme
|
|
104
|
-
function useStylixTheme() {
|
|
105
|
-
return (0, react_1.useContext)(stylixContext).theme;
|
|
106
|
-
}
|
|
107
|
-
exports.useStylixTheme = useStylixTheme;
|
|
108
|
-
function StylixProvider(_a) {
|
|
109
|
-
var { id, devMode, plugins, styleElement, children } = _a, themeProps = __rest(_a, ["id", "devMode", "plugins", "styleElement", "children"]);
|
|
110
|
-
const ctx = (0, react_1.useRef)();
|
|
111
|
-
if (!ctx.current)
|
|
112
|
-
ctx.current = createStylixContext({ id, devMode, plugins, styleElement });
|
|
113
|
-
ctx.current.styleCollector = (0, react_1.useContext)(styleCollector_1.styleCollectorContext);
|
|
114
|
-
return (react_1.default.createElement(stylixContext.Provider, { value: ctx.current },
|
|
115
|
-
react_1.default.createElement(StylixTheme, Object.assign({}, themeProps), children)));
|
|
116
|
-
}
|
|
117
|
-
exports.StylixProvider = StylixProvider;
|
|
118
|
-
function mergeContexts(contextA, contextB) {
|
|
119
|
-
const obj = Object.assign({}, contextA);
|
|
120
|
-
const themeB = contextB.theme;
|
|
121
|
-
if (contextB) {
|
|
122
|
-
for (const key in contextB) {
|
|
123
|
-
const value = contextB[key];
|
|
124
|
-
if (typeof value !== 'undefined')
|
|
125
|
-
obj[key] = value;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
obj.theme = (0, merge_1.merge)(contextA.theme || {}, themeB);
|
|
129
|
-
return obj;
|
|
130
|
-
}
|
|
131
|
-
function StylixTheme({ children, media, theme }) {
|
|
132
|
-
const parentCtx = (0, react_1.useContext)(stylixContext);
|
|
133
|
-
const [contextValue, setContextValue] = (0, react_1.useState)(() => mergeContexts(parentCtx, { media, theme }));
|
|
134
|
-
// contextValue should only update (and cause re-renders) when relevant properties change.
|
|
135
|
-
// `media` is treated as special because providing an array of strings is easier to do inline,
|
|
136
|
-
// but we don't want to cause descendent re-renders if the values don't change.
|
|
137
|
-
(0, useIsoLayoutEffect_1.default)(() => {
|
|
138
|
-
setContextValue(mergeContexts(parentCtx, { media, theme }));
|
|
139
|
-
}, [parentCtx, (media === null || media === void 0 ? void 0 : media.join('|')) || '', theme], false);
|
|
140
|
-
return react_1.default.createElement(stylixContext.Provider, { value: contextValue }, children);
|
|
141
|
-
}
|
|
142
|
-
exports.StylixTheme = StylixTheme;
|
|
143
|
-
//# sourceMappingURL=StylixProvider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"StylixProvider.js","sourceRoot":"","sources":["../src/StylixProvider.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAA4D;AAE5D,mDAAwD;AACxD,sEAAwC;AACxC,uCAAuE;AACvE,qDAAyD;AACzD,4CAAyC;AACzC,wCAAqC;AACrC,mFAA2D;AAE3D,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAC;AAyDzD,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAC7B,KAAK,MAAM,KAAK,IAAI,wBAAQ,EAAE;IAC5B,iBAAiB,CAAC,IAAA,qCAAqB,EAAC,KAAK,CAAC,CAAC,GAAG,KAAK,CAAC;CACzD;AAED,SAAS,mBAAmB,CAAC,aAAa,EAAkC;;IAC1E,MAAM,GAAG,GAAG;QACV,EAAE,EAAE,UAAU,CAAC,EAAE,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC;QACnE,OAAO,EAAE,MAAA,UAAU,CAAC,OAAO,mCAAI,UAAU;QACzC,UAAU,EAAE,iBAAiB;QAC7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SAAS,EAAE,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,CAAC,GAAG,CAAC,KAAI,EAAE,EAAE,KAAK,CAAC,EAC1C,KAAK,CACN,CAAC;IAEF,OAAO,8BAAC,aAAa,CAAC,QAAQ,IAAC,KAAK,EAAE,YAAY,IAAG,QAAQ,CAA0B,CAAC;AAC1F,CAAC;AAnBD,kCAmBC"}
|
package/dist/applyRules.d.ts
DELETED
package/dist/applyRules.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/**
|
|
4
|
-
* Applies rules from given StylixContext to the <style> element.
|
|
5
|
-
*/
|
|
6
|
-
function applyRules(ctx) {
|
|
7
|
-
const flattenedRules = [];
|
|
8
|
-
for (const key in ctx.rules) {
|
|
9
|
-
const val = ctx.rules[key];
|
|
10
|
-
flattenedRules.push(...val.rules);
|
|
11
|
-
}
|
|
12
|
-
if (ctx.styleCollector) {
|
|
13
|
-
ctx.styleCollector.length = 0;
|
|
14
|
-
ctx.styleCollector.push(...flattenedRules);
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
if (ctx.devMode) {
|
|
18
|
-
ctx.styleElement.innerHTML = flattenedRules.join('\n');
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
const container = ctx.stylesheet;
|
|
22
|
-
if (container.rules)
|
|
23
|
-
while (container.rules.length) {
|
|
24
|
-
container.deleteRule(0);
|
|
25
|
-
}
|
|
26
|
-
for (const i in flattenedRules)
|
|
27
|
-
container.insertRule(flattenedRules[i], +i);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
exports.default = applyRules;
|
|
31
|
-
//# sourceMappingURL=applyRules.js.map
|
package/dist/applyRules.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"applyRules.js","sourceRoot":"","sources":["../src/applyRules.ts"],"names":[],"mappings":";;AAEA;;GAEG;AACH,SAAwB,UAAU,CAAC,GAAkB;IACnD,MAAM,cAAc,GAAa,EAAE,CAAC;IAEpC,KAAK,MAAM,GAAG,IAAI,GAAG,CAAC,KAAK,EAAE;QAC3B,MAAM,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC3B,cAAc,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC;KACnC;IAED,IAAI,GAAG,CAAC,cAAc,EAAE;QACtB,GAAG,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC;QAC9B,GAAG,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,cAAc,CAAC,CAAC;QAC3C,OAAO;KACR;IAED,IAAI,GAAG,CAAC,OAAO,EAAE;QACf,GAAG,CAAC,YAAY,CAAC,SAAS,GAAG,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;KACxD;SAAM;QACL,MAAM,SAAS,GAAG,GAAG,CAAC,UAAU,CAAC;QACjC,IAAI,SAAS,CAAC,KAAK;YACjB,OAAO,SAAS,CAAC,KAAK,CAAC,MAAM,EAAE;gBAC7B,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;aACzB;QACH,KAAK,MAAM,CAAC,IAAI,cAAc;YAAE,SAAS,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;KAC7E;AACH,CAAC;AAxBD,6BAwBC"}
|
package/dist/classifyProps.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export declare function classifyProps(props: any, knownProps: Record<string, string>): [any, any];
|
|
2
|
-
/**
|
|
3
|
-
* Determines if `value` is a recognized CSS property (can be standard CSS or custom Stylix prop).
|
|
4
|
-
*/
|
|
5
|
-
export declare function isStyleProp(value: string, knownProps: Record<string, string>): boolean;
|
|
6
|
-
export declare function isValidJSXProp(value: string): boolean;
|
|
7
|
-
export declare function simplifyStylePropName(value: string): string;
|
package/dist/classifyProps.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.simplifyStylePropName = exports.isValidJSXProp = exports.isStyleProp = exports.classifyProps = void 0;
|
|
4
|
-
function classifyProps(props, knownProps) {
|
|
5
|
-
const styles = {};
|
|
6
|
-
const other = {};
|
|
7
|
-
for (const key in props) {
|
|
8
|
-
// If prop is not a valid JSX prop, it must be a CSS selector
|
|
9
|
-
if (!isValidJSXProp(key) || isStyleProp(key, knownProps)) {
|
|
10
|
-
styles[key] = props[key];
|
|
11
|
-
}
|
|
12
|
-
else {
|
|
13
|
-
other[key] = props[key];
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
return [styles, other];
|
|
17
|
-
}
|
|
18
|
-
exports.classifyProps = classifyProps;
|
|
19
|
-
/**
|
|
20
|
-
* Determines if `value` is a recognized CSS property (can be standard CSS or custom Stylix prop).
|
|
21
|
-
*/
|
|
22
|
-
function isStyleProp(value, knownProps) {
|
|
23
|
-
return isValidJSXProp(value) && simplifyStylePropName(value) in knownProps;
|
|
24
|
-
}
|
|
25
|
-
exports.isStyleProp = isStyleProp;
|
|
26
|
-
function isValidJSXProp(value) {
|
|
27
|
-
// Not an exact check, but mostly rules out complex css selectors
|
|
28
|
-
return /^[a-z$][a-z0-9_-]*$/i.test(value);
|
|
29
|
-
}
|
|
30
|
-
exports.isValidJSXProp = isValidJSXProp;
|
|
31
|
-
function simplifyStylePropName(value) {
|
|
32
|
-
return value.toLowerCase().replace(/[^a-z]/gi, '');
|
|
33
|
-
}
|
|
34
|
-
exports.simplifyStylePropName = simplifyStylePropName;
|
|
35
|
-
//# sourceMappingURL=classifyProps.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"classifyProps.js","sourceRoot":"","sources":["../src/classifyProps.ts"],"names":[],"mappings":";;;AAAA,SAAgB,aAAa,CAAC,KAAU,EAAE,UAAkC;IAC1E,MAAM,MAAM,GAAG,EAAS,CAAC;IACzB,MAAM,KAAK,GAAG,EAAS,CAAC;IAExB,KAAK,MAAM,GAAG,IAAI,KAAK,EAAE;QACvB,6DAA6D;QAC7D,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,IAAI,WAAW,CAAC,GAAG,EAAE,UAAU,CAAC,EAAE;YACxD,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;SAC1B;aAAM;YACL,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;SACzB;KACF;IAED,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AACzB,CAAC;AAdD,sCAcC;AAED;;GAEG;AACH,SAAgB,WAAW,CAAC,KAAa,EAAE,UAAkC;IAC3E,OAAO,cAAc,CAAC,KAAK,CAAC,IAAI,qBAAqB,CAAC,KAAK,CAAC,IAAI,UAAU,CAAC;AAC7E,CAAC;AAFD,kCAEC;AAED,SAAgB,cAAc,CAAC,KAAa;IAC1C,iEAAiE;IACjE,OAAO,sBAAsB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC5C,CAAC;AAHD,wCAGC;AAED,SAAgB,qBAAqB,CAAC,KAAa;IACjD,OAAO,KAAK,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;AACrD,CAAC;AAFD,sDAEC"}
|