0.2.0 - Mid migration

This commit is contained in:
Daniel Mason 2022-04-25 14:47:15 +12:00
parent 139e6a915e
commit 7e38fdbd7d
42393 changed files with 5358157 additions and 62 deletions

View file

@ -0,0 +1,8 @@
The MIT License (MIT)
Copyright (c) 2014-present Oleg Isonen (Slobodskoi) & contributors
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:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
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.

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,76 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var warning = require('tiny-warning');
var jss = require('jss');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var warning__default = /*#__PURE__*/_interopDefaultLegacy(warning);
var now = Date.now();
var fnValuesNs = "fnValues" + now;
var fnRuleNs = "fnStyle" + ++now;
var functionPlugin = function functionPlugin() {
return {
onCreateRule: function onCreateRule(name, decl, options) {
if (typeof decl !== 'function') return null;
var rule = jss.createRule(name, {}, options);
rule[fnRuleNs] = decl;
return rule;
},
onProcessStyle: function onProcessStyle(style, rule) {
// We need to extract function values from the declaration, so that we can keep core unaware of them.
// We need to do that only once.
// We don't need to extract functions on each style update, since this can happen only once.
// We don't support function values inside of function rules.
if (fnValuesNs in rule || fnRuleNs in rule) return style;
var fnValues = {};
for (var prop in style) {
var value = style[prop];
if (typeof value !== 'function') continue;
delete style[prop];
fnValues[prop] = value;
} // $FlowFixMe[prop-missing]
rule[fnValuesNs] = fnValues;
return style;
},
onUpdate: function onUpdate(data, rule, sheet, options) {
var styleRule = rule; // $FlowFixMe[prop-missing]
var fnRule = styleRule[fnRuleNs]; // If we have a style function, the entire rule is dynamic and style object
// will be returned from that function.
if (fnRule) {
// Empty object will remove all currently defined props
// in case function rule returns a falsy value.
styleRule.style = fnRule(data) || {};
if (process.env.NODE_ENV === 'development') {
for (var prop in styleRule.style) {
if (typeof styleRule.style[prop] === 'function') {
process.env.NODE_ENV !== "production" ? warning__default['default'](false, '[JSS] Function values inside function rules are not supported.') : void 0;
break;
}
}
}
} // $FlowFixMe[prop-missing]
var fnValues = styleRule[fnValuesNs]; // If we have a fn values map, it is a rule with function values.
if (fnValues) {
for (var _prop in fnValues) {
styleRule.prop(_prop, fnValues[_prop](data), options);
}
}
}
};
};
exports.default = functionPlugin;

View file

@ -0,0 +1,3 @@
// @flow
export * from '../src';

View file

@ -0,0 +1,68 @@
import warning from 'tiny-warning';
import { createRule } from 'jss';
var now = Date.now();
var fnValuesNs = "fnValues" + now;
var fnRuleNs = "fnStyle" + ++now;
var functionPlugin = function functionPlugin() {
return {
onCreateRule: function onCreateRule(name, decl, options) {
if (typeof decl !== 'function') return null;
var rule = createRule(name, {}, options);
rule[fnRuleNs] = decl;
return rule;
},
onProcessStyle: function onProcessStyle(style, rule) {
// We need to extract function values from the declaration, so that we can keep core unaware of them.
// We need to do that only once.
// We don't need to extract functions on each style update, since this can happen only once.
// We don't support function values inside of function rules.
if (fnValuesNs in rule || fnRuleNs in rule) return style;
var fnValues = {};
for (var prop in style) {
var value = style[prop];
if (typeof value !== 'function') continue;
delete style[prop];
fnValues[prop] = value;
} // $FlowFixMe[prop-missing]
rule[fnValuesNs] = fnValues;
return style;
},
onUpdate: function onUpdate(data, rule, sheet, options) {
var styleRule = rule; // $FlowFixMe[prop-missing]
var fnRule = styleRule[fnRuleNs]; // If we have a style function, the entire rule is dynamic and style object
// will be returned from that function.
if (fnRule) {
// Empty object will remove all currently defined props
// in case function rule returns a falsy value.
styleRule.style = fnRule(data) || {};
if (process.env.NODE_ENV === 'development') {
for (var prop in styleRule.style) {
if (typeof styleRule.style[prop] === 'function') {
process.env.NODE_ENV !== "production" ? warning(false, '[JSS] Function values inside function rules are not supported.') : void 0;
break;
}
}
}
} // $FlowFixMe[prop-missing]
var fnValues = styleRule[fnValuesNs]; // If we have a fn values map, it is a rule with function values.
if (fnValues) {
for (var _prop in fnValues) {
styleRule.prop(_prop, fnValues[_prop](data), options);
}
}
}
};
};
export default functionPlugin;

