Initial commit
This commit is contained in:
21
node_modules/react-style-singleton/dist/es5/component.d.ts
generated
vendored
Normal file
21
node_modules/react-style-singleton/dist/es5/component.d.ts
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
import * as React from 'react';
|
||||
declare type Props = {
|
||||
/**
|
||||
* styles to apply
|
||||
*/
|
||||
styles: string;
|
||||
/**
|
||||
* marks style as dynamic, so it will be reapplied on styles change
|
||||
* note: this is not expected behavior from a "singleton"
|
||||
* @default false
|
||||
*/
|
||||
dynamic?: boolean;
|
||||
};
|
||||
/**
|
||||
* create a Component to add styles on demand
|
||||
* - styles are added when first instance is mounted
|
||||
* - styles are removed when the last instance is unmounted
|
||||
* - changing styles in runtime does nothing unless dynamic is set. But with multiple components that can lead to the undefined behavior
|
||||
*/
|
||||
export declare const styleSingleton: () => React.FC<Props>;
|
||||
export {};
|
||||
20
node_modules/react-style-singleton/dist/es5/component.js
generated
vendored
Normal file
20
node_modules/react-style-singleton/dist/es5/component.js
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.styleSingleton = void 0;
|
||||
var hook_1 = require("./hook");
|
||||
/**
|
||||
* create a Component to add styles on demand
|
||||
* - styles are added when first instance is mounted
|
||||
* - styles are removed when the last instance is unmounted
|
||||
* - changing styles in runtime does nothing unless dynamic is set. But with multiple components that can lead to the undefined behavior
|
||||
*/
|
||||
var styleSingleton = function () {
|
||||
var useStyle = (0, hook_1.styleHookSingleton)();
|
||||
var Sheet = function (_a) {
|
||||
var styles = _a.styles, dynamic = _a.dynamic;
|
||||
useStyle(styles, dynamic);
|
||||
return null;
|
||||
};
|
||||
return Sheet;
|
||||
};
|
||||
exports.styleSingleton = styleSingleton;
|
||||
23
node_modules/react-style-singleton/dist/es5/hook.d.ts
generated
vendored
Normal file
23
node_modules/react-style-singleton/dist/es5/hook.d.ts
generated
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
/**
|
||||
* creates a style on demand
|
||||
*/
|
||||
declare type StyleSingletonHook = (
|
||||
/**
|
||||
* styles to create
|
||||
*/
|
||||
styles: string,
|
||||
/**
|
||||
* indication that styles should be reapplied on change
|
||||
*/
|
||||
isDynamic?: boolean) => void;
|
||||
/**
|
||||
* creates a hook to control style singleton
|
||||
* @see {@link styleSingleton} for a safer component version
|
||||
* @example
|
||||
* ```tsx
|
||||
* const useStyle = styleHookSingleton();
|
||||
* ///
|
||||
* useStyle('body { overflow: hidden}');
|
||||
*/
|
||||
export declare const styleHookSingleton: () => StyleSingletonHook;
|
||||
export {};
|
||||
27
node_modules/react-style-singleton/dist/es5/hook.js
generated
vendored
Normal file
27
node_modules/react-style-singleton/dist/es5/hook.js
generated
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.styleHookSingleton = void 0;
|
||||
var tslib_1 = require("tslib");
|
||||
var React = tslib_1.__importStar(require("react"));
|
||||
var singleton_1 = require("./singleton");
|
||||
/**
|
||||
* creates a hook to control style singleton
|
||||
* @see {@link styleSingleton} for a safer component version
|
||||
* @example
|
||||
* ```tsx
|
||||
* const useStyle = styleHookSingleton();
|
||||
* ///
|
||||
* useStyle('body { overflow: hidden}');
|
||||
*/
|
||||
var styleHookSingleton = function () {
|
||||
var sheet = (0, singleton_1.stylesheetSingleton)();
|
||||
return function (styles, isDynamic) {
|
||||
React.useEffect(function () {
|
||||
sheet.add(styles);
|
||||
return function () {
|
||||
sheet.remove();
|
||||
};
|
||||
}, [styles && isDynamic]);
|
||||
};
|
||||
};
|
||||
exports.styleHookSingleton = styleHookSingleton;
|
||||
3
node_modules/react-style-singleton/dist/es5/index.d.ts
generated
vendored
Normal file
3
node_modules/react-style-singleton/dist/es5/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
export { styleSingleton } from './component';
|
||||
export { stylesheetSingleton } from './singleton';
|
||||
export { styleHookSingleton } from './hook';
|
||||
9
node_modules/react-style-singleton/dist/es5/index.js
generated
vendored
Normal file
9
node_modules/react-style-singleton/dist/es5/index.js
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.styleHookSingleton = exports.stylesheetSingleton = exports.styleSingleton = void 0;
|
||||
var component_1 = require("./component");
|
||||
Object.defineProperty(exports, "styleSingleton", { enumerable: true, get: function () { return component_1.styleSingleton; } });
|
||||
var singleton_1 = require("./singleton");
|
||||
Object.defineProperty(exports, "stylesheetSingleton", { enumerable: true, get: function () { return singleton_1.stylesheetSingleton; } });
|
||||
var hook_1 = require("./hook");
|
||||
Object.defineProperty(exports, "styleHookSingleton", { enumerable: true, get: function () { return hook_1.styleHookSingleton; } });
|
||||
4
node_modules/react-style-singleton/dist/es5/singleton.d.ts
generated
vendored
Normal file
4
node_modules/react-style-singleton/dist/es5/singleton.d.ts
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
export declare const stylesheetSingleton: () => {
|
||||
add: (style: string) => void;
|
||||
remove: () => void;
|
||||
};
|
||||
52
node_modules/react-style-singleton/dist/es5/singleton.js
generated
vendored
Normal file
52
node_modules/react-style-singleton/dist/es5/singleton.js
generated
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.stylesheetSingleton = void 0;
|
||||
var get_nonce_1 = require("get-nonce");
|
||||
function makeStyleTag() {
|
||||
if (!document)
|
||||
return null;
|
||||
var tag = document.createElement('style');
|
||||
tag.type = 'text/css';
|
||||
var nonce = (0, get_nonce_1.getNonce)();
|
||||
if (nonce) {
|
||||
tag.setAttribute('nonce', nonce);
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
function injectStyles(tag, css) {
|
||||
// @ts-ignore
|
||||
if (tag.styleSheet) {
|
||||
// @ts-ignore
|
||||
tag.styleSheet.cssText = css;
|
||||
}
|
||||
else {
|
||||
tag.appendChild(document.createTextNode(css));
|
||||
}
|
||||
}
|
||||
function insertStyleTag(tag) {
|
||||
var head = document.head || document.getElementsByTagName('head')[0];
|
||||
head.appendChild(tag);
|
||||
}
|
||||
var stylesheetSingleton = function () {
|
||||
var counter = 0;
|
||||
var stylesheet = null;
|
||||
return {
|
||||
add: function (style) {
|
||||
if (counter == 0) {
|
||||
if ((stylesheet = makeStyleTag())) {
|
||||
injectStyles(stylesheet, style);
|
||||
insertStyleTag(stylesheet);
|
||||
}
|
||||
}
|
||||
counter++;
|
||||
},
|
||||
remove: function () {
|
||||
counter--;
|
||||
if (!counter && stylesheet) {
|
||||
stylesheet.parentNode && stylesheet.parentNode.removeChild(stylesheet);
|
||||
stylesheet = null;
|
||||
}
|
||||
},
|
||||
};
|
||||
};
|
||||
exports.stylesheetSingleton = stylesheetSingleton;
|
||||
Reference in New Issue
Block a user