@antscorp/antsomi-ui 1.5.6 → 1.5.8
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/es/components/atoms/ReactIframe/ReactIframe.d.ts +3 -0
- package/es/components/atoms/ReactIframe/ReactIframe.js +42 -0
- package/es/components/atoms/ReactIframe/index.d.ts +2 -0
- package/es/components/atoms/ReactIframe/index.js +1 -0
- package/es/components/atoms/ReactIframe/styled.d.ts +1 -0
- package/es/components/atoms/ReactIframe/styled.js +16 -0
- package/es/components/atoms/ReactIframe/types.d.ts +10 -0
- package/es/components/atoms/ReactIframe/types.js +1 -0
- package/es/components/atoms/index.d.ts +1 -0
- package/es/components/atoms/index.js +1 -0
- package/es/components/organism/Help/Help.js +3 -2
- package/es/utils/index.d.ts +1 -0
- package/es/utils/index.js +1 -0
- package/es/utils/styles.d.ts +2 -0
- package/es/utils/styles.js +175 -0
- package/package.json +4 -2
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
// Styled
|
|
13
|
+
import React, { useEffect, useRef } from 'react';
|
|
14
|
+
import Frame from 'react-frame-component';
|
|
15
|
+
// Styled
|
|
16
|
+
import { useForceUpdate } from '@antscorp/antsomi-ui/es/hooks';
|
|
17
|
+
const bodyStyle = `
|
|
18
|
+
body {
|
|
19
|
+
padding: 0;
|
|
20
|
+
margin: 0;
|
|
21
|
+
}
|
|
22
|
+
`;
|
|
23
|
+
export const ReactIframe = props => {
|
|
24
|
+
const { head, style } = props, restOfProps = __rest(props, ["head", "style"]);
|
|
25
|
+
const forceUpdate = useForceUpdate();
|
|
26
|
+
// Refs
|
|
27
|
+
const frameRef = useRef();
|
|
28
|
+
// Clone stylesheets from parent html to iframe for content of iframe to be styled correctly
|
|
29
|
+
const documentHead = document.querySelector('head');
|
|
30
|
+
// Force update for fix bug can't get style in first render
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
setTimeout(() => {
|
|
33
|
+
forceUpdate();
|
|
34
|
+
}, 500);
|
|
35
|
+
}, [forceUpdate]);
|
|
36
|
+
return (React.createElement(Frame, Object.assign({}, restOfProps, { style: Object.assign({ border: 'none', width: '100%', height: '100%' }, style), ref: ref => {
|
|
37
|
+
frameRef.current = ref;
|
|
38
|
+
}, head: React.createElement(React.Fragment, null,
|
|
39
|
+
React.createElement("style", null, documentHead === null || documentHead === void 0 ? void 0 : documentHead.innerHTML),
|
|
40
|
+
React.createElement("style", null, bodyStyle),
|
|
41
|
+
head) })));
|
|
42
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ReactIframe';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const StyledIframeContent: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
var _a;
|
|
2
|
+
// Libraries
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
// Constants
|
|
5
|
+
import { THEME } from '@antscorp/antsomi-ui/es/constants';
|
|
6
|
+
/* Storybook */
|
|
7
|
+
export const StyledIframeContent = styled.div `
|
|
8
|
+
width: 100%;
|
|
9
|
+
padding: 20px;
|
|
10
|
+
border: 1px solid ${(_a = THEME.token) === null || _a === void 0 ? void 0 : _a.bw3};
|
|
11
|
+
box-sizing: border-box;
|
|
12
|
+
|
|
13
|
+
body {
|
|
14
|
+
padding: 0;
|
|
15
|
+
}
|
|
16
|
+
`;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { FrameComponentProps } from 'react-frame-component';
|
|
3
|
+
export interface ReactIframeProps extends FrameComponentProps {
|
|
4
|
+
head?: React.ReactNode | undefined;
|
|
5
|
+
mountTarget?: string | undefined;
|
|
6
|
+
initialContent?: string | undefined;
|
|
7
|
+
contentDidMount?: (() => void) | undefined;
|
|
8
|
+
contentDidUpdate?: (() => void) | undefined;
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -37,6 +37,7 @@ export * from './PreviewTabs';
|
|
|
37
37
|
export * from './MobileFrame';
|
|
38
38
|
export * from './MobileFrameV2';
|
|
39
39
|
export * from './SlideBar';
|
|
40
|
+
export * from './ReactIframe';
|
|
40
41
|
export type { SliderProps } from './Slider';
|
|
41
42
|
export type { PaginationProps } from './Pagination';
|
|
42
43
|
export type { InputDynamicProps } from './InputDynamic';
|
|
@@ -991,11 +991,12 @@ const Help = props => {
|
|
|
991
991
|
width: 36,
|
|
992
992
|
height: 36,
|
|
993
993
|
borderRadius: '5px',
|
|
994
|
-
},
|
|
994
|
+
}, className: `${isOpenDropdown ? 'antsomi-btn-default-active' : ''}`, onClick: e => e.preventDefault() },
|
|
995
|
+
React.createElement(QuestionCircleOutlined, { style: {
|
|
995
996
|
color: '#666666',
|
|
996
997
|
fontSize: '24px',
|
|
997
998
|
transform: 'unset',
|
|
998
|
-
} })
|
|
999
|
+
} })))),
|
|
999
1000
|
isShowPopup &&
|
|
1000
1001
|
createPortal(React.createElement(PopupDraggable, { isHiddenResizing: true, bounds: boundsDraggable, isShowResizeHover: isShowResizeHover, callback: callback, styleContainer: {
|
|
1001
1002
|
display: 'flex',
|
package/es/utils/index.d.ts
CHANGED
package/es/utils/index.js
CHANGED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CSS properties which accept numbers but are not in units of "px".
|
|
3
|
+
*/
|
|
4
|
+
const isUnitlessNumber = {
|
|
5
|
+
boxFlex: true,
|
|
6
|
+
boxFlexGroup: true,
|
|
7
|
+
columnCount: true,
|
|
8
|
+
flex: true,
|
|
9
|
+
flexGrow: true,
|
|
10
|
+
flexPositive: true,
|
|
11
|
+
flexShrink: true,
|
|
12
|
+
flexNegative: true,
|
|
13
|
+
fontWeight: true,
|
|
14
|
+
lineClamp: true,
|
|
15
|
+
lineHeight: true,
|
|
16
|
+
opacity: true,
|
|
17
|
+
order: true,
|
|
18
|
+
orphans: true,
|
|
19
|
+
widows: true,
|
|
20
|
+
zIndex: true,
|
|
21
|
+
zoom: true,
|
|
22
|
+
// SVG-related properties
|
|
23
|
+
fillOpacity: true,
|
|
24
|
+
strokeDashoffset: true,
|
|
25
|
+
strokeOpacity: true,
|
|
26
|
+
strokeWidth: true,
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* @param {string} prefix vendor-specific prefix, eg: Webkit
|
|
30
|
+
* @param {string} key style name, eg: transitionDuration
|
|
31
|
+
* @return {string} style name prefixed with `prefix`, properly camelCased, eg:
|
|
32
|
+
* WebkitTransitionDuration
|
|
33
|
+
*/
|
|
34
|
+
function prefixKey(prefix, key) {
|
|
35
|
+
return prefix + key.charAt(0).toUpperCase() + key.substring(1);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Support style names that may come passed in prefixed by adding permutations
|
|
39
|
+
* of vendor prefixes.
|
|
40
|
+
*/
|
|
41
|
+
const prefixes = ['Webkit', 'ms', 'Moz', 'O'];
|
|
42
|
+
// Using Object.keys here, or else the vanilla for-in loop makes IE8 go into an
|
|
43
|
+
// infinite loop, because it iterates over the newly added props too.
|
|
44
|
+
Object.keys(isUnitlessNumber).forEach(prop => {
|
|
45
|
+
prefixes.forEach(prefix => {
|
|
46
|
+
isUnitlessNumber[prefixKey(prefix, prop)] = isUnitlessNumber[prop];
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
/**
|
|
50
|
+
* Most style properties can be unset by doing .style[prop] = '' but IE8
|
|
51
|
+
* doesn't like doing that with shorthand properties so for the properties that
|
|
52
|
+
* IE8 breaks on, which are listed here, we instead unset each of the
|
|
53
|
+
* individual properties. See http://bugs.jquery.com/ticket/12385.
|
|
54
|
+
* The 4-value 'clock' properties like margin, padding, border-width seem to
|
|
55
|
+
* behave without any problems. Curiously, list-style works too without any
|
|
56
|
+
* special prodding.
|
|
57
|
+
*/
|
|
58
|
+
const shorthandPropertyExpansions = {
|
|
59
|
+
background: {
|
|
60
|
+
backgroundImage: true,
|
|
61
|
+
backgroundPosition: true,
|
|
62
|
+
backgroundRepeat: true,
|
|
63
|
+
backgroundColor: true,
|
|
64
|
+
},
|
|
65
|
+
border: {
|
|
66
|
+
borderWidth: true,
|
|
67
|
+
borderStyle: true,
|
|
68
|
+
borderColor: true,
|
|
69
|
+
},
|
|
70
|
+
borderBottom: {
|
|
71
|
+
borderBottomWidth: true,
|
|
72
|
+
borderBottomStyle: true,
|
|
73
|
+
borderBottomColor: true,
|
|
74
|
+
},
|
|
75
|
+
borderLeft: {
|
|
76
|
+
borderLeftWidth: true,
|
|
77
|
+
borderLeftStyle: true,
|
|
78
|
+
borderLeftColor: true,
|
|
79
|
+
},
|
|
80
|
+
borderRight: {
|
|
81
|
+
borderRightWidth: true,
|
|
82
|
+
borderRightStyle: true,
|
|
83
|
+
borderRightColor: true,
|
|
84
|
+
},
|
|
85
|
+
borderTop: {
|
|
86
|
+
borderTopWidth: true,
|
|
87
|
+
borderTopStyle: true,
|
|
88
|
+
borderTopColor: true,
|
|
89
|
+
},
|
|
90
|
+
font: {
|
|
91
|
+
fontStyle: true,
|
|
92
|
+
fontconstiant: true,
|
|
93
|
+
fontWeight: true,
|
|
94
|
+
fontSize: true,
|
|
95
|
+
lineHeight: true,
|
|
96
|
+
fontFamily: true,
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
const CSSProperty = {
|
|
100
|
+
isUnitlessNumber,
|
|
101
|
+
shorthandPropertyExpansions,
|
|
102
|
+
};
|
|
103
|
+
/* eslint-disable no-underscore-dangle */
|
|
104
|
+
const msPattern = /^ms-/;
|
|
105
|
+
const _uppercasePattern = /([A-Z])/g;
|
|
106
|
+
/**
|
|
107
|
+
* Hyphenates a camelcased string, for example:
|
|
108
|
+
*
|
|
109
|
+
* > hyphenate('backgroundColor')
|
|
110
|
+
* < "background-color"
|
|
111
|
+
*
|
|
112
|
+
* For CSS style names, use `hyphenateStyleName` instead which works properly
|
|
113
|
+
* with all vendor prefixes, including `ms`.
|
|
114
|
+
*
|
|
115
|
+
* @param {string} string
|
|
116
|
+
* @return {string}
|
|
117
|
+
*/
|
|
118
|
+
function hyphenate(string) {
|
|
119
|
+
return string.replace(_uppercasePattern, '-$1').toLowerCase();
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Hyphenates a camelcased CSS property name, for example:
|
|
123
|
+
*
|
|
124
|
+
* > hyphenateStyleName('backgroundColor')
|
|
125
|
+
* < "background-color"
|
|
126
|
+
* > hyphenateStyleName('MozTransition')
|
|
127
|
+
* < "-moz-transition"
|
|
128
|
+
* > hyphenateStyleName('msTransition')
|
|
129
|
+
* < "-ms-transition"
|
|
130
|
+
*
|
|
131
|
+
* As Modernizr suggests (http://modernizr.com/docs/#prefixed), an `ms` prefix
|
|
132
|
+
* is converted to `-ms-`.
|
|
133
|
+
*
|
|
134
|
+
* @param {string} string
|
|
135
|
+
* @return {string}
|
|
136
|
+
*/
|
|
137
|
+
function hyphenateStyleName(string) {
|
|
138
|
+
return hyphenate(string).replace(msPattern, '-ms-');
|
|
139
|
+
}
|
|
140
|
+
const { isArray } = Array;
|
|
141
|
+
const { keys } = Object;
|
|
142
|
+
const counter = 1;
|
|
143
|
+
// Follows syntax at https://developer.mozilla.org/en-US/docs/Web/CSS/content,
|
|
144
|
+
// including multiple space separated values.
|
|
145
|
+
const unquotedContentValueRegex = /^(normal|none|(\b(url\([^)]*\)|chapter_counter|attr\([^)]*\)|(no-)?(open|close)-quote|inherit)((\b\s*)|$|\s+))+)$/;
|
|
146
|
+
function buildRule(key, value) {
|
|
147
|
+
if (!isUnitlessNumber[key] && typeof value === 'number') {
|
|
148
|
+
value = `${value}px`;
|
|
149
|
+
}
|
|
150
|
+
else if (key === 'content' && !unquotedContentValueRegex.test(value)) {
|
|
151
|
+
value = `'${value.replace(/'/g, "\\'")}'`;
|
|
152
|
+
}
|
|
153
|
+
return `${hyphenateStyleName(key)}: ${value}; `;
|
|
154
|
+
}
|
|
155
|
+
export function styleToCssString(rules) {
|
|
156
|
+
let result = '';
|
|
157
|
+
if (!rules || keys(rules).length === 0) {
|
|
158
|
+
return result;
|
|
159
|
+
}
|
|
160
|
+
const styleKeys = keys(rules);
|
|
161
|
+
for (let j = 0, l = styleKeys.length; j < l; j++) {
|
|
162
|
+
const styleKey = styleKeys[j];
|
|
163
|
+
const value = rules[styleKey];
|
|
164
|
+
if (isArray(value)) {
|
|
165
|
+
for (let i = 0, len = value.length; i < len; i++) {
|
|
166
|
+
result += buildRule(styleKey, value[i]);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
result += buildRule(styleKey, value);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return result;
|
|
174
|
+
}
|
|
175
|
+
export default styleToCssString;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antscorp/antsomi-ui",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.8",
|
|
4
4
|
"description": "An enterprise-class UI design language and React UI library.",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"dist/*",
|
|
@@ -19,7 +19,6 @@
|
|
|
19
19
|
"unpkg": "dist/index.js",
|
|
20
20
|
"types": "es/index.d.ts",
|
|
21
21
|
"scripts": {
|
|
22
|
-
"publish": "npm run clean && npm run build:es",
|
|
23
22
|
"build:es": "npm run copy-files && npm run ts-compile",
|
|
24
23
|
"clean": "rimraf dist lib es",
|
|
25
24
|
"dev": "vite",
|
|
@@ -98,8 +97,10 @@
|
|
|
98
97
|
"react-color": "2.19.3",
|
|
99
98
|
"react-draggable": "^4.4.5",
|
|
100
99
|
"react-konva": "^18.2.10",
|
|
100
|
+
"react-frame-component": "^5.2.6",
|
|
101
101
|
"react-markdown": "^8.0.7",
|
|
102
102
|
"react-resizable": "^3.0.5",
|
|
103
|
+
"react-syntax-highlighter": "^15.5.0",
|
|
103
104
|
"rehype-highlight": "^6.0.0",
|
|
104
105
|
"remark-gfm": "^3.0.1",
|
|
105
106
|
"swiper": "^11.0.7",
|
|
@@ -144,6 +145,7 @@
|
|
|
144
145
|
"@types/react": "^18.0.33",
|
|
145
146
|
"@types/react-beautiful-dnd": "^13.1.8",
|
|
146
147
|
"@types/react-dom": "^18.0.11",
|
|
148
|
+
"@types/react-syntax-highlighter": "^15.5.11",
|
|
147
149
|
"@types/react-test-renderer": "^18.0.0",
|
|
148
150
|
"@types/styled-components": "^5.1.26",
|
|
149
151
|
"@typescript-eslint/eslint-plugin": "^5.55.0",
|