View file

@ -0,0 +1,94 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('jss')) :
typeof define === 'function' && define.amd ? define(['exports', 'jss'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.jssPluginRuleValueFunction = {}, global.jss));
}(this, (function (exports, jss) { 'use strict';
function warning(condition, message) {
{
if (condition) {
return;
}
var text = "Warning: " + message;
if (typeof console !== 'undefined') {
console.warn(text);
}
try {
throw Error(text);
} catch (x) {}
}
}
var now = Date.now();
var fnValuesNs = "fnValues" + now;
var fnRuleNs = "fnStyle" + ++now;
var functionPlugin = function functionPlugin() {
return {
onCreateRule: function onCreateRule(name, decl, options) {
if (typeof decl !== 'function') return null;
var rule = jss.createRule(name, {}, options);
rule[fnRuleNs] = decl;
return rule;
},
onProcessStyle: function onProcessStyle(style, rule) {
// We need to extract function values from the declaration, so that we can keep core unaware of them.
// We need to do that only once.
// We don't need to extract functions on each style update, since this can happen only once.
// We don't support function values inside of function rules.
if (fnValuesNs in rule || fnRuleNs in rule) return style;
var fnValues = {};
for (var prop in style) {
var value = style[prop];
if (typeof value !== 'function') continue;
delete style[prop];
fnValues[prop] = value;
} // $FlowFixMe[prop-missing]
rule[fnValuesNs] = fnValues;
return style;
},
onUpdate: function onUpdate(data, rule, sheet, options) {
var styleRule = rule; // $FlowFixMe[prop-missing]
var fnRule = styleRule[fnRuleNs]; // If we have a style function, the entire rule is dynamic and style object
// will be returned from that function.
if (fnRule) {
// Empty object will remove all currently defined props
// in case function rule returns a falsy value.
styleRule.style = fnRule(data) || {};
{
for (var prop in styleRule.style) {
if (typeof styleRule.style[prop] === 'function') {
warning(false, '[JSS] Function values inside function rules are not supported.') ;
break;
}
}
}
} // $FlowFixMe[prop-missing]
var fnValues = styleRule[fnValuesNs]; // If we have a fn values map, it is a rule with function values.
if (fnValues) {
for (var _prop in fnValues) {
styleRule.prop(_prop, fnValues[_prop](data), options);
}
}
}
};
};
exports.default = functionPlugin;
Object.defineProperty(exports, '__esModule', { value: true });
})));
//# sourceMappingURL=jss-plugin-rule-value-function.js.map

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1 @@
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("jss")):"function"==typeof define&&define.amd?define(["exports","jss"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).jssPluginRuleValueFunction={},e.jss)}(this,(function(e,n){"use strict";var t=Date.now(),o="fnValues"+t,r="fnStyle"+ ++t;e.default=function(){return{onCreateRule:function(e,t,o){if("function"!=typeof t)return null;var f=n.createRule(e,{},o);return f[r]=t,f},onProcessStyle:function(e,n){if(o in n||r in n)return e;var t={};for(var f in e){var u=e[f];"function"==typeof u&&(delete e[f],t[f]=u)}return n[o]=t,e},onUpdate:function(e,n,t,f){var u=n,i=u[r];i&&(u.style=i(e)||{});var s=u[o];if(s)for(var l in s)u.prop(l,s[l](e),f)}}},Object.defineProperty(e,"__esModule",{value:!0})}));

View file

@ -0,0 +1,50 @@
{
"name": "jss-plugin-rule-value-function",
"description": "JSS plugin for function value and rule syntax",
"version": "10.7.1",
"license": "MIT",
"homepage": "https://cssinjs.org/",
"main": "dist/jss-plugin-rule-value-function.cjs.js",
"module": "dist/jss-plugin-rule-value-function.esm.js",
"unpkg": "dist/jss-plugin-rule-value-function.bundle.js",
"sideEffects": false,
"typings": "./src/index.d.ts",
"author": "JSS Team",
"repository": {
"type": "git",
"url": "https://github.com/cssinjs/jss"
},
"bugs": {
"url": "https://github.com/cssinjs/jss/issues/new?title=[jss-plugin-rule-value-function]"
},
"files": [
"dist",
"src",
"!*.test.*"
],
"keywords": [
"jss",
"style",
"sheet",
"stylesheet",
"css",
"components",
"composable",
"css in js",
"css-in-js",
"dynamic",
"function",
"reactive",
"animation"
],
"scripts": {
"build": "node ../../scripts/build.js",
"check-snapshot": "node ../../scripts/match-snapshot.js"
},
"dependencies": {
"@babel/runtime": "^7.3.1",
"jss": "10.7.1",
"tiny-warning": "^1.0.2"
},
"gitHead": "2b54776c03d97a3bccbbcb28b63508f74103ebbc"
}

