@antscorp/antsomi-ui 1.3.5-beta.124 → 1.3.5-beta.126

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.
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ import { ReactIframeProps } from './types';
3
+ export declare const ReactIframe: React.FC<ReactIframeProps>;
@@ -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,2 @@
1
+ export * from './ReactIframe';
2
+ export type { ReactIframeProps } from './types';
@@ -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 {};
@@ -38,6 +38,7 @@ export * from './PreviewTabs';
38
38
  export * from './MobileFrame';
39
39
  export * from './MobileFrameV2';
40
40
  export * from './SlideBar';
41
+ export * from './ReactIframe';
41
42
  export type { SliderProps } from './Slider';
42
43
  export type { PaginationProps } from './Pagination';
43
44
  export type { InputDynamicProps } from './InputDynamic';
@@ -38,3 +38,4 @@ export * from './PreviewTabs';
38
38
  export * from './MobileFrame';
39
39
  export * from './MobileFrameV2';
40
40
  export * from './SlideBar';
41
+ export * from './ReactIframe';
@@ -23,6 +23,7 @@ import { Button, Flex } from '../../../../atoms';
23
23
  import { ThumbnailCard } from '../../../../molecules';
24
24
  // Constants
25
25
  import { THUMBNAIL_HEIGHT_DEFAULT, THUMBNAIL_WIDTH_DEFAULT } from '../../constants';
26
+ import classNames from 'classnames';
26
27
  /** Max width of list thumbnail's wrapper, it is used to show swiper if the width is greater than 990 */
27
28
  const WRAPPER_WIDTH = 990;
28
29
  const GAP_X = 10;
@@ -30,7 +31,7 @@ const ICON_SIZE = 24;
30
31
  export const ThumbnailSlider = memo(props => {
31
32
  const { thumbnails, width = THUMBNAIL_WIDTH_DEFAULT, height = THUMBNAIL_HEIGHT_DEFAULT, onClickThumbnail } = props, restOfThumbnailProps = __rest(props, ["thumbnails", "width", "height", "onClickThumbnail"]);
32
33
  // States
33
- const [isSlideBeginning, setSlideBeginning] = useState(false);
34
+ const [isSlideBeginning, setSlideBeginning] = useState(true);
34
35
  const [isSlideEnd, setSlideEnd] = useState(false);
35
36
  // Refs
36
37
  const navigationPrevRef = useRef(null);
@@ -72,8 +73,8 @@ export const ThumbnailSlider = memo(props => {
72
73
  setSlideBeginning(isBeginning);
73
74
  setSlideEnd(isEnd);
74
75
  } }, thumbnails.map((thumbnail, index) => (React.createElement(SwiperSlideWrapper, { key: `slide-${thumbnail.id}` }, renderThumbnail({ thumbnail, index }))))),
75
- React.createElement(Button, { ref: navigationPrevRef, className: "custom-button-prev", disabled: isSlideBeginning },
76
+ React.createElement(Button, { ref: navigationPrevRef, className: classNames({ 'custom-button-prev': true, hidden: isSlideBeginning }) },
76
77
  React.createElement(Icon, { type: "icon-ants-expand-more" })),
77
- React.createElement(Button, { ref: navigationNextRef, className: "custom-button-next", disabled: isSlideEnd },
78
+ React.createElement(Button, { ref: navigationNextRef, className: classNames({ 'custom-button-next': true, hidden: isSlideEnd }) },
78
79
  React.createElement(Icon, { type: "icon-ants-expand-more" })))) : (React.createElement(Flex, { gap: GAP_X, style: { width: 'fit-content' } }, thumbnails === null || thumbnails === void 0 ? void 0 : thumbnails.map((thumbnail, index) => (React.createElement(React.Fragment, { key: thumbnail.id }, renderThumbnail({ thumbnail, index })))))))) : null;
79
80
  });
@@ -58,6 +58,10 @@ export const ThumbnailSliderWrapper = styled.div `
58
58
  transform: rotate(-90deg);
59
59
  }
60
60
 
61
+ .hidden {
62
+ display: none !important;
63
+ }
64
+
61
65
  i {
62
66
  font-size: 20px;
63
67
  color: ${(_a = THEME === null || THEME === void 0 ? void 0 : THEME.token) === null || _a === void 0 ? void 0 : _a.bw8};
@@ -79,9 +79,8 @@ export const CustomLabelStyled = styled.div `
79
79
  height: fit-content;
80
80
  }
81
81
  `;
82
- // TODO: tách class dùng chung
83
82
  export const CustomRootLabel = styled.div `
84
- font-size: 11px;
83
+ font-size: 11px !important;
85
84
  font-weight: 400;
86
85
  color: ${(_b = THEME === null || THEME === void 0 ? void 0 : THEME.token) === null || _b === void 0 ? void 0 : _b.bw8};
87
86
  height: 100%;
@@ -91,7 +90,7 @@ export const CustomRootLabel = styled.div `
91
90
  `;
92
91
  export const TextWrapper = styled(Text) `
93
92
  max-width: 100%;
94
- color: inherit;
93
+ color: inherit !important;
95
94
  height: fit-content;
96
- font-size: inherit;
95
+ font-size: inherit !important;
97
96
  `;
@@ -2,3 +2,4 @@ export * from './color';
2
2
  export * from './common';
3
3
  export * from './handleError';
4
4
  export * from './templateListing';
5
+ export * from './styles';
package/es/utils/index.js CHANGED
@@ -2,3 +2,4 @@ export * from './color';
2
2
  export * from './common';
3
3
  export * from './handleError';
4
4
  export * from './templateListing';
5
+ export * from './styles';
@@ -0,0 +1,2 @@
1
+ export declare function styleToCssString(rules: any): string;
2
+ export default styleToCssString;
@@ -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.3.5-beta.124",
3
+ "version": "1.3.5-beta.126",
4
4
  "description": "An enterprise-class UI design language and React UI library.",
5
5
  "sideEffects": [
6
6
  "dist/*",
@@ -97,8 +97,10 @@
97
97
  "react-beautiful-dnd": "^13.1.1",
98
98
  "react-color": "2.19.3",
99
99
  "react-draggable": "^4.4.5",
100
+ "react-frame-component": "^5.2.6",
100
101
  "react-markdown": "^8.0.7",
101
102
  "react-resizable": "^3.0.5",
103
+ "react-syntax-highlighter": "^15.5.0",
102
104
  "rehype-highlight": "^6.0.0",
103
105
  "remark-gfm": "^3.0.1",
104
106
  "swiper": "^11.0.7",
@@ -143,6 +145,7 @@
143
145
  "@types/react": "^18.0.33",
144
146
  "@types/react-beautiful-dnd": "^13.1.8",
145
147
  "@types/react-dom": "^18.0.11",
148
+ "@types/react-syntax-highlighter": "^15.5.11",
146
149
  "@types/react-test-renderer": "^18.0.0",
147
150
  "@types/styled-components": "^5.1.26",
148
151
  "@typescript-eslint/eslint-plugin": "^5.55.0",