@measured/puck-plugin-emotion-cache 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -0
- package/dist/index.d.ts +229 -0
- package/dist/index.js +866 -0
- package/package.json +37 -0
package/README.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# plugin-emotion-cache
|
2
|
+
|
3
|
+
Inject [emotion cache](https://emotion.sh/docs/@emotion/cache) into the Puck iframe.
|
4
|
+
|
5
|
+
## Quick start
|
6
|
+
|
7
|
+
```sh
|
8
|
+
npm i @measured/puck-plugin-emotion-cache
|
9
|
+
```
|
10
|
+
|
11
|
+
```jsx
|
12
|
+
import { Puck } from "@measured/puck";
|
13
|
+
import createEmotionCache from "@measured/puck-plugin-emotion-cache";
|
14
|
+
|
15
|
+
// Create your emotion cache plugin. This example configures it for Chakra.
|
16
|
+
const chakraEmotionCache = createEmotionCache("cha");
|
17
|
+
|
18
|
+
// Render Puck
|
19
|
+
export function Page() {
|
20
|
+
return <Puck config={config} data={data} plugins={[chakraEmotionCache]} />;
|
21
|
+
}
|
22
|
+
```
|
23
|
+
|
24
|
+
## Args
|
25
|
+
|
26
|
+
| Param | Example | Type | Status |
|
27
|
+
| ------------- | ------- | ------ | -------- |
|
28
|
+
| [`key`](#key) | `cha` | String | Required |
|
29
|
+
|
30
|
+
### Required args
|
31
|
+
|
32
|
+
#### `key`
|
33
|
+
|
34
|
+
Key to pass to Emotion's [`createCache` method](https://emotion.sh/docs/@emotion/cache#createcache).
|
35
|
+
|
36
|
+
## License
|
37
|
+
|
38
|
+
MIT © [Measured Corporation Ltd](https://measured.co)
|
package/dist/index.d.ts
ADDED
@@ -0,0 +1,229 @@
|
|
1
|
+
import { ReactNode, ReactElement } from 'react';
|
2
|
+
|
3
|
+
type ItemSelector = {
|
4
|
+
index: number;
|
5
|
+
zone?: string;
|
6
|
+
};
|
7
|
+
|
8
|
+
type iconTypes = "Smartphone" | "Monitor" | "Tablet";
|
9
|
+
type Viewport = {
|
10
|
+
width: number;
|
11
|
+
height?: number | "auto";
|
12
|
+
label?: string;
|
13
|
+
icon?: iconTypes | ReactNode;
|
14
|
+
};
|
15
|
+
|
16
|
+
type ItemWithId = {
|
17
|
+
_arrayId: string;
|
18
|
+
_originalIndex: number;
|
19
|
+
};
|
20
|
+
type ArrayState = {
|
21
|
+
items: ItemWithId[];
|
22
|
+
openId: string;
|
23
|
+
};
|
24
|
+
type UiState = {
|
25
|
+
leftSideBarVisible: boolean;
|
26
|
+
rightSideBarVisible: boolean;
|
27
|
+
itemSelector: ItemSelector | null;
|
28
|
+
arrayState: Record<string, ArrayState | undefined>;
|
29
|
+
componentList: Record<string, {
|
30
|
+
components?: string[];
|
31
|
+
title?: string;
|
32
|
+
visible?: boolean;
|
33
|
+
expanded?: boolean;
|
34
|
+
}>;
|
35
|
+
isDragging: boolean;
|
36
|
+
viewports: {
|
37
|
+
current: {
|
38
|
+
width: number;
|
39
|
+
height: number | "auto";
|
40
|
+
};
|
41
|
+
controlsVisible: boolean;
|
42
|
+
options: Viewport[];
|
43
|
+
};
|
44
|
+
};
|
45
|
+
|
46
|
+
type FieldOption = {
|
47
|
+
label: string;
|
48
|
+
value: string | number | boolean;
|
49
|
+
};
|
50
|
+
type FieldOptions = Array<FieldOption> | ReadonlyArray<FieldOption>;
|
51
|
+
type BaseField = {
|
52
|
+
label?: string;
|
53
|
+
};
|
54
|
+
type TextField = BaseField & {
|
55
|
+
type: "text";
|
56
|
+
};
|
57
|
+
type NumberField = BaseField & {
|
58
|
+
type: "number";
|
59
|
+
min?: number;
|
60
|
+
max?: number;
|
61
|
+
};
|
62
|
+
type TextareaField = BaseField & {
|
63
|
+
type: "textarea";
|
64
|
+
};
|
65
|
+
type SelectField = BaseField & {
|
66
|
+
type: "select";
|
67
|
+
options: FieldOptions;
|
68
|
+
};
|
69
|
+
type RadioField = BaseField & {
|
70
|
+
type: "radio";
|
71
|
+
options: FieldOptions;
|
72
|
+
};
|
73
|
+
type ArrayField<Props extends {
|
74
|
+
[key: string]: any;
|
75
|
+
} = {
|
76
|
+
[key: string]: any;
|
77
|
+
}> = BaseField & {
|
78
|
+
type: "array";
|
79
|
+
arrayFields: {
|
80
|
+
[SubPropName in keyof Props[0]]: Field<Props[0][SubPropName]>;
|
81
|
+
};
|
82
|
+
defaultItemProps?: Props[0];
|
83
|
+
getItemSummary?: (item: Props[0], index?: number) => string;
|
84
|
+
max?: number;
|
85
|
+
min?: number;
|
86
|
+
};
|
87
|
+
type ObjectField<Props extends {
|
88
|
+
[key: string]: any;
|
89
|
+
} = {
|
90
|
+
[key: string]: any;
|
91
|
+
}> = BaseField & {
|
92
|
+
type: "object";
|
93
|
+
objectFields: Props extends any[] ? never : {
|
94
|
+
[SubPropName in keyof Props]: Field<Props[SubPropName]>;
|
95
|
+
};
|
96
|
+
};
|
97
|
+
type Adaptor<AdaptorParams = {}, TableShape extends Record<string, any> = {}, PropShape = TableShape> = {
|
98
|
+
name: string;
|
99
|
+
fetchList: (adaptorParams?: AdaptorParams) => Promise<TableShape[] | null>;
|
100
|
+
mapProp?: (value: TableShape) => PropShape;
|
101
|
+
};
|
102
|
+
type ExternalFieldWithAdaptor<Props extends {
|
103
|
+
[key: string]: any;
|
104
|
+
} = {
|
105
|
+
[key: string]: any;
|
106
|
+
}> = BaseField & {
|
107
|
+
type: "external";
|
108
|
+
placeholder?: string;
|
109
|
+
adaptor: Adaptor<any, any, Props>;
|
110
|
+
adaptorParams?: object;
|
111
|
+
getItemSummary: (item: Props, index?: number) => string;
|
112
|
+
};
|
113
|
+
type ExternalField<Props extends {
|
114
|
+
[key: string]: any;
|
115
|
+
} = {
|
116
|
+
[key: string]: any;
|
117
|
+
}> = BaseField & {
|
118
|
+
type: "external";
|
119
|
+
placeholder?: string;
|
120
|
+
fetchList: (params: {
|
121
|
+
query: string;
|
122
|
+
filters: Record<string, any>;
|
123
|
+
}) => Promise<any[] | null>;
|
124
|
+
mapProp?: (value: any) => Props;
|
125
|
+
mapRow?: (value: any) => Record<string, string | number>;
|
126
|
+
getItemSummary?: (item: Props, index?: number) => string;
|
127
|
+
showSearch?: boolean;
|
128
|
+
initialQuery?: string;
|
129
|
+
filterFields?: Record<string, Field>;
|
130
|
+
initialFilters?: Record<string, any>;
|
131
|
+
};
|
132
|
+
type CustomField<Props extends any = {}> = BaseField & {
|
133
|
+
type: "custom";
|
134
|
+
render: (props: {
|
135
|
+
field: CustomField<Props>;
|
136
|
+
name: string;
|
137
|
+
id: string;
|
138
|
+
value: Props;
|
139
|
+
onChange: (value: Props) => void;
|
140
|
+
readOnly?: boolean;
|
141
|
+
}) => ReactElement;
|
142
|
+
};
|
143
|
+
type Field<Props extends any = any> = TextField | NumberField | TextareaField | SelectField | RadioField | ArrayField<Props extends {
|
144
|
+
[key: string]: any;
|
145
|
+
} ? Props : any> | ObjectField<Props extends {
|
146
|
+
[key: string]: any;
|
147
|
+
} ? Props : any> | ExternalField<Props extends {
|
148
|
+
[key: string]: any;
|
149
|
+
} ? Props : any> | ExternalFieldWithAdaptor<Props extends {
|
150
|
+
[key: string]: any;
|
151
|
+
} ? Props : any> | CustomField<Props>;
|
152
|
+
type FieldProps<ValueType = any, F = Field<any>> = {
|
153
|
+
field: F;
|
154
|
+
value: ValueType;
|
155
|
+
id?: string;
|
156
|
+
onChange: (value: ValueType, uiState?: Partial<UiState>) => void;
|
157
|
+
readOnly?: boolean;
|
158
|
+
};
|
159
|
+
|
160
|
+
type RenderFunc<Props extends {
|
161
|
+
[key: string]: any;
|
162
|
+
} = {
|
163
|
+
children: ReactNode;
|
164
|
+
}> = (props: Props) => ReactElement;
|
165
|
+
declare const overrideKeys: readonly ["header", "headerActions", "fields", "fieldLabel", "components", "componentItem", "outline", "puck", "preview"];
|
166
|
+
type OverrideKey = (typeof overrideKeys)[number];
|
167
|
+
type OverridesGeneric<Shape extends {
|
168
|
+
[key in OverrideKey]: any;
|
169
|
+
}> = Shape;
|
170
|
+
type Overrides = OverridesGeneric<{
|
171
|
+
fieldTypes: Partial<FieldRenderFunctions>;
|
172
|
+
header: RenderFunc<{
|
173
|
+
actions: ReactNode;
|
174
|
+
children: ReactNode;
|
175
|
+
}>;
|
176
|
+
actionBar: RenderFunc<{
|
177
|
+
label?: string;
|
178
|
+
children: ReactNode;
|
179
|
+
}>;
|
180
|
+
headerActions: RenderFunc<{
|
181
|
+
children: ReactNode;
|
182
|
+
}>;
|
183
|
+
preview: RenderFunc;
|
184
|
+
fields: RenderFunc<{
|
185
|
+
children: ReactNode;
|
186
|
+
isLoading: boolean;
|
187
|
+
itemSelector?: ItemSelector | null;
|
188
|
+
}>;
|
189
|
+
fieldLabel: RenderFunc<{
|
190
|
+
children?: ReactNode;
|
191
|
+
icon?: ReactNode;
|
192
|
+
label: string;
|
193
|
+
el?: "label" | "div";
|
194
|
+
readOnly?: boolean;
|
195
|
+
className?: string;
|
196
|
+
}>;
|
197
|
+
components: RenderFunc;
|
198
|
+
componentItem: RenderFunc<{
|
199
|
+
children: ReactNode;
|
200
|
+
name: string;
|
201
|
+
}>;
|
202
|
+
iframe: RenderFunc<{
|
203
|
+
children: ReactNode;
|
204
|
+
document?: Document;
|
205
|
+
}>;
|
206
|
+
outline: RenderFunc;
|
207
|
+
puck: RenderFunc;
|
208
|
+
}>;
|
209
|
+
type FieldRenderFunctions = Omit<{
|
210
|
+
[Type in Field["type"]]: React.FunctionComponent<FieldProps<Extract<Field, {
|
211
|
+
type: Type;
|
212
|
+
}>> & {
|
213
|
+
children: ReactNode;
|
214
|
+
name: string;
|
215
|
+
}>;
|
216
|
+
}, "custom"> & {
|
217
|
+
[key: string]: React.FunctionComponent<FieldProps<any> & {
|
218
|
+
children: ReactNode;
|
219
|
+
name: string;
|
220
|
+
}>;
|
221
|
+
};
|
222
|
+
|
223
|
+
type Plugin = {
|
224
|
+
overrides: Partial<Overrides>;
|
225
|
+
};
|
226
|
+
|
227
|
+
declare const createEmotionCachePlugin: (key: string) => Plugin;
|
228
|
+
|
229
|
+
export { createEmotionCachePlugin as default };
|
package/dist/index.js
ADDED
@@ -0,0 +1,866 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __create = Object.create;
|
3
|
+
var __defProp = Object.defineProperty;
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
+
var __export = (target, all) => {
|
9
|
+
for (var name in all)
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
11
|
+
};
|
12
|
+
var __copyProps = (to, from2, except, desc) => {
|
13
|
+
if (from2 && typeof from2 === "object" || typeof from2 === "function") {
|
14
|
+
for (let key of __getOwnPropNames(from2))
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
16
|
+
__defProp(to, key, { get: () => from2[key], enumerable: !(desc = __getOwnPropDesc(from2, key)) || desc.enumerable });
|
17
|
+
}
|
18
|
+
return to;
|
19
|
+
};
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
26
|
+
mod
|
27
|
+
));
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
29
|
+
|
30
|
+
// index.tsx
|
31
|
+
var plugin_emotion_cache_exports = {};
|
32
|
+
__export(plugin_emotion_cache_exports, {
|
33
|
+
default: () => plugin_emotion_cache_default
|
34
|
+
});
|
35
|
+
module.exports = __toCommonJS(plugin_emotion_cache_exports);
|
36
|
+
|
37
|
+
// ../tsup-config/react-import.js
|
38
|
+
var import_react = __toESM(require("react"));
|
39
|
+
|
40
|
+
// index.tsx
|
41
|
+
var import_react2 = require("react");
|
42
|
+
|
43
|
+
// ../../node_modules/@emotion/sheet/dist/emotion-sheet.esm.js
|
44
|
+
var isDevelopment = false;
|
45
|
+
function sheetForTag(tag) {
|
46
|
+
if (tag.sheet) {
|
47
|
+
return tag.sheet;
|
48
|
+
}
|
49
|
+
for (var i = 0; i < document.styleSheets.length; i++) {
|
50
|
+
if (document.styleSheets[i].ownerNode === tag) {
|
51
|
+
return document.styleSheets[i];
|
52
|
+
}
|
53
|
+
}
|
54
|
+
return void 0;
|
55
|
+
}
|
56
|
+
function createStyleElement(options) {
|
57
|
+
var tag = document.createElement("style");
|
58
|
+
tag.setAttribute("data-emotion", options.key);
|
59
|
+
if (options.nonce !== void 0) {
|
60
|
+
tag.setAttribute("nonce", options.nonce);
|
61
|
+
}
|
62
|
+
tag.appendChild(document.createTextNode(""));
|
63
|
+
tag.setAttribute("data-s", "");
|
64
|
+
return tag;
|
65
|
+
}
|
66
|
+
var StyleSheet = /* @__PURE__ */ function() {
|
67
|
+
function StyleSheet2(options) {
|
68
|
+
var _this = this;
|
69
|
+
this._insertTag = function(tag) {
|
70
|
+
var before;
|
71
|
+
if (_this.tags.length === 0) {
|
72
|
+
if (_this.insertionPoint) {
|
73
|
+
before = _this.insertionPoint.nextSibling;
|
74
|
+
} else if (_this.prepend) {
|
75
|
+
before = _this.container.firstChild;
|
76
|
+
} else {
|
77
|
+
before = _this.before;
|
78
|
+
}
|
79
|
+
} else {
|
80
|
+
before = _this.tags[_this.tags.length - 1].nextSibling;
|
81
|
+
}
|
82
|
+
_this.container.insertBefore(tag, before);
|
83
|
+
_this.tags.push(tag);
|
84
|
+
};
|
85
|
+
this.isSpeedy = options.speedy === void 0 ? !isDevelopment : options.speedy;
|
86
|
+
this.tags = [];
|
87
|
+
this.ctr = 0;
|
88
|
+
this.nonce = options.nonce;
|
89
|
+
this.key = options.key;
|
90
|
+
this.container = options.container;
|
91
|
+
this.prepend = options.prepend;
|
92
|
+
this.insertionPoint = options.insertionPoint;
|
93
|
+
this.before = null;
|
94
|
+
}
|
95
|
+
var _proto = StyleSheet2.prototype;
|
96
|
+
_proto.hydrate = function hydrate(nodes) {
|
97
|
+
nodes.forEach(this._insertTag);
|
98
|
+
};
|
99
|
+
_proto.insert = function insert(rule) {
|
100
|
+
if (this.ctr % (this.isSpeedy ? 65e3 : 1) === 0) {
|
101
|
+
this._insertTag(createStyleElement(this));
|
102
|
+
}
|
103
|
+
var tag = this.tags[this.tags.length - 1];
|
104
|
+
if (this.isSpeedy) {
|
105
|
+
var sheet = sheetForTag(tag);
|
106
|
+
try {
|
107
|
+
sheet.insertRule(rule, sheet.cssRules.length);
|
108
|
+
} catch (e) {
|
109
|
+
}
|
110
|
+
} else {
|
111
|
+
tag.appendChild(document.createTextNode(rule));
|
112
|
+
}
|
113
|
+
this.ctr++;
|
114
|
+
};
|
115
|
+
_proto.flush = function flush() {
|
116
|
+
this.tags.forEach(function(tag) {
|
117
|
+
var _tag$parentNode;
|
118
|
+
return (_tag$parentNode = tag.parentNode) == null ? void 0 : _tag$parentNode.removeChild(tag);
|
119
|
+
});
|
120
|
+
this.tags = [];
|
121
|
+
this.ctr = 0;
|
122
|
+
};
|
123
|
+
return StyleSheet2;
|
124
|
+
}();
|
125
|
+
|
126
|
+
// ../../node_modules/stylis/src/Enum.js
|
127
|
+
var MS = "-ms-";
|
128
|
+
var MOZ = "-moz-";
|
129
|
+
var WEBKIT = "-webkit-";
|
130
|
+
var COMMENT = "comm";
|
131
|
+
var RULESET = "rule";
|
132
|
+
var DECLARATION = "decl";
|
133
|
+
var IMPORT = "@import";
|
134
|
+
var KEYFRAMES = "@keyframes";
|
135
|
+
var LAYER = "@layer";
|
136
|
+
|
137
|
+
// ../../node_modules/stylis/src/Utility.js
|
138
|
+
var abs = Math.abs;
|
139
|
+
var from = String.fromCharCode;
|
140
|
+
var assign = Object.assign;
|
141
|
+
function hash(value, length2) {
|
142
|
+
return charat(value, 0) ^ 45 ? (((length2 << 2 ^ charat(value, 0)) << 2 ^ charat(value, 1)) << 2 ^ charat(value, 2)) << 2 ^ charat(value, 3) : 0;
|
143
|
+
}
|
144
|
+
function trim(value) {
|
145
|
+
return value.trim();
|
146
|
+
}
|
147
|
+
function match(value, pattern) {
|
148
|
+
return (value = pattern.exec(value)) ? value[0] : value;
|
149
|
+
}
|
150
|
+
function replace(value, pattern, replacement) {
|
151
|
+
return value.replace(pattern, replacement);
|
152
|
+
}
|
153
|
+
function indexof(value, search) {
|
154
|
+
return value.indexOf(search);
|
155
|
+
}
|
156
|
+
function charat(value, index) {
|
157
|
+
return value.charCodeAt(index) | 0;
|
158
|
+
}
|
159
|
+
function substr(value, begin, end) {
|
160
|
+
return value.slice(begin, end);
|
161
|
+
}
|
162
|
+
function strlen(value) {
|
163
|
+
return value.length;
|
164
|
+
}
|
165
|
+
function sizeof(value) {
|
166
|
+
return value.length;
|
167
|
+
}
|
168
|
+
function append(value, array) {
|
169
|
+
return array.push(value), value;
|
170
|
+
}
|
171
|
+
function combine(array, callback) {
|
172
|
+
return array.map(callback).join("");
|
173
|
+
}
|
174
|
+
|
175
|
+
// ../../node_modules/stylis/src/Tokenizer.js
|
176
|
+
var line = 1;
|
177
|
+
var column = 1;
|
178
|
+
var length = 0;
|
179
|
+
var position = 0;
|
180
|
+
var character = 0;
|
181
|
+
var characters = "";
|
182
|
+
function node(value, root, parent, type, props, children, length2) {
|
183
|
+
return { value, root, parent, type, props, children, line, column, length: length2, return: "" };
|
184
|
+
}
|
185
|
+
function copy(root, props) {
|
186
|
+
return assign(node("", null, null, "", null, null, 0), root, { length: -root.length }, props);
|
187
|
+
}
|
188
|
+
function char() {
|
189
|
+
return character;
|
190
|
+
}
|
191
|
+
function prev() {
|
192
|
+
character = position > 0 ? charat(characters, --position) : 0;
|
193
|
+
if (column--, character === 10)
|
194
|
+
column = 1, line--;
|
195
|
+
return character;
|
196
|
+
}
|
197
|
+
function next() {
|
198
|
+
character = position < length ? charat(characters, position++) : 0;
|
199
|
+
if (column++, character === 10)
|
200
|
+
column = 1, line++;
|
201
|
+
return character;
|
202
|
+
}
|
203
|
+
function peek() {
|
204
|
+
return charat(characters, position);
|
205
|
+
}
|
206
|
+
function caret() {
|
207
|
+
return position;
|
208
|
+
}
|
209
|
+
function slice(begin, end) {
|
210
|
+
return substr(characters, begin, end);
|
211
|
+
}
|
212
|
+
function token(type) {
|
213
|
+
switch (type) {
|
214
|
+
case 0:
|
215
|
+
case 9:
|
216
|
+
case 10:
|
217
|
+
case 13:
|
218
|
+
case 32:
|
219
|
+
return 5;
|
220
|
+
case 33:
|
221
|
+
case 43:
|
222
|
+
case 44:
|
223
|
+
case 47:
|
224
|
+
case 62:
|
225
|
+
case 64:
|
226
|
+
case 126:
|
227
|
+
case 59:
|
228
|
+
case 123:
|
229
|
+
case 125:
|
230
|
+
return 4;
|
231
|
+
case 58:
|
232
|
+
return 3;
|
233
|
+
case 34:
|
234
|
+
case 39:
|
235
|
+
case 40:
|
236
|
+
case 91:
|
237
|
+
return 2;
|
238
|
+
case 41:
|
239
|
+
case 93:
|
240
|
+
return 1;
|
241
|
+
}
|
242
|
+
return 0;
|
243
|
+
}
|
244
|
+
function alloc(value) {
|
245
|
+
return line = column = 1, length = strlen(characters = value), position = 0, [];
|
246
|
+
}
|
247
|
+
function dealloc(value) {
|
248
|
+
return characters = "", value;
|
249
|
+
}
|
250
|
+
function delimit(type) {
|
251
|
+
return trim(slice(position - 1, delimiter(type === 91 ? type + 2 : type === 40 ? type + 1 : type)));
|
252
|
+
}
|
253
|
+
function whitespace(type) {
|
254
|
+
while (character = peek())
|
255
|
+
if (character < 33)
|
256
|
+
next();
|
257
|
+
else
|
258
|
+
break;
|
259
|
+
return token(type) > 2 || token(character) > 3 ? "" : " ";
|
260
|
+
}
|
261
|
+
function escaping(index, count) {
|
262
|
+
while (--count && next())
|
263
|
+
if (character < 48 || character > 102 || character > 57 && character < 65 || character > 70 && character < 97)
|
264
|
+
break;
|
265
|
+
return slice(index, caret() + (count < 6 && peek() == 32 && next() == 32));
|
266
|
+
}
|
267
|
+
function delimiter(type) {
|
268
|
+
while (next())
|
269
|
+
switch (character) {
|
270
|
+
case type:
|
271
|
+
return position;
|
272
|
+
case 34:
|
273
|
+
case 39:
|
274
|
+
if (type !== 34 && type !== 39)
|
275
|
+
delimiter(character);
|
276
|
+
break;
|
277
|
+
case 40:
|
278
|
+
if (type === 41)
|
279
|
+
delimiter(type);
|
280
|
+
break;
|
281
|
+
case 92:
|
282
|
+
next();
|
283
|
+
break;
|
284
|
+
}
|
285
|
+
return position;
|
286
|
+
}
|
287
|
+
function commenter(type, index) {
|
288
|
+
while (next())
|
289
|
+
if (type + character === 47 + 10)
|
290
|
+
break;
|
291
|
+
else if (type + character === 42 + 42 && peek() === 47)
|
292
|
+
break;
|
293
|
+
return "/*" + slice(index, position - 1) + "*" + from(type === 47 ? type : next());
|
294
|
+
}
|
295
|
+
function identifier(index) {
|
296
|
+
while (!token(peek()))
|
297
|
+
next();
|
298
|
+
return slice(index, position);
|
299
|
+
}
|
300
|
+
|
301
|
+
// ../../node_modules/stylis/src/Parser.js
|
302
|
+
function compile(value) {
|
303
|
+
return dealloc(parse("", null, null, null, [""], value = alloc(value), 0, [0], value));
|
304
|
+
}
|
305
|
+
function parse(value, root, parent, rule, rules, rulesets, pseudo, points, declarations) {
|
306
|
+
var index = 0;
|
307
|
+
var offset = 0;
|
308
|
+
var length2 = pseudo;
|
309
|
+
var atrule = 0;
|
310
|
+
var property = 0;
|
311
|
+
var previous = 0;
|
312
|
+
var variable = 1;
|
313
|
+
var scanning = 1;
|
314
|
+
var ampersand = 1;
|
315
|
+
var character2 = 0;
|
316
|
+
var type = "";
|
317
|
+
var props = rules;
|
318
|
+
var children = rulesets;
|
319
|
+
var reference = rule;
|
320
|
+
var characters2 = type;
|
321
|
+
while (scanning)
|
322
|
+
switch (previous = character2, character2 = next()) {
|
323
|
+
case 40:
|
324
|
+
if (previous != 108 && charat(characters2, length2 - 1) == 58) {
|
325
|
+
if (indexof(characters2 += replace(delimit(character2), "&", "&\f"), "&\f") != -1)
|
326
|
+
ampersand = -1;
|
327
|
+
break;
|
328
|
+
}
|
329
|
+
case 34:
|
330
|
+
case 39:
|
331
|
+
case 91:
|
332
|
+
characters2 += delimit(character2);
|
333
|
+
break;
|
334
|
+
case 9:
|
335
|
+
case 10:
|
336
|
+
case 13:
|
337
|
+
case 32:
|
338
|
+
characters2 += whitespace(previous);
|
339
|
+
break;
|
340
|
+
case 92:
|
341
|
+
characters2 += escaping(caret() - 1, 7);
|
342
|
+
continue;
|
343
|
+
case 47:
|
344
|
+
switch (peek()) {
|
345
|
+
case 42:
|
346
|
+
case 47:
|
347
|
+
append(comment(commenter(next(), caret()), root, parent), declarations);
|
348
|
+
break;
|
349
|
+
default:
|
350
|
+
characters2 += "/";
|
351
|
+
}
|
352
|
+
break;
|
353
|
+
case 123 * variable:
|
354
|
+
points[index++] = strlen(characters2) * ampersand;
|
355
|
+
case 125 * variable:
|
356
|
+
case 59:
|
357
|
+
case 0:
|
358
|
+
switch (character2) {
|
359
|
+
case 0:
|
360
|
+
case 125:
|
361
|
+
scanning = 0;
|
362
|
+
case 59 + offset:
|
363
|
+
if (ampersand == -1) characters2 = replace(characters2, /\f/g, "");
|
364
|
+
if (property > 0 && strlen(characters2) - length2)
|
365
|
+
append(property > 32 ? declaration(characters2 + ";", rule, parent, length2 - 1) : declaration(replace(characters2, " ", "") + ";", rule, parent, length2 - 2), declarations);
|
366
|
+
break;
|
367
|
+
case 59:
|
368
|
+
characters2 += ";";
|
369
|
+
default:
|
370
|
+
append(reference = ruleset(characters2, root, parent, index, offset, rules, points, type, props = [], children = [], length2), rulesets);
|
371
|
+
if (character2 === 123)
|
372
|
+
if (offset === 0)
|
373
|
+
parse(characters2, root, reference, reference, props, rulesets, length2, points, children);
|
374
|
+
else
|
375
|
+
switch (atrule === 99 && charat(characters2, 3) === 110 ? 100 : atrule) {
|
376
|
+
case 100:
|
377
|
+
case 108:
|
378
|
+
case 109:
|
379
|
+
case 115:
|
380
|
+
parse(value, reference, reference, rule && append(ruleset(value, reference, reference, 0, 0, rules, points, type, rules, props = [], length2), children), rules, children, length2, points, rule ? props : children);
|
381
|
+
break;
|
382
|
+
default:
|
383
|
+
parse(characters2, reference, reference, reference, [""], children, 0, points, children);
|
384
|
+
}
|
385
|
+
}
|
386
|
+
index = offset = property = 0, variable = ampersand = 1, type = characters2 = "", length2 = pseudo;
|
387
|
+
break;
|
388
|
+
case 58:
|
389
|
+
length2 = 1 + strlen(characters2), property = previous;
|
390
|
+
default:
|
391
|
+
if (variable < 1) {
|
392
|
+
if (character2 == 123)
|
393
|
+
--variable;
|
394
|
+
else if (character2 == 125 && variable++ == 0 && prev() == 125)
|
395
|
+
continue;
|
396
|
+
}
|
397
|
+
switch (characters2 += from(character2), character2 * variable) {
|
398
|
+
case 38:
|
399
|
+
ampersand = offset > 0 ? 1 : (characters2 += "\f", -1);
|
400
|
+
break;
|
401
|
+
case 44:
|
402
|
+
points[index++] = (strlen(characters2) - 1) * ampersand, ampersand = 1;
|
403
|
+
break;
|
404
|
+
case 64:
|
405
|
+
if (peek() === 45)
|
406
|
+
characters2 += delimit(next());
|
407
|
+
atrule = peek(), offset = length2 = strlen(type = characters2 += identifier(caret())), character2++;
|
408
|
+
break;
|
409
|
+
case 45:
|
410
|
+
if (previous === 45 && strlen(characters2) == 2)
|
411
|
+
variable = 0;
|
412
|
+
}
|
413
|
+
}
|
414
|
+
return rulesets;
|
415
|
+
}
|
416
|
+
function ruleset(value, root, parent, index, offset, rules, points, type, props, children, length2) {
|
417
|
+
var post = offset - 1;
|
418
|
+
var rule = offset === 0 ? rules : [""];
|
419
|
+
var size = sizeof(rule);
|
420
|
+
for (var i = 0, j = 0, k = 0; i < index; ++i)
|
421
|
+
for (var x = 0, y = substr(value, post + 1, post = abs(j = points[i])), z = value; x < size; ++x)
|
422
|
+
if (z = trim(j > 0 ? rule[x] + " " + y : replace(y, /&\f/g, rule[x])))
|
423
|
+
props[k++] = z;
|
424
|
+
return node(value, root, parent, offset === 0 ? RULESET : type, props, children, length2);
|
425
|
+
}
|
426
|
+
function comment(value, root, parent) {
|
427
|
+
return node(value, root, parent, COMMENT, from(char()), substr(value, 2, -2), 0);
|
428
|
+
}
|
429
|
+
function declaration(value, root, parent, length2) {
|
430
|
+
return node(value, root, parent, DECLARATION, substr(value, 0, length2), substr(value, length2 + 1, -1), length2);
|
431
|
+
}
|
432
|
+
|
433
|
+
// ../../node_modules/stylis/src/Serializer.js
|
434
|
+
function serialize(children, callback) {
|
435
|
+
var output = "";
|
436
|
+
var length2 = sizeof(children);
|
437
|
+
for (var i = 0; i < length2; i++)
|
438
|
+
output += callback(children[i], i, children, callback) || "";
|
439
|
+
return output;
|
440
|
+
}
|
441
|
+
function stringify(element, index, children, callback) {
|
442
|
+
switch (element.type) {
|
443
|
+
case LAYER:
|
444
|
+
if (element.children.length) break;
|
445
|
+
case IMPORT:
|
446
|
+
case DECLARATION:
|
447
|
+
return element.return = element.return || element.value;
|
448
|
+
case COMMENT:
|
449
|
+
return "";
|
450
|
+
case KEYFRAMES:
|
451
|
+
return element.return = element.value + "{" + serialize(element.children, callback) + "}";
|
452
|
+
case RULESET:
|
453
|
+
element.value = element.props.join(",");
|
454
|
+
}
|
455
|
+
return strlen(children = serialize(element.children, callback)) ? element.return = element.value + "{" + children + "}" : "";
|
456
|
+
}
|
457
|
+
|
458
|
+
// ../../node_modules/stylis/src/Middleware.js
|
459
|
+
function middleware(collection) {
|
460
|
+
var length2 = sizeof(collection);
|
461
|
+
return function(element, index, children, callback) {
|
462
|
+
var output = "";
|
463
|
+
for (var i = 0; i < length2; i++)
|
464
|
+
output += collection[i](element, index, children, callback) || "";
|
465
|
+
return output;
|
466
|
+
};
|
467
|
+
}
|
468
|
+
function rulesheet(callback) {
|
469
|
+
return function(element) {
|
470
|
+
if (!element.root) {
|
471
|
+
if (element = element.return)
|
472
|
+
callback(element);
|
473
|
+
}
|
474
|
+
};
|
475
|
+
}
|
476
|
+
|
477
|
+
// ../../node_modules/@emotion/weak-memoize/dist/emotion-weak-memoize.esm.js
|
478
|
+
var weakMemoize = function weakMemoize2(func) {
|
479
|
+
var cache = /* @__PURE__ */ new WeakMap();
|
480
|
+
return function(arg) {
|
481
|
+
if (cache.has(arg)) {
|
482
|
+
return cache.get(arg);
|
483
|
+
}
|
484
|
+
var ret = func(arg);
|
485
|
+
cache.set(arg, ret);
|
486
|
+
return ret;
|
487
|
+
};
|
488
|
+
};
|
489
|
+
|
490
|
+
// ../../node_modules/@emotion/memoize/dist/emotion-memoize.esm.js
|
491
|
+
function memoize(fn) {
|
492
|
+
var cache = /* @__PURE__ */ Object.create(null);
|
493
|
+
return function(arg) {
|
494
|
+
if (cache[arg] === void 0) cache[arg] = fn(arg);
|
495
|
+
return cache[arg];
|
496
|
+
};
|
497
|
+
}
|
498
|
+
|
499
|
+
// ../../node_modules/@emotion/cache/dist/emotion-cache.esm.js
|
500
|
+
var isBrowser = typeof document !== "undefined";
|
501
|
+
var identifierWithPointTracking = function identifierWithPointTracking2(begin, points, index) {
|
502
|
+
var previous = 0;
|
503
|
+
var character2 = 0;
|
504
|
+
while (true) {
|
505
|
+
previous = character2;
|
506
|
+
character2 = peek();
|
507
|
+
if (previous === 38 && character2 === 12) {
|
508
|
+
points[index] = 1;
|
509
|
+
}
|
510
|
+
if (token(character2)) {
|
511
|
+
break;
|
512
|
+
}
|
513
|
+
next();
|
514
|
+
}
|
515
|
+
return slice(begin, position);
|
516
|
+
};
|
517
|
+
var toRules = function toRules2(parsed, points) {
|
518
|
+
var index = -1;
|
519
|
+
var character2 = 44;
|
520
|
+
do {
|
521
|
+
switch (token(character2)) {
|
522
|
+
case 0:
|
523
|
+
if (character2 === 38 && peek() === 12) {
|
524
|
+
points[index] = 1;
|
525
|
+
}
|
526
|
+
parsed[index] += identifierWithPointTracking(position - 1, points, index);
|
527
|
+
break;
|
528
|
+
case 2:
|
529
|
+
parsed[index] += delimit(character2);
|
530
|
+
break;
|
531
|
+
case 4:
|
532
|
+
if (character2 === 44) {
|
533
|
+
parsed[++index] = peek() === 58 ? "&\f" : "";
|
534
|
+
points[index] = parsed[index].length;
|
535
|
+
break;
|
536
|
+
}
|
537
|
+
default:
|
538
|
+
parsed[index] += from(character2);
|
539
|
+
}
|
540
|
+
} while (character2 = next());
|
541
|
+
return parsed;
|
542
|
+
};
|
543
|
+
var getRules = function getRules2(value, points) {
|
544
|
+
return dealloc(toRules(alloc(value), points));
|
545
|
+
};
|
546
|
+
var fixedElements = /* @__PURE__ */ new WeakMap();
|
547
|
+
var compat = function compat2(element) {
|
548
|
+
if (element.type !== "rule" || !element.parent || // positive .length indicates that this rule contains pseudo
|
549
|
+
// negative .length indicates that this rule has been already prefixed
|
550
|
+
element.length < 1) {
|
551
|
+
return;
|
552
|
+
}
|
553
|
+
var value = element.value, parent = element.parent;
|
554
|
+
var isImplicitRule = element.column === parent.column && element.line === parent.line;
|
555
|
+
while (parent.type !== "rule") {
|
556
|
+
parent = parent.parent;
|
557
|
+
if (!parent) return;
|
558
|
+
}
|
559
|
+
if (element.props.length === 1 && value.charCodeAt(0) !== 58 && !fixedElements.get(parent)) {
|
560
|
+
return;
|
561
|
+
}
|
562
|
+
if (isImplicitRule) {
|
563
|
+
return;
|
564
|
+
}
|
565
|
+
fixedElements.set(element, true);
|
566
|
+
var points = [];
|
567
|
+
var rules = getRules(value, points);
|
568
|
+
var parentRules = parent.props;
|
569
|
+
for (var i = 0, k = 0; i < rules.length; i++) {
|
570
|
+
for (var j = 0; j < parentRules.length; j++, k++) {
|
571
|
+
element.props[k] = points[i] ? rules[i].replace(/&\f/g, parentRules[j]) : parentRules[j] + " " + rules[i];
|
572
|
+
}
|
573
|
+
}
|
574
|
+
};
|
575
|
+
var removeLabel = function removeLabel2(element) {
|
576
|
+
if (element.type === "decl") {
|
577
|
+
var value = element.value;
|
578
|
+
if (
|
579
|
+
// charcode for l
|
580
|
+
value.charCodeAt(0) === 108 && // charcode for b
|
581
|
+
value.charCodeAt(2) === 98
|
582
|
+
) {
|
583
|
+
element["return"] = "";
|
584
|
+
element.value = "";
|
585
|
+
}
|
586
|
+
}
|
587
|
+
};
|
588
|
+
function prefix(value, length2) {
|
589
|
+
switch (hash(value, length2)) {
|
590
|
+
case 5103:
|
591
|
+
return WEBKIT + "print-" + value + value;
|
592
|
+
case 5737:
|
593
|
+
case 4201:
|
594
|
+
case 3177:
|
595
|
+
case 3433:
|
596
|
+
case 1641:
|
597
|
+
case 4457:
|
598
|
+
case 2921:
|
599
|
+
case 5572:
|
600
|
+
case 6356:
|
601
|
+
case 5844:
|
602
|
+
case 3191:
|
603
|
+
case 6645:
|
604
|
+
case 3005:
|
605
|
+
case 6391:
|
606
|
+
case 5879:
|
607
|
+
case 5623:
|
608
|
+
case 6135:
|
609
|
+
case 4599:
|
610
|
+
case 4855:
|
611
|
+
case 4215:
|
612
|
+
case 6389:
|
613
|
+
case 5109:
|
614
|
+
case 5365:
|
615
|
+
case 5621:
|
616
|
+
case 3829:
|
617
|
+
return WEBKIT + value + value;
|
618
|
+
case 5349:
|
619
|
+
case 4246:
|
620
|
+
case 4810:
|
621
|
+
case 6968:
|
622
|
+
case 2756:
|
623
|
+
return WEBKIT + value + MOZ + value + MS + value + value;
|
624
|
+
case 6828:
|
625
|
+
case 4268:
|
626
|
+
return WEBKIT + value + MS + value + value;
|
627
|
+
case 6165:
|
628
|
+
return WEBKIT + value + MS + "flex-" + value + value;
|
629
|
+
case 5187:
|
630
|
+
return WEBKIT + value + replace(value, /(\w+).+(:[^]+)/, WEBKIT + "box-$1$2" + MS + "flex-$1$2") + value;
|
631
|
+
case 5443:
|
632
|
+
return WEBKIT + value + MS + "flex-item-" + replace(value, /flex-|-self/, "") + value;
|
633
|
+
case 4675:
|
634
|
+
return WEBKIT + value + MS + "flex-line-pack" + replace(value, /align-content|flex-|-self/, "") + value;
|
635
|
+
case 5548:
|
636
|
+
return WEBKIT + value + MS + replace(value, "shrink", "negative") + value;
|
637
|
+
case 5292:
|
638
|
+
return WEBKIT + value + MS + replace(value, "basis", "preferred-size") + value;
|
639
|
+
case 6060:
|
640
|
+
return WEBKIT + "box-" + replace(value, "-grow", "") + WEBKIT + value + MS + replace(value, "grow", "positive") + value;
|
641
|
+
case 4554:
|
642
|
+
return WEBKIT + replace(value, /([^-])(transform)/g, "$1" + WEBKIT + "$2") + value;
|
643
|
+
case 6187:
|
644
|
+
return replace(replace(replace(value, /(zoom-|grab)/, WEBKIT + "$1"), /(image-set)/, WEBKIT + "$1"), value, "") + value;
|
645
|
+
case 5495:
|
646
|
+
case 3959:
|
647
|
+
return replace(value, /(image-set\([^]*)/, WEBKIT + "$1$`$1");
|
648
|
+
case 4968:
|
649
|
+
return replace(replace(value, /(.+:)(flex-)?(.*)/, WEBKIT + "box-pack:$3" + MS + "flex-pack:$3"), /s.+-b[^;]+/, "justify") + WEBKIT + value + value;
|
650
|
+
case 4095:
|
651
|
+
case 3583:
|
652
|
+
case 4068:
|
653
|
+
case 2532:
|
654
|
+
return replace(value, /(.+)-inline(.+)/, WEBKIT + "$1$2") + value;
|
655
|
+
case 8116:
|
656
|
+
case 7059:
|
657
|
+
case 5753:
|
658
|
+
case 5535:
|
659
|
+
case 5445:
|
660
|
+
case 5701:
|
661
|
+
case 4933:
|
662
|
+
case 4677:
|
663
|
+
case 5533:
|
664
|
+
case 5789:
|
665
|
+
case 5021:
|
666
|
+
case 4765:
|
667
|
+
if (strlen(value) - 1 - length2 > 6) switch (charat(value, length2 + 1)) {
|
668
|
+
case 109:
|
669
|
+
if (charat(value, length2 + 4) !== 45) break;
|
670
|
+
case 102:
|
671
|
+
return replace(value, /(.+:)(.+)-([^]+)/, "$1" + WEBKIT + "$2-$3$1" + MOZ + (charat(value, length2 + 3) == 108 ? "$3" : "$2-$3")) + value;
|
672
|
+
case 115:
|
673
|
+
return ~indexof(value, "stretch") ? prefix(replace(value, "stretch", "fill-available"), length2) + value : value;
|
674
|
+
}
|
675
|
+
break;
|
676
|
+
case 4949:
|
677
|
+
if (charat(value, length2 + 1) !== 115) break;
|
678
|
+
case 6444:
|
679
|
+
switch (charat(value, strlen(value) - 3 - (~indexof(value, "!important") && 10))) {
|
680
|
+
case 107:
|
681
|
+
return replace(value, ":", ":" + WEBKIT) + value;
|
682
|
+
case 101:
|
683
|
+
return replace(value, /(.+:)([^;!]+)(;|!.+)?/, "$1" + WEBKIT + (charat(value, 14) === 45 ? "inline-" : "") + "box$3$1" + WEBKIT + "$2$3$1" + MS + "$2box$3") + value;
|
684
|
+
}
|
685
|
+
break;
|
686
|
+
case 5936:
|
687
|
+
switch (charat(value, length2 + 11)) {
|
688
|
+
case 114:
|
689
|
+
return WEBKIT + value + MS + replace(value, /[svh]\w+-[tblr]{2}/, "tb") + value;
|
690
|
+
case 108:
|
691
|
+
return WEBKIT + value + MS + replace(value, /[svh]\w+-[tblr]{2}/, "tb-rl") + value;
|
692
|
+
case 45:
|
693
|
+
return WEBKIT + value + MS + replace(value, /[svh]\w+-[tblr]{2}/, "lr") + value;
|
694
|
+
}
|
695
|
+
return WEBKIT + value + MS + value + value;
|
696
|
+
}
|
697
|
+
return value;
|
698
|
+
}
|
699
|
+
var prefixer = function prefixer2(element, index, children, callback) {
|
700
|
+
if (element.length > -1) {
|
701
|
+
if (!element["return"]) switch (element.type) {
|
702
|
+
case DECLARATION:
|
703
|
+
element["return"] = prefix(element.value, element.length);
|
704
|
+
break;
|
705
|
+
case KEYFRAMES:
|
706
|
+
return serialize([copy(element, {
|
707
|
+
value: replace(element.value, "@", "@" + WEBKIT)
|
708
|
+
})], callback);
|
709
|
+
case RULESET:
|
710
|
+
if (element.length) return combine(element.props, function(value) {
|
711
|
+
switch (match(value, /(::plac\w+|:read-\w+)/)) {
|
712
|
+
case ":read-only":
|
713
|
+
case ":read-write":
|
714
|
+
return serialize([copy(element, {
|
715
|
+
props: [replace(value, /:(read-\w+)/, ":" + MOZ + "$1")]
|
716
|
+
})], callback);
|
717
|
+
case "::placeholder":
|
718
|
+
return serialize([copy(element, {
|
719
|
+
props: [replace(value, /:(plac\w+)/, ":" + WEBKIT + "input-$1")]
|
720
|
+
}), copy(element, {
|
721
|
+
props: [replace(value, /:(plac\w+)/, ":" + MOZ + "$1")]
|
722
|
+
}), copy(element, {
|
723
|
+
props: [replace(value, /:(plac\w+)/, MS + "input-$1")]
|
724
|
+
})], callback);
|
725
|
+
}
|
726
|
+
return "";
|
727
|
+
});
|
728
|
+
}
|
729
|
+
}
|
730
|
+
};
|
731
|
+
var getServerStylisCache = isBrowser ? void 0 : weakMemoize(function() {
|
732
|
+
return memoize(function() {
|
733
|
+
var cache = {};
|
734
|
+
return function(name) {
|
735
|
+
return cache[name];
|
736
|
+
};
|
737
|
+
});
|
738
|
+
});
|
739
|
+
var defaultStylisPlugins = [prefixer];
|
740
|
+
var createCache = function createCache2(options) {
|
741
|
+
var key = options.key;
|
742
|
+
if (isBrowser && key === "css") {
|
743
|
+
var ssrStyles = document.querySelectorAll("style[data-emotion]:not([data-s])");
|
744
|
+
Array.prototype.forEach.call(ssrStyles, function(node2) {
|
745
|
+
var dataEmotionAttribute = node2.getAttribute("data-emotion");
|
746
|
+
if (dataEmotionAttribute.indexOf(" ") === -1) {
|
747
|
+
return;
|
748
|
+
}
|
749
|
+
document.head.appendChild(node2);
|
750
|
+
node2.setAttribute("data-s", "");
|
751
|
+
});
|
752
|
+
}
|
753
|
+
var stylisPlugins = options.stylisPlugins || defaultStylisPlugins;
|
754
|
+
var inserted = {};
|
755
|
+
var container;
|
756
|
+
var nodesToHydrate = [];
|
757
|
+
if (isBrowser) {
|
758
|
+
container = options.container || document.head;
|
759
|
+
Array.prototype.forEach.call(
|
760
|
+
// this means we will ignore elements which don't have a space in them which
|
761
|
+
// means that the style elements we're looking at are only Emotion 11 server-rendered style elements
|
762
|
+
document.querySelectorAll('style[data-emotion^="' + key + ' "]'),
|
763
|
+
function(node2) {
|
764
|
+
var attrib = node2.getAttribute("data-emotion").split(" ");
|
765
|
+
for (var i = 1; i < attrib.length; i++) {
|
766
|
+
inserted[attrib[i]] = true;
|
767
|
+
}
|
768
|
+
nodesToHydrate.push(node2);
|
769
|
+
}
|
770
|
+
);
|
771
|
+
}
|
772
|
+
var _insert;
|
773
|
+
var omnipresentPlugins = [compat, removeLabel];
|
774
|
+
if (isBrowser) {
|
775
|
+
var currentSheet;
|
776
|
+
var finalizingPlugins = [stringify, rulesheet(function(rule) {
|
777
|
+
currentSheet.insert(rule);
|
778
|
+
})];
|
779
|
+
var serializer = middleware(omnipresentPlugins.concat(stylisPlugins, finalizingPlugins));
|
780
|
+
var stylis = function stylis2(styles) {
|
781
|
+
return serialize(compile(styles), serializer);
|
782
|
+
};
|
783
|
+
_insert = function insert(selector, serialized, sheet, shouldCache) {
|
784
|
+
currentSheet = sheet;
|
785
|
+
stylis(selector ? selector + "{" + serialized.styles + "}" : serialized.styles);
|
786
|
+
if (shouldCache) {
|
787
|
+
cache.inserted[serialized.name] = true;
|
788
|
+
}
|
789
|
+
};
|
790
|
+
} else {
|
791
|
+
var _finalizingPlugins = [stringify];
|
792
|
+
var _serializer = middleware(omnipresentPlugins.concat(stylisPlugins, _finalizingPlugins));
|
793
|
+
var _stylis = function _stylis2(styles) {
|
794
|
+
return serialize(compile(styles), _serializer);
|
795
|
+
};
|
796
|
+
var serverStylisCache = getServerStylisCache(stylisPlugins)(key);
|
797
|
+
var getRules3 = function getRules4(selector, serialized) {
|
798
|
+
var name = serialized.name;
|
799
|
+
if (serverStylisCache[name] === void 0) {
|
800
|
+
serverStylisCache[name] = _stylis(selector ? selector + "{" + serialized.styles + "}" : serialized.styles);
|
801
|
+
}
|
802
|
+
return serverStylisCache[name];
|
803
|
+
};
|
804
|
+
_insert = function _insert2(selector, serialized, sheet, shouldCache) {
|
805
|
+
var name = serialized.name;
|
806
|
+
var rules = getRules3(selector, serialized);
|
807
|
+
if (cache.compat === void 0) {
|
808
|
+
if (shouldCache) {
|
809
|
+
cache.inserted[name] = true;
|
810
|
+
}
|
811
|
+
return rules;
|
812
|
+
} else {
|
813
|
+
if (shouldCache) {
|
814
|
+
cache.inserted[name] = rules;
|
815
|
+
} else {
|
816
|
+
return rules;
|
817
|
+
}
|
818
|
+
}
|
819
|
+
};
|
820
|
+
}
|
821
|
+
var cache = {
|
822
|
+
key,
|
823
|
+
sheet: new StyleSheet({
|
824
|
+
key,
|
825
|
+
container,
|
826
|
+
nonce: options.nonce,
|
827
|
+
speedy: options.speedy,
|
828
|
+
prepend: options.prepend,
|
829
|
+
insertionPoint: options.insertionPoint
|
830
|
+
}),
|
831
|
+
nonce: options.nonce,
|
832
|
+
inserted,
|
833
|
+
registered: {},
|
834
|
+
insert: _insert
|
835
|
+
};
|
836
|
+
cache.sheet.hydrate(nodesToHydrate);
|
837
|
+
return cache;
|
838
|
+
};
|
839
|
+
|
840
|
+
// index.tsx
|
841
|
+
var import_react3 = require("@emotion/react");
|
842
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
843
|
+
var createEmotionCachePlugin = (key) => {
|
844
|
+
return {
|
845
|
+
overrides: {
|
846
|
+
iframe: ({ children, document: document2 }) => {
|
847
|
+
const [cache, setCache] = (0, import_react2.useState)(null);
|
848
|
+
(0, import_react2.useEffect)(() => {
|
849
|
+
if (document2) {
|
850
|
+
setCache(
|
851
|
+
createCache({
|
852
|
+
key,
|
853
|
+
container: document2.head
|
854
|
+
})
|
855
|
+
);
|
856
|
+
}
|
857
|
+
}, [document2, key]);
|
858
|
+
if (cache) {
|
859
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react3.CacheProvider, { value: cache, children });
|
860
|
+
}
|
861
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children });
|
862
|
+
}
|
863
|
+
}
|
864
|
+
};
|
865
|
+
};
|
866
|
+
var plugin_emotion_cache_default = createEmotionCachePlugin;
|
package/package.json
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
{
|
2
|
+
"name": "@measured/puck-plugin-emotion-cache",
|
3
|
+
"version": "0.15.0",
|
4
|
+
"author": "Measured Corporation Ltd <hello@measured.co>",
|
5
|
+
"repository": "measuredco/puck",
|
6
|
+
"bugs": "https://github.com/measuredco/puck/issues",
|
7
|
+
"homepage": "https://puckeditor.com",
|
8
|
+
"private": false,
|
9
|
+
"main": "./dist/index.js",
|
10
|
+
"types": "./dist/index.d.ts",
|
11
|
+
"license": "MIT",
|
12
|
+
"scripts": {
|
13
|
+
"lint": "eslint \"**/*.ts*\"",
|
14
|
+
"build": "rm -rf dist && tsup index.tsx",
|
15
|
+
"prepare": "yarn build"
|
16
|
+
},
|
17
|
+
"files": [
|
18
|
+
"dist"
|
19
|
+
],
|
20
|
+
"devDependencies": {
|
21
|
+
"@emotion/react": "^11.13.3",
|
22
|
+
"@measured/puck": "^0.15.0",
|
23
|
+
"@types/react": "^18.2.0",
|
24
|
+
"@types/react-dom": "^18.2.0",
|
25
|
+
"eslint": "^7.32.0",
|
26
|
+
"eslint-config-custom": "*",
|
27
|
+
"tsconfig": "*",
|
28
|
+
"tsup": "^8.2.4",
|
29
|
+
"tsup-config": "*",
|
30
|
+
"typescript": "^5.5.4"
|
31
|
+
},
|
32
|
+
"dependencies": {},
|
33
|
+
"peerDependencies": {
|
34
|
+
"react": "^17.0.0 || ^18.0.0",
|
35
|
+
"@emotion/react": "^11.0.0"
|
36
|
+
}
|
37
|
+
}
|