@rijkshuisstijl-community/web-components 1.0.1-alpha.13 → 1.0.1-alpha.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +25 -6
- package/dist/index.mjs +3009 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -5
package/dist/index.mjs
CHANGED
|
@@ -7960,6 +7960,2936 @@ const UnorderedList = /*#__PURE__*/reactExports.forwardRef(({
|
|
|
7960
7960
|
});
|
|
7961
7961
|
UnorderedList.displayName = 'UnorderedList';
|
|
7962
7962
|
|
|
7963
|
+
var lib$3 = {};
|
|
7964
|
+
|
|
7965
|
+
var htmlToDom = {};
|
|
7966
|
+
|
|
7967
|
+
var domparser = {};
|
|
7968
|
+
|
|
7969
|
+
var utilities$2 = {};
|
|
7970
|
+
|
|
7971
|
+
var lib$2 = {};
|
|
7972
|
+
|
|
7973
|
+
var lib$1 = {};
|
|
7974
|
+
|
|
7975
|
+
var hasRequiredLib$3;
|
|
7976
|
+
|
|
7977
|
+
function requireLib$3 () {
|
|
7978
|
+
if (hasRequiredLib$3) return lib$1;
|
|
7979
|
+
hasRequiredLib$3 = 1;
|
|
7980
|
+
(function (exports) {
|
|
7981
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7982
|
+
exports.Doctype = exports.CDATA = exports.Tag = exports.Style = exports.Script = exports.Comment = exports.Directive = exports.Text = exports.Root = exports.isTag = exports.ElementType = void 0;
|
|
7983
|
+
/** Types of elements found in htmlparser2's DOM */
|
|
7984
|
+
var ElementType;
|
|
7985
|
+
(function (ElementType) {
|
|
7986
|
+
/** Type for the root element of a document */
|
|
7987
|
+
ElementType["Root"] = "root";
|
|
7988
|
+
/** Type for Text */
|
|
7989
|
+
ElementType["Text"] = "text";
|
|
7990
|
+
/** Type for <? ... ?> */
|
|
7991
|
+
ElementType["Directive"] = "directive";
|
|
7992
|
+
/** Type for <!-- ... --> */
|
|
7993
|
+
ElementType["Comment"] = "comment";
|
|
7994
|
+
/** Type for <script> tags */
|
|
7995
|
+
ElementType["Script"] = "script";
|
|
7996
|
+
/** Type for <style> tags */
|
|
7997
|
+
ElementType["Style"] = "style";
|
|
7998
|
+
/** Type for Any tag */
|
|
7999
|
+
ElementType["Tag"] = "tag";
|
|
8000
|
+
/** Type for <![CDATA[ ... ]]> */
|
|
8001
|
+
ElementType["CDATA"] = "cdata";
|
|
8002
|
+
/** Type for <!doctype ...> */
|
|
8003
|
+
ElementType["Doctype"] = "doctype";
|
|
8004
|
+
})(ElementType = exports.ElementType || (exports.ElementType = {}));
|
|
8005
|
+
/**
|
|
8006
|
+
* Tests whether an element is a tag or not.
|
|
8007
|
+
*
|
|
8008
|
+
* @param elem Element to test
|
|
8009
|
+
*/
|
|
8010
|
+
function isTag(elem) {
|
|
8011
|
+
return (elem.type === ElementType.Tag ||
|
|
8012
|
+
elem.type === ElementType.Script ||
|
|
8013
|
+
elem.type === ElementType.Style);
|
|
8014
|
+
}
|
|
8015
|
+
exports.isTag = isTag;
|
|
8016
|
+
// Exports for backwards compatibility
|
|
8017
|
+
/** Type for the root element of a document */
|
|
8018
|
+
exports.Root = ElementType.Root;
|
|
8019
|
+
/** Type for Text */
|
|
8020
|
+
exports.Text = ElementType.Text;
|
|
8021
|
+
/** Type for <? ... ?> */
|
|
8022
|
+
exports.Directive = ElementType.Directive;
|
|
8023
|
+
/** Type for <!-- ... --> */
|
|
8024
|
+
exports.Comment = ElementType.Comment;
|
|
8025
|
+
/** Type for <script> tags */
|
|
8026
|
+
exports.Script = ElementType.Script;
|
|
8027
|
+
/** Type for <style> tags */
|
|
8028
|
+
exports.Style = ElementType.Style;
|
|
8029
|
+
/** Type for Any tag */
|
|
8030
|
+
exports.Tag = ElementType.Tag;
|
|
8031
|
+
/** Type for <![CDATA[ ... ]]> */
|
|
8032
|
+
exports.CDATA = ElementType.CDATA;
|
|
8033
|
+
/** Type for <!doctype ...> */
|
|
8034
|
+
exports.Doctype = ElementType.Doctype;
|
|
8035
|
+
} (lib$1));
|
|
8036
|
+
return lib$1;
|
|
8037
|
+
}
|
|
8038
|
+
|
|
8039
|
+
var node = {};
|
|
8040
|
+
|
|
8041
|
+
var hasRequiredNode;
|
|
8042
|
+
|
|
8043
|
+
function requireNode () {
|
|
8044
|
+
if (hasRequiredNode) return node;
|
|
8045
|
+
hasRequiredNode = 1;
|
|
8046
|
+
var __extends = (node && node.__extends) || (function () {
|
|
8047
|
+
var extendStatics = function (d, b) {
|
|
8048
|
+
extendStatics = Object.setPrototypeOf ||
|
|
8049
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
8050
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
8051
|
+
return extendStatics(d, b);
|
|
8052
|
+
};
|
|
8053
|
+
return function (d, b) {
|
|
8054
|
+
if (typeof b !== "function" && b !== null)
|
|
8055
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
8056
|
+
extendStatics(d, b);
|
|
8057
|
+
function __() { this.constructor = d; }
|
|
8058
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
8059
|
+
};
|
|
8060
|
+
})();
|
|
8061
|
+
var __assign = (node && node.__assign) || function () {
|
|
8062
|
+
__assign = Object.assign || function(t) {
|
|
8063
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
8064
|
+
s = arguments[i];
|
|
8065
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
8066
|
+
t[p] = s[p];
|
|
8067
|
+
}
|
|
8068
|
+
return t;
|
|
8069
|
+
};
|
|
8070
|
+
return __assign.apply(this, arguments);
|
|
8071
|
+
};
|
|
8072
|
+
Object.defineProperty(node, "__esModule", { value: true });
|
|
8073
|
+
node.cloneNode = node.hasChildren = node.isDocument = node.isDirective = node.isComment = node.isText = node.isCDATA = node.isTag = node.Element = node.Document = node.CDATA = node.NodeWithChildren = node.ProcessingInstruction = node.Comment = node.Text = node.DataNode = node.Node = void 0;
|
|
8074
|
+
var domelementtype_1 = /*@__PURE__*/ requireLib$3();
|
|
8075
|
+
/**
|
|
8076
|
+
* This object will be used as the prototype for Nodes when creating a
|
|
8077
|
+
* DOM-Level-1-compliant structure.
|
|
8078
|
+
*/
|
|
8079
|
+
var Node = /** @class */ (function () {
|
|
8080
|
+
function Node() {
|
|
8081
|
+
/** Parent of the node */
|
|
8082
|
+
this.parent = null;
|
|
8083
|
+
/** Previous sibling */
|
|
8084
|
+
this.prev = null;
|
|
8085
|
+
/** Next sibling */
|
|
8086
|
+
this.next = null;
|
|
8087
|
+
/** The start index of the node. Requires `withStartIndices` on the handler to be `true. */
|
|
8088
|
+
this.startIndex = null;
|
|
8089
|
+
/** The end index of the node. Requires `withEndIndices` on the handler to be `true. */
|
|
8090
|
+
this.endIndex = null;
|
|
8091
|
+
}
|
|
8092
|
+
Object.defineProperty(Node.prototype, "parentNode", {
|
|
8093
|
+
// Read-write aliases for properties
|
|
8094
|
+
/**
|
|
8095
|
+
* Same as {@link parent}.
|
|
8096
|
+
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
8097
|
+
*/
|
|
8098
|
+
get: function () {
|
|
8099
|
+
return this.parent;
|
|
8100
|
+
},
|
|
8101
|
+
set: function (parent) {
|
|
8102
|
+
this.parent = parent;
|
|
8103
|
+
},
|
|
8104
|
+
enumerable: false,
|
|
8105
|
+
configurable: true
|
|
8106
|
+
});
|
|
8107
|
+
Object.defineProperty(Node.prototype, "previousSibling", {
|
|
8108
|
+
/**
|
|
8109
|
+
* Same as {@link prev}.
|
|
8110
|
+
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
8111
|
+
*/
|
|
8112
|
+
get: function () {
|
|
8113
|
+
return this.prev;
|
|
8114
|
+
},
|
|
8115
|
+
set: function (prev) {
|
|
8116
|
+
this.prev = prev;
|
|
8117
|
+
},
|
|
8118
|
+
enumerable: false,
|
|
8119
|
+
configurable: true
|
|
8120
|
+
});
|
|
8121
|
+
Object.defineProperty(Node.prototype, "nextSibling", {
|
|
8122
|
+
/**
|
|
8123
|
+
* Same as {@link next}.
|
|
8124
|
+
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
8125
|
+
*/
|
|
8126
|
+
get: function () {
|
|
8127
|
+
return this.next;
|
|
8128
|
+
},
|
|
8129
|
+
set: function (next) {
|
|
8130
|
+
this.next = next;
|
|
8131
|
+
},
|
|
8132
|
+
enumerable: false,
|
|
8133
|
+
configurable: true
|
|
8134
|
+
});
|
|
8135
|
+
/**
|
|
8136
|
+
* Clone this node, and optionally its children.
|
|
8137
|
+
*
|
|
8138
|
+
* @param recursive Clone child nodes as well.
|
|
8139
|
+
* @returns A clone of the node.
|
|
8140
|
+
*/
|
|
8141
|
+
Node.prototype.cloneNode = function (recursive) {
|
|
8142
|
+
if (recursive === void 0) { recursive = false; }
|
|
8143
|
+
return cloneNode(this, recursive);
|
|
8144
|
+
};
|
|
8145
|
+
return Node;
|
|
8146
|
+
}());
|
|
8147
|
+
node.Node = Node;
|
|
8148
|
+
/**
|
|
8149
|
+
* A node that contains some data.
|
|
8150
|
+
*/
|
|
8151
|
+
var DataNode = /** @class */ (function (_super) {
|
|
8152
|
+
__extends(DataNode, _super);
|
|
8153
|
+
/**
|
|
8154
|
+
* @param data The content of the data node
|
|
8155
|
+
*/
|
|
8156
|
+
function DataNode(data) {
|
|
8157
|
+
var _this = _super.call(this) || this;
|
|
8158
|
+
_this.data = data;
|
|
8159
|
+
return _this;
|
|
8160
|
+
}
|
|
8161
|
+
Object.defineProperty(DataNode.prototype, "nodeValue", {
|
|
8162
|
+
/**
|
|
8163
|
+
* Same as {@link data}.
|
|
8164
|
+
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
8165
|
+
*/
|
|
8166
|
+
get: function () {
|
|
8167
|
+
return this.data;
|
|
8168
|
+
},
|
|
8169
|
+
set: function (data) {
|
|
8170
|
+
this.data = data;
|
|
8171
|
+
},
|
|
8172
|
+
enumerable: false,
|
|
8173
|
+
configurable: true
|
|
8174
|
+
});
|
|
8175
|
+
return DataNode;
|
|
8176
|
+
}(Node));
|
|
8177
|
+
node.DataNode = DataNode;
|
|
8178
|
+
/**
|
|
8179
|
+
* Text within the document.
|
|
8180
|
+
*/
|
|
8181
|
+
var Text = /** @class */ (function (_super) {
|
|
8182
|
+
__extends(Text, _super);
|
|
8183
|
+
function Text() {
|
|
8184
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
8185
|
+
_this.type = domelementtype_1.ElementType.Text;
|
|
8186
|
+
return _this;
|
|
8187
|
+
}
|
|
8188
|
+
Object.defineProperty(Text.prototype, "nodeType", {
|
|
8189
|
+
get: function () {
|
|
8190
|
+
return 3;
|
|
8191
|
+
},
|
|
8192
|
+
enumerable: false,
|
|
8193
|
+
configurable: true
|
|
8194
|
+
});
|
|
8195
|
+
return Text;
|
|
8196
|
+
}(DataNode));
|
|
8197
|
+
node.Text = Text;
|
|
8198
|
+
/**
|
|
8199
|
+
* Comments within the document.
|
|
8200
|
+
*/
|
|
8201
|
+
var Comment = /** @class */ (function (_super) {
|
|
8202
|
+
__extends(Comment, _super);
|
|
8203
|
+
function Comment() {
|
|
8204
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
8205
|
+
_this.type = domelementtype_1.ElementType.Comment;
|
|
8206
|
+
return _this;
|
|
8207
|
+
}
|
|
8208
|
+
Object.defineProperty(Comment.prototype, "nodeType", {
|
|
8209
|
+
get: function () {
|
|
8210
|
+
return 8;
|
|
8211
|
+
},
|
|
8212
|
+
enumerable: false,
|
|
8213
|
+
configurable: true
|
|
8214
|
+
});
|
|
8215
|
+
return Comment;
|
|
8216
|
+
}(DataNode));
|
|
8217
|
+
node.Comment = Comment;
|
|
8218
|
+
/**
|
|
8219
|
+
* Processing instructions, including doc types.
|
|
8220
|
+
*/
|
|
8221
|
+
var ProcessingInstruction = /** @class */ (function (_super) {
|
|
8222
|
+
__extends(ProcessingInstruction, _super);
|
|
8223
|
+
function ProcessingInstruction(name, data) {
|
|
8224
|
+
var _this = _super.call(this, data) || this;
|
|
8225
|
+
_this.name = name;
|
|
8226
|
+
_this.type = domelementtype_1.ElementType.Directive;
|
|
8227
|
+
return _this;
|
|
8228
|
+
}
|
|
8229
|
+
Object.defineProperty(ProcessingInstruction.prototype, "nodeType", {
|
|
8230
|
+
get: function () {
|
|
8231
|
+
return 1;
|
|
8232
|
+
},
|
|
8233
|
+
enumerable: false,
|
|
8234
|
+
configurable: true
|
|
8235
|
+
});
|
|
8236
|
+
return ProcessingInstruction;
|
|
8237
|
+
}(DataNode));
|
|
8238
|
+
node.ProcessingInstruction = ProcessingInstruction;
|
|
8239
|
+
/**
|
|
8240
|
+
* A `Node` that can have children.
|
|
8241
|
+
*/
|
|
8242
|
+
var NodeWithChildren = /** @class */ (function (_super) {
|
|
8243
|
+
__extends(NodeWithChildren, _super);
|
|
8244
|
+
/**
|
|
8245
|
+
* @param children Children of the node. Only certain node types can have children.
|
|
8246
|
+
*/
|
|
8247
|
+
function NodeWithChildren(children) {
|
|
8248
|
+
var _this = _super.call(this) || this;
|
|
8249
|
+
_this.children = children;
|
|
8250
|
+
return _this;
|
|
8251
|
+
}
|
|
8252
|
+
Object.defineProperty(NodeWithChildren.prototype, "firstChild", {
|
|
8253
|
+
// Aliases
|
|
8254
|
+
/** First child of the node. */
|
|
8255
|
+
get: function () {
|
|
8256
|
+
var _a;
|
|
8257
|
+
return (_a = this.children[0]) !== null && _a !== void 0 ? _a : null;
|
|
8258
|
+
},
|
|
8259
|
+
enumerable: false,
|
|
8260
|
+
configurable: true
|
|
8261
|
+
});
|
|
8262
|
+
Object.defineProperty(NodeWithChildren.prototype, "lastChild", {
|
|
8263
|
+
/** Last child of the node. */
|
|
8264
|
+
get: function () {
|
|
8265
|
+
return this.children.length > 0
|
|
8266
|
+
? this.children[this.children.length - 1]
|
|
8267
|
+
: null;
|
|
8268
|
+
},
|
|
8269
|
+
enumerable: false,
|
|
8270
|
+
configurable: true
|
|
8271
|
+
});
|
|
8272
|
+
Object.defineProperty(NodeWithChildren.prototype, "childNodes", {
|
|
8273
|
+
/**
|
|
8274
|
+
* Same as {@link children}.
|
|
8275
|
+
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
8276
|
+
*/
|
|
8277
|
+
get: function () {
|
|
8278
|
+
return this.children;
|
|
8279
|
+
},
|
|
8280
|
+
set: function (children) {
|
|
8281
|
+
this.children = children;
|
|
8282
|
+
},
|
|
8283
|
+
enumerable: false,
|
|
8284
|
+
configurable: true
|
|
8285
|
+
});
|
|
8286
|
+
return NodeWithChildren;
|
|
8287
|
+
}(Node));
|
|
8288
|
+
node.NodeWithChildren = NodeWithChildren;
|
|
8289
|
+
var CDATA = /** @class */ (function (_super) {
|
|
8290
|
+
__extends(CDATA, _super);
|
|
8291
|
+
function CDATA() {
|
|
8292
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
8293
|
+
_this.type = domelementtype_1.ElementType.CDATA;
|
|
8294
|
+
return _this;
|
|
8295
|
+
}
|
|
8296
|
+
Object.defineProperty(CDATA.prototype, "nodeType", {
|
|
8297
|
+
get: function () {
|
|
8298
|
+
return 4;
|
|
8299
|
+
},
|
|
8300
|
+
enumerable: false,
|
|
8301
|
+
configurable: true
|
|
8302
|
+
});
|
|
8303
|
+
return CDATA;
|
|
8304
|
+
}(NodeWithChildren));
|
|
8305
|
+
node.CDATA = CDATA;
|
|
8306
|
+
/**
|
|
8307
|
+
* The root node of the document.
|
|
8308
|
+
*/
|
|
8309
|
+
var Document = /** @class */ (function (_super) {
|
|
8310
|
+
__extends(Document, _super);
|
|
8311
|
+
function Document() {
|
|
8312
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
8313
|
+
_this.type = domelementtype_1.ElementType.Root;
|
|
8314
|
+
return _this;
|
|
8315
|
+
}
|
|
8316
|
+
Object.defineProperty(Document.prototype, "nodeType", {
|
|
8317
|
+
get: function () {
|
|
8318
|
+
return 9;
|
|
8319
|
+
},
|
|
8320
|
+
enumerable: false,
|
|
8321
|
+
configurable: true
|
|
8322
|
+
});
|
|
8323
|
+
return Document;
|
|
8324
|
+
}(NodeWithChildren));
|
|
8325
|
+
node.Document = Document;
|
|
8326
|
+
/**
|
|
8327
|
+
* An element within the DOM.
|
|
8328
|
+
*/
|
|
8329
|
+
var Element = /** @class */ (function (_super) {
|
|
8330
|
+
__extends(Element, _super);
|
|
8331
|
+
/**
|
|
8332
|
+
* @param name Name of the tag, eg. `div`, `span`.
|
|
8333
|
+
* @param attribs Object mapping attribute names to attribute values.
|
|
8334
|
+
* @param children Children of the node.
|
|
8335
|
+
*/
|
|
8336
|
+
function Element(name, attribs, children, type) {
|
|
8337
|
+
if (children === void 0) { children = []; }
|
|
8338
|
+
if (type === void 0) { type = name === "script"
|
|
8339
|
+
? domelementtype_1.ElementType.Script
|
|
8340
|
+
: name === "style"
|
|
8341
|
+
? domelementtype_1.ElementType.Style
|
|
8342
|
+
: domelementtype_1.ElementType.Tag; }
|
|
8343
|
+
var _this = _super.call(this, children) || this;
|
|
8344
|
+
_this.name = name;
|
|
8345
|
+
_this.attribs = attribs;
|
|
8346
|
+
_this.type = type;
|
|
8347
|
+
return _this;
|
|
8348
|
+
}
|
|
8349
|
+
Object.defineProperty(Element.prototype, "nodeType", {
|
|
8350
|
+
get: function () {
|
|
8351
|
+
return 1;
|
|
8352
|
+
},
|
|
8353
|
+
enumerable: false,
|
|
8354
|
+
configurable: true
|
|
8355
|
+
});
|
|
8356
|
+
Object.defineProperty(Element.prototype, "tagName", {
|
|
8357
|
+
// DOM Level 1 aliases
|
|
8358
|
+
/**
|
|
8359
|
+
* Same as {@link name}.
|
|
8360
|
+
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
8361
|
+
*/
|
|
8362
|
+
get: function () {
|
|
8363
|
+
return this.name;
|
|
8364
|
+
},
|
|
8365
|
+
set: function (name) {
|
|
8366
|
+
this.name = name;
|
|
8367
|
+
},
|
|
8368
|
+
enumerable: false,
|
|
8369
|
+
configurable: true
|
|
8370
|
+
});
|
|
8371
|
+
Object.defineProperty(Element.prototype, "attributes", {
|
|
8372
|
+
get: function () {
|
|
8373
|
+
var _this = this;
|
|
8374
|
+
return Object.keys(this.attribs).map(function (name) {
|
|
8375
|
+
var _a, _b;
|
|
8376
|
+
return ({
|
|
8377
|
+
name: name,
|
|
8378
|
+
value: _this.attribs[name],
|
|
8379
|
+
namespace: (_a = _this["x-attribsNamespace"]) === null || _a === void 0 ? void 0 : _a[name],
|
|
8380
|
+
prefix: (_b = _this["x-attribsPrefix"]) === null || _b === void 0 ? void 0 : _b[name],
|
|
8381
|
+
});
|
|
8382
|
+
});
|
|
8383
|
+
},
|
|
8384
|
+
enumerable: false,
|
|
8385
|
+
configurable: true
|
|
8386
|
+
});
|
|
8387
|
+
return Element;
|
|
8388
|
+
}(NodeWithChildren));
|
|
8389
|
+
node.Element = Element;
|
|
8390
|
+
/**
|
|
8391
|
+
* @param node Node to check.
|
|
8392
|
+
* @returns `true` if the node is a `Element`, `false` otherwise.
|
|
8393
|
+
*/
|
|
8394
|
+
function isTag(node) {
|
|
8395
|
+
return (0, domelementtype_1.isTag)(node);
|
|
8396
|
+
}
|
|
8397
|
+
node.isTag = isTag;
|
|
8398
|
+
/**
|
|
8399
|
+
* @param node Node to check.
|
|
8400
|
+
* @returns `true` if the node has the type `CDATA`, `false` otherwise.
|
|
8401
|
+
*/
|
|
8402
|
+
function isCDATA(node) {
|
|
8403
|
+
return node.type === domelementtype_1.ElementType.CDATA;
|
|
8404
|
+
}
|
|
8405
|
+
node.isCDATA = isCDATA;
|
|
8406
|
+
/**
|
|
8407
|
+
* @param node Node to check.
|
|
8408
|
+
* @returns `true` if the node has the type `Text`, `false` otherwise.
|
|
8409
|
+
*/
|
|
8410
|
+
function isText(node) {
|
|
8411
|
+
return node.type === domelementtype_1.ElementType.Text;
|
|
8412
|
+
}
|
|
8413
|
+
node.isText = isText;
|
|
8414
|
+
/**
|
|
8415
|
+
* @param node Node to check.
|
|
8416
|
+
* @returns `true` if the node has the type `Comment`, `false` otherwise.
|
|
8417
|
+
*/
|
|
8418
|
+
function isComment(node) {
|
|
8419
|
+
return node.type === domelementtype_1.ElementType.Comment;
|
|
8420
|
+
}
|
|
8421
|
+
node.isComment = isComment;
|
|
8422
|
+
/**
|
|
8423
|
+
* @param node Node to check.
|
|
8424
|
+
* @returns `true` if the node has the type `ProcessingInstruction`, `false` otherwise.
|
|
8425
|
+
*/
|
|
8426
|
+
function isDirective(node) {
|
|
8427
|
+
return node.type === domelementtype_1.ElementType.Directive;
|
|
8428
|
+
}
|
|
8429
|
+
node.isDirective = isDirective;
|
|
8430
|
+
/**
|
|
8431
|
+
* @param node Node to check.
|
|
8432
|
+
* @returns `true` if the node has the type `ProcessingInstruction`, `false` otherwise.
|
|
8433
|
+
*/
|
|
8434
|
+
function isDocument(node) {
|
|
8435
|
+
return node.type === domelementtype_1.ElementType.Root;
|
|
8436
|
+
}
|
|
8437
|
+
node.isDocument = isDocument;
|
|
8438
|
+
/**
|
|
8439
|
+
* @param node Node to check.
|
|
8440
|
+
* @returns `true` if the node has children, `false` otherwise.
|
|
8441
|
+
*/
|
|
8442
|
+
function hasChildren(node) {
|
|
8443
|
+
return Object.prototype.hasOwnProperty.call(node, "children");
|
|
8444
|
+
}
|
|
8445
|
+
node.hasChildren = hasChildren;
|
|
8446
|
+
/**
|
|
8447
|
+
* Clone a node, and optionally its children.
|
|
8448
|
+
*
|
|
8449
|
+
* @param recursive Clone child nodes as well.
|
|
8450
|
+
* @returns A clone of the node.
|
|
8451
|
+
*/
|
|
8452
|
+
function cloneNode(node, recursive) {
|
|
8453
|
+
if (recursive === void 0) { recursive = false; }
|
|
8454
|
+
var result;
|
|
8455
|
+
if (isText(node)) {
|
|
8456
|
+
result = new Text(node.data);
|
|
8457
|
+
}
|
|
8458
|
+
else if (isComment(node)) {
|
|
8459
|
+
result = new Comment(node.data);
|
|
8460
|
+
}
|
|
8461
|
+
else if (isTag(node)) {
|
|
8462
|
+
var children = recursive ? cloneChildren(node.children) : [];
|
|
8463
|
+
var clone_1 = new Element(node.name, __assign({}, node.attribs), children);
|
|
8464
|
+
children.forEach(function (child) { return (child.parent = clone_1); });
|
|
8465
|
+
if (node.namespace != null) {
|
|
8466
|
+
clone_1.namespace = node.namespace;
|
|
8467
|
+
}
|
|
8468
|
+
if (node["x-attribsNamespace"]) {
|
|
8469
|
+
clone_1["x-attribsNamespace"] = __assign({}, node["x-attribsNamespace"]);
|
|
8470
|
+
}
|
|
8471
|
+
if (node["x-attribsPrefix"]) {
|
|
8472
|
+
clone_1["x-attribsPrefix"] = __assign({}, node["x-attribsPrefix"]);
|
|
8473
|
+
}
|
|
8474
|
+
result = clone_1;
|
|
8475
|
+
}
|
|
8476
|
+
else if (isCDATA(node)) {
|
|
8477
|
+
var children = recursive ? cloneChildren(node.children) : [];
|
|
8478
|
+
var clone_2 = new CDATA(children);
|
|
8479
|
+
children.forEach(function (child) { return (child.parent = clone_2); });
|
|
8480
|
+
result = clone_2;
|
|
8481
|
+
}
|
|
8482
|
+
else if (isDocument(node)) {
|
|
8483
|
+
var children = recursive ? cloneChildren(node.children) : [];
|
|
8484
|
+
var clone_3 = new Document(children);
|
|
8485
|
+
children.forEach(function (child) { return (child.parent = clone_3); });
|
|
8486
|
+
if (node["x-mode"]) {
|
|
8487
|
+
clone_3["x-mode"] = node["x-mode"];
|
|
8488
|
+
}
|
|
8489
|
+
result = clone_3;
|
|
8490
|
+
}
|
|
8491
|
+
else if (isDirective(node)) {
|
|
8492
|
+
var instruction = new ProcessingInstruction(node.name, node.data);
|
|
8493
|
+
if (node["x-name"] != null) {
|
|
8494
|
+
instruction["x-name"] = node["x-name"];
|
|
8495
|
+
instruction["x-publicId"] = node["x-publicId"];
|
|
8496
|
+
instruction["x-systemId"] = node["x-systemId"];
|
|
8497
|
+
}
|
|
8498
|
+
result = instruction;
|
|
8499
|
+
}
|
|
8500
|
+
else {
|
|
8501
|
+
throw new Error("Not implemented yet: ".concat(node.type));
|
|
8502
|
+
}
|
|
8503
|
+
result.startIndex = node.startIndex;
|
|
8504
|
+
result.endIndex = node.endIndex;
|
|
8505
|
+
if (node.sourceCodeLocation != null) {
|
|
8506
|
+
result.sourceCodeLocation = node.sourceCodeLocation;
|
|
8507
|
+
}
|
|
8508
|
+
return result;
|
|
8509
|
+
}
|
|
8510
|
+
node.cloneNode = cloneNode;
|
|
8511
|
+
function cloneChildren(childs) {
|
|
8512
|
+
var children = childs.map(function (child) { return cloneNode(child, true); });
|
|
8513
|
+
for (var i = 1; i < children.length; i++) {
|
|
8514
|
+
children[i].prev = children[i - 1];
|
|
8515
|
+
children[i - 1].next = children[i];
|
|
8516
|
+
}
|
|
8517
|
+
return children;
|
|
8518
|
+
}
|
|
8519
|
+
return node;
|
|
8520
|
+
}
|
|
8521
|
+
|
|
8522
|
+
var hasRequiredLib$2;
|
|
8523
|
+
|
|
8524
|
+
function requireLib$2 () {
|
|
8525
|
+
if (hasRequiredLib$2) return lib$2;
|
|
8526
|
+
hasRequiredLib$2 = 1;
|
|
8527
|
+
(function (exports) {
|
|
8528
|
+
var __createBinding = (lib$2 && lib$2.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8529
|
+
if (k2 === undefined) k2 = k;
|
|
8530
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8531
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
8532
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8533
|
+
}
|
|
8534
|
+
Object.defineProperty(o, k2, desc);
|
|
8535
|
+
}) : (function(o, m, k, k2) {
|
|
8536
|
+
if (k2 === undefined) k2 = k;
|
|
8537
|
+
o[k2] = m[k];
|
|
8538
|
+
}));
|
|
8539
|
+
var __exportStar = (lib$2 && lib$2.__exportStar) || function(m, exports) {
|
|
8540
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
8541
|
+
};
|
|
8542
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8543
|
+
exports.DomHandler = void 0;
|
|
8544
|
+
var domelementtype_1 = /*@__PURE__*/ requireLib$3();
|
|
8545
|
+
var node_js_1 = /*@__PURE__*/ requireNode();
|
|
8546
|
+
__exportStar(/*@__PURE__*/ requireNode(), exports);
|
|
8547
|
+
// Default options
|
|
8548
|
+
var defaultOpts = {
|
|
8549
|
+
withStartIndices: false,
|
|
8550
|
+
withEndIndices: false,
|
|
8551
|
+
xmlMode: false,
|
|
8552
|
+
};
|
|
8553
|
+
var DomHandler = /** @class */ (function () {
|
|
8554
|
+
/**
|
|
8555
|
+
* @param callback Called once parsing has completed.
|
|
8556
|
+
* @param options Settings for the handler.
|
|
8557
|
+
* @param elementCB Callback whenever a tag is closed.
|
|
8558
|
+
*/
|
|
8559
|
+
function DomHandler(callback, options, elementCB) {
|
|
8560
|
+
/** The elements of the DOM */
|
|
8561
|
+
this.dom = [];
|
|
8562
|
+
/** The root element for the DOM */
|
|
8563
|
+
this.root = new node_js_1.Document(this.dom);
|
|
8564
|
+
/** Indicated whether parsing has been completed. */
|
|
8565
|
+
this.done = false;
|
|
8566
|
+
/** Stack of open tags. */
|
|
8567
|
+
this.tagStack = [this.root];
|
|
8568
|
+
/** A data node that is still being written to. */
|
|
8569
|
+
this.lastNode = null;
|
|
8570
|
+
/** Reference to the parser instance. Used for location information. */
|
|
8571
|
+
this.parser = null;
|
|
8572
|
+
// Make it possible to skip arguments, for backwards-compatibility
|
|
8573
|
+
if (typeof options === "function") {
|
|
8574
|
+
elementCB = options;
|
|
8575
|
+
options = defaultOpts;
|
|
8576
|
+
}
|
|
8577
|
+
if (typeof callback === "object") {
|
|
8578
|
+
options = callback;
|
|
8579
|
+
callback = undefined;
|
|
8580
|
+
}
|
|
8581
|
+
this.callback = callback !== null && callback !== void 0 ? callback : null;
|
|
8582
|
+
this.options = options !== null && options !== void 0 ? options : defaultOpts;
|
|
8583
|
+
this.elementCB = elementCB !== null && elementCB !== void 0 ? elementCB : null;
|
|
8584
|
+
}
|
|
8585
|
+
DomHandler.prototype.onparserinit = function (parser) {
|
|
8586
|
+
this.parser = parser;
|
|
8587
|
+
};
|
|
8588
|
+
// Resets the handler back to starting state
|
|
8589
|
+
DomHandler.prototype.onreset = function () {
|
|
8590
|
+
this.dom = [];
|
|
8591
|
+
this.root = new node_js_1.Document(this.dom);
|
|
8592
|
+
this.done = false;
|
|
8593
|
+
this.tagStack = [this.root];
|
|
8594
|
+
this.lastNode = null;
|
|
8595
|
+
this.parser = null;
|
|
8596
|
+
};
|
|
8597
|
+
// Signals the handler that parsing is done
|
|
8598
|
+
DomHandler.prototype.onend = function () {
|
|
8599
|
+
if (this.done)
|
|
8600
|
+
return;
|
|
8601
|
+
this.done = true;
|
|
8602
|
+
this.parser = null;
|
|
8603
|
+
this.handleCallback(null);
|
|
8604
|
+
};
|
|
8605
|
+
DomHandler.prototype.onerror = function (error) {
|
|
8606
|
+
this.handleCallback(error);
|
|
8607
|
+
};
|
|
8608
|
+
DomHandler.prototype.onclosetag = function () {
|
|
8609
|
+
this.lastNode = null;
|
|
8610
|
+
var elem = this.tagStack.pop();
|
|
8611
|
+
if (this.options.withEndIndices) {
|
|
8612
|
+
elem.endIndex = this.parser.endIndex;
|
|
8613
|
+
}
|
|
8614
|
+
if (this.elementCB)
|
|
8615
|
+
this.elementCB(elem);
|
|
8616
|
+
};
|
|
8617
|
+
DomHandler.prototype.onopentag = function (name, attribs) {
|
|
8618
|
+
var type = this.options.xmlMode ? domelementtype_1.ElementType.Tag : undefined;
|
|
8619
|
+
var element = new node_js_1.Element(name, attribs, undefined, type);
|
|
8620
|
+
this.addNode(element);
|
|
8621
|
+
this.tagStack.push(element);
|
|
8622
|
+
};
|
|
8623
|
+
DomHandler.prototype.ontext = function (data) {
|
|
8624
|
+
var lastNode = this.lastNode;
|
|
8625
|
+
if (lastNode && lastNode.type === domelementtype_1.ElementType.Text) {
|
|
8626
|
+
lastNode.data += data;
|
|
8627
|
+
if (this.options.withEndIndices) {
|
|
8628
|
+
lastNode.endIndex = this.parser.endIndex;
|
|
8629
|
+
}
|
|
8630
|
+
}
|
|
8631
|
+
else {
|
|
8632
|
+
var node = new node_js_1.Text(data);
|
|
8633
|
+
this.addNode(node);
|
|
8634
|
+
this.lastNode = node;
|
|
8635
|
+
}
|
|
8636
|
+
};
|
|
8637
|
+
DomHandler.prototype.oncomment = function (data) {
|
|
8638
|
+
if (this.lastNode && this.lastNode.type === domelementtype_1.ElementType.Comment) {
|
|
8639
|
+
this.lastNode.data += data;
|
|
8640
|
+
return;
|
|
8641
|
+
}
|
|
8642
|
+
var node = new node_js_1.Comment(data);
|
|
8643
|
+
this.addNode(node);
|
|
8644
|
+
this.lastNode = node;
|
|
8645
|
+
};
|
|
8646
|
+
DomHandler.prototype.oncommentend = function () {
|
|
8647
|
+
this.lastNode = null;
|
|
8648
|
+
};
|
|
8649
|
+
DomHandler.prototype.oncdatastart = function () {
|
|
8650
|
+
var text = new node_js_1.Text("");
|
|
8651
|
+
var node = new node_js_1.CDATA([text]);
|
|
8652
|
+
this.addNode(node);
|
|
8653
|
+
text.parent = node;
|
|
8654
|
+
this.lastNode = text;
|
|
8655
|
+
};
|
|
8656
|
+
DomHandler.prototype.oncdataend = function () {
|
|
8657
|
+
this.lastNode = null;
|
|
8658
|
+
};
|
|
8659
|
+
DomHandler.prototype.onprocessinginstruction = function (name, data) {
|
|
8660
|
+
var node = new node_js_1.ProcessingInstruction(name, data);
|
|
8661
|
+
this.addNode(node);
|
|
8662
|
+
};
|
|
8663
|
+
DomHandler.prototype.handleCallback = function (error) {
|
|
8664
|
+
if (typeof this.callback === "function") {
|
|
8665
|
+
this.callback(error, this.dom);
|
|
8666
|
+
}
|
|
8667
|
+
else if (error) {
|
|
8668
|
+
throw error;
|
|
8669
|
+
}
|
|
8670
|
+
};
|
|
8671
|
+
DomHandler.prototype.addNode = function (node) {
|
|
8672
|
+
var parent = this.tagStack[this.tagStack.length - 1];
|
|
8673
|
+
var previousSibling = parent.children[parent.children.length - 1];
|
|
8674
|
+
if (this.options.withStartIndices) {
|
|
8675
|
+
node.startIndex = this.parser.startIndex;
|
|
8676
|
+
}
|
|
8677
|
+
if (this.options.withEndIndices) {
|
|
8678
|
+
node.endIndex = this.parser.endIndex;
|
|
8679
|
+
}
|
|
8680
|
+
parent.children.push(node);
|
|
8681
|
+
if (previousSibling) {
|
|
8682
|
+
node.prev = previousSibling;
|
|
8683
|
+
previousSibling.next = node;
|
|
8684
|
+
}
|
|
8685
|
+
node.parent = parent;
|
|
8686
|
+
this.lastNode = null;
|
|
8687
|
+
};
|
|
8688
|
+
return DomHandler;
|
|
8689
|
+
}());
|
|
8690
|
+
exports.DomHandler = DomHandler;
|
|
8691
|
+
exports.default = DomHandler;
|
|
8692
|
+
} (lib$2));
|
|
8693
|
+
return lib$2;
|
|
8694
|
+
}
|
|
8695
|
+
|
|
8696
|
+
var constants = {};
|
|
8697
|
+
|
|
8698
|
+
var hasRequiredConstants;
|
|
8699
|
+
|
|
8700
|
+
function requireConstants () {
|
|
8701
|
+
if (hasRequiredConstants) return constants;
|
|
8702
|
+
hasRequiredConstants = 1;
|
|
8703
|
+
(function (exports) {
|
|
8704
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8705
|
+
exports.CARRIAGE_RETURN_PLACEHOLDER_REGEX = exports.CARRIAGE_RETURN_PLACEHOLDER = exports.CARRIAGE_RETURN_REGEX = exports.CARRIAGE_RETURN = exports.CASE_SENSITIVE_TAG_NAMES_MAP = exports.CASE_SENSITIVE_TAG_NAMES = void 0;
|
|
8706
|
+
/**
|
|
8707
|
+
* SVG elements are case-sensitive.
|
|
8708
|
+
*
|
|
8709
|
+
* @see https://developer.mozilla.org/docs/Web/SVG/Element#svg_elements_a_to_z
|
|
8710
|
+
*/
|
|
8711
|
+
exports.CASE_SENSITIVE_TAG_NAMES = [
|
|
8712
|
+
'animateMotion',
|
|
8713
|
+
'animateTransform',
|
|
8714
|
+
'clipPath',
|
|
8715
|
+
'feBlend',
|
|
8716
|
+
'feColorMatrix',
|
|
8717
|
+
'feComponentTransfer',
|
|
8718
|
+
'feComposite',
|
|
8719
|
+
'feConvolveMatrix',
|
|
8720
|
+
'feDiffuseLighting',
|
|
8721
|
+
'feDisplacementMap',
|
|
8722
|
+
'feDropShadow',
|
|
8723
|
+
'feFlood',
|
|
8724
|
+
'feFuncA',
|
|
8725
|
+
'feFuncB',
|
|
8726
|
+
'feFuncG',
|
|
8727
|
+
'feFuncR',
|
|
8728
|
+
'feGaussianBlur',
|
|
8729
|
+
'feImage',
|
|
8730
|
+
'feMerge',
|
|
8731
|
+
'feMergeNode',
|
|
8732
|
+
'feMorphology',
|
|
8733
|
+
'feOffset',
|
|
8734
|
+
'fePointLight',
|
|
8735
|
+
'feSpecularLighting',
|
|
8736
|
+
'feSpotLight',
|
|
8737
|
+
'feTile',
|
|
8738
|
+
'feTurbulence',
|
|
8739
|
+
'foreignObject',
|
|
8740
|
+
'linearGradient',
|
|
8741
|
+
'radialGradient',
|
|
8742
|
+
'textPath',
|
|
8743
|
+
];
|
|
8744
|
+
exports.CASE_SENSITIVE_TAG_NAMES_MAP = exports.CASE_SENSITIVE_TAG_NAMES.reduce(function (accumulator, tagName) {
|
|
8745
|
+
accumulator[tagName.toLowerCase()] = tagName;
|
|
8746
|
+
return accumulator;
|
|
8747
|
+
}, {});
|
|
8748
|
+
exports.CARRIAGE_RETURN = '\r';
|
|
8749
|
+
exports.CARRIAGE_RETURN_REGEX = new RegExp(exports.CARRIAGE_RETURN, 'g');
|
|
8750
|
+
exports.CARRIAGE_RETURN_PLACEHOLDER = "__HTML_DOM_PARSER_CARRIAGE_RETURN_PLACEHOLDER_".concat(Date.now(), "__");
|
|
8751
|
+
exports.CARRIAGE_RETURN_PLACEHOLDER_REGEX = new RegExp(exports.CARRIAGE_RETURN_PLACEHOLDER, 'g');
|
|
8752
|
+
|
|
8753
|
+
} (constants));
|
|
8754
|
+
return constants;
|
|
8755
|
+
}
|
|
8756
|
+
|
|
8757
|
+
var hasRequiredUtilities$2;
|
|
8758
|
+
|
|
8759
|
+
function requireUtilities$2 () {
|
|
8760
|
+
if (hasRequiredUtilities$2) return utilities$2;
|
|
8761
|
+
hasRequiredUtilities$2 = 1;
|
|
8762
|
+
Object.defineProperty(utilities$2, "__esModule", { value: true });
|
|
8763
|
+
utilities$2.formatAttributes = formatAttributes;
|
|
8764
|
+
utilities$2.escapeSpecialCharacters = escapeSpecialCharacters;
|
|
8765
|
+
utilities$2.revertEscapedCharacters = revertEscapedCharacters;
|
|
8766
|
+
utilities$2.formatDOM = formatDOM;
|
|
8767
|
+
var domhandler_1 = /*@__PURE__*/ requireLib$2();
|
|
8768
|
+
var constants_1 = requireConstants();
|
|
8769
|
+
/**
|
|
8770
|
+
* Gets case-sensitive tag name.
|
|
8771
|
+
*
|
|
8772
|
+
* @param tagName - Tag name in lowercase.
|
|
8773
|
+
* @returns - Case-sensitive tag name.
|
|
8774
|
+
*/
|
|
8775
|
+
function getCaseSensitiveTagName(tagName) {
|
|
8776
|
+
return constants_1.CASE_SENSITIVE_TAG_NAMES_MAP[tagName];
|
|
8777
|
+
}
|
|
8778
|
+
/**
|
|
8779
|
+
* Formats DOM attributes to a hash map.
|
|
8780
|
+
*
|
|
8781
|
+
* @param attributes - List of attributes.
|
|
8782
|
+
* @returns - Map of attribute name to value.
|
|
8783
|
+
*/
|
|
8784
|
+
function formatAttributes(attributes) {
|
|
8785
|
+
var map = {};
|
|
8786
|
+
var index = 0;
|
|
8787
|
+
var attributesLength = attributes.length;
|
|
8788
|
+
// `NamedNodeMap` is array-like
|
|
8789
|
+
for (; index < attributesLength; index++) {
|
|
8790
|
+
var attribute = attributes[index];
|
|
8791
|
+
map[attribute.name] = attribute.value;
|
|
8792
|
+
}
|
|
8793
|
+
return map;
|
|
8794
|
+
}
|
|
8795
|
+
/**
|
|
8796
|
+
* Corrects the tag name if it is case-sensitive (SVG).
|
|
8797
|
+
* Otherwise, returns the lowercase tag name (HTML).
|
|
8798
|
+
*
|
|
8799
|
+
* @param tagName - Lowercase tag name.
|
|
8800
|
+
* @returns - Formatted tag name.
|
|
8801
|
+
*/
|
|
8802
|
+
function formatTagName(tagName) {
|
|
8803
|
+
tagName = tagName.toLowerCase();
|
|
8804
|
+
var caseSensitiveTagName = getCaseSensitiveTagName(tagName);
|
|
8805
|
+
if (caseSensitiveTagName) {
|
|
8806
|
+
return caseSensitiveTagName;
|
|
8807
|
+
}
|
|
8808
|
+
return tagName;
|
|
8809
|
+
}
|
|
8810
|
+
/**
|
|
8811
|
+
* Escapes special characters before parsing.
|
|
8812
|
+
*
|
|
8813
|
+
* @param html - The HTML string.
|
|
8814
|
+
* @returns - HTML string with escaped special characters.
|
|
8815
|
+
*/
|
|
8816
|
+
function escapeSpecialCharacters(html) {
|
|
8817
|
+
return html.replace(constants_1.CARRIAGE_RETURN_REGEX, constants_1.CARRIAGE_RETURN_PLACEHOLDER);
|
|
8818
|
+
}
|
|
8819
|
+
/**
|
|
8820
|
+
* Reverts escaped special characters back to actual characters.
|
|
8821
|
+
*
|
|
8822
|
+
* @param text - The text with escaped characters.
|
|
8823
|
+
* @returns - Text with escaped characters reverted.
|
|
8824
|
+
*/
|
|
8825
|
+
function revertEscapedCharacters(text) {
|
|
8826
|
+
return text.replace(constants_1.CARRIAGE_RETURN_PLACEHOLDER_REGEX, constants_1.CARRIAGE_RETURN);
|
|
8827
|
+
}
|
|
8828
|
+
/**
|
|
8829
|
+
* Transforms DOM nodes to `domhandler` nodes.
|
|
8830
|
+
*
|
|
8831
|
+
* @param nodes - DOM nodes.
|
|
8832
|
+
* @param parent - Parent node.
|
|
8833
|
+
* @param directive - Directive.
|
|
8834
|
+
* @returns - Nodes.
|
|
8835
|
+
*/
|
|
8836
|
+
function formatDOM(nodes, parent, directive) {
|
|
8837
|
+
if (parent === void 0) { parent = null; }
|
|
8838
|
+
var domNodes = [];
|
|
8839
|
+
var current;
|
|
8840
|
+
var index = 0;
|
|
8841
|
+
var nodesLength = nodes.length;
|
|
8842
|
+
for (; index < nodesLength; index++) {
|
|
8843
|
+
var node = nodes[index];
|
|
8844
|
+
// set the node data given the type
|
|
8845
|
+
switch (node.nodeType) {
|
|
8846
|
+
case 1: {
|
|
8847
|
+
var tagName = formatTagName(node.nodeName);
|
|
8848
|
+
// script, style, or tag
|
|
8849
|
+
current = new domhandler_1.Element(tagName, formatAttributes(node.attributes));
|
|
8850
|
+
current.children = formatDOM(
|
|
8851
|
+
// template children are on content
|
|
8852
|
+
tagName === 'template'
|
|
8853
|
+
? node.content.childNodes
|
|
8854
|
+
: node.childNodes, current);
|
|
8855
|
+
break;
|
|
8856
|
+
}
|
|
8857
|
+
case 3:
|
|
8858
|
+
current = new domhandler_1.Text(revertEscapedCharacters(node.nodeValue));
|
|
8859
|
+
break;
|
|
8860
|
+
case 8:
|
|
8861
|
+
current = new domhandler_1.Comment(node.nodeValue);
|
|
8862
|
+
break;
|
|
8863
|
+
default:
|
|
8864
|
+
continue;
|
|
8865
|
+
}
|
|
8866
|
+
// set previous node next
|
|
8867
|
+
var prev = domNodes[index - 1] || null;
|
|
8868
|
+
if (prev) {
|
|
8869
|
+
prev.next = current;
|
|
8870
|
+
}
|
|
8871
|
+
// set properties for current node
|
|
8872
|
+
current.parent = parent;
|
|
8873
|
+
current.prev = prev;
|
|
8874
|
+
current.next = null;
|
|
8875
|
+
domNodes.push(current);
|
|
8876
|
+
}
|
|
8877
|
+
if (directive) {
|
|
8878
|
+
current = new domhandler_1.ProcessingInstruction(directive.substring(0, directive.indexOf(' ')).toLowerCase(), directive);
|
|
8879
|
+
current.next = domNodes[0] || null;
|
|
8880
|
+
current.parent = parent;
|
|
8881
|
+
domNodes.unshift(current);
|
|
8882
|
+
if (domNodes[1]) {
|
|
8883
|
+
domNodes[1].prev = domNodes[0];
|
|
8884
|
+
}
|
|
8885
|
+
}
|
|
8886
|
+
return domNodes;
|
|
8887
|
+
}
|
|
8888
|
+
|
|
8889
|
+
return utilities$2;
|
|
8890
|
+
}
|
|
8891
|
+
|
|
8892
|
+
var hasRequiredDomparser;
|
|
8893
|
+
|
|
8894
|
+
function requireDomparser () {
|
|
8895
|
+
if (hasRequiredDomparser) return domparser;
|
|
8896
|
+
hasRequiredDomparser = 1;
|
|
8897
|
+
Object.defineProperty(domparser, "__esModule", { value: true });
|
|
8898
|
+
domparser.default = domparser$1;
|
|
8899
|
+
var utilities_1 = requireUtilities$2();
|
|
8900
|
+
// constants
|
|
8901
|
+
var HTML = 'html';
|
|
8902
|
+
var HEAD = 'head';
|
|
8903
|
+
var BODY = 'body';
|
|
8904
|
+
var FIRST_TAG_REGEX = /<([a-zA-Z]+[0-9]?)/; // e.g., <h1>
|
|
8905
|
+
// match-all-characters in case of newlines (DOTALL)
|
|
8906
|
+
var HEAD_TAG_REGEX = /<head[^]*>/i;
|
|
8907
|
+
var BODY_TAG_REGEX = /<body[^]*>/i;
|
|
8908
|
+
// falls back to `parseFromString` if `createHTMLDocument` cannot be used
|
|
8909
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
8910
|
+
var parseFromDocument = function (html, tagName) {
|
|
8911
|
+
/* istanbul ignore next */
|
|
8912
|
+
throw new Error('This browser does not support `document.implementation.createHTMLDocument`');
|
|
8913
|
+
};
|
|
8914
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
8915
|
+
var parseFromString = function (html, tagName) {
|
|
8916
|
+
/* istanbul ignore next */
|
|
8917
|
+
throw new Error('This browser does not support `DOMParser.prototype.parseFromString`');
|
|
8918
|
+
};
|
|
8919
|
+
var DOMParser = typeof window === 'object' && window.DOMParser;
|
|
8920
|
+
/**
|
|
8921
|
+
* DOMParser (performance: slow).
|
|
8922
|
+
*
|
|
8923
|
+
* @see https://developer.mozilla.org/docs/Web/API/DOMParser#Parsing_an_SVG_or_HTML_document
|
|
8924
|
+
*/
|
|
8925
|
+
if (typeof DOMParser === 'function') {
|
|
8926
|
+
var domParser_1 = new DOMParser();
|
|
8927
|
+
var mimeType_1 = 'text/html';
|
|
8928
|
+
/**
|
|
8929
|
+
* Creates an HTML document using `DOMParser.parseFromString`.
|
|
8930
|
+
*
|
|
8931
|
+
* @param html - The HTML string.
|
|
8932
|
+
* @param tagName - The element to render the HTML (with 'body' as fallback).
|
|
8933
|
+
* @returns - Document.
|
|
8934
|
+
*/
|
|
8935
|
+
parseFromString = function (html, tagName) {
|
|
8936
|
+
if (tagName) {
|
|
8937
|
+
/* istanbul ignore next */
|
|
8938
|
+
html = "<".concat(tagName, ">").concat(html, "</").concat(tagName, ">");
|
|
8939
|
+
}
|
|
8940
|
+
return domParser_1.parseFromString(html, mimeType_1);
|
|
8941
|
+
};
|
|
8942
|
+
parseFromDocument = parseFromString;
|
|
8943
|
+
}
|
|
8944
|
+
/**
|
|
8945
|
+
* DOMImplementation (performance: fair).
|
|
8946
|
+
*
|
|
8947
|
+
* @see https://developer.mozilla.org/docs/Web/API/DOMImplementation/createHTMLDocument
|
|
8948
|
+
*/
|
|
8949
|
+
if (typeof document === 'object' && document.implementation) {
|
|
8950
|
+
var htmlDocument_1 = document.implementation.createHTMLDocument();
|
|
8951
|
+
/**
|
|
8952
|
+
* Use HTML document created by `document.implementation.createHTMLDocument`.
|
|
8953
|
+
*
|
|
8954
|
+
* @param html - The HTML string.
|
|
8955
|
+
* @param tagName - The element to render the HTML (with 'body' as fallback).
|
|
8956
|
+
* @returns - Document
|
|
8957
|
+
*/
|
|
8958
|
+
parseFromDocument = function (html, tagName) {
|
|
8959
|
+
if (tagName) {
|
|
8960
|
+
var element = htmlDocument_1.documentElement.querySelector(tagName);
|
|
8961
|
+
if (element) {
|
|
8962
|
+
element.innerHTML = html;
|
|
8963
|
+
}
|
|
8964
|
+
return htmlDocument_1;
|
|
8965
|
+
}
|
|
8966
|
+
htmlDocument_1.documentElement.innerHTML = html;
|
|
8967
|
+
return htmlDocument_1;
|
|
8968
|
+
};
|
|
8969
|
+
}
|
|
8970
|
+
/**
|
|
8971
|
+
* Template (performance: fast).
|
|
8972
|
+
*
|
|
8973
|
+
* @see https://developer.mozilla.org/docs/Web/HTML/Element/template
|
|
8974
|
+
*/
|
|
8975
|
+
var template = typeof document === 'object' && document.createElement('template');
|
|
8976
|
+
var parseFromTemplate;
|
|
8977
|
+
if (template && template.content) {
|
|
8978
|
+
/**
|
|
8979
|
+
* Uses a template element (content fragment) to parse HTML.
|
|
8980
|
+
*
|
|
8981
|
+
* @param html - HTML string.
|
|
8982
|
+
* @returns - Nodes.
|
|
8983
|
+
*/
|
|
8984
|
+
parseFromTemplate = function (html) {
|
|
8985
|
+
template.innerHTML = html;
|
|
8986
|
+
return template.content.childNodes;
|
|
8987
|
+
};
|
|
8988
|
+
}
|
|
8989
|
+
/**
|
|
8990
|
+
* Parses HTML string to DOM nodes.
|
|
8991
|
+
*
|
|
8992
|
+
* @param html - HTML markup.
|
|
8993
|
+
* @returns - DOM nodes.
|
|
8994
|
+
*/
|
|
8995
|
+
function domparser$1(html) {
|
|
8996
|
+
var _a, _b;
|
|
8997
|
+
// Escape special characters before parsing
|
|
8998
|
+
html = (0, utilities_1.escapeSpecialCharacters)(html);
|
|
8999
|
+
var match = html.match(FIRST_TAG_REGEX);
|
|
9000
|
+
var firstTagName = match && match[1] ? match[1].toLowerCase() : '';
|
|
9001
|
+
switch (firstTagName) {
|
|
9002
|
+
case HTML: {
|
|
9003
|
+
var doc = parseFromString(html);
|
|
9004
|
+
// the created document may come with filler head/body elements,
|
|
9005
|
+
// so make sure to remove them if they don't actually exist
|
|
9006
|
+
if (!HEAD_TAG_REGEX.test(html)) {
|
|
9007
|
+
var element = doc.querySelector(HEAD);
|
|
9008
|
+
(_a = element === null || element === void 0 ? void 0 : element.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(element);
|
|
9009
|
+
}
|
|
9010
|
+
if (!BODY_TAG_REGEX.test(html)) {
|
|
9011
|
+
var element = doc.querySelector(BODY);
|
|
9012
|
+
(_b = element === null || element === void 0 ? void 0 : element.parentNode) === null || _b === void 0 ? void 0 : _b.removeChild(element);
|
|
9013
|
+
}
|
|
9014
|
+
return doc.querySelectorAll(HTML);
|
|
9015
|
+
}
|
|
9016
|
+
case HEAD:
|
|
9017
|
+
case BODY: {
|
|
9018
|
+
var elements = parseFromDocument(html).querySelectorAll(firstTagName);
|
|
9019
|
+
// if there's a sibling element, then return both elements
|
|
9020
|
+
if (BODY_TAG_REGEX.test(html) && HEAD_TAG_REGEX.test(html)) {
|
|
9021
|
+
return elements[0].parentNode.childNodes;
|
|
9022
|
+
}
|
|
9023
|
+
return elements;
|
|
9024
|
+
}
|
|
9025
|
+
// low-level tag or text
|
|
9026
|
+
default: {
|
|
9027
|
+
if (parseFromTemplate) {
|
|
9028
|
+
return parseFromTemplate(html);
|
|
9029
|
+
}
|
|
9030
|
+
var element = parseFromDocument(html, BODY).querySelector(BODY);
|
|
9031
|
+
return element.childNodes;
|
|
9032
|
+
}
|
|
9033
|
+
}
|
|
9034
|
+
}
|
|
9035
|
+
|
|
9036
|
+
return domparser;
|
|
9037
|
+
}
|
|
9038
|
+
|
|
9039
|
+
var hasRequiredHtmlToDom;
|
|
9040
|
+
|
|
9041
|
+
function requireHtmlToDom () {
|
|
9042
|
+
if (hasRequiredHtmlToDom) return htmlToDom;
|
|
9043
|
+
hasRequiredHtmlToDom = 1;
|
|
9044
|
+
var __importDefault = (htmlToDom && htmlToDom.__importDefault) || function (mod) {
|
|
9045
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
9046
|
+
};
|
|
9047
|
+
Object.defineProperty(htmlToDom, "__esModule", { value: true });
|
|
9048
|
+
htmlToDom.default = HTMLDOMParser;
|
|
9049
|
+
var domparser_1 = __importDefault(requireDomparser());
|
|
9050
|
+
var utilities_1 = requireUtilities$2();
|
|
9051
|
+
var DIRECTIVE_REGEX = /<(![a-zA-Z\s]+)>/; // e.g., <!doctype html>
|
|
9052
|
+
/**
|
|
9053
|
+
* Parses HTML string to DOM nodes in browser.
|
|
9054
|
+
*
|
|
9055
|
+
* @param html - HTML markup.
|
|
9056
|
+
* @returns - DOM elements.
|
|
9057
|
+
*/
|
|
9058
|
+
function HTMLDOMParser(html) {
|
|
9059
|
+
if (typeof html !== 'string') {
|
|
9060
|
+
throw new TypeError('First argument must be a string');
|
|
9061
|
+
}
|
|
9062
|
+
if (!html) {
|
|
9063
|
+
return [];
|
|
9064
|
+
}
|
|
9065
|
+
// match directive
|
|
9066
|
+
var match = html.match(DIRECTIVE_REGEX);
|
|
9067
|
+
var directive = match ? match[1] : undefined;
|
|
9068
|
+
return (0, utilities_1.formatDOM)((0, domparser_1.default)(html), null, directive);
|
|
9069
|
+
}
|
|
9070
|
+
|
|
9071
|
+
return htmlToDom;
|
|
9072
|
+
}
|
|
9073
|
+
|
|
9074
|
+
var attributesToProps = {};
|
|
9075
|
+
|
|
9076
|
+
var lib = {};
|
|
9077
|
+
|
|
9078
|
+
var possibleStandardNamesOptimized = {};
|
|
9079
|
+
|
|
9080
|
+
var hasRequiredPossibleStandardNamesOptimized;
|
|
9081
|
+
|
|
9082
|
+
function requirePossibleStandardNamesOptimized () {
|
|
9083
|
+
if (hasRequiredPossibleStandardNamesOptimized) return possibleStandardNamesOptimized;
|
|
9084
|
+
hasRequiredPossibleStandardNamesOptimized = 1;
|
|
9085
|
+
// An attribute in which the DOM/SVG standard name is the same as the React prop name (e.g., 'accept').
|
|
9086
|
+
var SAME = 0;
|
|
9087
|
+
possibleStandardNamesOptimized.SAME = SAME;
|
|
9088
|
+
|
|
9089
|
+
// An attribute in which the React prop name is the camelcased version of the DOM/SVG standard name (e.g., 'acceptCharset').
|
|
9090
|
+
var CAMELCASE = 1;
|
|
9091
|
+
possibleStandardNamesOptimized.CAMELCASE = CAMELCASE;
|
|
9092
|
+
|
|
9093
|
+
possibleStandardNamesOptimized.possibleStandardNames = {
|
|
9094
|
+
accept: 0,
|
|
9095
|
+
acceptCharset: 1,
|
|
9096
|
+
'accept-charset': 'acceptCharset',
|
|
9097
|
+
accessKey: 1,
|
|
9098
|
+
action: 0,
|
|
9099
|
+
allowFullScreen: 1,
|
|
9100
|
+
alt: 0,
|
|
9101
|
+
as: 0,
|
|
9102
|
+
async: 0,
|
|
9103
|
+
autoCapitalize: 1,
|
|
9104
|
+
autoComplete: 1,
|
|
9105
|
+
autoCorrect: 1,
|
|
9106
|
+
autoFocus: 1,
|
|
9107
|
+
autoPlay: 1,
|
|
9108
|
+
autoSave: 1,
|
|
9109
|
+
capture: 0,
|
|
9110
|
+
cellPadding: 1,
|
|
9111
|
+
cellSpacing: 1,
|
|
9112
|
+
challenge: 0,
|
|
9113
|
+
charSet: 1,
|
|
9114
|
+
checked: 0,
|
|
9115
|
+
children: 0,
|
|
9116
|
+
cite: 0,
|
|
9117
|
+
class: 'className',
|
|
9118
|
+
classID: 1,
|
|
9119
|
+
className: 1,
|
|
9120
|
+
cols: 0,
|
|
9121
|
+
colSpan: 1,
|
|
9122
|
+
content: 0,
|
|
9123
|
+
contentEditable: 1,
|
|
9124
|
+
contextMenu: 1,
|
|
9125
|
+
controls: 0,
|
|
9126
|
+
controlsList: 1,
|
|
9127
|
+
coords: 0,
|
|
9128
|
+
crossOrigin: 1,
|
|
9129
|
+
dangerouslySetInnerHTML: 1,
|
|
9130
|
+
data: 0,
|
|
9131
|
+
dateTime: 1,
|
|
9132
|
+
default: 0,
|
|
9133
|
+
defaultChecked: 1,
|
|
9134
|
+
defaultValue: 1,
|
|
9135
|
+
defer: 0,
|
|
9136
|
+
dir: 0,
|
|
9137
|
+
disabled: 0,
|
|
9138
|
+
disablePictureInPicture: 1,
|
|
9139
|
+
disableRemotePlayback: 1,
|
|
9140
|
+
download: 0,
|
|
9141
|
+
draggable: 0,
|
|
9142
|
+
encType: 1,
|
|
9143
|
+
enterKeyHint: 1,
|
|
9144
|
+
for: 'htmlFor',
|
|
9145
|
+
form: 0,
|
|
9146
|
+
formMethod: 1,
|
|
9147
|
+
formAction: 1,
|
|
9148
|
+
formEncType: 1,
|
|
9149
|
+
formNoValidate: 1,
|
|
9150
|
+
formTarget: 1,
|
|
9151
|
+
frameBorder: 1,
|
|
9152
|
+
headers: 0,
|
|
9153
|
+
height: 0,
|
|
9154
|
+
hidden: 0,
|
|
9155
|
+
high: 0,
|
|
9156
|
+
href: 0,
|
|
9157
|
+
hrefLang: 1,
|
|
9158
|
+
htmlFor: 1,
|
|
9159
|
+
httpEquiv: 1,
|
|
9160
|
+
'http-equiv': 'httpEquiv',
|
|
9161
|
+
icon: 0,
|
|
9162
|
+
id: 0,
|
|
9163
|
+
innerHTML: 1,
|
|
9164
|
+
inputMode: 1,
|
|
9165
|
+
integrity: 0,
|
|
9166
|
+
is: 0,
|
|
9167
|
+
itemID: 1,
|
|
9168
|
+
itemProp: 1,
|
|
9169
|
+
itemRef: 1,
|
|
9170
|
+
itemScope: 1,
|
|
9171
|
+
itemType: 1,
|
|
9172
|
+
keyParams: 1,
|
|
9173
|
+
keyType: 1,
|
|
9174
|
+
kind: 0,
|
|
9175
|
+
label: 0,
|
|
9176
|
+
lang: 0,
|
|
9177
|
+
list: 0,
|
|
9178
|
+
loop: 0,
|
|
9179
|
+
low: 0,
|
|
9180
|
+
manifest: 0,
|
|
9181
|
+
marginWidth: 1,
|
|
9182
|
+
marginHeight: 1,
|
|
9183
|
+
max: 0,
|
|
9184
|
+
maxLength: 1,
|
|
9185
|
+
media: 0,
|
|
9186
|
+
mediaGroup: 1,
|
|
9187
|
+
method: 0,
|
|
9188
|
+
min: 0,
|
|
9189
|
+
minLength: 1,
|
|
9190
|
+
multiple: 0,
|
|
9191
|
+
muted: 0,
|
|
9192
|
+
name: 0,
|
|
9193
|
+
noModule: 1,
|
|
9194
|
+
nonce: 0,
|
|
9195
|
+
noValidate: 1,
|
|
9196
|
+
open: 0,
|
|
9197
|
+
optimum: 0,
|
|
9198
|
+
pattern: 0,
|
|
9199
|
+
placeholder: 0,
|
|
9200
|
+
playsInline: 1,
|
|
9201
|
+
poster: 0,
|
|
9202
|
+
preload: 0,
|
|
9203
|
+
profile: 0,
|
|
9204
|
+
radioGroup: 1,
|
|
9205
|
+
readOnly: 1,
|
|
9206
|
+
referrerPolicy: 1,
|
|
9207
|
+
rel: 0,
|
|
9208
|
+
required: 0,
|
|
9209
|
+
reversed: 0,
|
|
9210
|
+
role: 0,
|
|
9211
|
+
rows: 0,
|
|
9212
|
+
rowSpan: 1,
|
|
9213
|
+
sandbox: 0,
|
|
9214
|
+
scope: 0,
|
|
9215
|
+
scoped: 0,
|
|
9216
|
+
scrolling: 0,
|
|
9217
|
+
seamless: 0,
|
|
9218
|
+
selected: 0,
|
|
9219
|
+
shape: 0,
|
|
9220
|
+
size: 0,
|
|
9221
|
+
sizes: 0,
|
|
9222
|
+
span: 0,
|
|
9223
|
+
spellCheck: 1,
|
|
9224
|
+
src: 0,
|
|
9225
|
+
srcDoc: 1,
|
|
9226
|
+
srcLang: 1,
|
|
9227
|
+
srcSet: 1,
|
|
9228
|
+
start: 0,
|
|
9229
|
+
step: 0,
|
|
9230
|
+
style: 0,
|
|
9231
|
+
summary: 0,
|
|
9232
|
+
tabIndex: 1,
|
|
9233
|
+
target: 0,
|
|
9234
|
+
title: 0,
|
|
9235
|
+
type: 0,
|
|
9236
|
+
useMap: 1,
|
|
9237
|
+
value: 0,
|
|
9238
|
+
width: 0,
|
|
9239
|
+
wmode: 0,
|
|
9240
|
+
wrap: 0,
|
|
9241
|
+
about: 0,
|
|
9242
|
+
accentHeight: 1,
|
|
9243
|
+
'accent-height': 'accentHeight',
|
|
9244
|
+
accumulate: 0,
|
|
9245
|
+
additive: 0,
|
|
9246
|
+
alignmentBaseline: 1,
|
|
9247
|
+
'alignment-baseline': 'alignmentBaseline',
|
|
9248
|
+
allowReorder: 1,
|
|
9249
|
+
alphabetic: 0,
|
|
9250
|
+
amplitude: 0,
|
|
9251
|
+
arabicForm: 1,
|
|
9252
|
+
'arabic-form': 'arabicForm',
|
|
9253
|
+
ascent: 0,
|
|
9254
|
+
attributeName: 1,
|
|
9255
|
+
attributeType: 1,
|
|
9256
|
+
autoReverse: 1,
|
|
9257
|
+
azimuth: 0,
|
|
9258
|
+
baseFrequency: 1,
|
|
9259
|
+
baselineShift: 1,
|
|
9260
|
+
'baseline-shift': 'baselineShift',
|
|
9261
|
+
baseProfile: 1,
|
|
9262
|
+
bbox: 0,
|
|
9263
|
+
begin: 0,
|
|
9264
|
+
bias: 0,
|
|
9265
|
+
by: 0,
|
|
9266
|
+
calcMode: 1,
|
|
9267
|
+
capHeight: 1,
|
|
9268
|
+
'cap-height': 'capHeight',
|
|
9269
|
+
clip: 0,
|
|
9270
|
+
clipPath: 1,
|
|
9271
|
+
'clip-path': 'clipPath',
|
|
9272
|
+
clipPathUnits: 1,
|
|
9273
|
+
clipRule: 1,
|
|
9274
|
+
'clip-rule': 'clipRule',
|
|
9275
|
+
color: 0,
|
|
9276
|
+
colorInterpolation: 1,
|
|
9277
|
+
'color-interpolation': 'colorInterpolation',
|
|
9278
|
+
colorInterpolationFilters: 1,
|
|
9279
|
+
'color-interpolation-filters': 'colorInterpolationFilters',
|
|
9280
|
+
colorProfile: 1,
|
|
9281
|
+
'color-profile': 'colorProfile',
|
|
9282
|
+
colorRendering: 1,
|
|
9283
|
+
'color-rendering': 'colorRendering',
|
|
9284
|
+
contentScriptType: 1,
|
|
9285
|
+
contentStyleType: 1,
|
|
9286
|
+
cursor: 0,
|
|
9287
|
+
cx: 0,
|
|
9288
|
+
cy: 0,
|
|
9289
|
+
d: 0,
|
|
9290
|
+
datatype: 0,
|
|
9291
|
+
decelerate: 0,
|
|
9292
|
+
descent: 0,
|
|
9293
|
+
diffuseConstant: 1,
|
|
9294
|
+
direction: 0,
|
|
9295
|
+
display: 0,
|
|
9296
|
+
divisor: 0,
|
|
9297
|
+
dominantBaseline: 1,
|
|
9298
|
+
'dominant-baseline': 'dominantBaseline',
|
|
9299
|
+
dur: 0,
|
|
9300
|
+
dx: 0,
|
|
9301
|
+
dy: 0,
|
|
9302
|
+
edgeMode: 1,
|
|
9303
|
+
elevation: 0,
|
|
9304
|
+
enableBackground: 1,
|
|
9305
|
+
'enable-background': 'enableBackground',
|
|
9306
|
+
end: 0,
|
|
9307
|
+
exponent: 0,
|
|
9308
|
+
externalResourcesRequired: 1,
|
|
9309
|
+
fill: 0,
|
|
9310
|
+
fillOpacity: 1,
|
|
9311
|
+
'fill-opacity': 'fillOpacity',
|
|
9312
|
+
fillRule: 1,
|
|
9313
|
+
'fill-rule': 'fillRule',
|
|
9314
|
+
filter: 0,
|
|
9315
|
+
filterRes: 1,
|
|
9316
|
+
filterUnits: 1,
|
|
9317
|
+
floodOpacity: 1,
|
|
9318
|
+
'flood-opacity': 'floodOpacity',
|
|
9319
|
+
floodColor: 1,
|
|
9320
|
+
'flood-color': 'floodColor',
|
|
9321
|
+
focusable: 0,
|
|
9322
|
+
fontFamily: 1,
|
|
9323
|
+
'font-family': 'fontFamily',
|
|
9324
|
+
fontSize: 1,
|
|
9325
|
+
'font-size': 'fontSize',
|
|
9326
|
+
fontSizeAdjust: 1,
|
|
9327
|
+
'font-size-adjust': 'fontSizeAdjust',
|
|
9328
|
+
fontStretch: 1,
|
|
9329
|
+
'font-stretch': 'fontStretch',
|
|
9330
|
+
fontStyle: 1,
|
|
9331
|
+
'font-style': 'fontStyle',
|
|
9332
|
+
fontVariant: 1,
|
|
9333
|
+
'font-variant': 'fontVariant',
|
|
9334
|
+
fontWeight: 1,
|
|
9335
|
+
'font-weight': 'fontWeight',
|
|
9336
|
+
format: 0,
|
|
9337
|
+
from: 0,
|
|
9338
|
+
fx: 0,
|
|
9339
|
+
fy: 0,
|
|
9340
|
+
g1: 0,
|
|
9341
|
+
g2: 0,
|
|
9342
|
+
glyphName: 1,
|
|
9343
|
+
'glyph-name': 'glyphName',
|
|
9344
|
+
glyphOrientationHorizontal: 1,
|
|
9345
|
+
'glyph-orientation-horizontal': 'glyphOrientationHorizontal',
|
|
9346
|
+
glyphOrientationVertical: 1,
|
|
9347
|
+
'glyph-orientation-vertical': 'glyphOrientationVertical',
|
|
9348
|
+
glyphRef: 1,
|
|
9349
|
+
gradientTransform: 1,
|
|
9350
|
+
gradientUnits: 1,
|
|
9351
|
+
hanging: 0,
|
|
9352
|
+
horizAdvX: 1,
|
|
9353
|
+
'horiz-adv-x': 'horizAdvX',
|
|
9354
|
+
horizOriginX: 1,
|
|
9355
|
+
'horiz-origin-x': 'horizOriginX',
|
|
9356
|
+
ideographic: 0,
|
|
9357
|
+
imageRendering: 1,
|
|
9358
|
+
'image-rendering': 'imageRendering',
|
|
9359
|
+
in2: 0,
|
|
9360
|
+
in: 0,
|
|
9361
|
+
inlist: 0,
|
|
9362
|
+
intercept: 0,
|
|
9363
|
+
k1: 0,
|
|
9364
|
+
k2: 0,
|
|
9365
|
+
k3: 0,
|
|
9366
|
+
k4: 0,
|
|
9367
|
+
k: 0,
|
|
9368
|
+
kernelMatrix: 1,
|
|
9369
|
+
kernelUnitLength: 1,
|
|
9370
|
+
kerning: 0,
|
|
9371
|
+
keyPoints: 1,
|
|
9372
|
+
keySplines: 1,
|
|
9373
|
+
keyTimes: 1,
|
|
9374
|
+
lengthAdjust: 1,
|
|
9375
|
+
letterSpacing: 1,
|
|
9376
|
+
'letter-spacing': 'letterSpacing',
|
|
9377
|
+
lightingColor: 1,
|
|
9378
|
+
'lighting-color': 'lightingColor',
|
|
9379
|
+
limitingConeAngle: 1,
|
|
9380
|
+
local: 0,
|
|
9381
|
+
markerEnd: 1,
|
|
9382
|
+
'marker-end': 'markerEnd',
|
|
9383
|
+
markerHeight: 1,
|
|
9384
|
+
markerMid: 1,
|
|
9385
|
+
'marker-mid': 'markerMid',
|
|
9386
|
+
markerStart: 1,
|
|
9387
|
+
'marker-start': 'markerStart',
|
|
9388
|
+
markerUnits: 1,
|
|
9389
|
+
markerWidth: 1,
|
|
9390
|
+
mask: 0,
|
|
9391
|
+
maskContentUnits: 1,
|
|
9392
|
+
maskUnits: 1,
|
|
9393
|
+
mathematical: 0,
|
|
9394
|
+
mode: 0,
|
|
9395
|
+
numOctaves: 1,
|
|
9396
|
+
offset: 0,
|
|
9397
|
+
opacity: 0,
|
|
9398
|
+
operator: 0,
|
|
9399
|
+
order: 0,
|
|
9400
|
+
orient: 0,
|
|
9401
|
+
orientation: 0,
|
|
9402
|
+
origin: 0,
|
|
9403
|
+
overflow: 0,
|
|
9404
|
+
overlinePosition: 1,
|
|
9405
|
+
'overline-position': 'overlinePosition',
|
|
9406
|
+
overlineThickness: 1,
|
|
9407
|
+
'overline-thickness': 'overlineThickness',
|
|
9408
|
+
paintOrder: 1,
|
|
9409
|
+
'paint-order': 'paintOrder',
|
|
9410
|
+
panose1: 0,
|
|
9411
|
+
'panose-1': 'panose1',
|
|
9412
|
+
pathLength: 1,
|
|
9413
|
+
patternContentUnits: 1,
|
|
9414
|
+
patternTransform: 1,
|
|
9415
|
+
patternUnits: 1,
|
|
9416
|
+
pointerEvents: 1,
|
|
9417
|
+
'pointer-events': 'pointerEvents',
|
|
9418
|
+
points: 0,
|
|
9419
|
+
pointsAtX: 1,
|
|
9420
|
+
pointsAtY: 1,
|
|
9421
|
+
pointsAtZ: 1,
|
|
9422
|
+
prefix: 0,
|
|
9423
|
+
preserveAlpha: 1,
|
|
9424
|
+
preserveAspectRatio: 1,
|
|
9425
|
+
primitiveUnits: 1,
|
|
9426
|
+
property: 0,
|
|
9427
|
+
r: 0,
|
|
9428
|
+
radius: 0,
|
|
9429
|
+
refX: 1,
|
|
9430
|
+
refY: 1,
|
|
9431
|
+
renderingIntent: 1,
|
|
9432
|
+
'rendering-intent': 'renderingIntent',
|
|
9433
|
+
repeatCount: 1,
|
|
9434
|
+
repeatDur: 1,
|
|
9435
|
+
requiredExtensions: 1,
|
|
9436
|
+
requiredFeatures: 1,
|
|
9437
|
+
resource: 0,
|
|
9438
|
+
restart: 0,
|
|
9439
|
+
result: 0,
|
|
9440
|
+
results: 0,
|
|
9441
|
+
rotate: 0,
|
|
9442
|
+
rx: 0,
|
|
9443
|
+
ry: 0,
|
|
9444
|
+
scale: 0,
|
|
9445
|
+
security: 0,
|
|
9446
|
+
seed: 0,
|
|
9447
|
+
shapeRendering: 1,
|
|
9448
|
+
'shape-rendering': 'shapeRendering',
|
|
9449
|
+
slope: 0,
|
|
9450
|
+
spacing: 0,
|
|
9451
|
+
specularConstant: 1,
|
|
9452
|
+
specularExponent: 1,
|
|
9453
|
+
speed: 0,
|
|
9454
|
+
spreadMethod: 1,
|
|
9455
|
+
startOffset: 1,
|
|
9456
|
+
stdDeviation: 1,
|
|
9457
|
+
stemh: 0,
|
|
9458
|
+
stemv: 0,
|
|
9459
|
+
stitchTiles: 1,
|
|
9460
|
+
stopColor: 1,
|
|
9461
|
+
'stop-color': 'stopColor',
|
|
9462
|
+
stopOpacity: 1,
|
|
9463
|
+
'stop-opacity': 'stopOpacity',
|
|
9464
|
+
strikethroughPosition: 1,
|
|
9465
|
+
'strikethrough-position': 'strikethroughPosition',
|
|
9466
|
+
strikethroughThickness: 1,
|
|
9467
|
+
'strikethrough-thickness': 'strikethroughThickness',
|
|
9468
|
+
string: 0,
|
|
9469
|
+
stroke: 0,
|
|
9470
|
+
strokeDasharray: 1,
|
|
9471
|
+
'stroke-dasharray': 'strokeDasharray',
|
|
9472
|
+
strokeDashoffset: 1,
|
|
9473
|
+
'stroke-dashoffset': 'strokeDashoffset',
|
|
9474
|
+
strokeLinecap: 1,
|
|
9475
|
+
'stroke-linecap': 'strokeLinecap',
|
|
9476
|
+
strokeLinejoin: 1,
|
|
9477
|
+
'stroke-linejoin': 'strokeLinejoin',
|
|
9478
|
+
strokeMiterlimit: 1,
|
|
9479
|
+
'stroke-miterlimit': 'strokeMiterlimit',
|
|
9480
|
+
strokeWidth: 1,
|
|
9481
|
+
'stroke-width': 'strokeWidth',
|
|
9482
|
+
strokeOpacity: 1,
|
|
9483
|
+
'stroke-opacity': 'strokeOpacity',
|
|
9484
|
+
suppressContentEditableWarning: 1,
|
|
9485
|
+
suppressHydrationWarning: 1,
|
|
9486
|
+
surfaceScale: 1,
|
|
9487
|
+
systemLanguage: 1,
|
|
9488
|
+
tableValues: 1,
|
|
9489
|
+
targetX: 1,
|
|
9490
|
+
targetY: 1,
|
|
9491
|
+
textAnchor: 1,
|
|
9492
|
+
'text-anchor': 'textAnchor',
|
|
9493
|
+
textDecoration: 1,
|
|
9494
|
+
'text-decoration': 'textDecoration',
|
|
9495
|
+
textLength: 1,
|
|
9496
|
+
textRendering: 1,
|
|
9497
|
+
'text-rendering': 'textRendering',
|
|
9498
|
+
to: 0,
|
|
9499
|
+
transform: 0,
|
|
9500
|
+
typeof: 0,
|
|
9501
|
+
u1: 0,
|
|
9502
|
+
u2: 0,
|
|
9503
|
+
underlinePosition: 1,
|
|
9504
|
+
'underline-position': 'underlinePosition',
|
|
9505
|
+
underlineThickness: 1,
|
|
9506
|
+
'underline-thickness': 'underlineThickness',
|
|
9507
|
+
unicode: 0,
|
|
9508
|
+
unicodeBidi: 1,
|
|
9509
|
+
'unicode-bidi': 'unicodeBidi',
|
|
9510
|
+
unicodeRange: 1,
|
|
9511
|
+
'unicode-range': 'unicodeRange',
|
|
9512
|
+
unitsPerEm: 1,
|
|
9513
|
+
'units-per-em': 'unitsPerEm',
|
|
9514
|
+
unselectable: 0,
|
|
9515
|
+
vAlphabetic: 1,
|
|
9516
|
+
'v-alphabetic': 'vAlphabetic',
|
|
9517
|
+
values: 0,
|
|
9518
|
+
vectorEffect: 1,
|
|
9519
|
+
'vector-effect': 'vectorEffect',
|
|
9520
|
+
version: 0,
|
|
9521
|
+
vertAdvY: 1,
|
|
9522
|
+
'vert-adv-y': 'vertAdvY',
|
|
9523
|
+
vertOriginX: 1,
|
|
9524
|
+
'vert-origin-x': 'vertOriginX',
|
|
9525
|
+
vertOriginY: 1,
|
|
9526
|
+
'vert-origin-y': 'vertOriginY',
|
|
9527
|
+
vHanging: 1,
|
|
9528
|
+
'v-hanging': 'vHanging',
|
|
9529
|
+
vIdeographic: 1,
|
|
9530
|
+
'v-ideographic': 'vIdeographic',
|
|
9531
|
+
viewBox: 1,
|
|
9532
|
+
viewTarget: 1,
|
|
9533
|
+
visibility: 0,
|
|
9534
|
+
vMathematical: 1,
|
|
9535
|
+
'v-mathematical': 'vMathematical',
|
|
9536
|
+
vocab: 0,
|
|
9537
|
+
widths: 0,
|
|
9538
|
+
wordSpacing: 1,
|
|
9539
|
+
'word-spacing': 'wordSpacing',
|
|
9540
|
+
writingMode: 1,
|
|
9541
|
+
'writing-mode': 'writingMode',
|
|
9542
|
+
x1: 0,
|
|
9543
|
+
x2: 0,
|
|
9544
|
+
x: 0,
|
|
9545
|
+
xChannelSelector: 1,
|
|
9546
|
+
xHeight: 1,
|
|
9547
|
+
'x-height': 'xHeight',
|
|
9548
|
+
xlinkActuate: 1,
|
|
9549
|
+
'xlink:actuate': 'xlinkActuate',
|
|
9550
|
+
xlinkArcrole: 1,
|
|
9551
|
+
'xlink:arcrole': 'xlinkArcrole',
|
|
9552
|
+
xlinkHref: 1,
|
|
9553
|
+
'xlink:href': 'xlinkHref',
|
|
9554
|
+
xlinkRole: 1,
|
|
9555
|
+
'xlink:role': 'xlinkRole',
|
|
9556
|
+
xlinkShow: 1,
|
|
9557
|
+
'xlink:show': 'xlinkShow',
|
|
9558
|
+
xlinkTitle: 1,
|
|
9559
|
+
'xlink:title': 'xlinkTitle',
|
|
9560
|
+
xlinkType: 1,
|
|
9561
|
+
'xlink:type': 'xlinkType',
|
|
9562
|
+
xmlBase: 1,
|
|
9563
|
+
'xml:base': 'xmlBase',
|
|
9564
|
+
xmlLang: 1,
|
|
9565
|
+
'xml:lang': 'xmlLang',
|
|
9566
|
+
xmlns: 0,
|
|
9567
|
+
'xml:space': 'xmlSpace',
|
|
9568
|
+
xmlnsXlink: 1,
|
|
9569
|
+
'xmlns:xlink': 'xmlnsXlink',
|
|
9570
|
+
xmlSpace: 1,
|
|
9571
|
+
y1: 0,
|
|
9572
|
+
y2: 0,
|
|
9573
|
+
y: 0,
|
|
9574
|
+
yChannelSelector: 1,
|
|
9575
|
+
z: 0,
|
|
9576
|
+
zoomAndPan: 1
|
|
9577
|
+
};
|
|
9578
|
+
return possibleStandardNamesOptimized;
|
|
9579
|
+
}
|
|
9580
|
+
|
|
9581
|
+
var hasRequiredLib$1;
|
|
9582
|
+
|
|
9583
|
+
function requireLib$1 () {
|
|
9584
|
+
if (hasRequiredLib$1) return lib;
|
|
9585
|
+
hasRequiredLib$1 = 1;
|
|
9586
|
+
|
|
9587
|
+
/**
|
|
9588
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
9589
|
+
*
|
|
9590
|
+
* This source code is licensed under the MIT license found in the
|
|
9591
|
+
* LICENSE file in the root directory of this source tree.
|
|
9592
|
+
*
|
|
9593
|
+
*
|
|
9594
|
+
*/
|
|
9595
|
+
|
|
9596
|
+
|
|
9597
|
+
|
|
9598
|
+
|
|
9599
|
+
// A reserved attribute.
|
|
9600
|
+
// It is handled by React separately and shouldn't be written to the DOM.
|
|
9601
|
+
const RESERVED = 0;
|
|
9602
|
+
|
|
9603
|
+
// A simple string attribute.
|
|
9604
|
+
// Attributes that aren't in the filter are presumed to have this type.
|
|
9605
|
+
const STRING = 1;
|
|
9606
|
+
|
|
9607
|
+
// A string attribute that accepts booleans in React. In HTML, these are called
|
|
9608
|
+
// "enumerated" attributes with "true" and "false" as possible values.
|
|
9609
|
+
// When true, it should be set to a "true" string.
|
|
9610
|
+
// When false, it should be set to a "false" string.
|
|
9611
|
+
const BOOLEANISH_STRING = 2;
|
|
9612
|
+
|
|
9613
|
+
// A real boolean attribute.
|
|
9614
|
+
// When true, it should be present (set either to an empty string or its name).
|
|
9615
|
+
// When false, it should be omitted.
|
|
9616
|
+
const BOOLEAN = 3;
|
|
9617
|
+
|
|
9618
|
+
// An attribute that can be used as a flag as well as with a value.
|
|
9619
|
+
// When true, it should be present (set either to an empty string or its name).
|
|
9620
|
+
// When false, it should be omitted.
|
|
9621
|
+
// For any other value, should be present with that value.
|
|
9622
|
+
const OVERLOADED_BOOLEAN = 4;
|
|
9623
|
+
|
|
9624
|
+
// An attribute that must be numeric or parse as a numeric.
|
|
9625
|
+
// When falsy, it should be removed.
|
|
9626
|
+
const NUMERIC = 5;
|
|
9627
|
+
|
|
9628
|
+
// An attribute that must be positive numeric or parse as a positive numeric.
|
|
9629
|
+
// When falsy, it should be removed.
|
|
9630
|
+
const POSITIVE_NUMERIC = 6;
|
|
9631
|
+
|
|
9632
|
+
function getPropertyInfo(name) {
|
|
9633
|
+
return properties.hasOwnProperty(name) ? properties[name] : null;
|
|
9634
|
+
}
|
|
9635
|
+
|
|
9636
|
+
function PropertyInfoRecord(
|
|
9637
|
+
name,
|
|
9638
|
+
type,
|
|
9639
|
+
mustUseProperty,
|
|
9640
|
+
attributeName,
|
|
9641
|
+
attributeNamespace,
|
|
9642
|
+
sanitizeURL,
|
|
9643
|
+
removeEmptyString,
|
|
9644
|
+
) {
|
|
9645
|
+
this.acceptsBooleans =
|
|
9646
|
+
type === BOOLEANISH_STRING ||
|
|
9647
|
+
type === BOOLEAN ||
|
|
9648
|
+
type === OVERLOADED_BOOLEAN;
|
|
9649
|
+
this.attributeName = attributeName;
|
|
9650
|
+
this.attributeNamespace = attributeNamespace;
|
|
9651
|
+
this.mustUseProperty = mustUseProperty;
|
|
9652
|
+
this.propertyName = name;
|
|
9653
|
+
this.type = type;
|
|
9654
|
+
this.sanitizeURL = sanitizeURL;
|
|
9655
|
+
this.removeEmptyString = removeEmptyString;
|
|
9656
|
+
}
|
|
9657
|
+
|
|
9658
|
+
// When adding attributes to this list, be sure to also add them to
|
|
9659
|
+
// the `possibleStandardNames` module to ensure casing and incorrect
|
|
9660
|
+
// name warnings.
|
|
9661
|
+
const properties = {};
|
|
9662
|
+
|
|
9663
|
+
// These props are reserved by React. They shouldn't be written to the DOM.
|
|
9664
|
+
const reservedProps = [
|
|
9665
|
+
'children',
|
|
9666
|
+
'dangerouslySetInnerHTML',
|
|
9667
|
+
// TODO: This prevents the assignment of defaultValue to regular
|
|
9668
|
+
// elements (not just inputs). Now that ReactDOMInput assigns to the
|
|
9669
|
+
// defaultValue property -- do we need this?
|
|
9670
|
+
'defaultValue',
|
|
9671
|
+
'defaultChecked',
|
|
9672
|
+
'innerHTML',
|
|
9673
|
+
'suppressContentEditableWarning',
|
|
9674
|
+
'suppressHydrationWarning',
|
|
9675
|
+
'style',
|
|
9676
|
+
];
|
|
9677
|
+
|
|
9678
|
+
reservedProps.forEach(name => {
|
|
9679
|
+
properties[name] = new PropertyInfoRecord(
|
|
9680
|
+
name,
|
|
9681
|
+
RESERVED,
|
|
9682
|
+
false, // mustUseProperty
|
|
9683
|
+
name, // attributeName
|
|
9684
|
+
null, // attributeNamespace
|
|
9685
|
+
false, // sanitizeURL
|
|
9686
|
+
false, // removeEmptyString
|
|
9687
|
+
);
|
|
9688
|
+
});
|
|
9689
|
+
|
|
9690
|
+
// A few React string attributes have a different name.
|
|
9691
|
+
// This is a mapping from React prop names to the attribute names.
|
|
9692
|
+
[
|
|
9693
|
+
['acceptCharset', 'accept-charset'],
|
|
9694
|
+
['className', 'class'],
|
|
9695
|
+
['htmlFor', 'for'],
|
|
9696
|
+
['httpEquiv', 'http-equiv'],
|
|
9697
|
+
].forEach(([name, attributeName]) => {
|
|
9698
|
+
properties[name] = new PropertyInfoRecord(
|
|
9699
|
+
name,
|
|
9700
|
+
STRING,
|
|
9701
|
+
false, // mustUseProperty
|
|
9702
|
+
attributeName, // attributeName
|
|
9703
|
+
null, // attributeNamespace
|
|
9704
|
+
false, // sanitizeURL
|
|
9705
|
+
false, // removeEmptyString
|
|
9706
|
+
);
|
|
9707
|
+
});
|
|
9708
|
+
|
|
9709
|
+
// These are "enumerated" HTML attributes that accept "true" and "false".
|
|
9710
|
+
// In React, we let users pass `true` and `false` even though technically
|
|
9711
|
+
// these aren't boolean attributes (they are coerced to strings).
|
|
9712
|
+
['contentEditable', 'draggable', 'spellCheck', 'value'].forEach(name => {
|
|
9713
|
+
properties[name] = new PropertyInfoRecord(
|
|
9714
|
+
name,
|
|
9715
|
+
BOOLEANISH_STRING,
|
|
9716
|
+
false, // mustUseProperty
|
|
9717
|
+
name.toLowerCase(), // attributeName
|
|
9718
|
+
null, // attributeNamespace
|
|
9719
|
+
false, // sanitizeURL
|
|
9720
|
+
false, // removeEmptyString
|
|
9721
|
+
);
|
|
9722
|
+
});
|
|
9723
|
+
|
|
9724
|
+
// These are "enumerated" SVG attributes that accept "true" and "false".
|
|
9725
|
+
// In React, we let users pass `true` and `false` even though technically
|
|
9726
|
+
// these aren't boolean attributes (they are coerced to strings).
|
|
9727
|
+
// Since these are SVG attributes, their attribute names are case-sensitive.
|
|
9728
|
+
[
|
|
9729
|
+
'autoReverse',
|
|
9730
|
+
'externalResourcesRequired',
|
|
9731
|
+
'focusable',
|
|
9732
|
+
'preserveAlpha',
|
|
9733
|
+
].forEach(name => {
|
|
9734
|
+
properties[name] = new PropertyInfoRecord(
|
|
9735
|
+
name,
|
|
9736
|
+
BOOLEANISH_STRING,
|
|
9737
|
+
false, // mustUseProperty
|
|
9738
|
+
name, // attributeName
|
|
9739
|
+
null, // attributeNamespace
|
|
9740
|
+
false, // sanitizeURL
|
|
9741
|
+
false, // removeEmptyString
|
|
9742
|
+
);
|
|
9743
|
+
});
|
|
9744
|
+
|
|
9745
|
+
// These are HTML boolean attributes.
|
|
9746
|
+
[
|
|
9747
|
+
'allowFullScreen',
|
|
9748
|
+
'async',
|
|
9749
|
+
// Note: there is a special case that prevents it from being written to the DOM
|
|
9750
|
+
// on the client side because the browsers are inconsistent. Instead we call focus().
|
|
9751
|
+
'autoFocus',
|
|
9752
|
+
'autoPlay',
|
|
9753
|
+
'controls',
|
|
9754
|
+
'default',
|
|
9755
|
+
'defer',
|
|
9756
|
+
'disabled',
|
|
9757
|
+
'disablePictureInPicture',
|
|
9758
|
+
'disableRemotePlayback',
|
|
9759
|
+
'formNoValidate',
|
|
9760
|
+
'hidden',
|
|
9761
|
+
'loop',
|
|
9762
|
+
'noModule',
|
|
9763
|
+
'noValidate',
|
|
9764
|
+
'open',
|
|
9765
|
+
'playsInline',
|
|
9766
|
+
'readOnly',
|
|
9767
|
+
'required',
|
|
9768
|
+
'reversed',
|
|
9769
|
+
'scoped',
|
|
9770
|
+
'seamless',
|
|
9771
|
+
// Microdata
|
|
9772
|
+
'itemScope',
|
|
9773
|
+
].forEach(name => {
|
|
9774
|
+
properties[name] = new PropertyInfoRecord(
|
|
9775
|
+
name,
|
|
9776
|
+
BOOLEAN,
|
|
9777
|
+
false, // mustUseProperty
|
|
9778
|
+
name.toLowerCase(), // attributeName
|
|
9779
|
+
null, // attributeNamespace
|
|
9780
|
+
false, // sanitizeURL
|
|
9781
|
+
false, // removeEmptyString
|
|
9782
|
+
);
|
|
9783
|
+
});
|
|
9784
|
+
|
|
9785
|
+
// These are the few React props that we set as DOM properties
|
|
9786
|
+
// rather than attributes. These are all booleans.
|
|
9787
|
+
[
|
|
9788
|
+
'checked',
|
|
9789
|
+
// Note: `option.selected` is not updated if `select.multiple` is
|
|
9790
|
+
// disabled with `removeAttribute`. We have special logic for handling this.
|
|
9791
|
+
'multiple',
|
|
9792
|
+
'muted',
|
|
9793
|
+
'selected',
|
|
9794
|
+
|
|
9795
|
+
// NOTE: if you add a camelCased prop to this list,
|
|
9796
|
+
// you'll need to set attributeName to name.toLowerCase()
|
|
9797
|
+
// instead in the assignment below.
|
|
9798
|
+
].forEach(name => {
|
|
9799
|
+
properties[name] = new PropertyInfoRecord(
|
|
9800
|
+
name,
|
|
9801
|
+
BOOLEAN,
|
|
9802
|
+
true, // mustUseProperty
|
|
9803
|
+
name, // attributeName
|
|
9804
|
+
null, // attributeNamespace
|
|
9805
|
+
false, // sanitizeURL
|
|
9806
|
+
false, // removeEmptyString
|
|
9807
|
+
);
|
|
9808
|
+
});
|
|
9809
|
+
|
|
9810
|
+
// These are HTML attributes that are "overloaded booleans": they behave like
|
|
9811
|
+
// booleans, but can also accept a string value.
|
|
9812
|
+
[
|
|
9813
|
+
'capture',
|
|
9814
|
+
'download',
|
|
9815
|
+
|
|
9816
|
+
// NOTE: if you add a camelCased prop to this list,
|
|
9817
|
+
// you'll need to set attributeName to name.toLowerCase()
|
|
9818
|
+
// instead in the assignment below.
|
|
9819
|
+
].forEach(name => {
|
|
9820
|
+
properties[name] = new PropertyInfoRecord(
|
|
9821
|
+
name,
|
|
9822
|
+
OVERLOADED_BOOLEAN,
|
|
9823
|
+
false, // mustUseProperty
|
|
9824
|
+
name, // attributeName
|
|
9825
|
+
null, // attributeNamespace
|
|
9826
|
+
false, // sanitizeURL
|
|
9827
|
+
false, // removeEmptyString
|
|
9828
|
+
);
|
|
9829
|
+
});
|
|
9830
|
+
|
|
9831
|
+
// These are HTML attributes that must be positive numbers.
|
|
9832
|
+
[
|
|
9833
|
+
'cols',
|
|
9834
|
+
'rows',
|
|
9835
|
+
'size',
|
|
9836
|
+
'span',
|
|
9837
|
+
|
|
9838
|
+
// NOTE: if you add a camelCased prop to this list,
|
|
9839
|
+
// you'll need to set attributeName to name.toLowerCase()
|
|
9840
|
+
// instead in the assignment below.
|
|
9841
|
+
].forEach(name => {
|
|
9842
|
+
properties[name] = new PropertyInfoRecord(
|
|
9843
|
+
name,
|
|
9844
|
+
POSITIVE_NUMERIC,
|
|
9845
|
+
false, // mustUseProperty
|
|
9846
|
+
name, // attributeName
|
|
9847
|
+
null, // attributeNamespace
|
|
9848
|
+
false, // sanitizeURL
|
|
9849
|
+
false, // removeEmptyString
|
|
9850
|
+
);
|
|
9851
|
+
});
|
|
9852
|
+
|
|
9853
|
+
// These are HTML attributes that must be numbers.
|
|
9854
|
+
['rowSpan', 'start'].forEach(name => {
|
|
9855
|
+
properties[name] = new PropertyInfoRecord(
|
|
9856
|
+
name,
|
|
9857
|
+
NUMERIC,
|
|
9858
|
+
false, // mustUseProperty
|
|
9859
|
+
name.toLowerCase(), // attributeName
|
|
9860
|
+
null, // attributeNamespace
|
|
9861
|
+
false, // sanitizeURL
|
|
9862
|
+
false, // removeEmptyString
|
|
9863
|
+
);
|
|
9864
|
+
});
|
|
9865
|
+
|
|
9866
|
+
const CAMELIZE = /[\-\:]([a-z])/g;
|
|
9867
|
+
const capitalize = token => token[1].toUpperCase();
|
|
9868
|
+
|
|
9869
|
+
// This is a list of all SVG attributes that need special casing, namespacing,
|
|
9870
|
+
// or boolean value assignment. Regular attributes that just accept strings
|
|
9871
|
+
// and have the same names are omitted, just like in the HTML attribute filter.
|
|
9872
|
+
// Some of these attributes can be hard to find. This list was created by
|
|
9873
|
+
// scraping the MDN documentation.
|
|
9874
|
+
[
|
|
9875
|
+
'accent-height',
|
|
9876
|
+
'alignment-baseline',
|
|
9877
|
+
'arabic-form',
|
|
9878
|
+
'baseline-shift',
|
|
9879
|
+
'cap-height',
|
|
9880
|
+
'clip-path',
|
|
9881
|
+
'clip-rule',
|
|
9882
|
+
'color-interpolation',
|
|
9883
|
+
'color-interpolation-filters',
|
|
9884
|
+
'color-profile',
|
|
9885
|
+
'color-rendering',
|
|
9886
|
+
'dominant-baseline',
|
|
9887
|
+
'enable-background',
|
|
9888
|
+
'fill-opacity',
|
|
9889
|
+
'fill-rule',
|
|
9890
|
+
'flood-color',
|
|
9891
|
+
'flood-opacity',
|
|
9892
|
+
'font-family',
|
|
9893
|
+
'font-size',
|
|
9894
|
+
'font-size-adjust',
|
|
9895
|
+
'font-stretch',
|
|
9896
|
+
'font-style',
|
|
9897
|
+
'font-variant',
|
|
9898
|
+
'font-weight',
|
|
9899
|
+
'glyph-name',
|
|
9900
|
+
'glyph-orientation-horizontal',
|
|
9901
|
+
'glyph-orientation-vertical',
|
|
9902
|
+
'horiz-adv-x',
|
|
9903
|
+
'horiz-origin-x',
|
|
9904
|
+
'image-rendering',
|
|
9905
|
+
'letter-spacing',
|
|
9906
|
+
'lighting-color',
|
|
9907
|
+
'marker-end',
|
|
9908
|
+
'marker-mid',
|
|
9909
|
+
'marker-start',
|
|
9910
|
+
'overline-position',
|
|
9911
|
+
'overline-thickness',
|
|
9912
|
+
'paint-order',
|
|
9913
|
+
'panose-1',
|
|
9914
|
+
'pointer-events',
|
|
9915
|
+
'rendering-intent',
|
|
9916
|
+
'shape-rendering',
|
|
9917
|
+
'stop-color',
|
|
9918
|
+
'stop-opacity',
|
|
9919
|
+
'strikethrough-position',
|
|
9920
|
+
'strikethrough-thickness',
|
|
9921
|
+
'stroke-dasharray',
|
|
9922
|
+
'stroke-dashoffset',
|
|
9923
|
+
'stroke-linecap',
|
|
9924
|
+
'stroke-linejoin',
|
|
9925
|
+
'stroke-miterlimit',
|
|
9926
|
+
'stroke-opacity',
|
|
9927
|
+
'stroke-width',
|
|
9928
|
+
'text-anchor',
|
|
9929
|
+
'text-decoration',
|
|
9930
|
+
'text-rendering',
|
|
9931
|
+
'underline-position',
|
|
9932
|
+
'underline-thickness',
|
|
9933
|
+
'unicode-bidi',
|
|
9934
|
+
'unicode-range',
|
|
9935
|
+
'units-per-em',
|
|
9936
|
+
'v-alphabetic',
|
|
9937
|
+
'v-hanging',
|
|
9938
|
+
'v-ideographic',
|
|
9939
|
+
'v-mathematical',
|
|
9940
|
+
'vector-effect',
|
|
9941
|
+
'vert-adv-y',
|
|
9942
|
+
'vert-origin-x',
|
|
9943
|
+
'vert-origin-y',
|
|
9944
|
+
'word-spacing',
|
|
9945
|
+
'writing-mode',
|
|
9946
|
+
'xmlns:xlink',
|
|
9947
|
+
'x-height',
|
|
9948
|
+
|
|
9949
|
+
// NOTE: if you add a camelCased prop to this list,
|
|
9950
|
+
// you'll need to set attributeName to name.toLowerCase()
|
|
9951
|
+
// instead in the assignment below.
|
|
9952
|
+
].forEach(attributeName => {
|
|
9953
|
+
const name = attributeName.replace(CAMELIZE, capitalize);
|
|
9954
|
+
properties[name] = new PropertyInfoRecord(
|
|
9955
|
+
name,
|
|
9956
|
+
STRING,
|
|
9957
|
+
false, // mustUseProperty
|
|
9958
|
+
attributeName,
|
|
9959
|
+
null, // attributeNamespace
|
|
9960
|
+
false, // sanitizeURL
|
|
9961
|
+
false, // removeEmptyString
|
|
9962
|
+
);
|
|
9963
|
+
});
|
|
9964
|
+
|
|
9965
|
+
// String SVG attributes with the xlink namespace.
|
|
9966
|
+
[
|
|
9967
|
+
'xlink:actuate',
|
|
9968
|
+
'xlink:arcrole',
|
|
9969
|
+
'xlink:role',
|
|
9970
|
+
'xlink:show',
|
|
9971
|
+
'xlink:title',
|
|
9972
|
+
'xlink:type',
|
|
9973
|
+
|
|
9974
|
+
// NOTE: if you add a camelCased prop to this list,
|
|
9975
|
+
// you'll need to set attributeName to name.toLowerCase()
|
|
9976
|
+
// instead in the assignment below.
|
|
9977
|
+
].forEach(attributeName => {
|
|
9978
|
+
const name = attributeName.replace(CAMELIZE, capitalize);
|
|
9979
|
+
properties[name] = new PropertyInfoRecord(
|
|
9980
|
+
name,
|
|
9981
|
+
STRING,
|
|
9982
|
+
false, // mustUseProperty
|
|
9983
|
+
attributeName,
|
|
9984
|
+
'http://www.w3.org/1999/xlink',
|
|
9985
|
+
false, // sanitizeURL
|
|
9986
|
+
false, // removeEmptyString
|
|
9987
|
+
);
|
|
9988
|
+
});
|
|
9989
|
+
|
|
9990
|
+
// String SVG attributes with the xml namespace.
|
|
9991
|
+
[
|
|
9992
|
+
'xml:base',
|
|
9993
|
+
'xml:lang',
|
|
9994
|
+
'xml:space',
|
|
9995
|
+
|
|
9996
|
+
// NOTE: if you add a camelCased prop to this list,
|
|
9997
|
+
// you'll need to set attributeName to name.toLowerCase()
|
|
9998
|
+
// instead in the assignment below.
|
|
9999
|
+
].forEach(attributeName => {
|
|
10000
|
+
const name = attributeName.replace(CAMELIZE, capitalize);
|
|
10001
|
+
properties[name] = new PropertyInfoRecord(
|
|
10002
|
+
name,
|
|
10003
|
+
STRING,
|
|
10004
|
+
false, // mustUseProperty
|
|
10005
|
+
attributeName,
|
|
10006
|
+
'http://www.w3.org/XML/1998/namespace',
|
|
10007
|
+
false, // sanitizeURL
|
|
10008
|
+
false, // removeEmptyString
|
|
10009
|
+
);
|
|
10010
|
+
});
|
|
10011
|
+
|
|
10012
|
+
// These attribute exists both in HTML and SVG.
|
|
10013
|
+
// The attribute name is case-sensitive in SVG so we can't just use
|
|
10014
|
+
// the React name like we do for attributes that exist only in HTML.
|
|
10015
|
+
['tabIndex', 'crossOrigin'].forEach(attributeName => {
|
|
10016
|
+
properties[attributeName] = new PropertyInfoRecord(
|
|
10017
|
+
attributeName,
|
|
10018
|
+
STRING,
|
|
10019
|
+
false, // mustUseProperty
|
|
10020
|
+
attributeName.toLowerCase(), // attributeName
|
|
10021
|
+
null, // attributeNamespace
|
|
10022
|
+
false, // sanitizeURL
|
|
10023
|
+
false, // removeEmptyString
|
|
10024
|
+
);
|
|
10025
|
+
});
|
|
10026
|
+
|
|
10027
|
+
// These attributes accept URLs. These must not allow javascript: URLS.
|
|
10028
|
+
// These will also need to accept Trusted Types object in the future.
|
|
10029
|
+
const xlinkHref = 'xlinkHref';
|
|
10030
|
+
properties[xlinkHref] = new PropertyInfoRecord(
|
|
10031
|
+
'xlinkHref',
|
|
10032
|
+
STRING,
|
|
10033
|
+
false, // mustUseProperty
|
|
10034
|
+
'xlink:href',
|
|
10035
|
+
'http://www.w3.org/1999/xlink',
|
|
10036
|
+
true, // sanitizeURL
|
|
10037
|
+
false, // removeEmptyString
|
|
10038
|
+
);
|
|
10039
|
+
|
|
10040
|
+
['src', 'href', 'action', 'formAction'].forEach(attributeName => {
|
|
10041
|
+
properties[attributeName] = new PropertyInfoRecord(
|
|
10042
|
+
attributeName,
|
|
10043
|
+
STRING,
|
|
10044
|
+
false, // mustUseProperty
|
|
10045
|
+
attributeName.toLowerCase(), // attributeName
|
|
10046
|
+
null, // attributeNamespace
|
|
10047
|
+
true, // sanitizeURL
|
|
10048
|
+
true, // removeEmptyString
|
|
10049
|
+
);
|
|
10050
|
+
});
|
|
10051
|
+
|
|
10052
|
+
//
|
|
10053
|
+
const {
|
|
10054
|
+
CAMELCASE,
|
|
10055
|
+
SAME,
|
|
10056
|
+
possibleStandardNames: possibleStandardNamesOptimized
|
|
10057
|
+
} = requirePossibleStandardNamesOptimized();
|
|
10058
|
+
|
|
10059
|
+
const ATTRIBUTE_NAME_START_CHAR =
|
|
10060
|
+
':A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD';
|
|
10061
|
+
|
|
10062
|
+
const ATTRIBUTE_NAME_CHAR =
|
|
10063
|
+
ATTRIBUTE_NAME_START_CHAR + '\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040';
|
|
10064
|
+
|
|
10065
|
+
/**
|
|
10066
|
+
* Checks whether a property name is a custom attribute.
|
|
10067
|
+
*
|
|
10068
|
+
* @see https://github.com/facebook/react/blob/15-stable/src/renderers/dom/shared/HTMLDOMPropertyConfig.js#L23-L25
|
|
10069
|
+
*
|
|
10070
|
+
* @type {(attribute: string) => boolean}
|
|
10071
|
+
*/
|
|
10072
|
+
const isCustomAttribute =
|
|
10073
|
+
RegExp.prototype.test.bind(
|
|
10074
|
+
// eslint-disable-next-line no-misleading-character-class
|
|
10075
|
+
new RegExp('^(data|aria)-[' + ATTRIBUTE_NAME_CHAR + ']*$')
|
|
10076
|
+
);
|
|
10077
|
+
|
|
10078
|
+
/**
|
|
10079
|
+
* @type {Record<string, string>}
|
|
10080
|
+
*/
|
|
10081
|
+
const possibleStandardNames = Object.keys(
|
|
10082
|
+
possibleStandardNamesOptimized
|
|
10083
|
+
).reduce((accumulator, standardName) => {
|
|
10084
|
+
const propName = possibleStandardNamesOptimized[standardName];
|
|
10085
|
+
if (propName === SAME) {
|
|
10086
|
+
accumulator[standardName] = standardName;
|
|
10087
|
+
} else if (propName === CAMELCASE) {
|
|
10088
|
+
accumulator[standardName.toLowerCase()] = standardName;
|
|
10089
|
+
} else {
|
|
10090
|
+
accumulator[standardName] = propName;
|
|
10091
|
+
}
|
|
10092
|
+
return accumulator;
|
|
10093
|
+
}, {});
|
|
10094
|
+
|
|
10095
|
+
lib.BOOLEAN = BOOLEAN;
|
|
10096
|
+
lib.BOOLEANISH_STRING = BOOLEANISH_STRING;
|
|
10097
|
+
lib.NUMERIC = NUMERIC;
|
|
10098
|
+
lib.OVERLOADED_BOOLEAN = OVERLOADED_BOOLEAN;
|
|
10099
|
+
lib.POSITIVE_NUMERIC = POSITIVE_NUMERIC;
|
|
10100
|
+
lib.RESERVED = RESERVED;
|
|
10101
|
+
lib.STRING = STRING;
|
|
10102
|
+
lib.getPropertyInfo = getPropertyInfo;
|
|
10103
|
+
lib.isCustomAttribute = isCustomAttribute;
|
|
10104
|
+
lib.possibleStandardNames = possibleStandardNames;
|
|
10105
|
+
return lib;
|
|
10106
|
+
}
|
|
10107
|
+
|
|
10108
|
+
var utilities$1 = {};
|
|
10109
|
+
|
|
10110
|
+
var cjs$1 = {};
|
|
10111
|
+
|
|
10112
|
+
var inlineStyleParser;
|
|
10113
|
+
var hasRequiredInlineStyleParser;
|
|
10114
|
+
|
|
10115
|
+
function requireInlineStyleParser () {
|
|
10116
|
+
if (hasRequiredInlineStyleParser) return inlineStyleParser;
|
|
10117
|
+
hasRequiredInlineStyleParser = 1;
|
|
10118
|
+
// http://www.w3.org/TR/CSS21/grammar.html
|
|
10119
|
+
// https://github.com/visionmedia/css-parse/pull/49#issuecomment-30088027
|
|
10120
|
+
var COMMENT_REGEX = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;
|
|
10121
|
+
|
|
10122
|
+
var NEWLINE_REGEX = /\n/g;
|
|
10123
|
+
var WHITESPACE_REGEX = /^\s*/;
|
|
10124
|
+
|
|
10125
|
+
// declaration
|
|
10126
|
+
var PROPERTY_REGEX = /^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/;
|
|
10127
|
+
var COLON_REGEX = /^:\s*/;
|
|
10128
|
+
var VALUE_REGEX = /^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/;
|
|
10129
|
+
var SEMICOLON_REGEX = /^[;\s]*/;
|
|
10130
|
+
|
|
10131
|
+
// https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/Trim#Polyfill
|
|
10132
|
+
var TRIM_REGEX = /^\s+|\s+$/g;
|
|
10133
|
+
|
|
10134
|
+
// strings
|
|
10135
|
+
var NEWLINE = '\n';
|
|
10136
|
+
var FORWARD_SLASH = '/';
|
|
10137
|
+
var ASTERISK = '*';
|
|
10138
|
+
var EMPTY_STRING = '';
|
|
10139
|
+
|
|
10140
|
+
// types
|
|
10141
|
+
var TYPE_COMMENT = 'comment';
|
|
10142
|
+
var TYPE_DECLARATION = 'declaration';
|
|
10143
|
+
|
|
10144
|
+
/**
|
|
10145
|
+
* @param {String} style
|
|
10146
|
+
* @param {Object} [options]
|
|
10147
|
+
* @return {Object[]}
|
|
10148
|
+
* @throws {TypeError}
|
|
10149
|
+
* @throws {Error}
|
|
10150
|
+
*/
|
|
10151
|
+
inlineStyleParser = function (style, options) {
|
|
10152
|
+
if (typeof style !== 'string') {
|
|
10153
|
+
throw new TypeError('First argument must be a string');
|
|
10154
|
+
}
|
|
10155
|
+
|
|
10156
|
+
if (!style) return [];
|
|
10157
|
+
|
|
10158
|
+
options = options || {};
|
|
10159
|
+
|
|
10160
|
+
/**
|
|
10161
|
+
* Positional.
|
|
10162
|
+
*/
|
|
10163
|
+
var lineno = 1;
|
|
10164
|
+
var column = 1;
|
|
10165
|
+
|
|
10166
|
+
/**
|
|
10167
|
+
* Update lineno and column based on `str`.
|
|
10168
|
+
*
|
|
10169
|
+
* @param {String} str
|
|
10170
|
+
*/
|
|
10171
|
+
function updatePosition(str) {
|
|
10172
|
+
var lines = str.match(NEWLINE_REGEX);
|
|
10173
|
+
if (lines) lineno += lines.length;
|
|
10174
|
+
var i = str.lastIndexOf(NEWLINE);
|
|
10175
|
+
column = ~i ? str.length - i : column + str.length;
|
|
10176
|
+
}
|
|
10177
|
+
|
|
10178
|
+
/**
|
|
10179
|
+
* Mark position and patch `node.position`.
|
|
10180
|
+
*
|
|
10181
|
+
* @return {Function}
|
|
10182
|
+
*/
|
|
10183
|
+
function position() {
|
|
10184
|
+
var start = { line: lineno, column: column };
|
|
10185
|
+
return function (node) {
|
|
10186
|
+
node.position = new Position(start);
|
|
10187
|
+
whitespace();
|
|
10188
|
+
return node;
|
|
10189
|
+
};
|
|
10190
|
+
}
|
|
10191
|
+
|
|
10192
|
+
/**
|
|
10193
|
+
* Store position information for a node.
|
|
10194
|
+
*
|
|
10195
|
+
* @constructor
|
|
10196
|
+
* @property {Object} start
|
|
10197
|
+
* @property {Object} end
|
|
10198
|
+
* @property {undefined|String} source
|
|
10199
|
+
*/
|
|
10200
|
+
function Position(start) {
|
|
10201
|
+
this.start = start;
|
|
10202
|
+
this.end = { line: lineno, column: column };
|
|
10203
|
+
this.source = options.source;
|
|
10204
|
+
}
|
|
10205
|
+
|
|
10206
|
+
/**
|
|
10207
|
+
* Non-enumerable source string.
|
|
10208
|
+
*/
|
|
10209
|
+
Position.prototype.content = style;
|
|
10210
|
+
|
|
10211
|
+
/**
|
|
10212
|
+
* Error `msg`.
|
|
10213
|
+
*
|
|
10214
|
+
* @param {String} msg
|
|
10215
|
+
* @throws {Error}
|
|
10216
|
+
*/
|
|
10217
|
+
function error(msg) {
|
|
10218
|
+
var err = new Error(
|
|
10219
|
+
options.source + ':' + lineno + ':' + column + ': ' + msg
|
|
10220
|
+
);
|
|
10221
|
+
err.reason = msg;
|
|
10222
|
+
err.filename = options.source;
|
|
10223
|
+
err.line = lineno;
|
|
10224
|
+
err.column = column;
|
|
10225
|
+
err.source = style;
|
|
10226
|
+
|
|
10227
|
+
if (options.silent) ; else {
|
|
10228
|
+
throw err;
|
|
10229
|
+
}
|
|
10230
|
+
}
|
|
10231
|
+
|
|
10232
|
+
/**
|
|
10233
|
+
* Match `re` and return captures.
|
|
10234
|
+
*
|
|
10235
|
+
* @param {RegExp} re
|
|
10236
|
+
* @return {undefined|Array}
|
|
10237
|
+
*/
|
|
10238
|
+
function match(re) {
|
|
10239
|
+
var m = re.exec(style);
|
|
10240
|
+
if (!m) return;
|
|
10241
|
+
var str = m[0];
|
|
10242
|
+
updatePosition(str);
|
|
10243
|
+
style = style.slice(str.length);
|
|
10244
|
+
return m;
|
|
10245
|
+
}
|
|
10246
|
+
|
|
10247
|
+
/**
|
|
10248
|
+
* Parse whitespace.
|
|
10249
|
+
*/
|
|
10250
|
+
function whitespace() {
|
|
10251
|
+
match(WHITESPACE_REGEX);
|
|
10252
|
+
}
|
|
10253
|
+
|
|
10254
|
+
/**
|
|
10255
|
+
* Parse comments.
|
|
10256
|
+
*
|
|
10257
|
+
* @param {Object[]} [rules]
|
|
10258
|
+
* @return {Object[]}
|
|
10259
|
+
*/
|
|
10260
|
+
function comments(rules) {
|
|
10261
|
+
var c;
|
|
10262
|
+
rules = rules || [];
|
|
10263
|
+
while ((c = comment())) {
|
|
10264
|
+
if (c !== false) {
|
|
10265
|
+
rules.push(c);
|
|
10266
|
+
}
|
|
10267
|
+
}
|
|
10268
|
+
return rules;
|
|
10269
|
+
}
|
|
10270
|
+
|
|
10271
|
+
/**
|
|
10272
|
+
* Parse comment.
|
|
10273
|
+
*
|
|
10274
|
+
* @return {Object}
|
|
10275
|
+
* @throws {Error}
|
|
10276
|
+
*/
|
|
10277
|
+
function comment() {
|
|
10278
|
+
var pos = position();
|
|
10279
|
+
if (FORWARD_SLASH != style.charAt(0) || ASTERISK != style.charAt(1)) return;
|
|
10280
|
+
|
|
10281
|
+
var i = 2;
|
|
10282
|
+
while (
|
|
10283
|
+
EMPTY_STRING != style.charAt(i) &&
|
|
10284
|
+
(ASTERISK != style.charAt(i) || FORWARD_SLASH != style.charAt(i + 1))
|
|
10285
|
+
) {
|
|
10286
|
+
++i;
|
|
10287
|
+
}
|
|
10288
|
+
i += 2;
|
|
10289
|
+
|
|
10290
|
+
if (EMPTY_STRING === style.charAt(i - 1)) {
|
|
10291
|
+
return error('End of comment missing');
|
|
10292
|
+
}
|
|
10293
|
+
|
|
10294
|
+
var str = style.slice(2, i - 2);
|
|
10295
|
+
column += 2;
|
|
10296
|
+
updatePosition(str);
|
|
10297
|
+
style = style.slice(i);
|
|
10298
|
+
column += 2;
|
|
10299
|
+
|
|
10300
|
+
return pos({
|
|
10301
|
+
type: TYPE_COMMENT,
|
|
10302
|
+
comment: str
|
|
10303
|
+
});
|
|
10304
|
+
}
|
|
10305
|
+
|
|
10306
|
+
/**
|
|
10307
|
+
* Parse declaration.
|
|
10308
|
+
*
|
|
10309
|
+
* @return {Object}
|
|
10310
|
+
* @throws {Error}
|
|
10311
|
+
*/
|
|
10312
|
+
function declaration() {
|
|
10313
|
+
var pos = position();
|
|
10314
|
+
|
|
10315
|
+
// prop
|
|
10316
|
+
var prop = match(PROPERTY_REGEX);
|
|
10317
|
+
if (!prop) return;
|
|
10318
|
+
comment();
|
|
10319
|
+
|
|
10320
|
+
// :
|
|
10321
|
+
if (!match(COLON_REGEX)) return error("property missing ':'");
|
|
10322
|
+
|
|
10323
|
+
// val
|
|
10324
|
+
var val = match(VALUE_REGEX);
|
|
10325
|
+
|
|
10326
|
+
var ret = pos({
|
|
10327
|
+
type: TYPE_DECLARATION,
|
|
10328
|
+
property: trim(prop[0].replace(COMMENT_REGEX, EMPTY_STRING)),
|
|
10329
|
+
value: val
|
|
10330
|
+
? trim(val[0].replace(COMMENT_REGEX, EMPTY_STRING))
|
|
10331
|
+
: EMPTY_STRING
|
|
10332
|
+
});
|
|
10333
|
+
|
|
10334
|
+
// ;
|
|
10335
|
+
match(SEMICOLON_REGEX);
|
|
10336
|
+
|
|
10337
|
+
return ret;
|
|
10338
|
+
}
|
|
10339
|
+
|
|
10340
|
+
/**
|
|
10341
|
+
* Parse declarations.
|
|
10342
|
+
*
|
|
10343
|
+
* @return {Object[]}
|
|
10344
|
+
*/
|
|
10345
|
+
function declarations() {
|
|
10346
|
+
var decls = [];
|
|
10347
|
+
|
|
10348
|
+
comments(decls);
|
|
10349
|
+
|
|
10350
|
+
// declarations
|
|
10351
|
+
var decl;
|
|
10352
|
+
while ((decl = declaration())) {
|
|
10353
|
+
if (decl !== false) {
|
|
10354
|
+
decls.push(decl);
|
|
10355
|
+
comments(decls);
|
|
10356
|
+
}
|
|
10357
|
+
}
|
|
10358
|
+
|
|
10359
|
+
return decls;
|
|
10360
|
+
}
|
|
10361
|
+
|
|
10362
|
+
whitespace();
|
|
10363
|
+
return declarations();
|
|
10364
|
+
};
|
|
10365
|
+
|
|
10366
|
+
/**
|
|
10367
|
+
* Trim `str`.
|
|
10368
|
+
*
|
|
10369
|
+
* @param {String} str
|
|
10370
|
+
* @return {String}
|
|
10371
|
+
*/
|
|
10372
|
+
function trim(str) {
|
|
10373
|
+
return str ? str.replace(TRIM_REGEX, EMPTY_STRING) : EMPTY_STRING;
|
|
10374
|
+
}
|
|
10375
|
+
return inlineStyleParser;
|
|
10376
|
+
}
|
|
10377
|
+
|
|
10378
|
+
var hasRequiredCjs$1;
|
|
10379
|
+
|
|
10380
|
+
function requireCjs$1 () {
|
|
10381
|
+
if (hasRequiredCjs$1) return cjs$1;
|
|
10382
|
+
hasRequiredCjs$1 = 1;
|
|
10383
|
+
var __importDefault = (cjs$1 && cjs$1.__importDefault) || function (mod) {
|
|
10384
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10385
|
+
};
|
|
10386
|
+
Object.defineProperty(cjs$1, "__esModule", { value: true });
|
|
10387
|
+
cjs$1.default = StyleToObject;
|
|
10388
|
+
var inline_style_parser_1 = __importDefault(requireInlineStyleParser());
|
|
10389
|
+
/**
|
|
10390
|
+
* Parses inline style to object.
|
|
10391
|
+
*
|
|
10392
|
+
* @param style - Inline style.
|
|
10393
|
+
* @param iterator - Iterator.
|
|
10394
|
+
* @returns - Style object or null.
|
|
10395
|
+
*
|
|
10396
|
+
* @example Parsing inline style to object:
|
|
10397
|
+
*
|
|
10398
|
+
* ```js
|
|
10399
|
+
* import parse from 'style-to-object';
|
|
10400
|
+
* parse('line-height: 42;'); // { 'line-height': '42' }
|
|
10401
|
+
* ```
|
|
10402
|
+
*/
|
|
10403
|
+
function StyleToObject(style, iterator) {
|
|
10404
|
+
var styleObject = null;
|
|
10405
|
+
if (!style || typeof style !== 'string') {
|
|
10406
|
+
return styleObject;
|
|
10407
|
+
}
|
|
10408
|
+
var declarations = (0, inline_style_parser_1.default)(style);
|
|
10409
|
+
var hasIterator = typeof iterator === 'function';
|
|
10410
|
+
declarations.forEach(function (declaration) {
|
|
10411
|
+
if (declaration.type !== 'declaration') {
|
|
10412
|
+
return;
|
|
10413
|
+
}
|
|
10414
|
+
var property = declaration.property, value = declaration.value;
|
|
10415
|
+
if (hasIterator) {
|
|
10416
|
+
iterator(property, value, declaration);
|
|
10417
|
+
}
|
|
10418
|
+
else if (value) {
|
|
10419
|
+
styleObject = styleObject || {};
|
|
10420
|
+
styleObject[property] = value;
|
|
10421
|
+
}
|
|
10422
|
+
});
|
|
10423
|
+
return styleObject;
|
|
10424
|
+
}
|
|
10425
|
+
|
|
10426
|
+
return cjs$1;
|
|
10427
|
+
}
|
|
10428
|
+
|
|
10429
|
+
var utilities = {};
|
|
10430
|
+
|
|
10431
|
+
var hasRequiredUtilities$1;
|
|
10432
|
+
|
|
10433
|
+
function requireUtilities$1 () {
|
|
10434
|
+
if (hasRequiredUtilities$1) return utilities;
|
|
10435
|
+
hasRequiredUtilities$1 = 1;
|
|
10436
|
+
Object.defineProperty(utilities, "__esModule", { value: true });
|
|
10437
|
+
utilities.camelCase = void 0;
|
|
10438
|
+
var CUSTOM_PROPERTY_REGEX = /^--[a-zA-Z0-9_-]+$/;
|
|
10439
|
+
var HYPHEN_REGEX = /-([a-z])/g;
|
|
10440
|
+
var NO_HYPHEN_REGEX = /^[^-]+$/;
|
|
10441
|
+
var VENDOR_PREFIX_REGEX = /^-(webkit|moz|ms|o|khtml)-/;
|
|
10442
|
+
var MS_VENDOR_PREFIX_REGEX = /^-(ms)-/;
|
|
10443
|
+
/**
|
|
10444
|
+
* Checks whether to skip camelCase.
|
|
10445
|
+
*/
|
|
10446
|
+
var skipCamelCase = function (property) {
|
|
10447
|
+
return !property ||
|
|
10448
|
+
NO_HYPHEN_REGEX.test(property) ||
|
|
10449
|
+
CUSTOM_PROPERTY_REGEX.test(property);
|
|
10450
|
+
};
|
|
10451
|
+
/**
|
|
10452
|
+
* Replacer that capitalizes first character.
|
|
10453
|
+
*/
|
|
10454
|
+
var capitalize = function (match, character) {
|
|
10455
|
+
return character.toUpperCase();
|
|
10456
|
+
};
|
|
10457
|
+
/**
|
|
10458
|
+
* Replacer that removes beginning hyphen of vendor prefix property.
|
|
10459
|
+
*/
|
|
10460
|
+
var trimHyphen = function (match, prefix) { return "".concat(prefix, "-"); };
|
|
10461
|
+
/**
|
|
10462
|
+
* CamelCases a CSS property.
|
|
10463
|
+
*/
|
|
10464
|
+
var camelCase = function (property, options) {
|
|
10465
|
+
if (options === void 0) { options = {}; }
|
|
10466
|
+
if (skipCamelCase(property)) {
|
|
10467
|
+
return property;
|
|
10468
|
+
}
|
|
10469
|
+
property = property.toLowerCase();
|
|
10470
|
+
if (options.reactCompat) {
|
|
10471
|
+
// `-ms` vendor prefix should not be capitalized
|
|
10472
|
+
property = property.replace(MS_VENDOR_PREFIX_REGEX, trimHyphen);
|
|
10473
|
+
}
|
|
10474
|
+
else {
|
|
10475
|
+
// for non-React, remove first hyphen so vendor prefix is not capitalized
|
|
10476
|
+
property = property.replace(VENDOR_PREFIX_REGEX, trimHyphen);
|
|
10477
|
+
}
|
|
10478
|
+
return property.replace(HYPHEN_REGEX, capitalize);
|
|
10479
|
+
};
|
|
10480
|
+
utilities.camelCase = camelCase;
|
|
10481
|
+
|
|
10482
|
+
return utilities;
|
|
10483
|
+
}
|
|
10484
|
+
|
|
10485
|
+
var cjs;
|
|
10486
|
+
var hasRequiredCjs;
|
|
10487
|
+
|
|
10488
|
+
function requireCjs () {
|
|
10489
|
+
if (hasRequiredCjs) return cjs;
|
|
10490
|
+
hasRequiredCjs = 1;
|
|
10491
|
+
var __importDefault = (cjs && cjs.__importDefault) || function (mod) {
|
|
10492
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10493
|
+
};
|
|
10494
|
+
var style_to_object_1 = __importDefault(requireCjs$1());
|
|
10495
|
+
var utilities_1 = requireUtilities$1();
|
|
10496
|
+
/**
|
|
10497
|
+
* Parses CSS inline style to JavaScript object (camelCased).
|
|
10498
|
+
*/
|
|
10499
|
+
function StyleToJS(style, options) {
|
|
10500
|
+
var output = {};
|
|
10501
|
+
if (!style || typeof style !== 'string') {
|
|
10502
|
+
return output;
|
|
10503
|
+
}
|
|
10504
|
+
(0, style_to_object_1.default)(style, function (property, value) {
|
|
10505
|
+
// skip CSS comment
|
|
10506
|
+
if (property && value) {
|
|
10507
|
+
output[(0, utilities_1.camelCase)(property, options)] = value;
|
|
10508
|
+
}
|
|
10509
|
+
});
|
|
10510
|
+
return output;
|
|
10511
|
+
}
|
|
10512
|
+
StyleToJS.default = StyleToJS;
|
|
10513
|
+
cjs = StyleToJS;
|
|
10514
|
+
|
|
10515
|
+
return cjs;
|
|
10516
|
+
}
|
|
10517
|
+
|
|
10518
|
+
var hasRequiredUtilities;
|
|
10519
|
+
|
|
10520
|
+
function requireUtilities () {
|
|
10521
|
+
if (hasRequiredUtilities) return utilities$1;
|
|
10522
|
+
hasRequiredUtilities = 1;
|
|
10523
|
+
(function (exports) {
|
|
10524
|
+
var __importDefault = (utilities$1 && utilities$1.__importDefault) || function (mod) {
|
|
10525
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10526
|
+
};
|
|
10527
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10528
|
+
exports.returnFirstArg = exports.canTextBeChildOfNode = exports.ELEMENTS_WITH_NO_TEXT_CHILDREN = exports.PRESERVE_CUSTOM_ATTRIBUTES = void 0;
|
|
10529
|
+
exports.isCustomComponent = isCustomComponent;
|
|
10530
|
+
exports.setStyleProp = setStyleProp;
|
|
10531
|
+
var react_1 = requireReact();
|
|
10532
|
+
var style_to_js_1 = __importDefault(requireCjs());
|
|
10533
|
+
var RESERVED_SVG_MATHML_ELEMENTS = new Set([
|
|
10534
|
+
'annotation-xml',
|
|
10535
|
+
'color-profile',
|
|
10536
|
+
'font-face',
|
|
10537
|
+
'font-face-src',
|
|
10538
|
+
'font-face-uri',
|
|
10539
|
+
'font-face-format',
|
|
10540
|
+
'font-face-name',
|
|
10541
|
+
'missing-glyph',
|
|
10542
|
+
]);
|
|
10543
|
+
/**
|
|
10544
|
+
* Check if a tag is a custom component.
|
|
10545
|
+
*
|
|
10546
|
+
* @see {@link https://github.com/facebook/react/blob/v16.6.3/packages/react-dom/src/shared/isCustomComponent.js}
|
|
10547
|
+
*
|
|
10548
|
+
* @param tagName - Tag name.
|
|
10549
|
+
* @param props - Props passed to the element.
|
|
10550
|
+
* @returns - Whether the tag is custom component.
|
|
10551
|
+
*/
|
|
10552
|
+
function isCustomComponent(tagName, props) {
|
|
10553
|
+
if (!tagName.includes('-')) {
|
|
10554
|
+
return Boolean(props && typeof props.is === 'string');
|
|
10555
|
+
}
|
|
10556
|
+
// These are reserved SVG and MathML elements.
|
|
10557
|
+
// We don't mind this whitelist too much because we expect it to never grow.
|
|
10558
|
+
// The alternative is to track the namespace in a few places which is convoluted.
|
|
10559
|
+
// https://w3c.github.io/webcomponents/spec/custom/#custom-elements-core-concepts
|
|
10560
|
+
if (RESERVED_SVG_MATHML_ELEMENTS.has(tagName)) {
|
|
10561
|
+
return false;
|
|
10562
|
+
}
|
|
10563
|
+
return true;
|
|
10564
|
+
}
|
|
10565
|
+
var styleOptions = {
|
|
10566
|
+
reactCompat: true,
|
|
10567
|
+
};
|
|
10568
|
+
/**
|
|
10569
|
+
* Sets style prop.
|
|
10570
|
+
*
|
|
10571
|
+
* @param style - Inline style.
|
|
10572
|
+
* @param props - Props object.
|
|
10573
|
+
*/
|
|
10574
|
+
function setStyleProp(style, props) {
|
|
10575
|
+
if (typeof style !== 'string') {
|
|
10576
|
+
return;
|
|
10577
|
+
}
|
|
10578
|
+
if (!style.trim()) {
|
|
10579
|
+
props.style = {};
|
|
10580
|
+
return;
|
|
10581
|
+
}
|
|
10582
|
+
try {
|
|
10583
|
+
props.style = (0, style_to_js_1.default)(style, styleOptions);
|
|
10584
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
10585
|
+
}
|
|
10586
|
+
catch (error) {
|
|
10587
|
+
props.style = {};
|
|
10588
|
+
}
|
|
10589
|
+
}
|
|
10590
|
+
/**
|
|
10591
|
+
* @see https://reactjs.org/blog/2017/09/08/dom-attributes-in-react-16.html
|
|
10592
|
+
*/
|
|
10593
|
+
exports.PRESERVE_CUSTOM_ATTRIBUTES = Number(react_1.version.split('.')[0]) >= 16;
|
|
10594
|
+
/**
|
|
10595
|
+
* @see https://github.com/facebook/react/blob/cae635054e17a6f107a39d328649137b83f25972/packages/react-dom/src/client/validateDOMNesting.js#L213
|
|
10596
|
+
*/
|
|
10597
|
+
exports.ELEMENTS_WITH_NO_TEXT_CHILDREN = new Set([
|
|
10598
|
+
'tr',
|
|
10599
|
+
'tbody',
|
|
10600
|
+
'thead',
|
|
10601
|
+
'tfoot',
|
|
10602
|
+
'colgroup',
|
|
10603
|
+
'table',
|
|
10604
|
+
'head',
|
|
10605
|
+
'html',
|
|
10606
|
+
'frameset',
|
|
10607
|
+
]);
|
|
10608
|
+
/**
|
|
10609
|
+
* Checks if the given node can contain text nodes
|
|
10610
|
+
*
|
|
10611
|
+
* @param node - Element node.
|
|
10612
|
+
* @returns - Whether the node can contain text nodes.
|
|
10613
|
+
*/
|
|
10614
|
+
var canTextBeChildOfNode = function (node) {
|
|
10615
|
+
return !exports.ELEMENTS_WITH_NO_TEXT_CHILDREN.has(node.name);
|
|
10616
|
+
};
|
|
10617
|
+
exports.canTextBeChildOfNode = canTextBeChildOfNode;
|
|
10618
|
+
/**
|
|
10619
|
+
* Returns the first argument as is.
|
|
10620
|
+
*
|
|
10621
|
+
* @param arg - The argument to be returned.
|
|
10622
|
+
* @returns - The input argument `arg`.
|
|
10623
|
+
*/
|
|
10624
|
+
var returnFirstArg = function (arg) { return arg; };
|
|
10625
|
+
exports.returnFirstArg = returnFirstArg;
|
|
10626
|
+
|
|
10627
|
+
} (utilities$1));
|
|
10628
|
+
return utilities$1;
|
|
10629
|
+
}
|
|
10630
|
+
|
|
10631
|
+
var hasRequiredAttributesToProps;
|
|
10632
|
+
|
|
10633
|
+
function requireAttributesToProps () {
|
|
10634
|
+
if (hasRequiredAttributesToProps) return attributesToProps;
|
|
10635
|
+
hasRequiredAttributesToProps = 1;
|
|
10636
|
+
Object.defineProperty(attributesToProps, "__esModule", { value: true });
|
|
10637
|
+
attributesToProps.default = attributesToProps$1;
|
|
10638
|
+
var react_property_1 = requireLib$1();
|
|
10639
|
+
var utilities_1 = requireUtilities();
|
|
10640
|
+
// https://react.dev/learn/sharing-state-between-components#controlled-and-uncontrolled-components
|
|
10641
|
+
// https://developer.mozilla.org/docs/Web/HTML/Attributes
|
|
10642
|
+
var UNCONTROLLED_COMPONENT_ATTRIBUTES = ['checked', 'value'];
|
|
10643
|
+
var UNCONTROLLED_COMPONENT_NAMES = ['input', 'select', 'textarea'];
|
|
10644
|
+
var valueOnlyInputs = {
|
|
10645
|
+
reset: true,
|
|
10646
|
+
submit: true,
|
|
10647
|
+
};
|
|
10648
|
+
/**
|
|
10649
|
+
* Converts HTML/SVG DOM attributes to React props.
|
|
10650
|
+
*
|
|
10651
|
+
* @param attributes - HTML/SVG DOM attributes.
|
|
10652
|
+
* @param nodeName - DOM node name.
|
|
10653
|
+
* @returns - React props.
|
|
10654
|
+
*/
|
|
10655
|
+
function attributesToProps$1(attributes, nodeName) {
|
|
10656
|
+
if (attributes === void 0) { attributes = {}; }
|
|
10657
|
+
var props = {};
|
|
10658
|
+
var isInputValueOnly = Boolean(attributes.type && valueOnlyInputs[attributes.type]);
|
|
10659
|
+
for (var attributeName in attributes) {
|
|
10660
|
+
var attributeValue = attributes[attributeName];
|
|
10661
|
+
// ARIA (aria-*) or custom data (data-*) attribute
|
|
10662
|
+
if ((0, react_property_1.isCustomAttribute)(attributeName)) {
|
|
10663
|
+
props[attributeName] = attributeValue;
|
|
10664
|
+
continue;
|
|
10665
|
+
}
|
|
10666
|
+
// convert HTML/SVG attribute to React prop
|
|
10667
|
+
var attributeNameLowerCased = attributeName.toLowerCase();
|
|
10668
|
+
var propName = getPropName(attributeNameLowerCased);
|
|
10669
|
+
if (propName) {
|
|
10670
|
+
var propertyInfo = (0, react_property_1.getPropertyInfo)(propName);
|
|
10671
|
+
// convert attribute to uncontrolled component prop (e.g., `value` to `defaultValue`)
|
|
10672
|
+
if (UNCONTROLLED_COMPONENT_ATTRIBUTES.includes(propName) &&
|
|
10673
|
+
UNCONTROLLED_COMPONENT_NAMES.includes(nodeName) &&
|
|
10674
|
+
!isInputValueOnly) {
|
|
10675
|
+
propName = getPropName('default' + attributeNameLowerCased);
|
|
10676
|
+
}
|
|
10677
|
+
props[propName] = attributeValue;
|
|
10678
|
+
switch (propertyInfo && propertyInfo.type) {
|
|
10679
|
+
case react_property_1.BOOLEAN:
|
|
10680
|
+
props[propName] = true;
|
|
10681
|
+
break;
|
|
10682
|
+
case react_property_1.OVERLOADED_BOOLEAN:
|
|
10683
|
+
if (attributeValue === '') {
|
|
10684
|
+
props[propName] = true;
|
|
10685
|
+
}
|
|
10686
|
+
break;
|
|
10687
|
+
}
|
|
10688
|
+
continue;
|
|
10689
|
+
}
|
|
10690
|
+
// preserve custom attribute if React >=16
|
|
10691
|
+
if (utilities_1.PRESERVE_CUSTOM_ATTRIBUTES) {
|
|
10692
|
+
props[attributeName] = attributeValue;
|
|
10693
|
+
}
|
|
10694
|
+
}
|
|
10695
|
+
// transform inline style to object
|
|
10696
|
+
(0, utilities_1.setStyleProp)(attributes.style, props);
|
|
10697
|
+
return props;
|
|
10698
|
+
}
|
|
10699
|
+
/**
|
|
10700
|
+
* Gets prop name from lowercased attribute name.
|
|
10701
|
+
*
|
|
10702
|
+
* @param attributeName - Lowercased attribute name.
|
|
10703
|
+
* @returns - Prop name.
|
|
10704
|
+
*/
|
|
10705
|
+
function getPropName(attributeName) {
|
|
10706
|
+
return react_property_1.possibleStandardNames[attributeName];
|
|
10707
|
+
}
|
|
10708
|
+
|
|
10709
|
+
return attributesToProps;
|
|
10710
|
+
}
|
|
10711
|
+
|
|
10712
|
+
var domToReact = {};
|
|
10713
|
+
|
|
10714
|
+
var hasRequiredDomToReact;
|
|
10715
|
+
|
|
10716
|
+
function requireDomToReact () {
|
|
10717
|
+
if (hasRequiredDomToReact) return domToReact;
|
|
10718
|
+
hasRequiredDomToReact = 1;
|
|
10719
|
+
var __importDefault = (domToReact && domToReact.__importDefault) || function (mod) {
|
|
10720
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10721
|
+
};
|
|
10722
|
+
Object.defineProperty(domToReact, "__esModule", { value: true });
|
|
10723
|
+
domToReact.default = domToReact$1;
|
|
10724
|
+
var react_1 = requireReact();
|
|
10725
|
+
var attributes_to_props_1 = __importDefault(requireAttributesToProps());
|
|
10726
|
+
var utilities_1 = requireUtilities();
|
|
10727
|
+
var React = {
|
|
10728
|
+
cloneElement: react_1.cloneElement,
|
|
10729
|
+
createElement: react_1.createElement,
|
|
10730
|
+
isValidElement: react_1.isValidElement,
|
|
10731
|
+
};
|
|
10732
|
+
/**
|
|
10733
|
+
* Converts DOM nodes to JSX element(s).
|
|
10734
|
+
*
|
|
10735
|
+
* @param nodes - DOM nodes.
|
|
10736
|
+
* @param options - Options.
|
|
10737
|
+
* @returns - String or JSX element(s).
|
|
10738
|
+
*/
|
|
10739
|
+
function domToReact$1(nodes, options) {
|
|
10740
|
+
if (options === void 0) { options = {}; }
|
|
10741
|
+
var reactElements = [];
|
|
10742
|
+
var hasReplace = typeof options.replace === 'function';
|
|
10743
|
+
var transform = options.transform || utilities_1.returnFirstArg;
|
|
10744
|
+
var _a = options.library || React, cloneElement = _a.cloneElement, createElement = _a.createElement, isValidElement = _a.isValidElement;
|
|
10745
|
+
var nodesLength = nodes.length;
|
|
10746
|
+
for (var index = 0; index < nodesLength; index++) {
|
|
10747
|
+
var node = nodes[index];
|
|
10748
|
+
// replace with custom React element (if present)
|
|
10749
|
+
if (hasReplace) {
|
|
10750
|
+
var replaceElement = options.replace(node, index);
|
|
10751
|
+
if (isValidElement(replaceElement)) {
|
|
10752
|
+
// set "key" prop for sibling elements
|
|
10753
|
+
// https://react.dev/learn/rendering-lists#rules-of-keys
|
|
10754
|
+
if (nodesLength > 1) {
|
|
10755
|
+
replaceElement = cloneElement(replaceElement, {
|
|
10756
|
+
key: replaceElement.key || index,
|
|
10757
|
+
});
|
|
10758
|
+
}
|
|
10759
|
+
reactElements.push(transform(replaceElement, node, index));
|
|
10760
|
+
continue;
|
|
10761
|
+
}
|
|
10762
|
+
}
|
|
10763
|
+
if (node.type === 'text') {
|
|
10764
|
+
var isWhitespace = !node.data.trim().length;
|
|
10765
|
+
// We have a whitespace node that can't be nested in its parent
|
|
10766
|
+
// so skip it
|
|
10767
|
+
if (isWhitespace &&
|
|
10768
|
+
node.parent &&
|
|
10769
|
+
!(0, utilities_1.canTextBeChildOfNode)(node.parent)) {
|
|
10770
|
+
continue;
|
|
10771
|
+
}
|
|
10772
|
+
// Trim is enabled and we have a whitespace node
|
|
10773
|
+
// so skip it
|
|
10774
|
+
if (options.trim && isWhitespace) {
|
|
10775
|
+
continue;
|
|
10776
|
+
}
|
|
10777
|
+
// We have a text node that's not whitespace and it can be nested
|
|
10778
|
+
// in its parent so add it to the results
|
|
10779
|
+
reactElements.push(transform(node.data, node, index));
|
|
10780
|
+
continue;
|
|
10781
|
+
}
|
|
10782
|
+
var element = node;
|
|
10783
|
+
var props = {};
|
|
10784
|
+
if (skipAttributesToProps(element)) {
|
|
10785
|
+
(0, utilities_1.setStyleProp)(element.attribs.style, element.attribs);
|
|
10786
|
+
props = element.attribs;
|
|
10787
|
+
}
|
|
10788
|
+
else if (element.attribs) {
|
|
10789
|
+
props = (0, attributes_to_props_1.default)(element.attribs, element.name);
|
|
10790
|
+
}
|
|
10791
|
+
var children = void 0;
|
|
10792
|
+
switch (node.type) {
|
|
10793
|
+
case 'script':
|
|
10794
|
+
case 'style':
|
|
10795
|
+
// prevent text in <script> or <style> from being escaped
|
|
10796
|
+
// https://react.dev/reference/react-dom/components/common#dangerously-setting-the-inner-html
|
|
10797
|
+
if (node.children[0]) {
|
|
10798
|
+
props.dangerouslySetInnerHTML = {
|
|
10799
|
+
__html: node.children[0].data,
|
|
10800
|
+
};
|
|
10801
|
+
}
|
|
10802
|
+
break;
|
|
10803
|
+
case 'tag':
|
|
10804
|
+
// setting textarea value in children is an antipattern in React
|
|
10805
|
+
// https://react.dev/reference/react-dom/components/textarea#caveats
|
|
10806
|
+
if (node.name === 'textarea' && node.children[0]) {
|
|
10807
|
+
props.defaultValue = node.children[0].data;
|
|
10808
|
+
}
|
|
10809
|
+
else if (node.children && node.children.length) {
|
|
10810
|
+
// continue recursion of creating React elements (if applicable)
|
|
10811
|
+
children = domToReact$1(node.children, options);
|
|
10812
|
+
}
|
|
10813
|
+
break;
|
|
10814
|
+
// skip all other cases (e.g., comment)
|
|
10815
|
+
default:
|
|
10816
|
+
continue;
|
|
10817
|
+
}
|
|
10818
|
+
// set "key" prop for sibling elements
|
|
10819
|
+
// https://react.dev/learn/rendering-lists#rules-of-keys
|
|
10820
|
+
if (nodesLength > 1) {
|
|
10821
|
+
props.key = index;
|
|
10822
|
+
}
|
|
10823
|
+
reactElements.push(transform(createElement(node.name, props, children), node, index));
|
|
10824
|
+
}
|
|
10825
|
+
return reactElements.length === 1 ? reactElements[0] : reactElements;
|
|
10826
|
+
}
|
|
10827
|
+
/**
|
|
10828
|
+
* Determines whether DOM element attributes should be transformed to props.
|
|
10829
|
+
* Web Components should not have their attributes transformed except for `style`.
|
|
10830
|
+
*
|
|
10831
|
+
* @param node - Element node.
|
|
10832
|
+
* @returns - Whether the node attributes should be converted to props.
|
|
10833
|
+
*/
|
|
10834
|
+
function skipAttributesToProps(node) {
|
|
10835
|
+
return (utilities_1.PRESERVE_CUSTOM_ATTRIBUTES &&
|
|
10836
|
+
node.type === 'tag' &&
|
|
10837
|
+
(0, utilities_1.isCustomComponent)(node.name, node.attribs));
|
|
10838
|
+
}
|
|
10839
|
+
|
|
10840
|
+
return domToReact;
|
|
10841
|
+
}
|
|
10842
|
+
|
|
10843
|
+
var hasRequiredLib;
|
|
10844
|
+
|
|
10845
|
+
function requireLib () {
|
|
10846
|
+
if (hasRequiredLib) return lib$3;
|
|
10847
|
+
hasRequiredLib = 1;
|
|
10848
|
+
(function (exports) {
|
|
10849
|
+
var __importDefault = (lib$3 && lib$3.__importDefault) || function (mod) {
|
|
10850
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10851
|
+
};
|
|
10852
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10853
|
+
exports.htmlToDOM = exports.domToReact = exports.attributesToProps = exports.Text = exports.ProcessingInstruction = exports.Element = exports.Comment = void 0;
|
|
10854
|
+
exports.default = HTMLReactParser;
|
|
10855
|
+
var html_dom_parser_1 = __importDefault(requireHtmlToDom());
|
|
10856
|
+
exports.htmlToDOM = html_dom_parser_1.default;
|
|
10857
|
+
var attributes_to_props_1 = __importDefault(requireAttributesToProps());
|
|
10858
|
+
exports.attributesToProps = attributes_to_props_1.default;
|
|
10859
|
+
var dom_to_react_1 = __importDefault(requireDomToReact());
|
|
10860
|
+
exports.domToReact = dom_to_react_1.default;
|
|
10861
|
+
var domhandler_1 = /*@__PURE__*/ requireLib$2();
|
|
10862
|
+
Object.defineProperty(exports, "Comment", { enumerable: true, get: function () { return domhandler_1.Comment; } });
|
|
10863
|
+
Object.defineProperty(exports, "Element", { enumerable: true, get: function () { return domhandler_1.Element; } });
|
|
10864
|
+
Object.defineProperty(exports, "ProcessingInstruction", { enumerable: true, get: function () { return domhandler_1.ProcessingInstruction; } });
|
|
10865
|
+
Object.defineProperty(exports, "Text", { enumerable: true, get: function () { return domhandler_1.Text; } });
|
|
10866
|
+
var domParserOptions = { lowerCaseAttributeNames: false };
|
|
10867
|
+
/**
|
|
10868
|
+
* Converts HTML string to React elements.
|
|
10869
|
+
*
|
|
10870
|
+
* @param html - HTML string.
|
|
10871
|
+
* @param options - Parser options.
|
|
10872
|
+
* @returns - React element(s), empty array, or string.
|
|
10873
|
+
*/
|
|
10874
|
+
function HTMLReactParser(html, options) {
|
|
10875
|
+
if (typeof html !== 'string') {
|
|
10876
|
+
throw new TypeError('First argument must be a string');
|
|
10877
|
+
}
|
|
10878
|
+
if (!html) {
|
|
10879
|
+
return [];
|
|
10880
|
+
}
|
|
10881
|
+
return (0, dom_to_react_1.default)((0, html_dom_parser_1.default)(html, (options === null || options === void 0 ? void 0 : options.htmlparser2) || domParserOptions), options);
|
|
10882
|
+
}
|
|
10883
|
+
|
|
10884
|
+
} (lib$3));
|
|
10885
|
+
return lib$3;
|
|
10886
|
+
}
|
|
10887
|
+
|
|
10888
|
+
var libExports = requireLib();
|
|
10889
|
+
const HTMLReactParser = /*@__PURE__*/getDefaultExportFromCjs(libExports);
|
|
10890
|
+
|
|
10891
|
+
const parse = HTMLReactParser.default || HTMLReactParser;
|
|
10892
|
+
|
|
7963
10893
|
var client = {exports: {}};
|
|
7964
10894
|
|
|
7965
10895
|
var reactDomClient_production = {};
|
|
@@ -49350,21 +52280,28 @@ function requireClient () {
|
|
|
49350
52280
|
var clientExports = requireClient();
|
|
49351
52281
|
const ReactDOM = /*@__PURE__*/getDefaultExportFromCjs(clientExports);
|
|
49352
52282
|
|
|
52283
|
+
const Slot = ({ children }) => {
|
|
52284
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: parse(children) });
|
|
52285
|
+
};
|
|
49353
52286
|
class BaseWebComponent extends HTMLElement {
|
|
49354
52287
|
root;
|
|
52288
|
+
restProps = {};
|
|
49355
52289
|
static get tagName() {
|
|
49356
52290
|
throw new Error("tagName must be defined in the derived class");
|
|
49357
52291
|
}
|
|
49358
52292
|
static observedAttributes;
|
|
49359
52293
|
constructor(stylesheet) {
|
|
49360
52294
|
super();
|
|
49361
|
-
|
|
49362
|
-
|
|
49363
|
-
|
|
49364
|
-
|
|
49365
|
-
|
|
52295
|
+
this.root = ReactDOM.createRoot(this);
|
|
52296
|
+
const style = document.createElement("style");
|
|
52297
|
+
style.textContent = stylesheet;
|
|
52298
|
+
document.head.appendChild(style);
|
|
52299
|
+
}
|
|
52300
|
+
setupRestProps() {
|
|
52301
|
+
throw new Error("setupRestProps() must be defined in the derived class");
|
|
49366
52302
|
}
|
|
49367
52303
|
connectedCallback() {
|
|
52304
|
+
this.setupRestProps();
|
|
49368
52305
|
this.render();
|
|
49369
52306
|
}
|
|
49370
52307
|
attributeChangedCallback() {
|
|
@@ -49386,6 +52323,12 @@ class AccordionWebComponent extends BaseWebComponent {
|
|
|
49386
52323
|
constructor() {
|
|
49387
52324
|
super(stylesheet);
|
|
49388
52325
|
}
|
|
52326
|
+
setupRestProps() {
|
|
52327
|
+
for (const attributeName of this.getAttributeNames()) {
|
|
52328
|
+
if (AccordionWebComponent.observedAttributes.includes(attributeName)) continue;
|
|
52329
|
+
this.restProps[attributeName] = this.getAttribute(attributeName);
|
|
52330
|
+
}
|
|
52331
|
+
}
|
|
49389
52332
|
render() {
|
|
49390
52333
|
this.root.render(
|
|
49391
52334
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
@@ -49395,7 +52338,8 @@ class AccordionWebComponent extends BaseWebComponent {
|
|
|
49395
52338
|
heading: this.getAttribute("heading") ?? void 0,
|
|
49396
52339
|
icon: this.getAttribute("icon") && /* @__PURE__ */ jsxRuntimeExports.jsx(Icon, { icon: this.getAttribute("icon") }),
|
|
49397
52340
|
headingLevel: this.getAttribute("headingLevel") ? Number(this.getAttribute("headingLevel")) : void 0,
|
|
49398
|
-
sections: this.getAttribute("sections") && JSON.parse(this.getAttribute("sections"))
|
|
52341
|
+
sections: this.getAttribute("sections") && JSON.parse(this.getAttribute("sections")),
|
|
52342
|
+
...this.restProps
|
|
49399
52343
|
}
|
|
49400
52344
|
)
|
|
49401
52345
|
);
|
|
@@ -49408,9 +52352,22 @@ class ActionGroupWebComponent extends BaseWebComponent {
|
|
|
49408
52352
|
constructor() {
|
|
49409
52353
|
super(stylesheet);
|
|
49410
52354
|
}
|
|
52355
|
+
setupRestProps() {
|
|
52356
|
+
for (const attributeName of this.getAttributeNames()) {
|
|
52357
|
+
if (ActionGroupWebComponent.observedAttributes.includes(attributeName)) continue;
|
|
52358
|
+
this.restProps[attributeName] = this.getAttribute(attributeName);
|
|
52359
|
+
}
|
|
52360
|
+
}
|
|
49411
52361
|
render() {
|
|
49412
52362
|
this.root.render(
|
|
49413
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
52363
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
52364
|
+
ButtonGroup,
|
|
52365
|
+
{
|
|
52366
|
+
direction: this.getAttribute("direction") ?? void 0,
|
|
52367
|
+
...this.restProps,
|
|
52368
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(Slot, { children: this.innerHTML })
|
|
52369
|
+
}
|
|
52370
|
+
)
|
|
49414
52371
|
);
|
|
49415
52372
|
}
|
|
49416
52373
|
}
|
|
@@ -49421,6 +52378,12 @@ class AlertWebComponent extends BaseWebComponent {
|
|
|
49421
52378
|
constructor() {
|
|
49422
52379
|
super(stylesheet);
|
|
49423
52380
|
}
|
|
52381
|
+
setupRestProps() {
|
|
52382
|
+
for (const attributeName of this.getAttributeNames()) {
|
|
52383
|
+
if (AlertWebComponent.observedAttributes.includes(attributeName)) continue;
|
|
52384
|
+
this.restProps[attributeName] = this.getAttribute(attributeName);
|
|
52385
|
+
}
|
|
52386
|
+
}
|
|
49424
52387
|
render() {
|
|
49425
52388
|
this.root.render(
|
|
49426
52389
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
@@ -49430,7 +52393,36 @@ class AlertWebComponent extends BaseWebComponent {
|
|
|
49430
52393
|
type: this.getAttribute("type") ?? "info",
|
|
49431
52394
|
headingLevel: this.getAttribute("headingLevel") && Number(this.getAttribute("headingLevel")),
|
|
49432
52395
|
textContent: this.getAttribute("messageText") ?? "This is a default alert message.",
|
|
49433
|
-
|
|
52396
|
+
...this.restProps,
|
|
52397
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(Slot, { children: this.innerHTML })
|
|
52398
|
+
}
|
|
52399
|
+
)
|
|
52400
|
+
);
|
|
52401
|
+
}
|
|
52402
|
+
}
|
|
52403
|
+
|
|
52404
|
+
class ButtonWebComponent extends BaseWebComponent {
|
|
52405
|
+
static tagName = "rhc-button";
|
|
52406
|
+
static observedAttributes = ["appearance", "disabled"];
|
|
52407
|
+
constructor() {
|
|
52408
|
+
super(stylesheet);
|
|
52409
|
+
}
|
|
52410
|
+
setupRestProps() {
|
|
52411
|
+
for (const attributeName of this.getAttributeNames()) {
|
|
52412
|
+
if (ButtonWebComponent.observedAttributes.includes(attributeName)) continue;
|
|
52413
|
+
this.restProps[attributeName] = this.getAttribute(attributeName);
|
|
52414
|
+
}
|
|
52415
|
+
}
|
|
52416
|
+
render() {
|
|
52417
|
+
this.root.render(
|
|
52418
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
52419
|
+
Button,
|
|
52420
|
+
{
|
|
52421
|
+
suppressHydrationWarning: true,
|
|
52422
|
+
appearance: this.getAttribute("appearance") ?? void 0,
|
|
52423
|
+
disabled: Boolean(this.getAttribute("disabled")),
|
|
52424
|
+
...this.restProps,
|
|
52425
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(Slot, { children: this.innerHTML })
|
|
49434
52426
|
}
|
|
49435
52427
|
)
|
|
49436
52428
|
);
|
|
@@ -49452,6 +52444,12 @@ class HeroWebComponent extends BaseWebComponent {
|
|
|
49452
52444
|
constructor() {
|
|
49453
52445
|
super(stylesheet);
|
|
49454
52446
|
}
|
|
52447
|
+
setupRestProps() {
|
|
52448
|
+
for (const attributeName of this.getAttributeNames()) {
|
|
52449
|
+
if (HeroWebComponent.observedAttributes.includes(attributeName)) continue;
|
|
52450
|
+
this.restProps[attributeName] = this.getAttribute(attributeName);
|
|
52451
|
+
}
|
|
52452
|
+
}
|
|
49455
52453
|
render() {
|
|
49456
52454
|
this.root.render(
|
|
49457
52455
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
@@ -49465,12 +52463,13 @@ class HeroWebComponent extends BaseWebComponent {
|
|
|
49465
52463
|
textAlign: this.getAttribute("textAlign"),
|
|
49466
52464
|
headingLevel: this.getAttribute("headingLevel") && Number(this.getAttribute("headingLevel")),
|
|
49467
52465
|
imageSrc: this.getAttribute("imageSrc") ?? "https://raw.githubusercontent.com/nl-design-system/rijkshuisstijl-community/main/proprietary/assets/src/placeholder.jpg",
|
|
49468
|
-
|
|
52466
|
+
...this.restProps,
|
|
52467
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(Slot, { children: this.innerHTML })
|
|
49469
52468
|
}
|
|
49470
52469
|
)
|
|
49471
52470
|
);
|
|
49472
52471
|
}
|
|
49473
52472
|
}
|
|
49474
52473
|
|
|
49475
|
-
export { AccordionWebComponent, ActionGroupWebComponent, AlertWebComponent, HeroWebComponent };
|
|
52474
|
+
export { AccordionWebComponent, ActionGroupWebComponent, AlertWebComponent, ButtonWebComponent, HeroWebComponent };
|
|
49476
52475
|
//# sourceMappingURL=index.mjs.map
|