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

8
web/node_modules/jss/LICENSE generated vendored Normal file
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.

2333
web/node_modules/jss/dist/jss.bundle.js generated vendored Normal file

File diff suppressed because it is too large Load diff

2279
web/node_modules/jss/dist/jss.cjs.js generated vendored Normal file

File diff suppressed because it is too large Load diff

3
web/node_modules/jss/dist/jss.cjs.js.flow generated vendored Normal file
View file

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

2256
web/node_modules/jss/dist/jss.esm.js generated vendored Normal file

File diff suppressed because it is too large Load diff

2353
web/node_modules/jss/dist/jss.js generated vendored Normal file

File diff suppressed because it is too large Load diff

1
web/node_modules/jss/dist/jss.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

8
web/node_modules/jss/dist/jss.min.js generated vendored Normal file

File diff suppressed because one or more lines are too long

19
web/node_modules/jss/node_modules/csstype/LICENSE generated vendored Normal file
View file

@ -0,0 +1,19 @@
Copyright (c) 2017-2018 Fredrik Nicol
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.

273
web/node_modules/jss/node_modules/csstype/README.md generated vendored Normal file
View file

@ -0,0 +1,273 @@
# CSSType
[![npm](https://img.shields.io/npm/v/csstype.svg)](https://www.npmjs.com/package/csstype)
TypeScript and Flow definitions for CSS, generated by [data from MDN](https://github.com/mdn/data). It provides autocompletion and type checking for CSS properties and values.
**TypeScript**
```ts
import * as CSS from 'csstype';
const style: CSS.Properties = {
colour: 'white', // Type error on property
textAlign: 'middle', // Type error on value
};
```
**Flow**
```js
// @flow strict
import * as CSS from 'csstype';
const style: CSS.Properties<> = {
colour: 'white', // Type error on property
textAlign: 'middle', // Type error on value
};
```
_Further examples below will be in TypeScript!_
## Getting started
```sh
$ npm install csstype
$ # or
$ yarn add csstype
```
## Table of content
- [Style types](#style-types)
- [At-rule types](#at-rule-types)
- [Pseudo types](#pseudo-types)
- [Generics](#generics)
- [Usage](#usage)
- [What should I do when I get type errors?](#what-should-i-do-when-i-get-type-errors)
- [Version 3.0](#version-30)
- [Contributing](#contributing)
## Style types
Properties are categorized in different uses and in several technical variations to provide typings that suits as many as possible.
| | Default | `Hyphen` | `Fallback` | `HyphenFallback` |
| -------------- | -------------------- | -------------------------- | ---------------------------- | ---------------------------------- |
| **All** | `Properties` | `PropertiesHyphen` | `PropertiesFallback` | `PropertiesHyphenFallback` |
| **`Standard`** | `StandardProperties` | `StandardPropertiesHyphen` | `StandardPropertiesFallback` | `StandardPropertiesHyphenFallback` |
| **`Vendor`** | `VendorProperties` | `VendorPropertiesHyphen` | `VendorPropertiesFallback` | `VendorPropertiesHyphenFallback` |
| **`Obsolete`** | `ObsoleteProperties` | `ObsoletePropertiesHyphen` | `ObsoletePropertiesFallback` | `ObsoletePropertiesHyphenFallback` |
| **`Svg`** | `SvgProperties` | `SvgPropertiesHyphen` | `SvgPropertiesFallback` | `SvgPropertiesHyphenFallback` |
Categories:
- **All** - Includes `Standard`, `Vendor`, `Obsolete` and `Svg`
- **`Standard`** - Current properties and extends subcategories `StandardLonghand` and `StandardShorthand` _(e.g. `StandardShorthandProperties`)_
- **`Vendor`** - Vendor prefixed properties and extends subcategories `VendorLonghand` and `VendorShorthand` _(e.g. `VendorShorthandProperties`)_
- **`Obsolete`** - Removed or deprecated properties
- **`Svg`** - SVG-specific properties
Variations:
- **Default** - JavaScript (camel) cased property names
- **`Hyphen`** - CSS (kebab) cased property names
- **`Fallback`** - Also accepts array of values e.g. `string | string[]`
## At-rule types
At-rule interfaces with descriptors.
**TypeScript**: These will be found in the `AtRule` namespace, e.g. `AtRule.Viewport`.
**Flow**: These will be prefixed with `AtRule$`, e.g. `AtRule$Viewport`.
| | Default | `Hyphen` | `Fallback` | `HyphenFallback` |
| -------------------- | -------------- | -------------------- | ---------------------- | ---------------------------- |
| **`@counter-style`** | `CounterStyle` | `CounterStyleHyphen` | `CounterStyleFallback` | `CounterStyleHyphenFallback` |
| **`@font-face`** | `FontFace` | `FontFaceHyphen` | `FontFaceFallback` | `FontFaceHyphenFallback` |
| **`@viewport`** | `Viewport` | `ViewportHyphen` | `ViewportFallback` | `ViewportHyphenFallback` |
## Pseudo types
String literals of pseudo classes and pseudo elements
- `Pseudos`
Extends:
- `AdvancedPseudos`
Function-like pseudos e.g. `:not(:first-child)`. The string literal contains the value excluding the parenthesis: `:not`. These are separated because they require an argument that results in infinite number of variations.
- `SimplePseudos`
Plain pseudos e.g. `:hover` that can only be **one** variation.
## Generics
All interfaces has two optional generic argument to define length and time: `CSS.Properties<TLength = string | 0, TTime = string>`
- **Length** is the first generic parameter and defaults to `string | 0` because `0` is the only [length where the unit identifier is optional](https://drafts.csswg.org/css-values-3/#lengths). You can specify this, e.g. `string | number`, for platforms and libraries that accepts any numeric value as length with a specific unit.
```tsx
const style: CSS.Properties<string | number> = {
width: 100,
};
```
- **Time** is the second generic argument and defaults to `string`. You can specify this, e.g. `string | number`, for platforms and libraries that accepts any numeric value as length with a specific unit.
```tsx
const style: CSS.Properties<string | number, number> = {
transitionDuration: 1000,
};
```
## Usage
```ts
import * as CSS from 'csstype';
const style: CSS.Properties = {
width: '10px',
margin: '1em',
};
```
In some cases, like for CSS-in-JS libraries, an array of values is a way to provide fallback values in CSS. Using `CSS.PropertiesFallback` instead of `CSS.Properties` will add the possibility to use any property value as an array of values.
```ts
import * as CSS from 'csstype';
const style: CSS.PropertiesFallback = {
display: ['-webkit-flex', 'flex'],
color: 'white',
};
```
There's even string literals for pseudo selectors and elements.
```ts
import * as CSS from 'csstype';
const pseudos: { [P in CSS.SimplePseudos]?: CSS.Properties } = {
':hover': {
display: 'flex',
},
};
```
Hyphen cased (kebab cased) properties are provided in `CSS.PropertiesHyphen` and `CSS.PropertiesHyphenFallback`. It's not **not** added by default in `CSS.Properties`. To allow both of them, you can simply extend with `CSS.PropertiesHyphen` or/and `CSS.PropertiesHyphenFallback`.
```ts
import * as CSS from 'csstype';
interface Style extends CSS.Properties, CSS.PropertiesHyphen {}
const style: Style = {
'flex-grow': 1,
'flex-shrink': 0,
'font-weight': 'normal',
backgroundColor: 'white',
};
```
Adding type checked CSS properties to a `HTMLElement`.
```ts
import * as CSS from 'csstype';
const style: CSS.Properties = {
color: 'red',
margin: '1em',
};
let button = document.createElement('button');
Object.assign(button.style, style);
```
## What should I do when I get type errors?
The goal is to have as perfect types as possible and we're trying to do our best. But with CSS Custom Properties, the CSS specification changing frequently and vendors implementing their own specifications with new releases sometimes causes type errors even if it should work. Here's some steps you could take to get it fixed:
_If you're using CSS Custom Properties you can step directly to step 3._
1. **First of all, make sure you're doing it right.** A type error could also indicate that you're not :wink:
- Some CSS specs that some vendors has implemented could have been officially rejected or haven't yet received any official acceptance and are therefor not included
- If you're using TypeScript, [type widening](https://blog.mariusschulz.com/2017/02/04/TypeScript-2-1-literal-type-widening) could be the reason you get `Type 'string' is not assignable to...` errors
2. **Have a look in [issues](https://github.com/frenic/csstype/issues) to see if an issue already has been filed. If not, create a new one.** To help us out, please refer to any information you have found.
3. Fix the issue locally with **TypeScript** (Flow further down):
- The recommended way is to use **module augmentation**. Here's a few examples:
```ts
// My css.d.ts file
import * as CSS from 'csstype';
declare module 'csstype' {
interface Properties {
// Add a missing property
WebkitRocketLauncher?: string;
// Add a CSS Custom Property
'--theme-color'?: 'black' | 'white';
// ...or allow any other property
[index: string]: any;
}
}
```
- The alternative way is to use **type assertion**. Here's a few examples:
```ts
const style: CSS.Properties = {
// Add a missing property
['WebkitRocketLauncher' as any]: 'launching',
// Add a CSS Custom Property
['--theme-color' as any]: 'black',
};
```
Fix the issue locally with **Flow**:
- Use **type assertion**. Here's a few examples:
```js
const style: $Exact<CSS.Properties<*>> = {
// Add a missing property
[('WebkitRocketLauncher': any)]: 'launching',
// Add a CSS Custom Property
[('--theme-color': any)]: 'black',
};
```
## Version 3.0
- **All property types are exposed with namespace**
TypeScript: `Property.AlignContent` (was `AlignContentProperty` before)
Flow: `Property$AlignContent`
- **All at-rules are exposed with namespace**
TypeScript: `AtRule.FontFace` (was `FontFace` before)
Flow: `AtRule$FontFace`
- **Data types are NOT exposed**
E.g. `Color` and `Box`. Because the generation of data types may suddenly be removed or renamed.
- **TypeScript hack for autocompletion**
Uses `(string & {})` for literal string unions and `(number & {})` for literal number unions ([related issue](https://github.com/microsoft/TypeScript/issues/29729)). Utilize `PropertyValue<T>` to unpack types from e.g. `(string & {})` to `string`.
- **New generic for time**
Read more on the ["Generics"](#generics) section.
- **Flow types improvements**
Flow Strict enabled and exact types are used.
## Contributing
**Never modify `index.d.ts` and `index.js.flow` directly. They are generated automatically and committed so that we can easily follow any change it results in.** Therefor it's important that you run `$ git config merge.ours.driver true` after you've forked and cloned. That setting prevents merge conflicts when doing rebase.
### Commands
- `yarn build` Generates typings and type checks them
- `yarn watch` Runs build on each save
- `yarn test` Runs the tests
- `yarn lazy` Type checks, lints and formats everything

20553
web/node_modules/jss/node_modules/csstype/index.d.ts generated vendored Normal file

File diff suppressed because it is too large Load diff

6278
web/node_modules/jss/node_modules/csstype/index.js.flow generated vendored Normal file

File diff suppressed because it is too large Load diff

62
web/node_modules/jss/node_modules/csstype/package.json generated vendored Normal file
View file

@ -0,0 +1,62 @@
{
"name": "csstype",
"version": "3.0.8",
"main": "",
"types": "index.d.ts",
"description": "Strict TypeScript and Flow types for style based on MDN data",
"repository": "https://github.com/frenic/csstype",
"author": "Fredrik Nicol <fredrik.nicol@gmail.com>",
"license": "MIT",
"devDependencies": {
"@types/chokidar": "^2.1.3",
"@types/jest": "^26.0.20",
"@types/jsdom": "^16.2.6",
"@types/node": "^14.14.31",
"@types/prettier": "^2.2.1",
"@types/request": "^2.48.5",
"@types/turndown": "^5.0.0",
"chalk": "^4.1.0",
"chokidar": "^3.5.1",
"fast-glob": "^3.2.5",
"flow-bin": "^0.145.0",
"jest": "^26.6.3",
"jsdom": "^16.4.0",
"mdn-browser-compat-data": "git+https://github.com/mdn/browser-compat-data.git#60214baa97657c798dd7eac44b7bc73af4968033",
"mdn-data": "git+https://github.com/mdn/data.git#7f622300bb7e285a2cbce7db6f8ecd8f964a18eb",
"prettier": "^2.2.1",
"request": "^2.88.2",
"ts-jest": "^26.5.2",
"ts-node": "^9.1.1",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0",
"turndown": "^7.0.0",
"typescript": "~4.2.2",
"yarn": "^1.22.10"
},
"scripts": {
"prepublish": "yarn install --cwd __tests__ && yarn install --cwd __tests__/__fixtures__",
"prepublishOnly": "tsc && npm run test:src && npm run build && ts-node --files prepublish.ts",
"update": "ts-node --files update.ts",
"build": "ts-node --files build.ts --start",
"watch": "ts-node --files build.ts --watch",
"lint": "tslint --exclude node_modules/**/* --exclude **/*.d.ts --fix **/*.ts",
"pretty": "prettier --write build.ts **/*.{ts,js,json,md}",
"lazy": "tsc && npm run lint && npm run pretty",
"test": "jest",
"test:src": "jest src.*.ts",
"test:dist": "jest dist.*.ts"
},
"files": [
"index.d.ts",
"index.js.flow"
],
"keywords": [
"css",
"style",
"typescript",
"flow",
"typings",
"types",
"definitions"
]
}

51
web/node_modules/jss/package.json generated vendored Normal file
View file

@ -0,0 +1,51 @@
{
"name": "jss",
"description": "A lib for generating Style Sheets with JavaScript.",
"version": "10.7.1",
"license": "MIT",
"homepage": "https://cssinjs.org/",
"main": "dist/jss.cjs.js",
"module": "dist/jss.esm.js",
"unpkg": "dist/jss.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"
},
"files": [
"dist",
"src",
"!*.test.*"
],
"keywords": [
"jss",
"style",
"sheet",
"stylesheet",
"css",
"components",
"composable",
"css in js",
"css-in-js"
],
"scripts": {
"build": "node ../../scripts/build.js",
"check-snapshot": "node ../../scripts/match-snapshot.js"
},
"dependencies": {
"@babel/runtime": "^7.3.1",
"csstype": "^3.0.2",
"is-in-browser": "^1.1.3",
"tiny-warning": "^1.0.2"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/jss"
},
"gitHead": "2b54776c03d97a3bccbbcb28b63508f74103ebbc"
}

25
web/node_modules/jss/readme.md generated vendored Normal file
View file

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

487
web/node_modules/jss/src/DomRenderer.js generated vendored Normal file
View file

@ -0,0 +1,487 @@
// @flow
import warning from 'tiny-warning'
import StyleSheet from './StyleSheet'
import sheets from './sheets'
import toCssValue from './utils/toCssValue'
import type {
CSSStyleRule,
CSSMediaRule,
CSSKeyframesRule,
CSSKeyframeRule,
HTMLElementWithStyleMap,
AnyCSSRule,
Rule,
RuleList,
ContainerRule,
JssValue,
InsertionPoint
} from './types'
type PriorityOptions = {
index: number,
insertionPoint?: InsertionPoint
}
/**
* Cache the value from the first time a function is called.
*/
const memoize = <Value>(fn: () => Value): (() => Value) => {
let value
return () => {
if (!value) value = fn()
return value
}
}
type GetPropertyValue = (HTMLElementWithStyleMap | CSSStyleRule | CSSKeyframeRule, string) => string
/**
* Get a style property value.
*/
const getPropertyValue: GetPropertyValue = (cssRule, prop) => {
try {
// Support CSSTOM.
if (cssRule.attributeStyleMap) {
return cssRule.attributeStyleMap.get(prop)
}
return cssRule.style.getPropertyValue(prop)
} catch (err) {
// IE may throw if property is unknown.
return ''
}
}
type SetProperty = (
HTMLElementWithStyleMap | CSSStyleRule | CSSKeyframeRule,
string,
JssValue
) => boolean
/**
* Set a style property.
*/
const setProperty: SetProperty = (cssRule, prop, value) => {
try {
let cssValue = ((value: any): string)
if (Array.isArray(value)) {
cssValue = toCssValue(value, true)
if (value[value.length - 1] === '!important') {
cssRule.style.setProperty(prop, cssValue, 'important')
return true
}
}
// Support CSSTOM.
if (cssRule.attributeStyleMap) {
cssRule.attributeStyleMap.set(prop, cssValue)
} else {
cssRule.style.setProperty(prop, cssValue)
}
} catch (err) {
// IE may throw if property is unknown.
return false
}
return true
}
type RemoveProperty = (HTMLElementWithStyleMap | CSSStyleRule | CSSKeyframeRule, string) => void
/**
* Remove a style property.
*/
const removeProperty: RemoveProperty = (cssRule, prop) => {
try {
// Support CSSTOM.
if (cssRule.attributeStyleMap) {
cssRule.attributeStyleMap.delete(prop)
} else {
cssRule.style.removeProperty(prop)
}
} catch (err) {
warning(
false,
`[JSS] DOMException "${err.message}" was thrown. Tried to remove property "${prop}".`
)
}
}
type SetSelector = (CSSStyleRule, string) => boolean
/**
* Set the selector.
*/
const setSelector: SetSelector = (cssRule, selectorText) => {
cssRule.selectorText = selectorText
// Return false if setter was not successful.
// Currently works in chrome only.
return cssRule.selectorText === selectorText
}
/**
* Gets the `head` element upon the first call and caches it.
* We assume it can't be null.
*/
const getHead = memoize((): HTMLElement => (document.querySelector('head'): any))
/**
* Find attached sheet with an index higher than the passed one.
*/
function findHigherSheet(registry: Array<StyleSheet>, options: PriorityOptions): StyleSheet | null {
for (let i = 0; i < registry.length; i++) {
const sheet = registry[i]
if (
sheet.attached &&
sheet.options.index > options.index &&
sheet.options.insertionPoint === options.insertionPoint
) {
return sheet
}
}
return null
}
/**
* Find attached sheet with the highest index.
*/
function findHighestSheet(
registry: Array<StyleSheet>,
options: PriorityOptions
): StyleSheet | null {
for (let i = registry.length - 1; i >= 0; i--) {
const sheet = registry[i]
if (sheet.attached && sheet.options.insertionPoint === options.insertionPoint) {
return sheet
}
}
return null
}
/**
* Find a comment with "jss" inside.
*/
function findCommentNode(text: string): Node | null {
const head = getHead()
for (let i = 0; i < head.childNodes.length; i++) {
const node = head.childNodes[i]
if (node.nodeType === 8 && node.nodeValue.trim() === text) {
return node
}
}
return null
}
type PrevNode = {
parent: ?Node,
node: ?Node
}
/**
* Find a node before which we can insert the sheet.
*/
function findPrevNode(options: PriorityOptions): PrevNode | false {
const {registry} = sheets
if (registry.length > 0) {
// Try to insert before the next higher sheet.
let sheet = findHigherSheet(registry, options)
if (sheet && sheet.renderer) {
return {
parent: sheet.renderer.element.parentNode,
node: sheet.renderer.element
}
}
// Otherwise insert after the last attached.
sheet = findHighestSheet(registry, options)
if (sheet && sheet.renderer) {
return {
parent: sheet.renderer.element.parentNode,
node: sheet.renderer.element.nextSibling
}
}
}
// Try to find a comment placeholder if registry is empty.
const {insertionPoint} = options
if (insertionPoint && typeof insertionPoint === 'string') {
const comment = findCommentNode(insertionPoint)
if (comment) {
return {
parent: comment.parentNode,
node: comment.nextSibling
}
}
// If user specifies an insertion point and it can't be found in the document -
// bad specificity issues may appear.
warning(false, `[JSS] Insertion point "${insertionPoint}" not found.`)
}
return false
}
/**
* Insert style element into the DOM.
*/
function insertStyle(style: HTMLElement, options: PriorityOptions) {
const {insertionPoint} = options
const nextNode = findPrevNode(options)
if (nextNode !== false && nextNode.parent) {
nextNode.parent.insertBefore(style, nextNode.node)
return
}
// Works with iframes and any node types.
if (insertionPoint && typeof insertionPoint.nodeType === 'number') {
// https://stackoverflow.com/questions/41328728/force-casting-in-flow
const insertionPointElement: HTMLElement = (insertionPoint: any)
const {parentNode} = insertionPointElement
if (parentNode) parentNode.insertBefore(style, insertionPointElement.nextSibling)
else warning(false, '[JSS] Insertion point is not in the DOM.')
return
}
getHead().appendChild(style)
}
/**
* Read jss nonce setting from the page if the user has set it.
*/
const getNonce = memoize(
(): ?string => {
const node = document.querySelector('meta[property="csp-nonce"]')
return node ? node.getAttribute('content') : null
}
)
const insertRule = (
container: CSSStyleSheet | CSSMediaRule | CSSKeyframesRule,
rule: string,
index: number
): false | any => {
try {
if ('insertRule' in container) {
const c = ((container: any): CSSStyleSheet)
c.insertRule(rule, index)
}
// Keyframes rule.
else if ('appendRule' in container) {
const c = ((container: any): CSSKeyframesRule)
c.appendRule(rule)
}
} catch (err) {
warning(false, `[JSS] ${err.message}`)
return false
}
return container.cssRules[index]
}
const getValidRuleInsertionIndex = (
container: CSSStyleSheet | CSSMediaRule | CSSKeyframesRule,
index?: number
): number => {
const maxIndex = container.cssRules.length
// In case previous insertion fails, passed index might be wrong
if (index === undefined || index > maxIndex) {
// eslint-disable-next-line no-param-reassign
return maxIndex
}
return index
}
const createStyle = (): HTMLElement => {
const el = document.createElement('style')
// Without it, IE will have a broken source order specificity if we
// insert rules after we insert the style tag.
// It seems to kick-off the source order specificity algorithm.
el.textContent = '\n'
return el
}
export default class DomRenderer {
getPropertyValue: GetPropertyValue = getPropertyValue
setProperty: SetProperty = setProperty
removeProperty: RemoveProperty = removeProperty
setSelector: SetSelector = setSelector
// HTMLStyleElement needs fixing https://github.com/facebook/flow/issues/2696
element: any
sheet: StyleSheet | void
hasInsertedRules: boolean = false
// Will be empty if link: true option is not set, because
// it is only for use together with insertRule API.
cssRules: AnyCSSRule[] = []
constructor(sheet?: StyleSheet) {
// There is no sheet when the renderer is used from a standalone StyleRule.
if (sheet) sheets.add(sheet)
this.sheet = sheet
const {media, meta, element} = this.sheet ? this.sheet.options : {}
this.element = element || createStyle()
this.element.setAttribute('data-jss', '')
if (media) this.element.setAttribute('media', media)
if (meta) this.element.setAttribute('data-meta', meta)
const nonce = getNonce()
if (nonce) this.element.setAttribute('nonce', nonce)
}
/**
* Insert style element into render tree.
*/
attach(): void {
// In the case the element node is external and it is already in the DOM.
if (this.element.parentNode || !this.sheet) return
insertStyle(this.element, this.sheet.options)
// When rules are inserted using `insertRule` API, after `sheet.detach().attach()`
// most browsers create a new CSSStyleSheet, except of all IEs.
const deployed = Boolean(this.sheet && this.sheet.deployed)
if (this.hasInsertedRules && deployed) {
this.hasInsertedRules = false
this.deploy()
}
}
/**
* Remove style element from render tree.
*/
detach(): void {
if (!this.sheet) return
const {parentNode} = this.element
if (parentNode) parentNode.removeChild(this.element)
// In the most browsers, rules inserted using insertRule() API will be lost when style element is removed.
// Though IE will keep them and we need a consistent behavior.
if (this.sheet.options.link) {
this.cssRules = []
this.element.textContent = '\n'
}
}
/**
* Inject CSS string into element.
*/
deploy(): void {
const {sheet} = this
if (!sheet) return
if (sheet.options.link) {
this.insertRules(sheet.rules)
return
}
this.element.textContent = `\n${sheet.toString()}\n`
}
/**
* Insert RuleList into an element.
*/
insertRules(rules: RuleList, nativeParent?: CSSStyleSheet | CSSMediaRule | CSSKeyframesRule) {
for (let i = 0; i < rules.index.length; i++) {
this.insertRule(rules.index[i], i, nativeParent)
}
}
/**
* Insert a rule into element.
*/
insertRule(
rule: Rule,
index?: number,
nativeParent?: CSSStyleSheet | CSSMediaRule | CSSKeyframesRule = this.element.sheet
): false | CSSStyleSheet | AnyCSSRule {
if (rule.rules) {
const parent: ContainerRule = (rule: any)
let latestNativeParent = nativeParent
if (rule.type === 'conditional' || rule.type === 'keyframes') {
const insertionIndex = getValidRuleInsertionIndex(nativeParent, index)
// We need to render the container without children first.
latestNativeParent = insertRule(
nativeParent,
parent.toString({children: false}),
insertionIndex
)
if (latestNativeParent === false) {
return false
}
this.refCssRule(rule, insertionIndex, latestNativeParent)
}
this.insertRules(parent.rules, latestNativeParent)
return latestNativeParent
}
const ruleStr = rule.toString()
if (!ruleStr) return false
const insertionIndex = getValidRuleInsertionIndex(nativeParent, index)
const nativeRule = insertRule(nativeParent, ruleStr, insertionIndex)
if (nativeRule === false) {
return false
}
this.hasInsertedRules = true
this.refCssRule(rule, insertionIndex, nativeRule)
return nativeRule
}
refCssRule(rule: Rule, index: number, cssRule: any) {
rule.renderable = cssRule
// We only want to reference the top level rules, deleteRule API doesn't support removing nested rules
// like rules inside media queries or keyframes
if (rule.options.parent instanceof StyleSheet) {
this.cssRules[index] = cssRule
}
}
/**
* Delete a rule.
*/
deleteRule(cssRule: AnyCSSRule): boolean {
const {sheet} = this.element
const index = this.indexOf(cssRule)
if (index === -1) return false
sheet.deleteRule(index)
this.cssRules.splice(index, 1)
return true
}
/**
* Get index of a CSS Rule.
*/
indexOf(cssRule: AnyCSSRule): number {
return this.cssRules.indexOf(cssRule)
}
/**
* Generate a new CSS rule and replace the existing one.
*
* Only used for some old browsers because they can't set a selector.
*/
replaceRule(cssRule: AnyCSSRule, rule: Rule): false | CSSStyleSheet | AnyCSSRule {
const index = this.indexOf(cssRule)
if (index === -1) return false
this.element.sheet.deleteRule(index)
this.cssRules.splice(index, 1)
return this.insertRule(rule, index)
}
/**
* Get all rules elements.
*/
getRules(): CSSRuleList {
return this.element.sheet.cssRules
}
}

144
web/node_modules/jss/src/Jss.js generated vendored Normal file
View file

@ -0,0 +1,144 @@
// @flow
import isInBrowser from 'is-in-browser'
import StyleSheet from './StyleSheet'
import PluginsRegistry from './PluginsRegistry'
import sheets from './sheets'
import {plugins as internalPlugins} from './plugins/index'
import createGenerateIdDefault from './utils/createGenerateId'
import createRule from './utils/createRule'
import DomRenderer from './DomRenderer'
import type {
Rule,
RuleFactoryOptions,
RuleOptions,
StyleSheetFactoryOptions,
Plugin,
JssOptions,
InternalJssOptions,
JssStyle
} from './types'
import type {GenerateId} from './utils/createGenerateId'
let instanceCounter = 0
export default class Jss {
id: number = instanceCounter++
version: string | void = process.env.VERSION
plugins: PluginsRegistry = new PluginsRegistry()
options: InternalJssOptions = {
id: {minify: false},
createGenerateId: createGenerateIdDefault,
Renderer: isInBrowser ? DomRenderer : null,
plugins: []
}
generateId: GenerateId = createGenerateIdDefault({minify: false})
constructor(options?: JssOptions) {
for (let i = 0; i < internalPlugins.length; i++) {
this.plugins.use(internalPlugins[i], {queue: 'internal'})
}
this.setup(options)
}
/**
* Prepares various options, applies plugins.
* Should not be used twice on the same instance, because there is no plugins
* deduplication logic.
*/
setup(options?: JssOptions = {}): this {
if (options.createGenerateId) {
this.options.createGenerateId = options.createGenerateId
}
if (options.id) {
this.options.id = {
...this.options.id,
...options.id
}
}
if (options.createGenerateId || options.id) {
this.generateId = this.options.createGenerateId(this.options.id)
}
if (options.insertionPoint != null) this.options.insertionPoint = options.insertionPoint
if ('Renderer' in options) {
this.options.Renderer = options.Renderer
}
// eslint-disable-next-line prefer-spread
if (options.plugins) this.use.apply(this, options.plugins)
return this
}
/**
* Create a Style Sheet.
*/
createStyleSheet(styles: Object, options: StyleSheetFactoryOptions = ({}: any)): StyleSheet {
let {index} = options
if (typeof index !== 'number') {
index = sheets.index === 0 ? 0 : sheets.index + 1
}
const sheet = new StyleSheet(styles, {
...options,
jss: this,
generateId: options.generateId || this.generateId,
insertionPoint: this.options.insertionPoint,
Renderer: this.options.Renderer,
index
})
this.plugins.onProcessSheet(sheet)
return sheet
}
/**
* Detach the Style Sheet and remove it from the registry.
*/
removeStyleSheet(sheet: StyleSheet): this {
sheet.detach()
sheets.remove(sheet)
return this
}
/**
* Create a rule without a Style Sheet.
* [Deprecated] will be removed in the next major version.
*/
createRule(name: string, style?: JssStyle = {}, options?: RuleFactoryOptions = {}): Rule | null {
// Enable rule without name for inline styles.
if (typeof name === 'object') {
// $FlowFixMe[incompatible-call]
return this.createRule(undefined, name, style)
}
// $FlowFixMe[incompatible-type]
const ruleOptions: RuleOptions = {...options, name, jss: this, Renderer: this.options.Renderer}
if (!ruleOptions.generateId) ruleOptions.generateId = this.generateId
if (!ruleOptions.classes) ruleOptions.classes = {}
if (!ruleOptions.keyframes) ruleOptions.keyframes = {}
const rule = createRule(name, style, ruleOptions)
if (rule) this.plugins.onProcessRule(rule)
return rule
}
/**
* Register plugin. Passed function will be invoked with a rule instance.
*/
use(...plugins: Array<Plugin>): this {
plugins.forEach(plugin => {
this.plugins.use(plugin)
})
return this
}
}

140
web/node_modules/jss/src/PluginsRegistry.js generated vendored Normal file
View file

@ -0,0 +1,140 @@
// @flow
import warning from 'tiny-warning'
import type StyleSheet from './StyleSheet'
import type {
Plugin,
Rule,
RuleOptions,
UpdateOptions,
JssStyle,
JssValue,
OnCreateRule,
OnProcessRule,
OnProcessStyle,
OnProcessSheet,
OnChangeValue,
OnUpdate
} from './types'
import type {StyleRule, BaseStyleRule} from './plugins/styleRule'
type Registry = {
onCreateRule: Array<OnCreateRule>,
onProcessRule: Array<OnProcessRule>,
onProcessStyle: Array<OnProcessStyle>,
onProcessSheet: Array<OnProcessSheet>,
onChangeValue: Array<OnChangeValue>,
onUpdate: Array<OnUpdate>
}
export default class PluginsRegistry {
plugins: {
internal: Array<Plugin>,
external: Array<Plugin>
} = {
internal: [],
external: []
}
registry: Registry
/**
* Call `onCreateRule` hooks and return an object if returned by a hook.
*/
onCreateRule(name: string, decl: JssStyle, options: RuleOptions): Rule | null {
for (let i = 0; i < this.registry.onCreateRule.length; i++) {
const rule = this.registry.onCreateRule[i](name, decl, options)
if (rule) return rule
}
return null
}
/**
* Call `onProcessRule` hooks.
*/
onProcessRule(rule: Rule): void {
if (rule.isProcessed) return
const {sheet} = rule.options
for (let i = 0; i < this.registry.onProcessRule.length; i++) {
this.registry.onProcessRule[i](rule, sheet)
}
if (rule.style) this.onProcessStyle(rule.style, rule, sheet)
rule.isProcessed = true
}
/**
* Call `onProcessStyle` hooks.
*/
onProcessStyle(style: JssStyle, rule: Rule, sheet?: StyleSheet): void {
for (let i = 0; i < this.registry.onProcessStyle.length; i++) {
// $FlowFixMe[prop-missing]
rule.style = this.registry.onProcessStyle[i](rule.style, rule, sheet)
}
}
/**
* Call `onProcessSheet` hooks.
*/
onProcessSheet(sheet: StyleSheet): void {
for (let i = 0; i < this.registry.onProcessSheet.length; i++) {
this.registry.onProcessSheet[i](sheet)
}
}
/**
* Call `onUpdate` hooks.
*/
onUpdate(data: Object, rule: Rule, sheet?: StyleSheet, options: UpdateOptions): void {
for (let i = 0; i < this.registry.onUpdate.length; i++) {
this.registry.onUpdate[i](data, rule, sheet, options)
}
}
/**
* Call `onChangeValue` hooks.
*/
onChangeValue(value: JssValue, prop: string, rule: StyleRule | BaseStyleRule): JssValue {
let processedValue = value
for (let i = 0; i < this.registry.onChangeValue.length; i++) {
processedValue = this.registry.onChangeValue[i](processedValue, prop, rule)
}
return processedValue
}
/**
* Register a plugin.
*/
use(newPlugin: Plugin, options: {queue: 'internal' | 'external'} = {queue: 'external'}): void {
const plugins = this.plugins[options.queue]
// Avoids applying same plugin twice, at least based on ref.
if (plugins.indexOf(newPlugin) !== -1) {
return
}
plugins.push(newPlugin)
this.registry = [...this.plugins.external, ...this.plugins.internal].reduce(
(registry: Registry, plugin: Plugin) => {
for (const name in plugin) {
if (name in registry) {
registry[name].push(plugin[name])
} else {
warning(false, `[JSS] Unknown hook "${name}".`)
}
}
return registry
},
{
onCreateRule: [],
onProcessRule: [],
onProcessStyle: [],
onProcessSheet: [],
onChangeValue: [],
onUpdate: []
}
)
}
}

264
web/node_modules/jss/src/RuleList.js generated vendored Normal file
View file

@ -0,0 +1,264 @@
// @flow
import createRule from './utils/createRule'
import {StyleRule, KeyframesRule} from './plugins/index'
import type {
RuleListOptions,
ToCssOptions,
Rule,
RuleOptions,
JssStyle,
Classes,
KeyframesMap,
UpdateArguments,
UpdateOptions
} from './types'
import escape from './utils/escape'
const defaultUpdateOptions = {
process: true
}
const forceUpdateOptions = {
force: true,
process: true
}
/**
* Contains rules objects and allows adding/removing etc.
* Is used for e.g. by `StyleSheet` or `ConditionalRule`.
*/
export default class RuleList {
// Rules registry for access by .get() method.
// It contains the same rule registered by name and by selector.
map: {[key: string]: Rule} = {}
// Original styles object.
raw: {[key: string]: JssStyle} = {}
// Used to ensure correct rules order.
index: Array<Rule> = []
counter: number = 0
options: RuleListOptions
classes: Classes
keyframes: KeyframesMap
constructor(options: RuleListOptions) {
this.options = options
this.classes = options.classes
this.keyframes = options.keyframes
}
/**
* Create and register rule.
*
* Will not render after Style Sheet was rendered the first time.
*/
add(name: string, decl: JssStyle, ruleOptions?: RuleOptions): Rule | null {
const {parent, sheet, jss, Renderer, generateId, scoped} = this.options
const options = {
classes: this.classes,
parent,
sheet,
jss,
Renderer,
generateId,
scoped,
name,
keyframes: this.keyframes,
selector: undefined,
...ruleOptions
}
// When user uses .createStyleSheet(), duplicate names are not possible, but
// `sheet.addRule()` opens the door for any duplicate rule name. When this happens
// we need to make the key unique within this RuleList instance scope.
let key = name
if (name in this.raw) {
key = `${name}-d${this.counter++}`
}
// We need to save the original decl before creating the rule
// because cache plugin needs to use it as a key to return a cached rule.
this.raw[key] = decl
if (key in this.classes) {
// E.g. rules inside of @media container
options.selector = `.${escape(this.classes[key])}`
}
const rule = createRule(key, decl, options)
if (!rule) return null
this.register(rule)
const index = options.index === undefined ? this.index.length : options.index
this.index.splice(index, 0, rule)
return rule
}
/**
* Get a rule.
*/
get(name: string): Rule {
return this.map[name]
}
/**
* Delete a rule.
*/
remove(rule: Rule): void {
this.unregister(rule)
delete this.raw[rule.key]
this.index.splice(this.index.indexOf(rule), 1)
}
/**
* Get index of a rule.
*/
indexOf(rule: Rule): number {
return this.index.indexOf(rule)
}
/**
* Run `onProcessRule()` plugins on every rule.
*/
process(): void {
const {plugins} = this.options.jss
// We need to clone array because if we modify the index somewhere else during a loop
// we end up with very hard-to-track-down side effects.
this.index.slice(0).forEach(plugins.onProcessRule, plugins)
}
/**
* Register a rule in `.map`, `.classes` and `.keyframes` maps.
*/
register(rule: Rule): void {
this.map[rule.key] = rule
if (rule instanceof StyleRule) {
this.map[rule.selector] = rule
if (rule.id) this.classes[rule.key] = rule.id
} else if (rule instanceof KeyframesRule && this.keyframes) {
this.keyframes[rule.name] = rule.id
}
}
/**
* Unregister a rule.
*/
unregister(rule: Rule): void {
delete this.map[rule.key]
if (rule instanceof StyleRule) {
delete this.map[rule.selector]
delete this.classes[rule.key]
} else if (rule instanceof KeyframesRule) {
delete this.keyframes[rule.name]
}
}
/**
* Update the function values with a new data.
*/
update(...args: UpdateArguments): void {
let name
let data
let options
if (typeof args[0] === 'string') {
name = args[0]
// $FlowFixMe[invalid-tuple-index]
data = args[1]
// $FlowFixMe[invalid-tuple-index]
options = args[2]
} else {
data = args[0]
// $FlowFixMe[invalid-tuple-index]
options = args[1]
name = null
}
if (name) {
this.updateOne(this.map[name], data, options)
} else {
for (let index = 0; index < this.index.length; index++) {
this.updateOne(this.index[index], data, options)
}
}
}
/**
* Execute plugins, update rule props.
*/
updateOne(rule: Rule, data: Object, options?: UpdateOptions = defaultUpdateOptions) {
const {
jss: {plugins},
sheet
} = this.options
// It is a rules container like for e.g. ConditionalRule.
if (rule.rules instanceof RuleList) {
rule.rules.update(data, options)
return
}
const styleRule: StyleRule = (rule: any)
const {style} = styleRule
plugins.onUpdate(data, rule, sheet, options)
// We rely on a new `style` ref in case it was mutated during onUpdate hook.
if (options.process && style && style !== styleRule.style) {
// We need to run the plugins in case new `style` relies on syntax plugins.
plugins.onProcessStyle(styleRule.style, styleRule, sheet)
// Update and add props.
for (const prop in styleRule.style) {
const nextValue = styleRule.style[prop]
const prevValue = style[prop]
// We need to use `force: true` because `rule.style` has been updated during onUpdate hook, so `rule.prop()` will not update the CSSOM rule.
// We do this comparison to avoid unneeded `rule.prop()` calls, since we have the old `style` object here.
if (nextValue !== prevValue) {
styleRule.prop(prop, nextValue, forceUpdateOptions)
}
}
// Remove props.
for (const prop in style) {
const nextValue = styleRule.style[prop]
const prevValue = style[prop]
// We need to use `force: true` because `rule.style` has been updated during onUpdate hook, so `rule.prop()` will not update the CSSOM rule.
// We do this comparison to avoid unneeded `rule.prop()` calls, since we have the old `style` object here.
if (nextValue == null && nextValue !== prevValue) {
styleRule.prop(prop, null, forceUpdateOptions)
}
}
}
}
/**
* Convert rules to a CSS string.
*/
toString(options?: ToCssOptions): string {
let str = ''
const {sheet} = this.options
const link = sheet ? sheet.options.link : false
for (let index = 0; index < this.index.length; index++) {
const rule = this.index[index]
const css = rule.toString(options)
// No need to render an empty rule.
if (!css && !link) continue
if (str) str += '\n'
str += css
}
return str
}
}

71
web/node_modules/jss/src/SheetsManager.js generated vendored Normal file
View file

@ -0,0 +1,71 @@
// @flow
import warn from 'tiny-warning'
import type StyleSheet from './StyleSheet'
/**
* SheetsManager is like a WeakMap which is designed to count StyleSheet
* instances and attach/detach automatically.
*/
export default class SheetsManager {
length: number = 0
sheets: WeakMap<
Object,
{
refs: number,
sheet: StyleSheet
}
> = new WeakMap()
get size(): number {
return this.length
}
get(key: Object): ?StyleSheet {
const entry = this.sheets.get(key)
return entry && entry.sheet
}
add(key: Object, sheet: StyleSheet) {
if (this.sheets.has(key)) return
this.length++
this.sheets.set(key, {
sheet,
refs: 0
})
}
manage(key: Object): ?StyleSheet {
const entry = this.sheets.get(key)
if (entry) {
if (entry.refs === 0) {
entry.sheet.attach()
}
entry.refs++
return entry.sheet
}
warn(false, "[JSS] SheetsManager: can't find sheet to manage")
return undefined
}
unmanage(key: Object) {
const entry = this.sheets.get(key)
if (entry) {
if (entry.refs > 0) {
entry.refs--
if (entry.refs === 0) entry.sheet.detach()
}
} else {
warn(false, "SheetsManager: can't find sheet to unmanage")
}
}
}

71
web/node_modules/jss/src/SheetsRegistry.js generated vendored Normal file
View file

@ -0,0 +1,71 @@
// @flow
import type {ToCssOptions} from './types'
import type StyleSheet from './StyleSheet'
/**
* Sheets registry to access them all at one place.
*/
export default class SheetsRegistry {
registry: Array<StyleSheet> = []
/**
* Current highest index number.
*/
get index(): number {
return this.registry.length === 0 ? 0 : this.registry[this.registry.length - 1].options.index
}
/**
* Register a Style Sheet.
*/
add(sheet: StyleSheet): void {
const {registry} = this
const {index} = sheet.options
if (registry.indexOf(sheet) !== -1) return
if (registry.length === 0 || index >= this.index) {
registry.push(sheet)
return
}
// Find a position.
for (let i = 0; i < registry.length; i++) {
if (registry[i].options.index > index) {
registry.splice(i, 0, sheet)
return
}
}
}
/**
* Reset the registry.
*/
reset(): void {
this.registry = []
}
/**
* Remove a Style Sheet.
*/
remove(sheet: StyleSheet): void {
const index = this.registry.indexOf(sheet)
this.registry.splice(index, 1)
}
/**
* Convert all attached sheets to a CSS string.
*/
toString({attached, ...options}: {|attached?: boolean, ...ToCssOptions|} = {}): string {
let css = ''
for (let i = 0; i < this.registry.length; i++) {
const sheet = this.registry[i]
if (attached != null && sheet.attached !== attached) {
continue
}
if (css) css += '\n'
css += sheet.toString(options)
}
return css
}
}

213
web/node_modules/jss/src/StyleSheet.js generated vendored Normal file
View file

@ -0,0 +1,213 @@
// @flow
import RuleList from './RuleList'
import type {
InternalStyleSheetOptions,
Rule,
ToCssOptions,
RuleOptions,
StyleSheetOptions,
JssStyle,
Classes,
KeyframesMap,
JssStyles,
Renderer,
UpdateArguments,
UpdateOptions
} from './types'
export default class StyleSheet {
options: InternalStyleSheetOptions
deployed: boolean
attached: boolean
rules: RuleList
renderer: Renderer | null
classes: Classes
keyframes: KeyframesMap
queue: ?Array<Rule>
constructor(styles: JssStyles, options: StyleSheetOptions) {
this.attached = false
this.deployed = false
this.classes = {}
this.keyframes = {}
this.options = {
...options,
sheet: this,
parent: this,
classes: this.classes,
keyframes: this.keyframes
}
if (options.Renderer) {
this.renderer = new options.Renderer(this)
}
this.rules = new RuleList(this.options)
for (const name in styles) {
this.rules.add(name, styles[name])
}
this.rules.process()
}
/**
* Attach renderable to the render tree.
*/
attach(): this {
if (this.attached) return this
if (this.renderer) this.renderer.attach()
this.attached = true
// Order is important, because we can't use insertRule API if style element is not attached.
if (!this.deployed) this.deploy()
return this
}
/**
* Remove renderable from render tree.
*/
detach(): this {
if (!this.attached) return this
if (this.renderer) this.renderer.detach()
this.attached = false
return this
}
/**
* Add a rule to the current stylesheet.
* Will insert a rule also after the stylesheet has been rendered first time.
*/
addRule(name: string, decl: JssStyle, options?: RuleOptions): Rule | null {
const {queue} = this
// Plugins can create rules.
// In order to preserve the right order, we need to queue all `.addRule` calls,
// which happen after the first `rules.add()` call.
if (this.attached && !queue) this.queue = []
const rule = this.rules.add(name, decl, options)
if (!rule) return null
this.options.jss.plugins.onProcessRule(rule)
if (this.attached) {
if (!this.deployed) return rule
// Don't insert rule directly if there is no stringified version yet.
// It will be inserted all together when .attach is called.
if (queue) queue.push(rule)
else {
this.insertRule(rule)
if (this.queue) {
this.queue.forEach(this.insertRule, this)
this.queue = undefined
}
}
return rule
}
// We can't add rules to a detached style node.
// We will redeploy the sheet once user will attach it.
this.deployed = false
return rule
}
/**
* Insert rule into the StyleSheet
*/
insertRule(rule: Rule) {
if (this.renderer) {
this.renderer.insertRule(rule)
}
}
/**
* Create and add rules.
* Will render also after Style Sheet was rendered the first time.
*/
addRules(styles: JssStyles, options?: RuleOptions): Array<Rule> {
const added = []
for (const name in styles) {
const rule = this.addRule(name, styles[name], options)
if (rule) added.push(rule)
}
return added
}
/**
* Get a rule by name.
*/
getRule(name: string): Rule {
return this.rules.get(name)
}
/**
* Delete a rule by name.
* Returns `true`: if rule has been deleted from the DOM.
*/
deleteRule(name: string | Rule): boolean {
const rule = typeof name === 'object' ? name : this.rules.get(name)
if (
!rule ||
// Style sheet was created without link: true and attached, in this case we
// won't be able to remove the CSS rule from the DOM.
(this.attached && !rule.renderable)
) {
return false
}
this.rules.remove(rule)
if (this.attached && rule.renderable && this.renderer) {
return this.renderer.deleteRule(rule.renderable)
}
return true
}
/**
* Get index of a rule.
*/
indexOf(rule: Rule): number {
return this.rules.indexOf(rule)
}
/**
* Deploy pure CSS string to a renderable.
*/
deploy(): this {
if (this.renderer) this.renderer.deploy()
this.deployed = true
return this
}
/**
* Update the function values with a new data.
*/
update(...args: UpdateArguments): this {
this.rules.update(...args)
return this
}
/**
* Updates a single rule.
*/
updateOne(rule: Rule, data: Object, options?: UpdateOptions): this {
this.rules.updateOne(rule, data, options)
return this
}
/**
* Convert rules to a CSS string.
*/
toString(options?: ToCssOptions): string {
return this.rules.toString(options)
}
}

287
web/node_modules/jss/src/index.d.ts generated vendored Normal file
View file

@ -0,0 +1,287 @@
import {Properties as CSSProperties} from 'csstype'
// Observable support is included as a plugin. Including it here allows
// TypeScript users to use Observables, which could be confusing if a user
// hasn't installed that plugin.
//
// TODO: refactor to only include Observable types if plugin is installed.
export interface MinimalObservable<T> {
subscribe(
nextOrObserver: ((value: T) => void) | {next: (value: T) => void}
): {unsubscribe: () => void}
}
type Func<P, T, R> = T extends undefined ? ((data: P) => R) : ((data: P & {theme: T}) => R)
type NormalCssProperties = CSSProperties<string | number>
type NormalCssValues<K> = K extends keyof NormalCssProperties ? NormalCssProperties[K] : JssValue
export type JssStyle<Props = any, Theme = undefined> =
| {
[K in keyof NormalCssProperties]:
| NormalCssValues<K>
| JssStyle<Props, Theme>
| Func<Props, Theme, NormalCssValues<K> | JssStyle<undefined, undefined> | undefined>
| MinimalObservable<NormalCssValues<K> | JssStyle | undefined>
}
| {
[K: string]:
| JssValue
| JssStyle<Props, Theme>
| Func<Props, Theme, JssValue | JssStyle<undefined, undefined> | undefined>
| MinimalObservable<JssValue | JssStyle | undefined>
}
export type Styles<
Name extends string | number | symbol = string,
Props = unknown,
Theme = undefined
> = Record<
Name,
| JssStyle<Props, Theme>
| Array<JssStyle<Props, Theme>>
| string
| Func<Props, Theme, JssStyle<undefined, undefined> | string | null | undefined>
| MinimalObservable<JssStyle | string | null | undefined>
>
export type Classes<Name extends string | number | symbol = string> = Record<Name, string>
export type Keyframes<Name extends string = string> = Record<Name, string>
export interface CreateGenerateIdOptions {
minify?: boolean
}
export type CreateGenerateId = (options?: CreateGenerateIdOptions) => GenerateId
export type GenerateId = (rule: Rule, sheet?: StyleSheet<string>) => string
export type JssValue =
| (string & {})
| (number & {})
| Array<string | number | Array<string | number> | '!important'>
| null
| false
export type InsertionPoint = string | HTMLElement | Comment
export interface UpdateOptions {
process?: boolean
force?: boolean
}
export interface ToCssOptions {
indent?: number
allowEmpty?: boolean
}
interface RuleListOptions {
classes: Classes
generateClassName: GenerateId
Renderer: Renderer
jss: Jss
sheet: StyleSheet
parent: ContainerRule | StyleSheet
}
declare class RuleList {
constructor(options: RuleListOptions)
add(name: string, decl: JssStyle, options?: RuleOptions): Rule
get(name: string): Rule
remove(rule: Rule): void
indexOf(rule: Rule): number
process(): void
register(rule: Rule, className?: string): void
unregister(rule: Rule): void
update(name: string, data: {}): void
update(data: {}): void
toString(options?: ToCssOptions): string
}
interface RuleOptions {
selector?: string
sheet?: StyleSheet
index?: number
parent?: ContainerRule | StyleSheet
classes: Classes
jss: Jss
generateId: GenerateId
Renderer: Renderer
}
interface BaseRule {
type: string
key: string
isProcessed: boolean
// eslint-disable-next-line no-use-before-define
options: RuleOptions
toString(options?: ToCssOptions): string
}
interface ContainerRule extends BaseRule {
rules: RuleList
}
export interface Plugin {
onCreateRule?(name: string, decl: JssStyle, options: RuleOptions): Rule
onProcessRule?(rule: Rule, sheet?: StyleSheet): void
onProcessStyle?(style: JssStyle, rule: Rule, sheet?: StyleSheet): JssStyle
onProcessSheet?(sheet?: StyleSheet): void
onChangeValue?(value: string, prop: string, rule: Rule): string | null | false
onUpdate?(data: object, rule: Rule, sheet?: StyleSheet): void
}
export type Rule = BaseRule | ContainerRule
export interface Renderer {
setProperty(cssRule: HTMLElement | CSSStyleRule, prop: string, value: JssValue): boolean
getPropertyValue(cssRule: HTMLElement | CSSStyleRule, prop: string): string
removeProperty(cssRule: HTMLElement | CSSStyleRule, prop: string): void
setSelector(cssRule: CSSStyleRule, selectorText: string): boolean
attach(): void
detach(): void
deploy(sheet: StyleSheet): void
insertRule(rule: Rule): false | CSSRule
deleteRule(cssRule: CSSRule): boolean
replaceRule(cssRule: CSSRule, rule: Rule): false | CSSRule
indexOf(cssRule: CSSRule): number
getRules(): CSSRuleList | void
}
interface RuleFactoryOptions {
selector?: string
classes?: object
sheet?: StyleSheet
index?: number
jss?: Jss
generateId?: GenerateId
Renderer?: Renderer
}
export interface StyleSheetFactoryOptions {
media?: string
meta?: string
index?: number
link?: boolean
element?: HTMLStyleElement
generateId?: GenerateId
classNamePrefix?: string
}
interface StyleSheetOptions extends StyleSheetFactoryOptions {
index: number
generateId: GenerateId
Renderer: Renderer
insertionPoint?: InsertionPoint
jss: Jss
}
declare class SheetsRegistry {
registry: StyleSheet[]
readonly index: number
add<RuleName extends string | number | symbol>(sheet: StyleSheet<RuleName>): void
reset(): void
remove<RuleName extends string | number | symbol>(sheet: StyleSheet<RuleName>): void
toString(options?: ToCssOptions): string
}
declare class SheetsManager {
readonly size: number
get(key: object): StyleSheet | null
add(key: object, sheet: StyleSheet): void
manage(key: object): StyleSheet | null
unmanage(key: object): void
}
export interface StyleSheet<RuleName extends string | number | symbol = string | number | symbol> {
// Gives auto-completion on the rules declared in `createStyleSheet` without
// causing errors for rules added dynamically after creation.
classes: Classes<RuleName>
keyframes: Keyframes<string>
options: StyleSheetOptions
linked: boolean
attached: boolean
/**
* Attach renderable to the render tree.
*/
attach(): this
/**
* Remove renderable from render tree.
*/
detach(): this
deploy(): this
/**
* Add a rule to the current stylesheet.
* Will insert a rule also after the stylesheet has been rendered first time.
*/
addRule(style: JssStyle, options?: Partial<RuleOptions>): Rule
addRule(name: RuleName, style: JssStyle, options?: Partial<RuleOptions>): Rule
insertRule(rule: Rule): void
/**
* Create and add rules.
* Will render also after Style Sheet was rendered the first time.
*/
addRules(
styles: Partial<Styles<RuleName, any, undefined>>,
options?: Partial<RuleOptions>
): Rule[]
/**
* Get a rule by name.
*/
getRule(name: RuleName): Rule
/**
* Delete a rule by name.
* Returns `true`: if rule has been deleted from the DOM.
*/
deleteRule(name: RuleName): boolean
/**
* Get index of a rule.
*/
indexOf(rule: Rule): number
/**
* Update the function values with a new data.
*/
update(name: string, data: object, options?: UpdateOptions): this
update(data: object, options?: UpdateOptions): this
/**
* Convert rules to a CSS string.
*/
toString(options?: ToCssOptions): string
}
export interface JssOptions {
createGenerateId: CreateGenerateId
plugins: ReadonlyArray<Plugin>
Renderer?: {new (): Renderer} | null
insertionPoint: InsertionPoint
id: CreateGenerateIdOptions
}
export interface Jss {
createStyleSheet<Name extends string | number | symbol>(
styles: Partial<Styles<Name, any, undefined>>,
options?: StyleSheetFactoryOptions
): StyleSheet<Name>
removeStyleSheet(sheet: StyleSheet): this
setup(options?: Partial<JssOptions>): this
use(...plugins: Plugin[]): this
createRule(style: JssStyle, options?: RuleFactoryOptions): Rule
createRule<Name extends string>(name: Name, style: JssStyle, options?: RuleFactoryOptions): Rule
}
/**
* Creates a new instance of JSS.
*/
declare const sheets: SheetsRegistry
export {sheets, SheetsManager, SheetsRegistry, RuleList}
export function create(options?: Partial<JssOptions>): Jss
export const createGenerateId: CreateGenerateId
export function createRule<D>(name: string, decl: JssStyle, options: RuleOptions): Rule
export function toCssValue(value: JssValue, ignoreImportant: boolean): string
export function getDynamicStyles(styles: Styles): Styles | null
declare const jss: Jss
/**
* A global JSS instance.
*/
export default jss

107
web/node_modules/jss/src/index.js generated vendored Normal file
View file

@ -0,0 +1,107 @@
// @flow
/**
* A better abstraction over CSS.
*
* @copyright Oleg Isonen (Slobodskoi) / Isonen 2014-present
* @website https://github.com/cssinjs/jss
* @license MIT
*/
import Jss from './Jss'
import type StyleSheet from './StyleSheet'
import type {
ConditionalRule,
KeyframesRule,
StyleRule,
ViewportRule,
SimpleRule,
FontFaceRule
} from './plugins'
import type {JssOptions} from './types'
/**
* Export types for better typing inside plugins and integrations.
*/
export type {
StyleSheetFactoryOptions,
JssValue,
JssOptions,
JssStyle,
Plugin,
RuleListOptions,
Rule,
Renderer,
RuleOptions,
UpdateOptions,
Classes,
BaseRule,
ContainerRule
} from './types'
export type {GenerateId, CreateGenerateId, CreateGenerateIdOptions} from './utils/createGenerateId'
export type {
Jss,
StyleSheet,
ConditionalRule,
KeyframesRule,
StyleRule,
ViewportRule,
SimpleRule,
FontFaceRule
}
/**
* Export a constant indicating if this browser has CSSTOM support.
* https://developers.google.com/web/updates/2018/03/cssom
*/
export const hasCSSTOMSupport: boolean = typeof CSS === 'object' && CSS != null && 'number' in CSS
/**
* Extracts a styles object with only rules that contain function values.
*/
export {default as getDynamicStyles} from './utils/getDynamicStyles'
/**
* Converts JSS array value to a CSS string.
*/
export {default as toCssValue} from './utils/toCssValue'
/**
* Create a rule instance.
*/
export {default as createRule} from './utils/createRule'
/**
* SheetsRegistry for SSR.
*/
export {default as SheetsRegistry} from './SheetsRegistry'
/**
* SheetsManager for react-jss and co.
*/
export {default as SheetsManager} from './SheetsManager'
/**
* RuleList for plugins.
*/
export {default as RuleList} from './RuleList'
/**
* Default global SheetsRegistry instance.
*/
export {default as sheets} from './sheets'
/**
* Class name generator creator.
*/
export {default as createGenerateId} from './utils/createGenerateId'
/**
* Creates a new instance of Jss.
*/
export const create = (options?: JssOptions): Jss => new Jss(options)
/**
* A global Jss instance.
*/
const jss: Jss = create()
export default jss

92
web/node_modules/jss/src/plugins/conditionalRule.js generated vendored Normal file
View file

@ -0,0 +1,92 @@
// @flow
import RuleList from '../RuleList'
import type {CSSMediaRule, Rule, RuleOptions, ToCssOptions, JssStyle, ContainerRule} from '../types'
const defaultToStringOptions = {
indent: 1,
children: true
}
const atRegExp = /@([\w-]+)/
/**
* Conditional rule for @media, @supports
*/
export class ConditionalRule implements ContainerRule {
type: string = 'conditional'
at: string
key: string
query: string
rules: RuleList
options: RuleOptions
isProcessed: boolean = false
renderable: ?CSSMediaRule
constructor(key: string, styles: Object, options: RuleOptions) {
this.key = key
const atMatch = key.match(atRegExp)
this.at = atMatch ? atMatch[1] : 'unknown'
// Key might contain a unique suffix in case the `name` passed by user was duplicate.
this.query = options.name || `@${this.at}`
this.options = options
this.rules = new RuleList({...options, parent: this})
for (const name in styles) {
this.rules.add(name, styles[name])
}
this.rules.process()
}
/**
* Get a rule.
*/
getRule(name: string): Rule {
return this.rules.get(name)
}
/**
* Get index of a rule.
*/
indexOf(rule: Rule): number {
return this.rules.indexOf(rule)
}
/**
* Create and register rule, run plugins.
*/
addRule(name: string, style: JssStyle, options?: RuleOptions): Rule | null {
const rule = this.rules.add(name, style, options)
if (!rule) return null
this.options.jss.plugins.onProcessRule(rule)
return rule
}
/**
* Generates a CSS string.
*/
toString(options?: ToCssOptions = defaultToStringOptions): string {
if (options.indent == null) options.indent = defaultToStringOptions.indent
if (options.children == null) options.children = defaultToStringOptions.children
if (options.children === false) {
return `${this.query} {}`
}
const children = this.rules.toString(options)
return children ? `${this.query} {\n${children}\n}` : ''
}
}
const keyRegExp = /@media|@supports\s+/
export default {
onCreateRule(key: string, styles: JssStyle, options: RuleOptions): ConditionalRule | null {
return keyRegExp.test(key) ? new ConditionalRule(key, styles, options) : null
}
}

49
web/node_modules/jss/src/plugins/fontFaceRule.js generated vendored Normal file
View file

@ -0,0 +1,49 @@
// @flow
import toCss from '../utils/toCss'
import type {CSSFontFaceRule, RuleOptions, JssStyle, ToCssOptions, BaseRule} from '../types'
export class FontFaceRule implements BaseRule {
type: string = 'font-face'
at: string = '@font-face'
key: string
style: JssStyle
options: RuleOptions
isProcessed: boolean = false
renderable: ?CSSFontFaceRule
constructor(key: string, style: JssStyle, options: RuleOptions) {
this.key = key
this.style = style
this.options = options
}
/**
* Generates a CSS string.
*/
toString(options?: ToCssOptions): string {
if (Array.isArray(this.style)) {
let str = ''
for (let index = 0; index < this.style.length; index++) {
str += toCss(this.at, this.style[index])
if (this.style[index + 1]) str += '\n'
}
return str
}
return toCss(this.at, this.style, options)
}
}
const keyRegExp = /@font-face/
export default {
onCreateRule(key: string, style: JssStyle, options: RuleOptions): FontFaceRule | null {
return keyRegExp.test(key) ? new FontFaceRule(key, style, options) : null
}
}

28
web/node_modules/jss/src/plugins/index.js generated vendored Normal file
View file

@ -0,0 +1,28 @@
// @flow
import pluginStyleRule, {StyleRule} from './styleRule'
import pluginConditionalRule, {ConditionalRule} from './conditionalRule'
import pluginKeyframesRule, {KeyframesRule} from './keyframesRule'
import pluginKeyframeRule, {KeyframeRule} from './keyframeRule'
import pluginFontFaceRule, {FontFaceRule} from './fontFaceRule'
import pluginViewportRule, {ViewportRule} from './viewportRule'
import pluginSimpleRule, {SimpleRule} from './simpleRule'
export const plugins = [
pluginStyleRule,
pluginConditionalRule,
pluginKeyframesRule,
pluginKeyframeRule,
pluginFontFaceRule,
pluginViewportRule,
pluginSimpleRule
]
export {
StyleRule,
ConditionalRule,
KeyframesRule,
KeyframeRule,
FontFaceRule,
ViewportRule,
SimpleRule
}

27
web/node_modules/jss/src/plugins/keyframeRule.js generated vendored Normal file
View file

@ -0,0 +1,27 @@
// @flow
import toCss from '../utils/toCss'
import type {JssStyle, RuleOptions, ToCssOptions, CSSKeyframeRule} from '../types'
import {BaseStyleRule} from './styleRule'
export class KeyframeRule extends BaseStyleRule {
renderable: ?CSSKeyframeRule
/**
* Generates a CSS string.
*/
toString(options?: ToCssOptions): string {
const {sheet} = this.options
const link = sheet ? sheet.options.link : false
const opts = link ? {...options, allowEmpty: true} : options
return toCss(this.key, this.style, opts)
}
}
export default {
onCreateRule(key: string, style: JssStyle, options: RuleOptions): KeyframeRule | null {
if (options.parent && options.parent.type === 'keyframes') {
return new KeyframeRule(key, style, options)
}
return null
}
}

149
web/node_modules/jss/src/plugins/keyframesRule.js generated vendored Normal file
View file

@ -0,0 +1,149 @@
// @flow
import warning from 'tiny-warning'
import RuleList from '../RuleList'
import type {
CSSKeyframesRule,
JssStyle,
RuleOptions,
ToCssOptions,
ContainerRule,
KeyframesMap,
Plugin
} from '../types'
import escape from '../utils/escape'
const defaultToStringOptions = {
indent: 1,
children: true
}
const nameRegExp = /@keyframes\s+([\w-]+)/
/**
* Rule for @keyframes
*/
export class KeyframesRule implements ContainerRule {
type: string = 'keyframes'
at: string = '@keyframes'
key: string
name: string
id: string
rules: RuleList
options: RuleOptions
isProcessed: boolean = false
renderable: ?CSSKeyframesRule
constructor(key: string, frames: Object, options: RuleOptions) {
const nameMatch = key.match(nameRegExp)
if (nameMatch && nameMatch[1]) {
this.name = nameMatch[1]
} else {
this.name = 'noname'
warning(false, `[JSS] Bad keyframes name ${key}`)
}
this.key = `${this.type}-${this.name}`
this.options = options
const {scoped, sheet, generateId} = options
this.id = scoped === false ? this.name : escape(generateId(this, sheet))
this.rules = new RuleList({...options, parent: this})
for (const name in frames) {
this.rules.add(name, frames[name], {
...options,
parent: this
})
}
this.rules.process()
}
/**
* Generates a CSS string.
*/
toString(options?: ToCssOptions = defaultToStringOptions): string {
if (options.indent == null) options.indent = defaultToStringOptions.indent
if (options.children == null) options.children = defaultToStringOptions.children
if (options.children === false) {
return `${this.at} ${this.id} {}`
}
let children = this.rules.toString(options)
if (children) children = `\n${children}\n`
return `${this.at} ${this.id} {${children}}`
}
}
const keyRegExp = /@keyframes\s+/
const refRegExp = /\$([\w-]+)/g
const findReferencedKeyframe = (val, keyframes) => {
if (typeof val === 'string') {
return val.replace(refRegExp, (match, name) => {
if (name in keyframes) {
return keyframes[name]
}
warning(false, `[JSS] Referenced keyframes rule "${name}" is not defined.`)
return match
})
}
return val
}
/**
* Replace the reference for a animation name.
*/
const replaceRef = (style: JssStyle, prop: string, keyframes: KeyframesMap) => {
const value = style[prop]
const refKeyframe = findReferencedKeyframe(value, keyframes)
if (refKeyframe !== value) {
style[prop] = refKeyframe
}
}
const plugin: Plugin = {
onCreateRule(key, frames, options) {
return typeof key === 'string' && keyRegExp.test(key)
? new KeyframesRule(key, frames, options)
: null
},
// Animation name ref replacer.
onProcessStyle: (style, rule, sheet) => {
if (rule.type !== 'style' || !sheet) return style
if ('animation-name' in style) replaceRef(style, 'animation-name', sheet.keyframes)
if ('animation' in style) replaceRef(style, 'animation', sheet.keyframes)
return style
},
onChangeValue(val, prop, rule) {
const {sheet} = rule.options
if (!sheet) {
return val
}
switch (prop) {
case 'animation':
return findReferencedKeyframe(val, sheet.keyframes)
case 'animation-name':
return findReferencedKeyframe(val, sheet.keyframes)
default:
return val
}
}
}
export default plugin

59
web/node_modules/jss/src/plugins/simpleRule.js generated vendored Normal file
View file

@ -0,0 +1,59 @@
// @flow
import type {
CSSCharsetRule,
CSSImportRule,
CSSNamespaceRule,
RuleOptions,
JssStyle,
ToCssOptions,
BaseRule
} from '../types'
export class SimpleRule implements BaseRule {
type: string = 'simple'
key: string
value: string | Array<string>
options: RuleOptions
isProcessed: boolean = false
renderable: ?CSSCharsetRule | CSSImportRule | CSSNamespaceRule
constructor(key: string, value: string, options: RuleOptions) {
this.key = key
this.value = value
this.options = options
}
/**
* Generates a CSS string.
*/
// eslint-disable-next-line no-unused-vars
toString(options?: ToCssOptions): string {
if (Array.isArray(this.value)) {
let str = ''
for (let index = 0; index < this.value.length; index++) {
str += `${this.key} ${this.value[index]};`
if (this.value[index + 1]) str += '\n'
}
return str
}
return `${this.key} ${this.value};`
}
}
const keysMap = {
'@charset': true,
'@import': true,
'@namespace': true
}
export default {
onCreateRule(key: string, value: JssStyle, options: RuleOptions): SimpleRule | null {
return key in keysMap ? new SimpleRule(key, value, options) : null
}
}

179
web/node_modules/jss/src/plugins/styleRule.js generated vendored Normal file
View file

@ -0,0 +1,179 @@
// @flow
import warning from 'tiny-warning'
import toCss from '../utils/toCss'
import toCssValue from '../utils/toCssValue'
import escape from '../utils/escape'
import type {
CSSStyleRule,
HTMLElementWithStyleMap,
ToCssOptions,
RuleOptions,
UpdateOptions,
Renderer as RendererInterface,
JssStyle,
JssValue,
BaseRule
} from '../types'
export class BaseStyleRule implements BaseRule {
type: string = 'style'
key: string
isProcessed: boolean = false
style: JssStyle
renderer: RendererInterface | null
renderable: ?Object
options: RuleOptions
constructor(key: string, style: JssStyle, options: RuleOptions) {
const {sheet, Renderer} = options
this.key = key
this.options = options
this.style = style
if (sheet) this.renderer = sheet.renderer
else if (Renderer) this.renderer = new Renderer()
}
/**
* Get or set a style property.
*/
prop(name: string, value?: JssValue, options?: UpdateOptions): this | string {
// It's a getter.
if (value === undefined) return this.style[name]
// Don't do anything if the value has not changed.
const force = options ? options.force : false
if (!force && this.style[name] === value) return this
let newValue = value
if (!options || options.process !== false) {
newValue = this.options.jss.plugins.onChangeValue(value, name, this)
}
const isEmpty = newValue == null || newValue === false
const isDefined = name in this.style
// Value is empty and wasn't defined before.
if (isEmpty && !isDefined && !force) return this
// We are going to remove this value.
const remove = isEmpty && isDefined
if (remove) delete this.style[name]
else this.style[name] = newValue
// Renderable is defined if StyleSheet option `link` is true.
if (this.renderable && this.renderer) {
if (remove) this.renderer.removeProperty(this.renderable, name)
else this.renderer.setProperty(this.renderable, name, newValue)
return this
}
const {sheet} = this.options
if (sheet && sheet.attached) {
warning(false, '[JSS] Rule is not linked. Missing sheet option "link: true".')
}
return this
}
}
export class StyleRule extends BaseStyleRule {
selectorText: string
id: ?string
renderable: ?CSSStyleRule
constructor(key: string, style: JssStyle, options: RuleOptions) {
super(key, style, options)
const {selector, scoped, sheet, generateId} = options
if (selector) {
this.selectorText = selector
} else if (scoped !== false) {
this.id = generateId(this, sheet)
this.selectorText = `.${escape(this.id)}`
}
}
/**
* Set selector string.
* Attention: use this with caution. Most browsers didn't implement
* selectorText setter, so this may result in rerendering of entire Style Sheet.
*/
set selector(selector: string): void {
if (selector === this.selectorText) return
this.selectorText = selector
const {renderer, renderable} = this
if (!renderable || !renderer) return
const hasChanged = renderer.setSelector(renderable, selector)
// If selector setter is not implemented, rerender the rule.
if (!hasChanged) {
renderer.replaceRule(renderable, this)
}
}
/**
* Get selector string.
*/
get selector(): string {
return this.selectorText
}
/**
* Apply rule to an element inline.
*/
applyTo(renderable: HTMLElementWithStyleMap): this {
const {renderer} = this
if (renderer) {
const json = this.toJSON()
for (const prop in json) {
renderer.setProperty(renderable, prop, json[prop])
}
}
return this
}
/**
* Returns JSON representation of the rule.
* Fallbacks are not supported.
* Useful for inline styles.
*/
toJSON(): Object {
const json = {}
for (const prop in this.style) {
const value = this.style[prop]
if (typeof value !== 'object') json[prop] = value
else if (Array.isArray(value)) json[prop] = toCssValue(value)
}
return json
}
/**
* Generates a CSS string.
*/
toString(options?: ToCssOptions): string {
const {sheet} = this.options
const link = sheet ? sheet.options.link : false
const opts = link ? {...options, allowEmpty: true} : options
return toCss(this.selectorText, this.style, opts)
}
}
export default {
onCreateRule(name: string, style: JssStyle, options: RuleOptions): StyleRule | null {
if (name[0] === '@' || (options.parent && options.parent.type === 'keyframes')) {
return null
}
return new StyleRule(name, style, options)
}
}

40
web/node_modules/jss/src/plugins/viewportRule.js generated vendored Normal file
View file

@ -0,0 +1,40 @@
// @flow
import toCss from '../utils/toCss'
import type {CSSViewportRule, RuleOptions, JssStyle, ToCssOptions, BaseRule} from '../types'
export class ViewportRule implements BaseRule {
type: string = 'viewport'
at: string = '@viewport'
key: string
style: JssStyle
options: RuleOptions
isProcessed: boolean = false
renderable: ?CSSViewportRule
constructor(key: string, style: JssStyle, options: RuleOptions) {
this.key = key
this.style = style
this.options = options
}
/**
* Generates a CSS string.
*/
toString(options?: ToCssOptions): string {
return toCss(this.key, this.style, options)
}
}
export default {
onCreateRule(key: string, style: JssStyle, options: RuleOptions): ViewportRule | null {
return key === '@viewport' || key === '@-ms-viewport'
? new ViewportRule(key, style, options)
: null
}
}

11
web/node_modules/jss/src/sheets.js generated vendored Normal file
View file

@ -0,0 +1,11 @@
// @flow
import SheetsRegistry from './SheetsRegistry'
/**
* This is a global sheets registry. Only DomRenderer will add sheets to it.
* On the server one should use an own SheetsRegistry instance and add the
* sheets to it, because you need to make sure to create a new registry for
* each request in order to not leak sheets across requests.
*/
const registry: SheetsRegistry = new SheetsRegistry()
export default registry

98
web/node_modules/jss/src/types/cssom.js generated vendored Normal file
View file

@ -0,0 +1,98 @@
// @flow
import type {DOMString} from './dom'
export interface StylePropertyMap {
get(property: DOMString): DOMString;
set(property: DOMString, value: DOMString): DOMString;
delete(property: DOMString): void;
}
export interface CSSRuleBase<T> {
+type: $PropertyType<T, 'type'>;
+CSSRule: ?CSSRule;
+CSSStyleSheet: ?CSSStyleSheet;
cssText: DOMString;
attributeStyleMap: StylePropertyMap;
}
export interface CSSGroupingRule<T> extends CSSRuleBase<T> {
// eslint-disable-next-line no-use-before-define
+cssRules: CSSRuleList;
insertRule(rule: DOMString, index: number): number;
deleteRule(index: number): void;
}
export interface CSSStyleRule extends CSSRuleBase<{type: 1 | 1}> {
+type: 1;
+style: CSSStyleDeclaration;
selectorText: DOMString;
}
export interface CSSCharsetRule extends CSSRuleBase<{type: 2 | 2}> {
+type: 2;
charset: DOMString;
}
export interface CSSImportRule extends CSSRuleBase<{type: 3 | 3}> {
+type: 3;
+mediaList: {
+mediaText: DOMString,
length: number,
item?: DOMString,
appendMedium(medium: DOMString): void,
deleteMedium(medium: DOMString): void
};
}
export interface CSSMediaRule extends CSSGroupingRule<{type: 4 | 4}> {
+type: 4;
+mediaList: {
+mediaText: DOMString,
length: number,
item?: DOMString,
appendMedium(medium: DOMString): void,
deleteMedium(medium: DOMString): void
};
}
export interface CSSFontFaceRule extends CSSRuleBase<{type: 5 | 5}> {
+type: 5;
+style: CSSStyleDeclaration;
}
export interface CSSKeyframeRule extends CSSRuleBase<{type: 8 | 8}> {
+type: 8;
+style: CSSStyleDeclaration;
keyText: DOMString;
}
export interface CSSKeyframesRule extends CSSRuleBase<{type: 7 | 7}> {
+type: 7;
+cssRules: CSSRuleList;
name: DOMString;
appendRule(rule: DOMString): void;
deleteRule(key: DOMString): void;
findRule(key: DOMString): CSSKeyframeRule;
}
export interface CSSNamespaceRule extends CSSRuleBase<{type: 10 | 10}> {
+type: 10;
namespaceURI: DOMString;
prefix: DOMString;
}
export interface CSSViewportRule extends CSSRuleBase<{type: 15 | 15}> {
+type: 15;
+style: CSSStyleDeclaration;
}
export type AnyCSSRule =
| CSSMediaRule
| CSSFontFaceRule
| CSSKeyframesRule
| CSSCharsetRule
| CSSImportRule
| CSSNamespaceRule
| CSSStyleRule
| CSSViewportRule

9
web/node_modules/jss/src/types/dom.js generated vendored Normal file
View file

@ -0,0 +1,9 @@
// @flow
import {StylePropertyMap} from './cssom'
export type DOMString = string
export interface HTMLElementWithStyleMap extends HTMLElement {
+attributeStyleMap?: StylePropertyMap;
}

5
web/node_modules/jss/src/types/index.js generated vendored Normal file
View file

@ -0,0 +1,5 @@
// @flow
export * from './cssom'
export * from './dom'
export * from './jss'

219
web/node_modules/jss/src/types/jss.js generated vendored Normal file
View file

@ -0,0 +1,219 @@
// @flow
import type Jss from '../Jss'
import type StyleSheet from '../StyleSheet'
import type {ConditionalRule} from '../plugins/conditionalRule'
import type {KeyframesRule} from '../plugins/keyframesRule'
import type {StyleRule, BaseStyleRule} from '../plugins/styleRule'
import type {ViewportRule} from '../plugins/viewportRule'
import type {SimpleRule} from '../plugins/simpleRule'
import type {FontFaceRule} from '../plugins/fontFaceRule'
import type {CSSStyleRule, AnyCSSRule} from './cssom'
import type {HTMLElementWithStyleMap} from './dom'
import type RuleList from '../RuleList'
import type {CreateGenerateId, CreateGenerateIdOptions, GenerateId} from '../utils/createGenerateId'
export type {RuleList, StyleSheet}
export type Classes = {[string]: string}
export type KeyframesMap = {[string]: string}
export type ToCssOptions = {|
indent?: number,
allowEmpty?: boolean,
children?: boolean
|}
export type UpdateOptions = {
process?: boolean,
force?: boolean
}
export type UpdateArguments =
| [Object]
| [Object, UpdateOptions]
| [string, Object]
| [string, Object, UpdateOptions]
export interface BaseRule {
type: string;
// Key is used as part of a class name and keyframes-name. It has to be
// a valid CSS identifier https://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
key: string;
isProcessed: boolean;
// eslint-disable-next-line no-use-before-define
options: RuleOptions;
renderable?: Object | null | void;
toString(options?: ToCssOptions): string;
}
export type Rule =
| StyleRule
| ConditionalRule
| FontFaceRule
| KeyframesRule
| SimpleRule
| ViewportRule
| BaseRule
// TODO
// Find a way to declare all types: Object|string|Array<Object>
export type JssStyle = Object
export type JssStyles = {[string]: JssStyle}
export type JssValue =
| string
| number
| Array<string | number | Array<string | number> | '!important'>
| Object
| null
| false
export interface Renderer {
constructor(sheet?: StyleSheet): void;
// HTMLStyleElement needs fixing https://github.com/facebook/flow/issues/2696
element: any;
setProperty(
cssRule: HTMLElementWithStyleMap | CSSStyleRule,
prop: string,
value: JssValue
): boolean;
getPropertyValue(cssRule: HTMLElementWithStyleMap | CSSStyleRule, prop: string): string;
removeProperty(cssRule: HTMLElementWithStyleMap | CSSStyleRule, prop: string): void;
setSelector(cssRule: CSSStyleRule, selectorText: string): boolean;
attach(): void;
detach(): void;
deploy(): void;
insertRule(rule: Rule): false | CSSStyleSheet | AnyCSSRule;
deleteRule(cssRule: AnyCSSRule): boolean;
replaceRule(cssRule: AnyCSSRule, rule: Rule): false | CSSStyleSheet | AnyCSSRule;
indexOf(cssRule: AnyCSSRule): number;
getRules(): CSSRuleList | void;
}
export type RuleFactoryOptions = {
selector?: string,
classes?: Classes,
keyframes?: KeyframesMap,
sheet?: StyleSheet,
index?: number,
jss?: Jss,
generateId?: GenerateId,
Renderer?: Class<Renderer> | null
}
export interface ContainerRule extends BaseRule {
at: string;
rules: RuleList;
}
export type RuleOptions = {
selector?: string,
scoped?: boolean,
sheet?: StyleSheet,
index?: number,
parent?: ContainerRule | StyleSheet,
classes: Classes,
keyframes: KeyframesMap,
jss: Jss,
generateId: GenerateId,
Renderer?: Class<Renderer> | null,
name?: string
}
export type RuleListOptions = {
classes: Classes,
scoped?: boolean,
keyframes: KeyframesMap,
generateId: GenerateId,
Renderer?: Class<Renderer> | null,
jss: Jss,
sheet?: StyleSheet,
parent: ContainerRule | StyleSheet
}
export type OnCreateRule = (name: string, decl: JssStyle, options: RuleOptions) => BaseRule | null
export type OnProcessRule = (rule: Rule, sheet?: StyleSheet) => void
export type OnProcessStyle = (style: JssStyle, rule: Rule, sheet?: StyleSheet) => JssStyle
export type OnProcessSheet = (sheet?: StyleSheet) => void
export type OnChangeValue = (
value: JssValue,
prop: string,
rule: StyleRule | BaseStyleRule
) => JssValue
export type OnUpdate = (
data: Object,
rule: Rule,
sheet?: StyleSheet,
options: UpdateOptions
) => void
export type Plugin = {|
onCreateRule?: OnCreateRule,
onProcessRule?: OnProcessRule,
onProcessStyle?: OnProcessStyle,
onProcessSheet?: OnProcessSheet,
onChangeValue?: OnChangeValue,
onUpdate?: OnUpdate
|}
export type InsertionPoint = string | HTMLElementWithStyleMap
export type JssOptions = {
createGenerateId?: CreateGenerateId,
id?: CreateGenerateIdOptions,
plugins?: Array<Plugin>,
insertionPoint?: InsertionPoint,
Renderer?: Class<Renderer> | null
}
export type InternalJssOptions = {|
createGenerateId: CreateGenerateId,
plugins: Array<Plugin>,
id: CreateGenerateIdOptions,
insertionPoint?: InsertionPoint,
Renderer?: Class<Renderer> | null
|}
export type StyleSheetFactoryOptions = {|
media?: string,
meta?: string,
index?: number,
link?: boolean,
element?: HTMLStyleElement,
generateId?: GenerateId,
classNamePrefix?: string
|}
export type StyleSheetOptions = {|
media?: string,
meta?: string,
link?: boolean,
element?: HTMLStyleElement,
index: number,
generateId: GenerateId,
classNamePrefix?: string,
Renderer?: Class<Renderer> | null,
insertionPoint?: InsertionPoint,
jss: Jss
|}
export type InternalStyleSheetOptions = {
media?: string,
meta?: string,
link?: boolean,
element?: HTMLStyleElement,
index: number,
insertionPoint?: InsertionPoint,
Renderer?: Class<Renderer> | null,
generateId: GenerateId,
classNamePrefix?: string,
jss: Jss,
sheet: StyleSheet,
parent: ConditionalRule | KeyframesRule | StyleSheet,
classes: Classes,
keyframes: KeyframesMap
}
export type FixMeAny = any

15
web/node_modules/jss/src/utils/cloneStyle.js generated vendored Normal file
View file

@ -0,0 +1,15 @@
import type {JssStyle} from '../types'
const plainObjectConstrurctor = {}.constructor
export default function cloneStyle(style: JssStyle): JssStyle {
if (style == null || typeof style !== 'object') return style
if (Array.isArray(style)) return style.map(cloneStyle)
if (style.constructor !== plainObjectConstrurctor) return style
const newStyle = {}
for (const name in style) {
newStyle[name] = cloneStyle(style[name])
}
return newStyle
}

54
web/node_modules/jss/src/utils/createGenerateId.js generated vendored Normal file
View file

@ -0,0 +1,54 @@
// @flow
import warning from 'tiny-warning'
import type {Rule} from '../types'
import StyleSheet from '../StyleSheet'
import moduleId from './moduleId'
const maxRules = 1e10
export type CreateGenerateIdOptions = {|
minify: boolean
|}
export type GenerateId = (rule: Rule, sheet?: StyleSheet) => string
export type CreateGenerateId = (options?: CreateGenerateIdOptions) => GenerateId
/**
* Returns a function which generates unique class names based on counters.
* When new generator function is created, rule counter is reseted.
* We need to reset the rule counter for SSR for each request.
*/
const createGenerateId: CreateGenerateId = (options = {}) => {
let ruleCounter = 0
const generateId: GenerateId = (rule, sheet) => {
ruleCounter += 1
if (ruleCounter > maxRules) {
warning(false, `[JSS] You might have a memory leak. Rule counter is at ${ruleCounter}.`)
}
let jssId = ''
let prefix = ''
if (sheet) {
if (sheet.options.classNamePrefix) {
prefix = sheet.options.classNamePrefix
}
if (sheet.options.jss.id != null) {
jssId = String(sheet.options.jss.id)
}
}
if (options.minify) {
// Using "c" because a number can't be the first char in a class name.
return `${prefix || 'c'}${moduleId}${jssId}${ruleCounter}`
}
return `${prefix + rule.key}-${moduleId}${jssId ? `-${jssId}` : ''}-${ruleCounter}`
}
return generateId
}
export default createGenerateId

26
web/node_modules/jss/src/utils/createRule.js generated vendored Normal file
View file

@ -0,0 +1,26 @@
// @flow
import warning from 'tiny-warning'
import type {Rule, RuleOptions, JssStyle} from '../types'
import cloneStyle from './cloneStyle'
/**
* Create a rule instance.
*/
export default function createRule(
name: string = 'unnamed',
decl: JssStyle,
options: RuleOptions
): Rule | null {
const {jss} = options
const declCopy = cloneStyle(decl)
const rule = jss.plugins.onCreateRule(name, declCopy, options)
if (rule) return rule
// It is an at-rule and it has no instance.
if (name[0] === '@') {
warning(false, `[JSS] Unknown rule ${name}`)
}
return null
}

4
web/node_modules/jss/src/utils/escape.js generated vendored Normal file
View file

@ -0,0 +1,4 @@
const escapeRegex = /([[\].#*$><+~=|^:(),"'`\s])/g
const nativeEscape = typeof CSS !== 'undefined' && CSS.escape
export default str => (nativeEscape ? nativeEscape(str) : str.replace(escapeRegex, '\\$1'))

24
web/node_modules/jss/src/utils/getDynamicStyles.js generated vendored Normal file
View file

@ -0,0 +1,24 @@
/**
* Extracts a styles object with only props that contain function values.
*/
export default function getDynamicStyles(styles: Object): Object | null {
let to = null
for (const key in styles) {
const value = styles[key]
const type = typeof value
if (type === 'function') {
if (!to) to = {}
to[key] = value
} else if (type === 'object' && value !== null && !Array.isArray(value)) {
const extracted = getDynamicStyles(value)
if (extracted) {
if (!to) to = {}
to[key] = extracted
}
}
}
return to
}

19
web/node_modules/jss/src/utils/globalThis.js generated vendored Normal file
View file

@ -0,0 +1,19 @@
/* eslint-disable */
/**
* Now that `globalThis` is available on most platforms
* (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis#browser_compatibility)
* we check for `globalThis` first. `globalThis` is necessary for jss
* to run in Agoric's secure version of JavaScript (SES). Under SES,
* `globalThis` exists, but `window`, `self`, and `Function('return
* this')()` are all undefined for security reasons.
*
* https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
*/
export default (typeof globalThis !== 'undefined'
? globalThis
: typeof window !== 'undefined' && window.Math === Math
? window
: typeof self !== 'undefined' && self.Math === Math
? self
: Function('return this')())

10
web/node_modules/jss/src/utils/moduleId.js generated vendored Normal file
View file

@ -0,0 +1,10 @@
import globalThis from './globalThis'
const ns = '2f1acc6c3a606b082e5eef5e54414ffb'
if (globalThis[ns] == null) globalThis[ns] = 0
// Bundle may contain multiple JSS versions at the same time. In order to identify
// the current version with just one short number and use it for classes generation
// we use a counter. Also it is more accurate, because user can manually reevaluate
// the module.
export default globalThis[ns]++

77
web/node_modules/jss/src/utils/toCss.js generated vendored Normal file
View file

@ -0,0 +1,77 @@
// @flow
import toCssValue from './toCssValue'
import type {ToCssOptions, JssStyle} from '../types'
/**
* Indent a string.
* http://jsperf.com/array-join-vs-for
*/
function indentStr(str: string, indent: number): string {
let result = ''
for (let index = 0; index < indent; index++) result += ' '
return result + str
}
/**
* Converts a Rule to CSS string.
*/
export default function toCss(
selector?: string,
style: JssStyle,
options: ToCssOptions = ({}: any)
): string {
let result = ''
if (!style) return result
let {indent = 0} = options
const {fallbacks} = style
if (selector) indent++
// Apply fallbacks first.
if (fallbacks) {
// Array syntax {fallbacks: [{prop: value}]}
if (Array.isArray(fallbacks)) {
for (let index = 0; index < fallbacks.length; index++) {
const fallback = fallbacks[index]
for (const prop in fallback) {
const value = fallback[prop]
if (value != null) {
if (result) result += '\n'
result += indentStr(`${prop}: ${toCssValue(value)};`, indent)
}
}
}
} else {
// Object syntax {fallbacks: {prop: value}}
for (const prop in fallbacks) {
const value = fallbacks[prop]
if (value != null) {
if (result) result += '\n'
result += indentStr(`${prop}: ${toCssValue(value)};`, indent)
}
}
}
}
for (const prop in style) {
const value = style[prop]
if (value != null && prop !== 'fallbacks') {
if (result) result += '\n'
result += indentStr(`${prop}: ${toCssValue(value)};`, indent)
}
}
// Allow empty style in this case, because properties will be added dynamically.
if (!result && !options.allowEmpty) return result
// When rule is being stringified before selector was defined.
if (!selector) return result
indent--
if (result) result = `\n${result}\n`
return indentStr(`${selector} {${result}`, indent) + indentStr('}', indent)
}

48
web/node_modules/jss/src/utils/toCssValue.js generated vendored Normal file
View file

@ -0,0 +1,48 @@
// @flow
import type {FixMeAny} from '../types'
const join = (value, by) => {
let result = ''
for (let i = 0; i < value.length; i++) {
// Remove !important from the value, it will be readded later.
if (value[i] === '!important') break
if (result) result += by
result += value[i]
}
return result
}
type ToCssValue = (FixMeAny, boolean | void) => string
/**
* Converts array values to string.
*
* `margin: [['5px', '10px']]` > `margin: 5px 10px;`
* `border: ['1px', '2px']` > `border: 1px, 2px;`
* `margin: [['5px', '10px'], '!important']` > `margin: 5px 10px !important;`
* `color: ['red', !important]` > `color: red !important;`
*/
const toCssValue: ToCssValue = (value, ignoreImportant = false) => {
if (!Array.isArray(value)) return value
let cssValue = ''
// Support space separated values via `[['5px', '10px']]`.
if (Array.isArray(value[0])) {
for (let i = 0; i < value.length; i++) {
if (value[i] === '!important') break
if (cssValue) cssValue += ', '
cssValue += join(value[i], ' ')
}
} else cssValue = join(value, ', ')
// Add !important, because it was ignored.
if (!ignoreImportant && value[value.length - 1] === '!important') {
cssValue += ' !important'
}
return cssValue
}
export default toCssValue