View file

@ -0,0 +1,25 @@
# jss-plugin-rule-value-function
[![Version](https://img.shields.io/npm/v/jss-plugin-rule-value-function.svg?style=flat)](https://npmjs.org/package/jss-plugin-rule-value-function)
[![License](https://img.shields.io/npm/l/jss-plugin-rule-value-function.svg?style=flat)](https://github.com/cssinjs/jss/blob/master/LICENSE)
[![Downlodas](https://img.shields.io/npm/dm/jss-plugin-rule-value-function.svg?style=flat)](https://npmjs.org/package/jss-plugin-rule-value-function)
[![Size](https://img.shields.io/bundlephobia/minzip/jss-plugin-rule-value-function.svg?style=flat)](https://npmjs.org/package/jss-plugin-rule-value-function)
[![Dependencies](https://img.shields.io/david/cssinjs/jss.svg?path=packages%2Fjss-plugin-rule-value-function&style=flat)](https://npmjs.org/package/jss-plugin-rule-value-function)
> JSS plugin for function value and rule syntax
See our website [jss-plugin-rule-value-function](https://cssinjs.org/jss-plugin-rule-value-function?v=v10.7.1) for more information.
## Install
Using npm:
```sh
npm install jss-plugin-rule-value-function
```
or using yarn:
```sh
yarn add jss-plugin-rule-value-function
```

View file

@ -0,0 +1,3 @@
import {Plugin} from 'jss'
export default function jssPluginSyntaxRuleValueFunction(): Plugin

View file

@ -0,0 +1,85 @@
// @flow
import warning from 'tiny-warning'
import {
createRule,
type Rule,
type JssStyle,
type RuleOptions,
type UpdateOptions,
type StyleRule,
type StyleSheet,
type Plugin
} from 'jss'
// A symbol replacement.
let now = Date.now()
const fnValuesNs = `fnValues${now}`
const fnRuleNs = `fnStyle${++now}`
type StyleRuleWithRuleFunction = StyleRule & {[key: string]: Function}
type FunctionPlugin = () => Plugin
const functionPlugin: FunctionPlugin = () => ({
onCreateRule(name?: string, decl: JssStyle, options: RuleOptions): Rule | null {
if (typeof decl !== 'function') return null
const rule: StyleRuleWithRuleFunction = (createRule(name, {}, options): any)
rule[fnRuleNs] = decl
return rule
},
onProcessStyle(style: JssStyle, rule: Rule): JssStyle {
// We need to extract function values from the declaration, so that we can keep core unaware of them.
// We need to do that only once.
// We don't need to extract functions on each style update, since this can happen only once.
// We don't support function values inside of function rules.
if (fnValuesNs in rule || fnRuleNs in rule) return style
const fnValues = {}
for (const prop in style) {
const value = style[prop]
if (typeof value !== 'function') continue
delete style[prop]
fnValues[prop] = value
}
// $FlowFixMe[prop-missing]
rule[fnValuesNs] = fnValues
return style
},
onUpdate(data: Object, rule: Rule, sheet?: StyleSheet, options: UpdateOptions) {
const styleRule: StyleRule = (rule: any)
// $FlowFixMe[prop-missing]
const fnRule = styleRule[fnRuleNs]
// If we have a style function, the entire rule is dynamic and style object
// will be returned from that function.
if (fnRule) {
// Empty object will remove all currently defined props
// in case function rule returns a falsy value.
styleRule.style = fnRule(data) || {}
if (process.env.NODE_ENV === 'development') {
for (const prop in styleRule.style) {
if (typeof styleRule.style[prop] === 'function') {
warning(false, '[JSS] Function values inside function rules are not supported.')
break
}
}
}
}
// $FlowFixMe[prop-missing]
const fnValues = styleRule[fnValuesNs]
// If we have a fn values map, it is a rule with function values.
if (fnValues) {
for (const prop in fnValues) {
styleRule.prop(prop, fnValues[prop](data), options)
}
}
}
})
export default functionPlugin