@peculiar/certificates-viewer-react 3.10.0 → 3.10.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/cjs/components.js +12 -7
- package/dist/cjs/index.js +0 -5
- package/dist/cjs/react-component-lib/createComponent.js +21 -5
- package/dist/cjs/react-component-lib/utils/attachProps.js +26 -13
- package/dist/cjs/react-component-lib/utils/index.js +18 -5
- package/dist/esm/components.js +11 -6
- package/dist/esm/index.js +0 -5
- package/dist/esm/react-component-lib/createComponent.js +22 -6
- package/dist/esm/react-component-lib/utils/attachProps.js +24 -12
- package/dist/esm/react-component-lib/utils/index.js +15 -4
- package/dist/esnext/components.js +11 -6
- package/dist/esnext/index.js +0 -5
- package/dist/esnext/react-component-lib/createComponent.js +22 -6
- package/dist/esnext/react-component-lib/utils/attachProps.js +24 -12
- package/dist/esnext/react-component-lib/utils/index.js +15 -4
- package/dist/types/components.d.ts +2 -3
- package/dist/types/react-component-lib/createComponent.d.ts +1 -1
- package/dist/types/react-component-lib/utils/attachProps.d.ts +5 -1
- package/dist/types/react-component-lib/utils/index.d.ts +4 -1
- package/package.json +4 -4
package/dist/cjs/components.js
CHANGED
|
@@ -7,13 +7,18 @@
|
|
|
7
7
|
* LICENSE file in the root directory of this source tree.
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.
|
|
10
|
+
exports.PeculiarCsrViewer = exports.PeculiarCrlViewer = exports.PeculiarCertificatesViewer = exports.PeculiarCertificateViewer = exports.PeculiarAttributeCertificateViewer = void 0;
|
|
11
11
|
/* eslint-disable */
|
|
12
12
|
/* tslint:disable */
|
|
13
|
+
/* auto-generated react proxies */
|
|
13
14
|
const react_component_lib_1 = require("./react-component-lib");
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
exports.
|
|
15
|
+
const peculiar_attribute_certificate_viewer_js_1 = require("@peculiar/certificates-viewer/components/peculiar-attribute-certificate-viewer.js");
|
|
16
|
+
const peculiar_certificate_viewer_js_1 = require("@peculiar/certificates-viewer/components/peculiar-certificate-viewer.js");
|
|
17
|
+
const peculiar_certificates_viewer_js_1 = require("@peculiar/certificates-viewer/components/peculiar-certificates-viewer.js");
|
|
18
|
+
const peculiar_crl_viewer_js_1 = require("@peculiar/certificates-viewer/components/peculiar-crl-viewer.js");
|
|
19
|
+
const peculiar_csr_viewer_js_1 = require("@peculiar/certificates-viewer/components/peculiar-csr-viewer.js");
|
|
20
|
+
exports.PeculiarAttributeCertificateViewer = (0, react_component_lib_1.createReactComponent)('peculiar-attribute-certificate-viewer', undefined, undefined, peculiar_attribute_certificate_viewer_js_1.defineCustomElement);
|
|
21
|
+
exports.PeculiarCertificateViewer = (0, react_component_lib_1.createReactComponent)('peculiar-certificate-viewer', undefined, undefined, peculiar_certificate_viewer_js_1.defineCustomElement);
|
|
22
|
+
exports.PeculiarCertificatesViewer = (0, react_component_lib_1.createReactComponent)('peculiar-certificates-viewer', undefined, undefined, peculiar_certificates_viewer_js_1.defineCustomElement);
|
|
23
|
+
exports.PeculiarCrlViewer = (0, react_component_lib_1.createReactComponent)('peculiar-crl-viewer', undefined, undefined, peculiar_crl_viewer_js_1.defineCustomElement);
|
|
24
|
+
exports.PeculiarCsrViewer = (0, react_component_lib_1.createReactComponent)('peculiar-csr-viewer', undefined, undefined, peculiar_csr_viewer_js_1.defineCustomElement);
|
package/dist/cjs/index.js
CHANGED
|
@@ -21,9 +21,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
21
21
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
22
22
|
};
|
|
23
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
-
const loader_1 = require("@peculiar/certificates-viewer/loader");
|
|
25
24
|
__exportStar(require("./components"), exports);
|
|
26
|
-
if (typeof window !== 'undefined') {
|
|
27
|
-
(0, loader_1.applyPolyfills)()
|
|
28
|
-
.then(() => (0, loader_1.defineCustomElements)(window));
|
|
29
|
-
}
|
|
@@ -14,7 +14,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
14
14
|
exports.createReactComponent = void 0;
|
|
15
15
|
const React = require("react");
|
|
16
16
|
const utils_1 = require("./utils");
|
|
17
|
-
const createReactComponent = (tagName, ReactComponentContext, manipulatePropsFunction) => {
|
|
17
|
+
const createReactComponent = (tagName, ReactComponentContext, manipulatePropsFunction, defineCustomElement) => {
|
|
18
|
+
if (defineCustomElement !== undefined) {
|
|
19
|
+
defineCustomElement();
|
|
20
|
+
}
|
|
18
21
|
const displayName = (0, utils_1.dashToPascalCase)(tagName);
|
|
19
22
|
const ReactComponent = class extends React.Component {
|
|
20
23
|
constructor(props) {
|
|
@@ -32,21 +35,34 @@ const createReactComponent = (tagName, ReactComponentContext, manipulatePropsFun
|
|
|
32
35
|
render() {
|
|
33
36
|
const _a = this.props, { children, forwardedRef, style, className, ref } = _a, cProps = __rest(_a, ["children", "forwardedRef", "style", "className", "ref"]);
|
|
34
37
|
let propsToPass = Object.keys(cProps).reduce((acc, name) => {
|
|
38
|
+
const value = cProps[name];
|
|
35
39
|
if (name.indexOf('on') === 0 && name[2] === name[2].toUpperCase()) {
|
|
36
40
|
const eventName = name.substring(2).toLowerCase();
|
|
37
|
-
if (typeof document !== 'undefined' && (0, utils_1.isCoveredByReact)(eventName
|
|
38
|
-
acc[name] =
|
|
41
|
+
if (typeof document !== 'undefined' && (0, utils_1.isCoveredByReact)(eventName)) {
|
|
42
|
+
acc[name] = value;
|
|
39
43
|
}
|
|
40
44
|
}
|
|
41
45
|
else {
|
|
42
|
-
|
|
46
|
+
// we should only render strings, booleans, and numbers as attrs in html.
|
|
47
|
+
// objects, functions, arrays etc get synced via properties on mount.
|
|
48
|
+
const type = typeof value;
|
|
49
|
+
if (type === 'string' || type === 'boolean' || type === 'number') {
|
|
50
|
+
acc[(0, utils_1.camelToDashCase)(name)] = value;
|
|
51
|
+
}
|
|
43
52
|
}
|
|
44
53
|
return acc;
|
|
45
54
|
}, {});
|
|
46
55
|
if (manipulatePropsFunction) {
|
|
47
56
|
propsToPass = manipulatePropsFunction(this.props, propsToPass);
|
|
48
57
|
}
|
|
49
|
-
|
|
58
|
+
const newProps = Object.assign(Object.assign({}, propsToPass), { ref: (0, utils_1.mergeRefs)(forwardedRef, this.setComponentElRef), style });
|
|
59
|
+
/**
|
|
60
|
+
* We use createElement here instead of
|
|
61
|
+
* React.createElement to work around a
|
|
62
|
+
* bug in Vite (https://github.com/vitejs/vite/issues/6104).
|
|
63
|
+
* React.createElement causes all elements to be rendered
|
|
64
|
+
* as <tagname> instead of the actual Web Component.
|
|
65
|
+
*/
|
|
50
66
|
return React.createElement(tagName, newProps, children);
|
|
51
67
|
}
|
|
52
68
|
static get displayName() {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.syncEvent = exports.isCoveredByReact = exports.getClassName = exports.attachProps = void 0;
|
|
3
|
+
exports.syncEvent = exports.isCoveredByReact = exports.transformReactEventName = exports.getClassName = exports.attachProps = void 0;
|
|
4
4
|
const case_1 = require("./case");
|
|
5
5
|
const attachProps = (node, newProps, oldProps = {}) => {
|
|
6
6
|
// some test frameworks don't render DOM elements, so we test here to make sure we are dealing with DOM first
|
|
@@ -22,7 +22,7 @@ const attachProps = (node, newProps, oldProps = {}) => {
|
|
|
22
22
|
if (name.indexOf('on') === 0 && name[2] === name[2].toUpperCase()) {
|
|
23
23
|
const eventName = name.substring(2);
|
|
24
24
|
const eventNameLc = eventName[0].toLowerCase() + eventName.substring(1);
|
|
25
|
-
if (
|
|
25
|
+
if (!(0, exports.isCoveredByReact)(eventNameLc)) {
|
|
26
26
|
(0, exports.syncEvent)(node, eventNameLc, newProps[name]);
|
|
27
27
|
}
|
|
28
28
|
}
|
|
@@ -32,9 +32,6 @@ const attachProps = (node, newProps, oldProps = {}) => {
|
|
|
32
32
|
if (propType === 'string') {
|
|
33
33
|
node.setAttribute((0, case_1.camelToDashCase)(name), newProps[name]);
|
|
34
34
|
}
|
|
35
|
-
else {
|
|
36
|
-
node[name] = newProps[name];
|
|
37
|
-
}
|
|
38
35
|
}
|
|
39
36
|
});
|
|
40
37
|
}
|
|
@@ -65,19 +62,35 @@ const getClassName = (classList, newProps, oldProps) => {
|
|
|
65
62
|
return finalClassNames.join(' ');
|
|
66
63
|
};
|
|
67
64
|
exports.getClassName = getClassName;
|
|
65
|
+
/**
|
|
66
|
+
* Transforms a React event name to a browser event name.
|
|
67
|
+
*/
|
|
68
|
+
const transformReactEventName = (eventNameSuffix) => {
|
|
69
|
+
switch (eventNameSuffix) {
|
|
70
|
+
case 'doubleclick':
|
|
71
|
+
return 'dblclick';
|
|
72
|
+
}
|
|
73
|
+
return eventNameSuffix;
|
|
74
|
+
};
|
|
75
|
+
exports.transformReactEventName = transformReactEventName;
|
|
68
76
|
/**
|
|
69
77
|
* Checks if an event is supported in the current execution environment.
|
|
70
78
|
* @license Modernizr 3.0.0pre (Custom Build) | MIT
|
|
71
79
|
*/
|
|
72
|
-
const isCoveredByReact = (eventNameSuffix
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
isSupported =
|
|
80
|
+
const isCoveredByReact = (eventNameSuffix) => {
|
|
81
|
+
if (typeof document === 'undefined') {
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
const eventName = 'on' + (0, exports.transformReactEventName)(eventNameSuffix);
|
|
86
|
+
let isSupported = eventName in document;
|
|
87
|
+
if (!isSupported) {
|
|
88
|
+
const element = document.createElement('div');
|
|
89
|
+
element.setAttribute(eventName, 'return;');
|
|
90
|
+
isSupported = typeof element[eventName] === 'function';
|
|
91
|
+
}
|
|
92
|
+
return isSupported;
|
|
79
93
|
}
|
|
80
|
-
return isSupported;
|
|
81
94
|
};
|
|
82
95
|
exports.isCoveredByReact = isCoveredByReact;
|
|
83
96
|
const syncEvent = (node, eventName, newEventHandler) => {
|
|
@@ -14,18 +14,25 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.createForwardRef = exports.mergeRefs = void 0;
|
|
17
|
+
exports.defineCustomElement = exports.createForwardRef = exports.mergeRefs = exports.setRef = void 0;
|
|
18
18
|
const React = require("react");
|
|
19
|
-
|
|
20
|
-
const mergeRefs = (...refs) => (value) => refs.forEach((ref) => {
|
|
19
|
+
const setRef = (ref, value) => {
|
|
21
20
|
if (typeof ref === 'function') {
|
|
22
21
|
ref(value);
|
|
23
22
|
}
|
|
24
23
|
else if (ref != null) {
|
|
25
|
-
//
|
|
24
|
+
// Cast as a MutableRef so we can assign current
|
|
26
25
|
ref.current = value;
|
|
27
26
|
}
|
|
28
|
-
}
|
|
27
|
+
};
|
|
28
|
+
exports.setRef = setRef;
|
|
29
|
+
const mergeRefs = (...refs) => {
|
|
30
|
+
return (value) => {
|
|
31
|
+
refs.forEach((ref) => {
|
|
32
|
+
(0, exports.setRef)(ref, value);
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
};
|
|
29
36
|
exports.mergeRefs = mergeRefs;
|
|
30
37
|
const createForwardRef = (ReactComponent, displayName) => {
|
|
31
38
|
const forwardRef = (props, ref) => {
|
|
@@ -35,5 +42,11 @@ const createForwardRef = (ReactComponent, displayName) => {
|
|
|
35
42
|
return React.forwardRef(forwardRef);
|
|
36
43
|
};
|
|
37
44
|
exports.createForwardRef = createForwardRef;
|
|
45
|
+
const defineCustomElement = (tagName, customElement) => {
|
|
46
|
+
if (customElement !== undefined && typeof customElements !== 'undefined' && !customElements.get(tagName)) {
|
|
47
|
+
customElements.define(tagName, customElement);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
exports.defineCustomElement = defineCustomElement;
|
|
38
51
|
__exportStar(require("./attachProps"), exports);
|
|
39
52
|
__exportStar(require("./case"), exports);
|
package/dist/esm/components.js
CHANGED
|
@@ -7,10 +7,15 @@
|
|
|
7
7
|
*/
|
|
8
8
|
/* eslint-disable */
|
|
9
9
|
/* tslint:disable */
|
|
10
|
+
/* auto-generated react proxies */
|
|
10
11
|
import { createReactComponent } from './react-component-lib';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
export const
|
|
12
|
+
import { defineCustomElement as definePeculiarAttributeCertificateViewer } from '@peculiar/certificates-viewer/components/peculiar-attribute-certificate-viewer.js';
|
|
13
|
+
import { defineCustomElement as definePeculiarCertificateViewer } from '@peculiar/certificates-viewer/components/peculiar-certificate-viewer.js';
|
|
14
|
+
import { defineCustomElement as definePeculiarCertificatesViewer } from '@peculiar/certificates-viewer/components/peculiar-certificates-viewer.js';
|
|
15
|
+
import { defineCustomElement as definePeculiarCrlViewer } from '@peculiar/certificates-viewer/components/peculiar-crl-viewer.js';
|
|
16
|
+
import { defineCustomElement as definePeculiarCsrViewer } from '@peculiar/certificates-viewer/components/peculiar-csr-viewer.js';
|
|
17
|
+
export const PeculiarAttributeCertificateViewer = /*@__PURE__*/ createReactComponent('peculiar-attribute-certificate-viewer', undefined, undefined, definePeculiarAttributeCertificateViewer);
|
|
18
|
+
export const PeculiarCertificateViewer = /*@__PURE__*/ createReactComponent('peculiar-certificate-viewer', undefined, undefined, definePeculiarCertificateViewer);
|
|
19
|
+
export const PeculiarCertificatesViewer = /*@__PURE__*/ createReactComponent('peculiar-certificates-viewer', undefined, undefined, definePeculiarCertificatesViewer);
|
|
20
|
+
export const PeculiarCrlViewer = /*@__PURE__*/ createReactComponent('peculiar-crl-viewer', undefined, undefined, definePeculiarCrlViewer);
|
|
21
|
+
export const PeculiarCsrViewer = /*@__PURE__*/ createReactComponent('peculiar-csr-viewer', undefined, undefined, definePeculiarCsrViewer);
|
package/dist/esm/index.js
CHANGED
|
@@ -5,9 +5,4 @@
|
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
|
-
import { defineCustomElements, applyPolyfills } from '@peculiar/certificates-viewer/loader';
|
|
9
8
|
export * from './components';
|
|
10
|
-
if (typeof window !== 'undefined') {
|
|
11
|
-
applyPolyfills()
|
|
12
|
-
.then(() => defineCustomElements(window));
|
|
13
|
-
}
|
|
@@ -10,8 +10,11 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import * as React from 'react';
|
|
13
|
-
import { attachProps, createForwardRef, dashToPascalCase, isCoveredByReact, mergeRefs
|
|
14
|
-
export const createReactComponent = (tagName, ReactComponentContext, manipulatePropsFunction) => {
|
|
13
|
+
import { attachProps, camelToDashCase, createForwardRef, dashToPascalCase, isCoveredByReact, mergeRefs } from './utils';
|
|
14
|
+
export const createReactComponent = (tagName, ReactComponentContext, manipulatePropsFunction, defineCustomElement) => {
|
|
15
|
+
if (defineCustomElement !== undefined) {
|
|
16
|
+
defineCustomElement();
|
|
17
|
+
}
|
|
15
18
|
const displayName = dashToPascalCase(tagName);
|
|
16
19
|
const ReactComponent = class extends React.Component {
|
|
17
20
|
constructor(props) {
|
|
@@ -29,21 +32,34 @@ export const createReactComponent = (tagName, ReactComponentContext, manipulateP
|
|
|
29
32
|
render() {
|
|
30
33
|
const _a = this.props, { children, forwardedRef, style, className, ref } = _a, cProps = __rest(_a, ["children", "forwardedRef", "style", "className", "ref"]);
|
|
31
34
|
let propsToPass = Object.keys(cProps).reduce((acc, name) => {
|
|
35
|
+
const value = cProps[name];
|
|
32
36
|
if (name.indexOf('on') === 0 && name[2] === name[2].toUpperCase()) {
|
|
33
37
|
const eventName = name.substring(2).toLowerCase();
|
|
34
|
-
if (typeof document !== 'undefined' && isCoveredByReact(eventName
|
|
35
|
-
acc[name] =
|
|
38
|
+
if (typeof document !== 'undefined' && isCoveredByReact(eventName)) {
|
|
39
|
+
acc[name] = value;
|
|
36
40
|
}
|
|
37
41
|
}
|
|
38
42
|
else {
|
|
39
|
-
|
|
43
|
+
// we should only render strings, booleans, and numbers as attrs in html.
|
|
44
|
+
// objects, functions, arrays etc get synced via properties on mount.
|
|
45
|
+
const type = typeof value;
|
|
46
|
+
if (type === 'string' || type === 'boolean' || type === 'number') {
|
|
47
|
+
acc[camelToDashCase(name)] = value;
|
|
48
|
+
}
|
|
40
49
|
}
|
|
41
50
|
return acc;
|
|
42
51
|
}, {});
|
|
43
52
|
if (manipulatePropsFunction) {
|
|
44
53
|
propsToPass = manipulatePropsFunction(this.props, propsToPass);
|
|
45
54
|
}
|
|
46
|
-
|
|
55
|
+
const newProps = Object.assign(Object.assign({}, propsToPass), { ref: mergeRefs(forwardedRef, this.setComponentElRef), style });
|
|
56
|
+
/**
|
|
57
|
+
* We use createElement here instead of
|
|
58
|
+
* React.createElement to work around a
|
|
59
|
+
* bug in Vite (https://github.com/vitejs/vite/issues/6104).
|
|
60
|
+
* React.createElement causes all elements to be rendered
|
|
61
|
+
* as <tagname> instead of the actual Web Component.
|
|
62
|
+
*/
|
|
47
63
|
return React.createElement(tagName, newProps, children);
|
|
48
64
|
}
|
|
49
65
|
static get displayName() {
|
|
@@ -19,7 +19,7 @@ export const attachProps = (node, newProps, oldProps = {}) => {
|
|
|
19
19
|
if (name.indexOf('on') === 0 && name[2] === name[2].toUpperCase()) {
|
|
20
20
|
const eventName = name.substring(2);
|
|
21
21
|
const eventNameLc = eventName[0].toLowerCase() + eventName.substring(1);
|
|
22
|
-
if (
|
|
22
|
+
if (!isCoveredByReact(eventNameLc)) {
|
|
23
23
|
syncEvent(node, eventNameLc, newProps[name]);
|
|
24
24
|
}
|
|
25
25
|
}
|
|
@@ -29,9 +29,6 @@ export const attachProps = (node, newProps, oldProps = {}) => {
|
|
|
29
29
|
if (propType === 'string') {
|
|
30
30
|
node.setAttribute(camelToDashCase(name), newProps[name]);
|
|
31
31
|
}
|
|
32
|
-
else {
|
|
33
|
-
node[name] = newProps[name];
|
|
34
|
-
}
|
|
35
32
|
}
|
|
36
33
|
});
|
|
37
34
|
}
|
|
@@ -60,19 +57,34 @@ export const getClassName = (classList, newProps, oldProps) => {
|
|
|
60
57
|
incomingPropClasses.forEach((s) => finalClassNames.push(s));
|
|
61
58
|
return finalClassNames.join(' ');
|
|
62
59
|
};
|
|
60
|
+
/**
|
|
61
|
+
* Transforms a React event name to a browser event name.
|
|
62
|
+
*/
|
|
63
|
+
export const transformReactEventName = (eventNameSuffix) => {
|
|
64
|
+
switch (eventNameSuffix) {
|
|
65
|
+
case 'doubleclick':
|
|
66
|
+
return 'dblclick';
|
|
67
|
+
}
|
|
68
|
+
return eventNameSuffix;
|
|
69
|
+
};
|
|
63
70
|
/**
|
|
64
71
|
* Checks if an event is supported in the current execution environment.
|
|
65
72
|
* @license Modernizr 3.0.0pre (Custom Build) | MIT
|
|
66
73
|
*/
|
|
67
|
-
export const isCoveredByReact = (eventNameSuffix
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
isSupported =
|
|
74
|
+
export const isCoveredByReact = (eventNameSuffix) => {
|
|
75
|
+
if (typeof document === 'undefined') {
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
const eventName = 'on' + transformReactEventName(eventNameSuffix);
|
|
80
|
+
let isSupported = eventName in document;
|
|
81
|
+
if (!isSupported) {
|
|
82
|
+
const element = document.createElement('div');
|
|
83
|
+
element.setAttribute(eventName, 'return;');
|
|
84
|
+
isSupported = typeof element[eventName] === 'function';
|
|
85
|
+
}
|
|
86
|
+
return isSupported;
|
|
74
87
|
}
|
|
75
|
-
return isSupported;
|
|
76
88
|
};
|
|
77
89
|
export const syncEvent = (node, eventName, newEventHandler) => {
|
|
78
90
|
const eventStore = node.__events || (node.__events = {});
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
export const mergeRefs = (...refs) => (value) => refs.forEach((ref) => {
|
|
2
|
+
export const setRef = (ref, value) => {
|
|
4
3
|
if (typeof ref === 'function') {
|
|
5
4
|
ref(value);
|
|
6
5
|
}
|
|
7
6
|
else if (ref != null) {
|
|
8
|
-
//
|
|
7
|
+
// Cast as a MutableRef so we can assign current
|
|
9
8
|
ref.current = value;
|
|
10
9
|
}
|
|
11
|
-
}
|
|
10
|
+
};
|
|
11
|
+
export const mergeRefs = (...refs) => {
|
|
12
|
+
return (value) => {
|
|
13
|
+
refs.forEach((ref) => {
|
|
14
|
+
setRef(ref, value);
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
};
|
|
12
18
|
export const createForwardRef = (ReactComponent, displayName) => {
|
|
13
19
|
const forwardRef = (props, ref) => {
|
|
14
20
|
return React.createElement(ReactComponent, Object.assign({}, props, { forwardedRef: ref }));
|
|
@@ -16,5 +22,10 @@ export const createForwardRef = (ReactComponent, displayName) => {
|
|
|
16
22
|
forwardRef.displayName = displayName;
|
|
17
23
|
return React.forwardRef(forwardRef);
|
|
18
24
|
};
|
|
25
|
+
export const defineCustomElement = (tagName, customElement) => {
|
|
26
|
+
if (customElement !== undefined && typeof customElements !== 'undefined' && !customElements.get(tagName)) {
|
|
27
|
+
customElements.define(tagName, customElement);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
19
30
|
export * from './attachProps';
|
|
20
31
|
export * from './case';
|
|
@@ -7,10 +7,15 @@
|
|
|
7
7
|
*/
|
|
8
8
|
/* eslint-disable */
|
|
9
9
|
/* tslint:disable */
|
|
10
|
+
/* auto-generated react proxies */
|
|
10
11
|
import { createReactComponent } from './react-component-lib';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
export const
|
|
12
|
+
import { defineCustomElement as definePeculiarAttributeCertificateViewer } from '@peculiar/certificates-viewer/components/peculiar-attribute-certificate-viewer.js';
|
|
13
|
+
import { defineCustomElement as definePeculiarCertificateViewer } from '@peculiar/certificates-viewer/components/peculiar-certificate-viewer.js';
|
|
14
|
+
import { defineCustomElement as definePeculiarCertificatesViewer } from '@peculiar/certificates-viewer/components/peculiar-certificates-viewer.js';
|
|
15
|
+
import { defineCustomElement as definePeculiarCrlViewer } from '@peculiar/certificates-viewer/components/peculiar-crl-viewer.js';
|
|
16
|
+
import { defineCustomElement as definePeculiarCsrViewer } from '@peculiar/certificates-viewer/components/peculiar-csr-viewer.js';
|
|
17
|
+
export const PeculiarAttributeCertificateViewer = /*@__PURE__*/ createReactComponent('peculiar-attribute-certificate-viewer', undefined, undefined, definePeculiarAttributeCertificateViewer);
|
|
18
|
+
export const PeculiarCertificateViewer = /*@__PURE__*/ createReactComponent('peculiar-certificate-viewer', undefined, undefined, definePeculiarCertificateViewer);
|
|
19
|
+
export const PeculiarCertificatesViewer = /*@__PURE__*/ createReactComponent('peculiar-certificates-viewer', undefined, undefined, definePeculiarCertificatesViewer);
|
|
20
|
+
export const PeculiarCrlViewer = /*@__PURE__*/ createReactComponent('peculiar-crl-viewer', undefined, undefined, definePeculiarCrlViewer);
|
|
21
|
+
export const PeculiarCsrViewer = /*@__PURE__*/ createReactComponent('peculiar-csr-viewer', undefined, undefined, definePeculiarCsrViewer);
|
package/dist/esnext/index.js
CHANGED
|
@@ -5,9 +5,4 @@
|
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
|
-
import { defineCustomElements, applyPolyfills } from '@peculiar/certificates-viewer/loader';
|
|
9
8
|
export * from './components';
|
|
10
|
-
if (typeof window !== 'undefined') {
|
|
11
|
-
applyPolyfills()
|
|
12
|
-
.then(() => defineCustomElements(window));
|
|
13
|
-
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { attachProps, createForwardRef, dashToPascalCase, isCoveredByReact, mergeRefs
|
|
3
|
-
export const createReactComponent = (tagName, ReactComponentContext, manipulatePropsFunction) => {
|
|
2
|
+
import { attachProps, camelToDashCase, createForwardRef, dashToPascalCase, isCoveredByReact, mergeRefs } from './utils';
|
|
3
|
+
export const createReactComponent = (tagName, ReactComponentContext, manipulatePropsFunction, defineCustomElement) => {
|
|
4
|
+
if (defineCustomElement !== undefined) {
|
|
5
|
+
defineCustomElement();
|
|
6
|
+
}
|
|
4
7
|
const displayName = dashToPascalCase(tagName);
|
|
5
8
|
const ReactComponent = class extends React.Component {
|
|
6
9
|
componentEl;
|
|
@@ -19,25 +22,38 @@ export const createReactComponent = (tagName, ReactComponentContext, manipulateP
|
|
|
19
22
|
render() {
|
|
20
23
|
const { children, forwardedRef, style, className, ref, ...cProps } = this.props;
|
|
21
24
|
let propsToPass = Object.keys(cProps).reduce((acc, name) => {
|
|
25
|
+
const value = cProps[name];
|
|
22
26
|
if (name.indexOf('on') === 0 && name[2] === name[2].toUpperCase()) {
|
|
23
27
|
const eventName = name.substring(2).toLowerCase();
|
|
24
|
-
if (typeof document !== 'undefined' && isCoveredByReact(eventName
|
|
25
|
-
acc[name] =
|
|
28
|
+
if (typeof document !== 'undefined' && isCoveredByReact(eventName)) {
|
|
29
|
+
acc[name] = value;
|
|
26
30
|
}
|
|
27
31
|
}
|
|
28
32
|
else {
|
|
29
|
-
|
|
33
|
+
// we should only render strings, booleans, and numbers as attrs in html.
|
|
34
|
+
// objects, functions, arrays etc get synced via properties on mount.
|
|
35
|
+
const type = typeof value;
|
|
36
|
+
if (type === 'string' || type === 'boolean' || type === 'number') {
|
|
37
|
+
acc[camelToDashCase(name)] = value;
|
|
38
|
+
}
|
|
30
39
|
}
|
|
31
40
|
return acc;
|
|
32
41
|
}, {});
|
|
33
42
|
if (manipulatePropsFunction) {
|
|
34
43
|
propsToPass = manipulatePropsFunction(this.props, propsToPass);
|
|
35
44
|
}
|
|
36
|
-
|
|
45
|
+
const newProps = {
|
|
37
46
|
...propsToPass,
|
|
38
47
|
ref: mergeRefs(forwardedRef, this.setComponentElRef),
|
|
39
48
|
style,
|
|
40
49
|
};
|
|
50
|
+
/**
|
|
51
|
+
* We use createElement here instead of
|
|
52
|
+
* React.createElement to work around a
|
|
53
|
+
* bug in Vite (https://github.com/vitejs/vite/issues/6104).
|
|
54
|
+
* React.createElement causes all elements to be rendered
|
|
55
|
+
* as <tagname> instead of the actual Web Component.
|
|
56
|
+
*/
|
|
41
57
|
return React.createElement(tagName, newProps, children);
|
|
42
58
|
}
|
|
43
59
|
static get displayName() {
|
|
@@ -19,7 +19,7 @@ export const attachProps = (node, newProps, oldProps = {}) => {
|
|
|
19
19
|
if (name.indexOf('on') === 0 && name[2] === name[2].toUpperCase()) {
|
|
20
20
|
const eventName = name.substring(2);
|
|
21
21
|
const eventNameLc = eventName[0].toLowerCase() + eventName.substring(1);
|
|
22
|
-
if (
|
|
22
|
+
if (!isCoveredByReact(eventNameLc)) {
|
|
23
23
|
syncEvent(node, eventNameLc, newProps[name]);
|
|
24
24
|
}
|
|
25
25
|
}
|
|
@@ -29,9 +29,6 @@ export const attachProps = (node, newProps, oldProps = {}) => {
|
|
|
29
29
|
if (propType === 'string') {
|
|
30
30
|
node.setAttribute(camelToDashCase(name), newProps[name]);
|
|
31
31
|
}
|
|
32
|
-
else {
|
|
33
|
-
node[name] = newProps[name];
|
|
34
|
-
}
|
|
35
32
|
}
|
|
36
33
|
});
|
|
37
34
|
}
|
|
@@ -60,19 +57,34 @@ export const getClassName = (classList, newProps, oldProps) => {
|
|
|
60
57
|
incomingPropClasses.forEach((s) => finalClassNames.push(s));
|
|
61
58
|
return finalClassNames.join(' ');
|
|
62
59
|
};
|
|
60
|
+
/**
|
|
61
|
+
* Transforms a React event name to a browser event name.
|
|
62
|
+
*/
|
|
63
|
+
export const transformReactEventName = (eventNameSuffix) => {
|
|
64
|
+
switch (eventNameSuffix) {
|
|
65
|
+
case 'doubleclick':
|
|
66
|
+
return 'dblclick';
|
|
67
|
+
}
|
|
68
|
+
return eventNameSuffix;
|
|
69
|
+
};
|
|
63
70
|
/**
|
|
64
71
|
* Checks if an event is supported in the current execution environment.
|
|
65
72
|
* @license Modernizr 3.0.0pre (Custom Build) | MIT
|
|
66
73
|
*/
|
|
67
|
-
export const isCoveredByReact = (eventNameSuffix
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
isSupported =
|
|
74
|
+
export const isCoveredByReact = (eventNameSuffix) => {
|
|
75
|
+
if (typeof document === 'undefined') {
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
const eventName = 'on' + transformReactEventName(eventNameSuffix);
|
|
80
|
+
let isSupported = eventName in document;
|
|
81
|
+
if (!isSupported) {
|
|
82
|
+
const element = document.createElement('div');
|
|
83
|
+
element.setAttribute(eventName, 'return;');
|
|
84
|
+
isSupported = typeof element[eventName] === 'function';
|
|
85
|
+
}
|
|
86
|
+
return isSupported;
|
|
74
87
|
}
|
|
75
|
-
return isSupported;
|
|
76
88
|
};
|
|
77
89
|
export const syncEvent = (node, eventName, newEventHandler) => {
|
|
78
90
|
const eventStore = node.__events || (node.__events = {});
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
export const mergeRefs = (...refs) => (value) => refs.forEach((ref) => {
|
|
2
|
+
export const setRef = (ref, value) => {
|
|
4
3
|
if (typeof ref === 'function') {
|
|
5
4
|
ref(value);
|
|
6
5
|
}
|
|
7
6
|
else if (ref != null) {
|
|
8
|
-
//
|
|
7
|
+
// Cast as a MutableRef so we can assign current
|
|
9
8
|
ref.current = value;
|
|
10
9
|
}
|
|
11
|
-
}
|
|
10
|
+
};
|
|
11
|
+
export const mergeRefs = (...refs) => {
|
|
12
|
+
return (value) => {
|
|
13
|
+
refs.forEach((ref) => {
|
|
14
|
+
setRef(ref, value);
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
};
|
|
12
18
|
export const createForwardRef = (ReactComponent, displayName) => {
|
|
13
19
|
const forwardRef = (props, ref) => {
|
|
14
20
|
return React.createElement(ReactComponent, { ...props, forwardedRef: ref });
|
|
@@ -16,5 +22,10 @@ export const createForwardRef = (ReactComponent, displayName) => {
|
|
|
16
22
|
forwardRef.displayName = displayName;
|
|
17
23
|
return React.forwardRef(forwardRef);
|
|
18
24
|
};
|
|
25
|
+
export const defineCustomElement = (tagName, customElement) => {
|
|
26
|
+
if (customElement !== undefined && typeof customElements !== 'undefined' && !customElements.get(tagName)) {
|
|
27
|
+
customElements.define(tagName, customElement);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
19
30
|
export * from './attachProps';
|
|
20
31
|
export * from './case';
|
|
@@ -6,10 +6,9 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
/// <reference types="react" />
|
|
9
|
-
import type { JSX } from '@peculiar/certificates-viewer';
|
|
9
|
+
import type { JSX } from '@peculiar/certificates-viewer/components';
|
|
10
10
|
export declare const PeculiarAttributeCertificateViewer: import("react").ForwardRefExoticComponent<JSX.PeculiarAttributeCertificateViewer & Omit<import("react").HTMLAttributes<HTMLPeculiarAttributeCertificateViewerElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLPeculiarAttributeCertificateViewerElement>>;
|
|
11
|
-
export declare const PeculiarCertificateDecoder: import("react").ForwardRefExoticComponent<JSX.PeculiarCertificateDecoder & Omit<import("react").HTMLAttributes<HTMLPeculiarCertificateDecoderElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLPeculiarCertificateDecoderElement>>;
|
|
12
11
|
export declare const PeculiarCertificateViewer: import("react").ForwardRefExoticComponent<JSX.PeculiarCertificateViewer & Omit<import("react").HTMLAttributes<HTMLPeculiarCertificateViewerElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLPeculiarCertificateViewerElement>>;
|
|
13
12
|
export declare const PeculiarCertificatesViewer: import("react").ForwardRefExoticComponent<JSX.PeculiarCertificatesViewer & Omit<import("react").HTMLAttributes<HTMLPeculiarCertificatesViewerElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLPeculiarCertificatesViewerElement>>;
|
|
14
|
-
export declare const PeculiarCsrViewer: import("react").ForwardRefExoticComponent<JSX.PeculiarCsrViewer & Omit<import("react").HTMLAttributes<HTMLPeculiarCsrViewerElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLPeculiarCsrViewerElement>>;
|
|
15
13
|
export declare const PeculiarCrlViewer: import("react").ForwardRefExoticComponent<JSX.PeculiarCrlViewer & Omit<import("react").HTMLAttributes<HTMLPeculiarCrlViewerElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLPeculiarCrlViewerElement>>;
|
|
14
|
+
export declare const PeculiarCsrViewer: import("react").ForwardRefExoticComponent<JSX.PeculiarCsrViewer & Omit<import("react").HTMLAttributes<HTMLPeculiarCsrViewerElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLPeculiarCsrViewerElement>>;
|
|
@@ -6,5 +6,5 @@ interface StencilReactInternalProps<ElementType> extends React.HTMLAttributes<El
|
|
|
6
6
|
forwardedRef: React.RefObject<ElementType>;
|
|
7
7
|
ref?: React.Ref<any>;
|
|
8
8
|
}
|
|
9
|
-
export declare const createReactComponent: <PropType, ElementType extends HTMLStencilElement, ContextStateType = {}, ExpandedPropsTypes = {}>(tagName: string, ReactComponentContext?: React.Context<ContextStateType>, manipulatePropsFunction?: (originalProps: StencilReactInternalProps<ElementType>, propsToPass: any) => ExpandedPropsTypes) => React.ForwardRefExoticComponent<React.PropsWithoutRef<PropType & Omit<React.HTMLAttributes<ElementType>, "style"> & import("./interfaces").StyleReactProps> & React.RefAttributes<ElementType>>;
|
|
9
|
+
export declare const createReactComponent: <PropType, ElementType extends HTMLStencilElement, ContextStateType = {}, ExpandedPropsTypes = {}>(tagName: string, ReactComponentContext?: React.Context<ContextStateType>, manipulatePropsFunction?: (originalProps: StencilReactInternalProps<ElementType>, propsToPass: any) => ExpandedPropsTypes, defineCustomElement?: () => void) => React.ForwardRefExoticComponent<React.PropsWithoutRef<PropType & Omit<React.HTMLAttributes<ElementType>, "style"> & import("./interfaces").StyleReactProps> & React.RefAttributes<ElementType>>;
|
|
10
10
|
export {};
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
export declare const attachProps: (node: HTMLElement, newProps: any, oldProps?: any) => void;
|
|
2
2
|
export declare const getClassName: (classList: DOMTokenList, newProps: any, oldProps: any) => string;
|
|
3
|
+
/**
|
|
4
|
+
* Transforms a React event name to a browser event name.
|
|
5
|
+
*/
|
|
6
|
+
export declare const transformReactEventName: (eventNameSuffix: string) => string;
|
|
3
7
|
/**
|
|
4
8
|
* Checks if an event is supported in the current execution environment.
|
|
5
9
|
* @license Modernizr 3.0.0pre (Custom Build) | MIT
|
|
6
10
|
*/
|
|
7
|
-
export declare const isCoveredByReact: (eventNameSuffix: string
|
|
11
|
+
export declare const isCoveredByReact: (eventNameSuffix: string) => boolean;
|
|
8
12
|
export declare const syncEvent: (node: Element & {
|
|
9
13
|
__events?: {
|
|
10
14
|
[key: string]: (e: Event) => any;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import type { StyleReactProps } from '../interfaces';
|
|
3
3
|
export declare type StencilReactExternalProps<PropType, ElementType> = PropType & Omit<React.HTMLAttributes<ElementType>, 'style'> & StyleReactProps;
|
|
4
|
-
export declare
|
|
4
|
+
export declare type StencilReactForwardedRef<T> = ((instance: T | null) => void) | React.MutableRefObject<T | null> | null;
|
|
5
|
+
export declare const setRef: (ref: StencilReactForwardedRef<any> | React.Ref<any> | undefined, value: any) => void;
|
|
6
|
+
export declare const mergeRefs: (...refs: (StencilReactForwardedRef<any> | React.Ref<any> | undefined)[]) => React.RefCallback<any>;
|
|
5
7
|
export declare const createForwardRef: <PropType, ElementType>(ReactComponent: any, displayName: string) => React.ForwardRefExoticComponent<React.PropsWithoutRef<PropType & Omit<React.HTMLAttributes<ElementType>, "style"> & StyleReactProps> & React.RefAttributes<ElementType>>;
|
|
8
|
+
export declare const defineCustomElement: (tagName: string, customElement: any) => void;
|
|
6
9
|
export * from './attachProps';
|
|
7
10
|
export * from './case';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@peculiar/certificates-viewer-react",
|
|
3
|
-
"version": "3.10.
|
|
3
|
+
"version": "3.10.1-alpha.14+849a2da",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
@@ -28,18 +28,18 @@
|
|
|
28
28
|
"access": "public"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@types/node": "^
|
|
31
|
+
"@types/node": "^16.11.7",
|
|
32
32
|
"@types/react": "^16.9.46",
|
|
33
33
|
"react": "^16.13.1",
|
|
34
34
|
"rimraf": "^3.0.2",
|
|
35
35
|
"typescript": "^4.0.5"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@peculiar/certificates-viewer": "^3.10.
|
|
38
|
+
"@peculiar/certificates-viewer": "^3.10.1-alpha.14+849a2da",
|
|
39
39
|
"tslib": "^2.4.1"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"react": ">=16.13.1"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "849a2da6283e42f3f03a3466d265718ce37bcf5b"
|
|
45
45
|
}
|