@sheinx/shineout-style 3.10.4-beta.1 → 3.10.4-beta.3
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/cjs/normalize.d.ts.map +1 -1
- package/cjs/normalize.js +44 -35
- package/cjs/version.d.ts +1 -1
- package/cjs/version.js +1 -1
- package/esm/normalize.d.ts.map +1 -1
- package/esm/normalize.js +44 -35
- package/esm/version.d.ts +1 -1
- package/esm/version.js +1 -1
- package/package.json +3 -3
package/cjs/normalize.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["normalize.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["normalize.ts"],"names":[],"mappings":"AA0BA,eAAO,MAAM,cAAc,QA6TzB,CAAC;AAEH,eAAO,MAAM,gBAAgB,QAAwC,CAAC;AACtE,eAAO,MAAM,mBAAmB,QAAkD,CAAC;AAqCnF,eAAO,MAAM,mBAAmB,kCAgC/B,CAAC"}
|
package/cjs/normalize.js
CHANGED
|
@@ -8,19 +8,16 @@ var _theme = require("@sheinx/theme");
|
|
|
8
8
|
var _jssStyle = require("./jss-style");
|
|
9
9
|
var _version = _interopRequireDefault(require("./version"));
|
|
10
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
// 4. Prevent adjustments of font size after orientation changes in IE on Windows Phone and in iOS.
|
|
15
|
-
// 5. Setting @viewport causes scrollbars to overlap content in IE11 and Edge, so
|
|
16
|
-
// we force a non-overlapping, non-auto-hiding scrollbar to counteract.
|
|
17
|
-
// 6. Change the default tap highlight to be completely transparent in iOS.
|
|
11
|
+
// 全局基础样式(normalize)与 jss 插入点。
|
|
12
|
+
// 引入本模块会产生副作用:在浏览器环境下向 document.head 最前面依次插入 normalize 样式和 jss 插入点,
|
|
13
|
+
// 并通过 setToken 向 html 注入主题 token。
|
|
18
14
|
|
|
19
15
|
var token = {
|
|
20
16
|
fontFamily: 'var(--common-body-font-family, PingFang SC, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Helvetica, Hiragino KaKu Gothic Pro, Microsoft YaHei, Arial, sans-serif )',
|
|
21
17
|
color: 'var(--common-body-color, #141737)',
|
|
22
18
|
fontSize: 'var(--font-size-base, 14px)',
|
|
23
|
-
|
|
19
|
+
// 变量名与 shineout 1.x / 2.x 保持一致
|
|
20
|
+
lineHeight: 'var(--common-line-height, 1.42857143)',
|
|
24
21
|
linkColor: _theme.CommonToken['Brand-6'],
|
|
25
22
|
linkHoverDecoration: 'none',
|
|
26
23
|
linkDisabledColor: _theme.CommonToken['Brand-3'],
|
|
@@ -30,23 +27,30 @@ var token = {
|
|
|
30
27
|
headingsLineHeight: '1.1',
|
|
31
28
|
headingsSmallColor: '#adb5bd'
|
|
32
29
|
};
|
|
33
|
-
var
|
|
34
|
-
var
|
|
35
|
-
var normalizeStyle = exports.normalizeStyle = "*,\n*::before,\n*::after {\n box-sizing: border-box;\n}\nhtml {\n font-family: sans-serif;\n line-height: 1.15;\n -ms-overflow-style: scrollbar;\n -webkit-tap-highlight-color: rgba(0, 0, 0, 0);\n -webkit-text-size-adjust: 100%;\n -ms-text-size-adjust: 100%;\n}\n\narticle,\naside,\ndialog,\nfigcaption,\nfigure,\nfooter,\nheader,\nhgroup,\nmain,\nnav,\nsection {\n display: block;\n}\n\nbody {\n margin: 0;\n color: ".concat(token.color, ";\n font-family: ").concat(token.fontFamily, ";\n font-size: ").concat(token.fontSize, ";\n line-height: ").concat(token.lineHeight, ";\n}\n\
|
|
30
|
+
var marginLarge = '20px';
|
|
31
|
+
var marginSmall = '10px';
|
|
32
|
+
var normalizeStyle = exports.normalizeStyle = "*,\n*::before,\n*::after {\n box-sizing: border-box;\n}\nhtml {\n font-family: sans-serif;\n line-height: 1.15;\n -ms-overflow-style: scrollbar;\n -webkit-tap-highlight-color: rgba(0, 0, 0, 0);\n -webkit-text-size-adjust: 100%;\n -ms-text-size-adjust: 100%;\n}\n\narticle,\naside,\ndialog,\nfigcaption,\nfigure,\nfooter,\nheader,\nhgroup,\nmain,\nnav,\nsection {\n display: block;\n}\n\nbody {\n margin: 0;\n color: ".concat(token.color, ";\n font-family: ").concat(token.fontFamily, ";\n font-size: ").concat(token.fontSize, ";\n line-height: ").concat(token.lineHeight, ";\n}\n\nh1 {\n margin: 0.67em 0;\n font-size: 2em;\n}\n\nfigure {\n margin: 1em 40px;\n}\n\nhr {\n overflow: visible;\n height: 0;\n box-sizing: content-box;\n}\n\npre {\n font-family: \"SFMono-Regular\", Menlo, Monaco, Consolas, \"Courier New\", monospace;\n font-size: 1em;\n}\n\na {\n background-color: transparent;\n color: ").concat(token.linkColor, ";\n cursor: pointer;\n outline: none;\n text-decoration: ").concat(token.linkHoverDecoration, ";\n -webkit-text-decoration-skip: objects;\n transition: color 0.3s;\n}\n\na:active,\na:hover {\n color: ").concat(token.linkColor, ";\n outline: 0;\n text-decoration: ").concat(token.linkHoverDecoration, ";\n}\na[disabled] {\n color: ").concat(token.linkDisabledColor, ";\n cursor: not-allowed;\n pointer-events: none;\n}\n\nabbr[title] {\n border-bottom: none;\n text-decoration: underline;\n text-decoration: underline dotted;\n}\n\nb,\nstrong {\n font-weight: bolder;\n}\n\ncode,\nkbd,\nsamp {\n font-family: monospace, monospace;\n font-size: 1em;\n}\n\ndfn {\n font-style: italic;\n}\n\nmark {\n background-color: #ff0;\n color: #000;\n}\n\nsmall {\n font-size: 80%;\n}\n\nsub,\nsup {\n position: relative;\n font-size: 75%;\n line-height: 0;\n vertical-align: baseline;\n}\n\nsub {\n bottom: -0.25em;\n}\n\nsup {\n top: -0.5em;\n}\n\naudio,\nvideo {\n display: inline-block;\n}\n\naudio:not([controls]) {\n display: none;\n height: 0;\n}\n\nimg {\n border-style: none;\n}\n\nsvg:not(:root) {\n overflow: hidden;\n}\n\nbutton,\ninput,\noptgroup,\nselect,\ntextarea {\n margin: 0;\n font-family: inherit;\n font-size: 100%;\n line-height: 1.15;\n}\n\nbutton,\ninput {\n overflow: visible;\n}\n\nbutton,\nselect {\n text-transform: none;\n}\n\nbutton,\nhtml [type='button'],\n[type='reset'],\n[type='submit'] {\n -webkit-appearance: button;\n}\n\nbutton::-moz-focus-inner,\n[type='button']::-moz-focus-inner,\n[type='reset']::-moz-focus-inner,\n[type='submit']::-moz-focus-inner {\n padding: 0;\n border-style: none;\n}\n\nbutton:-moz-focusring,\n[type='button']:-moz-focusring,\n[type='reset']:-moz-focusring,\n[type='submit']:-moz-focusring {\n outline: 1px dotted ButtonText;\n}\n\nfieldset {\n padding: 0.35em 0.75em 0.625em;\n}\n\nlegend {\n display: table;\n max-width: 100%;\n box-sizing: border-box;\n padding: 0;\n color: inherit;\n white-space: normal;\n}\n\nprogress {\n display: inline-block;\n vertical-align: baseline;\n}\n\ntextarea {\n overflow: auto;\n}\n\n[type='checkbox'],\n[type='radio'] {\n box-sizing: border-box;\n padding: 0;\n}\n\n[type='number']::-webkit-inner-spin-button,\n[type='number']::-webkit-outer-spin-button {\n height: auto;\n}\n\n[type='search'] {\n -webkit-appearance: textfield;\n outline-offset: -2px;\n}\n\n[type='search']::-webkit-search-cancel-button,\n[type='search']::-webkit-search-decoration {\n -webkit-appearance: none;\n}\n\n::-webkit-file-upload-button {\n -webkit-appearance: button;\n font: inherit;\n}\n\ndetails,\nmenu {\n display: block;\n}\n\nsummary {\n display: list-item;\n}\n\ncanvas {\n display: inline-block;\n}\n\ntemplate {\n display: none;\n}\n\n[hidden] {\n display: none;\n}\n\nh1,\nh2,\nh3,\nh4,\nh5,\nh6,\n.h1,\n.h2,\n.h3,\n.h4,\n.h5,\n.h6 {\n color: ").concat(token.headingsColor, ";\n font-family: ").concat(token.headingsFontFamily, ";\n font-weight: ").concat(token.headingsFontWeight, ";\n line-height: ").concat(token.headingsLineHeight, ";\n}\nh1 small, h1 .small, .h1 small, .h1 .small,\nh2 small, h2 .small, .h2 small, .h2 .small,\nh3 small, h3 .small, .h3 small, .h3 .small,\nh4 small, h4 .small, .h4 small, .h4 .small,\nh5 small, h5 .small, .h5 small, .h5 .small,\nh6 small, h6 .small, .h6 small, .h6 .small {\n color: ").concat(token.headingsSmallColor, ";\n font-weight: normal;\n line-height: 1;\n}\n\nh1,\n.h1,\nh2,\n.h2,\nh3,\n.h3 {\n margin-top: ").concat(marginLarge, ";\n margin-bottom: ").concat(marginSmall, ";\n}\n\nh1 small, h1 .small, .h1 small, .h1 .small,\nh2 small, h2 .small, .h2 small, .h2 .small,\nh3 small, h3 .small, .h3 small, .h3 .small {\n font-size: 65%;\n}\n\nh4,\n.h4,\nh5,\n.h5,\nh6,\n.h6 {\n margin-top: ").concat(marginSmall, ";\n margin-bottom: ").concat(marginSmall, ";\n}\n\nh4 small, h4 .small, .h4 small, .h4 .small,\nh5 small, h5 .small, .h5 small, .h5 .small,\nh6 small, h6 .small, .h6 small, .h6 .small {\n font-size: 75%;\n}\n\np {\n margin: 0 0 ").concat(marginSmall, ";\n}");
|
|
36
33
|
var normalizeStyleId = exports.normalizeStyleId = 'shineout-next-normalize__' + _version.default;
|
|
37
34
|
var jssInsertionPointId = exports.jssInsertionPointId = 'shineout-next-jss-insertion-point__' + _version.default;
|
|
38
|
-
|
|
35
|
+
|
|
36
|
+
// 创建带标识的 style 节点,并插入到 head 最前面
|
|
37
|
+
function insertStyleElement(id, cssText) {
|
|
39
38
|
var style = document.createElement('style');
|
|
40
39
|
style.setAttribute('name', id);
|
|
41
40
|
style.setAttribute('data-alita-ignore', 'true');
|
|
42
|
-
style.
|
|
41
|
+
if (cssText !== undefined) style.textContent = cssText;
|
|
43
42
|
document.head.insertBefore(style, document.head.firstChild);
|
|
43
|
+
return style;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// 当前模块实例自己创建的 normalize 节点。
|
|
47
|
+
// 同一页面里多份 bundle(如嵌入插件与业务项目)版本相同时节点同名,不能按名字查找,否则可能误改对方的节点
|
|
48
|
+
var normalizeStyleElement = null;
|
|
49
|
+
function appendNormalizeStyle(styleString, id) {
|
|
50
|
+
normalizeStyleElement = insertStyleElement(id, styleString);
|
|
44
51
|
}
|
|
45
52
|
function appendJssInsertionPoint() {
|
|
46
|
-
var insertionPoint =
|
|
47
|
-
insertionPoint.setAttribute('name', jssInsertionPointId);
|
|
48
|
-
insertionPoint.setAttribute('data-alita-ignore', 'true');
|
|
49
|
-
document.head.insertBefore(insertionPoint, document.head.firstChild);
|
|
53
|
+
var insertionPoint = insertStyleElement(jssInsertionPointId);
|
|
50
54
|
_jssStyle.jss.setup({
|
|
51
55
|
insertionPoint: insertionPoint
|
|
52
56
|
});
|
|
@@ -55,37 +59,42 @@ if (typeof window !== 'undefined') {
|
|
|
55
59
|
appendJssInsertionPoint();
|
|
56
60
|
appendNormalizeStyle(normalizeStyle, normalizeStyleId);
|
|
57
61
|
}
|
|
62
|
+
|
|
63
|
+
// html / body 作为根选择器时替换为 prefix,其余选择器统一加前缀
|
|
64
|
+
var scopeSelector = function scopeSelector(selector, prefix) {
|
|
65
|
+
var trimmed = selector.trim();
|
|
66
|
+
var root = /^(html|body)(?![\w-])/.exec(trimmed);
|
|
67
|
+
return root ? prefix + trimmed.slice(root[0].length) : "".concat(prefix, " ").concat(trimmed);
|
|
68
|
+
};
|
|
58
69
|
var scopeNormalizeStyle = exports.scopeNormalizeStyle = function scopeNormalizeStyle() {
|
|
70
|
+
var _sourceElement$sheet, _styleElement$parentN;
|
|
59
71
|
var csScopePrefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '#app';
|
|
60
|
-
|
|
61
|
-
|
|
72
|
+
if (typeof document === 'undefined') return;
|
|
73
|
+
var styleElement = normalizeStyleElement;
|
|
74
|
+
if (!styleElement || !styleElement.isConnected) return;
|
|
62
75
|
|
|
63
|
-
|
|
64
|
-
var
|
|
65
|
-
|
|
76
|
+
// 始终基于原始 normalizeStyle 重新生成,而不是在已加过前缀的样式上再加一次,保证重复调用结果一致
|
|
77
|
+
var sourceElement = document.createElement('style');
|
|
78
|
+
sourceElement.textContent = normalizeStyle;
|
|
79
|
+
document.head.appendChild(sourceElement);
|
|
80
|
+
var cssRules = (_sourceElement$sheet = sourceElement.sheet) === null || _sourceElement$sheet === void 0 ? void 0 : _sourceElement$sheet.cssRules;
|
|
66
81
|
if (cssRules) {
|
|
67
82
|
for (var i = 0; i < cssRules.length; i++) {
|
|
68
83
|
var rule = cssRules[i];
|
|
69
84
|
if (rule instanceof CSSStyleRule) {
|
|
70
|
-
//
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
rule.selectorText = rule.selectorText.replace('html', csScopePrefix);
|
|
75
|
-
} else {
|
|
76
|
-
var selectors = rule.selectorText.split(',');
|
|
77
|
-
var newSelectors = selectors.map(function (selector) {
|
|
78
|
-
return "".concat(csScopePrefix, " ").concat(selector);
|
|
79
|
-
});
|
|
80
|
-
rule.selectorText = newSelectors.join(',');
|
|
81
|
-
}
|
|
85
|
+
// 逐个选择器处理,同一条规则里混有 html / body 与其他选择器时也都能正确加前缀
|
|
86
|
+
rule.selectorText = rule.selectorText.split(',').map(function (selector) {
|
|
87
|
+
return scopeSelector(selector, csScopePrefix);
|
|
88
|
+
}).join(',');
|
|
82
89
|
}
|
|
83
90
|
}
|
|
84
91
|
}
|
|
85
92
|
var scopedStyleString = cssRules ? Array.from(cssRules).map(function (rule) {
|
|
86
93
|
return rule.cssText;
|
|
87
94
|
}).join('') : '';
|
|
88
|
-
document.head.removeChild(
|
|
95
|
+
document.head.removeChild(sourceElement);
|
|
96
|
+
// 移除旧的 styleElement,用加了前缀的样式替换
|
|
97
|
+
(_styleElement$parentN = styleElement.parentNode) === null || _styleElement$parentN === void 0 || _styleElement$parentN.removeChild(styleElement);
|
|
89
98
|
appendNormalizeStyle(scopedStyleString, normalizeStyleId);
|
|
90
99
|
};
|
|
91
100
|
(0, _theme.setToken)({
|
package/cjs/version.d.ts
CHANGED
package/cjs/version.js
CHANGED
package/esm/normalize.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["normalize.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["normalize.ts"],"names":[],"mappings":"AA0BA,eAAO,MAAM,cAAc,QA6TzB,CAAC;AAEH,eAAO,MAAM,gBAAgB,QAAwC,CAAC;AACtE,eAAO,MAAM,mBAAmB,QAAkD,CAAC;AAqCnF,eAAO,MAAM,mBAAmB,kCAgC/B,CAAC"}
|
package/esm/normalize.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
// 4. Prevent adjustments of font size after orientation changes in IE on Windows Phone and in iOS.
|
|
5
|
-
// 5. Setting @viewport causes scrollbars to overlap content in IE11 and Edge, so
|
|
6
|
-
// we force a non-overlapping, non-auto-hiding scrollbar to counteract.
|
|
7
|
-
// 6. Change the default tap highlight to be completely transparent in iOS.
|
|
1
|
+
// 全局基础样式(normalize)与 jss 插入点。
|
|
2
|
+
// 引入本模块会产生副作用:在浏览器环境下向 document.head 最前面依次插入 normalize 样式和 jss 插入点,
|
|
3
|
+
// 并通过 setToken 向 html 注入主题 token。
|
|
8
4
|
import { CommonToken, setToken } from '@sheinx/theme';
|
|
9
5
|
import { jss } from "./jss-style";
|
|
10
6
|
import version from "./version";
|
|
@@ -12,7 +8,8 @@ var token = {
|
|
|
12
8
|
fontFamily: 'var(--common-body-font-family, PingFang SC, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Helvetica, Hiragino KaKu Gothic Pro, Microsoft YaHei, Arial, sans-serif )',
|
|
13
9
|
color: 'var(--common-body-color, #141737)',
|
|
14
10
|
fontSize: 'var(--font-size-base, 14px)',
|
|
15
|
-
|
|
11
|
+
// 变量名与 shineout 1.x / 2.x 保持一致
|
|
12
|
+
lineHeight: 'var(--common-line-height, 1.42857143)',
|
|
16
13
|
linkColor: CommonToken['Brand-6'],
|
|
17
14
|
linkHoverDecoration: 'none',
|
|
18
15
|
linkDisabledColor: CommonToken['Brand-3'],
|
|
@@ -22,23 +19,30 @@ var token = {
|
|
|
22
19
|
headingsLineHeight: '1.1',
|
|
23
20
|
headingsSmallColor: '#adb5bd'
|
|
24
21
|
};
|
|
25
|
-
var
|
|
26
|
-
var
|
|
27
|
-
export var normalizeStyle = "*,\n*::before,\n*::after {\n box-sizing: border-box;\n}\nhtml {\n font-family: sans-serif;\n line-height: 1.15;\n -ms-overflow-style: scrollbar;\n -webkit-tap-highlight-color: rgba(0, 0, 0, 0);\n -webkit-text-size-adjust: 100%;\n -ms-text-size-adjust: 100%;\n}\n\narticle,\naside,\ndialog,\nfigcaption,\nfigure,\nfooter,\nheader,\nhgroup,\nmain,\nnav,\nsection {\n display: block;\n}\n\nbody {\n margin: 0;\n color: ".concat(token.color, ";\n font-family: ").concat(token.fontFamily, ";\n font-size: ").concat(token.fontSize, ";\n line-height: ").concat(token.lineHeight, ";\n}\n\
|
|
22
|
+
var marginLarge = '20px';
|
|
23
|
+
var marginSmall = '10px';
|
|
24
|
+
export var normalizeStyle = "*,\n*::before,\n*::after {\n box-sizing: border-box;\n}\nhtml {\n font-family: sans-serif;\n line-height: 1.15;\n -ms-overflow-style: scrollbar;\n -webkit-tap-highlight-color: rgba(0, 0, 0, 0);\n -webkit-text-size-adjust: 100%;\n -ms-text-size-adjust: 100%;\n}\n\narticle,\naside,\ndialog,\nfigcaption,\nfigure,\nfooter,\nheader,\nhgroup,\nmain,\nnav,\nsection {\n display: block;\n}\n\nbody {\n margin: 0;\n color: ".concat(token.color, ";\n font-family: ").concat(token.fontFamily, ";\n font-size: ").concat(token.fontSize, ";\n line-height: ").concat(token.lineHeight, ";\n}\n\nh1 {\n margin: 0.67em 0;\n font-size: 2em;\n}\n\nfigure {\n margin: 1em 40px;\n}\n\nhr {\n overflow: visible;\n height: 0;\n box-sizing: content-box;\n}\n\npre {\n font-family: \"SFMono-Regular\", Menlo, Monaco, Consolas, \"Courier New\", monospace;\n font-size: 1em;\n}\n\na {\n background-color: transparent;\n color: ").concat(token.linkColor, ";\n cursor: pointer;\n outline: none;\n text-decoration: ").concat(token.linkHoverDecoration, ";\n -webkit-text-decoration-skip: objects;\n transition: color 0.3s;\n}\n\na:active,\na:hover {\n color: ").concat(token.linkColor, ";\n outline: 0;\n text-decoration: ").concat(token.linkHoverDecoration, ";\n}\na[disabled] {\n color: ").concat(token.linkDisabledColor, ";\n cursor: not-allowed;\n pointer-events: none;\n}\n\nabbr[title] {\n border-bottom: none;\n text-decoration: underline;\n text-decoration: underline dotted;\n}\n\nb,\nstrong {\n font-weight: bolder;\n}\n\ncode,\nkbd,\nsamp {\n font-family: monospace, monospace;\n font-size: 1em;\n}\n\ndfn {\n font-style: italic;\n}\n\nmark {\n background-color: #ff0;\n color: #000;\n}\n\nsmall {\n font-size: 80%;\n}\n\nsub,\nsup {\n position: relative;\n font-size: 75%;\n line-height: 0;\n vertical-align: baseline;\n}\n\nsub {\n bottom: -0.25em;\n}\n\nsup {\n top: -0.5em;\n}\n\naudio,\nvideo {\n display: inline-block;\n}\n\naudio:not([controls]) {\n display: none;\n height: 0;\n}\n\nimg {\n border-style: none;\n}\n\nsvg:not(:root) {\n overflow: hidden;\n}\n\nbutton,\ninput,\noptgroup,\nselect,\ntextarea {\n margin: 0;\n font-family: inherit;\n font-size: 100%;\n line-height: 1.15;\n}\n\nbutton,\ninput {\n overflow: visible;\n}\n\nbutton,\nselect {\n text-transform: none;\n}\n\nbutton,\nhtml [type='button'],\n[type='reset'],\n[type='submit'] {\n -webkit-appearance: button;\n}\n\nbutton::-moz-focus-inner,\n[type='button']::-moz-focus-inner,\n[type='reset']::-moz-focus-inner,\n[type='submit']::-moz-focus-inner {\n padding: 0;\n border-style: none;\n}\n\nbutton:-moz-focusring,\n[type='button']:-moz-focusring,\n[type='reset']:-moz-focusring,\n[type='submit']:-moz-focusring {\n outline: 1px dotted ButtonText;\n}\n\nfieldset {\n padding: 0.35em 0.75em 0.625em;\n}\n\nlegend {\n display: table;\n max-width: 100%;\n box-sizing: border-box;\n padding: 0;\n color: inherit;\n white-space: normal;\n}\n\nprogress {\n display: inline-block;\n vertical-align: baseline;\n}\n\ntextarea {\n overflow: auto;\n}\n\n[type='checkbox'],\n[type='radio'] {\n box-sizing: border-box;\n padding: 0;\n}\n\n[type='number']::-webkit-inner-spin-button,\n[type='number']::-webkit-outer-spin-button {\n height: auto;\n}\n\n[type='search'] {\n -webkit-appearance: textfield;\n outline-offset: -2px;\n}\n\n[type='search']::-webkit-search-cancel-button,\n[type='search']::-webkit-search-decoration {\n -webkit-appearance: none;\n}\n\n::-webkit-file-upload-button {\n -webkit-appearance: button;\n font: inherit;\n}\n\ndetails,\nmenu {\n display: block;\n}\n\nsummary {\n display: list-item;\n}\n\ncanvas {\n display: inline-block;\n}\n\ntemplate {\n display: none;\n}\n\n[hidden] {\n display: none;\n}\n\nh1,\nh2,\nh3,\nh4,\nh5,\nh6,\n.h1,\n.h2,\n.h3,\n.h4,\n.h5,\n.h6 {\n color: ").concat(token.headingsColor, ";\n font-family: ").concat(token.headingsFontFamily, ";\n font-weight: ").concat(token.headingsFontWeight, ";\n line-height: ").concat(token.headingsLineHeight, ";\n}\nh1 small, h1 .small, .h1 small, .h1 .small,\nh2 small, h2 .small, .h2 small, .h2 .small,\nh3 small, h3 .small, .h3 small, .h3 .small,\nh4 small, h4 .small, .h4 small, .h4 .small,\nh5 small, h5 .small, .h5 small, .h5 .small,\nh6 small, h6 .small, .h6 small, .h6 .small {\n color: ").concat(token.headingsSmallColor, ";\n font-weight: normal;\n line-height: 1;\n}\n\nh1,\n.h1,\nh2,\n.h2,\nh3,\n.h3 {\n margin-top: ").concat(marginLarge, ";\n margin-bottom: ").concat(marginSmall, ";\n}\n\nh1 small, h1 .small, .h1 small, .h1 .small,\nh2 small, h2 .small, .h2 small, .h2 .small,\nh3 small, h3 .small, .h3 small, .h3 .small {\n font-size: 65%;\n}\n\nh4,\n.h4,\nh5,\n.h5,\nh6,\n.h6 {\n margin-top: ").concat(marginSmall, ";\n margin-bottom: ").concat(marginSmall, ";\n}\n\nh4 small, h4 .small, .h4 small, .h4 .small,\nh5 small, h5 .small, .h5 small, .h5 .small,\nh6 small, h6 .small, .h6 small, .h6 .small {\n font-size: 75%;\n}\n\np {\n margin: 0 0 ").concat(marginSmall, ";\n}");
|
|
28
25
|
export var normalizeStyleId = 'shineout-next-normalize__' + version;
|
|
29
26
|
export var jssInsertionPointId = 'shineout-next-jss-insertion-point__' + version;
|
|
30
|
-
|
|
27
|
+
|
|
28
|
+
// 创建带标识的 style 节点,并插入到 head 最前面
|
|
29
|
+
function insertStyleElement(id, cssText) {
|
|
31
30
|
var style = document.createElement('style');
|
|
32
31
|
style.setAttribute('name', id);
|
|
33
32
|
style.setAttribute('data-alita-ignore', 'true');
|
|
34
|
-
style.
|
|
33
|
+
if (cssText !== undefined) style.textContent = cssText;
|
|
35
34
|
document.head.insertBefore(style, document.head.firstChild);
|
|
35
|
+
return style;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// 当前模块实例自己创建的 normalize 节点。
|
|
39
|
+
// 同一页面里多份 bundle(如嵌入插件与业务项目)版本相同时节点同名,不能按名字查找,否则可能误改对方的节点
|
|
40
|
+
var normalizeStyleElement = null;
|
|
41
|
+
function appendNormalizeStyle(styleString, id) {
|
|
42
|
+
normalizeStyleElement = insertStyleElement(id, styleString);
|
|
36
43
|
}
|
|
37
44
|
function appendJssInsertionPoint() {
|
|
38
|
-
var insertionPoint =
|
|
39
|
-
insertionPoint.setAttribute('name', jssInsertionPointId);
|
|
40
|
-
insertionPoint.setAttribute('data-alita-ignore', 'true');
|
|
41
|
-
document.head.insertBefore(insertionPoint, document.head.firstChild);
|
|
45
|
+
var insertionPoint = insertStyleElement(jssInsertionPointId);
|
|
42
46
|
jss.setup({
|
|
43
47
|
insertionPoint: insertionPoint
|
|
44
48
|
});
|
|
@@ -47,37 +51,42 @@ if (typeof window !== 'undefined') {
|
|
|
47
51
|
appendJssInsertionPoint();
|
|
48
52
|
appendNormalizeStyle(normalizeStyle, normalizeStyleId);
|
|
49
53
|
}
|
|
54
|
+
|
|
55
|
+
// html / body 作为根选择器时替换为 prefix,其余选择器统一加前缀
|
|
56
|
+
var scopeSelector = function scopeSelector(selector, prefix) {
|
|
57
|
+
var trimmed = selector.trim();
|
|
58
|
+
var root = /^(html|body)(?![\w-])/.exec(trimmed);
|
|
59
|
+
return root ? prefix + trimmed.slice(root[0].length) : "".concat(prefix, " ").concat(trimmed);
|
|
60
|
+
};
|
|
50
61
|
export var scopeNormalizeStyle = function scopeNormalizeStyle() {
|
|
62
|
+
var _sourceElement$sheet, _styleElement$parentN;
|
|
51
63
|
var csScopePrefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '#app';
|
|
52
|
-
|
|
53
|
-
|
|
64
|
+
if (typeof document === 'undefined') return;
|
|
65
|
+
var styleElement = normalizeStyleElement;
|
|
66
|
+
if (!styleElement || !styleElement.isConnected) return;
|
|
54
67
|
|
|
55
|
-
|
|
56
|
-
var
|
|
57
|
-
|
|
68
|
+
// 始终基于原始 normalizeStyle 重新生成,而不是在已加过前缀的样式上再加一次,保证重复调用结果一致
|
|
69
|
+
var sourceElement = document.createElement('style');
|
|
70
|
+
sourceElement.textContent = normalizeStyle;
|
|
71
|
+
document.head.appendChild(sourceElement);
|
|
72
|
+
var cssRules = (_sourceElement$sheet = sourceElement.sheet) === null || _sourceElement$sheet === void 0 ? void 0 : _sourceElement$sheet.cssRules;
|
|
58
73
|
if (cssRules) {
|
|
59
74
|
for (var i = 0; i < cssRules.length; i++) {
|
|
60
75
|
var rule = cssRules[i];
|
|
61
76
|
if (rule instanceof CSSStyleRule) {
|
|
62
|
-
//
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
rule.selectorText = rule.selectorText.replace('html', csScopePrefix);
|
|
67
|
-
} else {
|
|
68
|
-
var selectors = rule.selectorText.split(',');
|
|
69
|
-
var newSelectors = selectors.map(function (selector) {
|
|
70
|
-
return "".concat(csScopePrefix, " ").concat(selector);
|
|
71
|
-
});
|
|
72
|
-
rule.selectorText = newSelectors.join(',');
|
|
73
|
-
}
|
|
77
|
+
// 逐个选择器处理,同一条规则里混有 html / body 与其他选择器时也都能正确加前缀
|
|
78
|
+
rule.selectorText = rule.selectorText.split(',').map(function (selector) {
|
|
79
|
+
return scopeSelector(selector, csScopePrefix);
|
|
80
|
+
}).join(',');
|
|
74
81
|
}
|
|
75
82
|
}
|
|
76
83
|
}
|
|
77
84
|
var scopedStyleString = cssRules ? Array.from(cssRules).map(function (rule) {
|
|
78
85
|
return rule.cssText;
|
|
79
86
|
}).join('') : '';
|
|
80
|
-
document.head.removeChild(
|
|
87
|
+
document.head.removeChild(sourceElement);
|
|
88
|
+
// 移除旧的 styleElement,用加了前缀的样式替换
|
|
89
|
+
(_styleElement$parentN = styleElement.parentNode) === null || _styleElement$parentN === void 0 || _styleElement$parentN.removeChild(styleElement);
|
|
81
90
|
appendNormalizeStyle(scopedStyleString, normalizeStyleId);
|
|
82
91
|
};
|
|
83
92
|
setToken({
|
package/esm/version.d.ts
CHANGED
package/esm/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default '3.10.4-beta.
|
|
1
|
+
export default '3.10.4-beta.3';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sheinx/shineout-style",
|
|
3
|
-
"version": "3.10.4-beta.
|
|
3
|
+
"version": "3.10.4-beta.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "MIT",
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"jss": "10.9.2",
|
|
19
19
|
"react-jss": "10.9.2",
|
|
20
|
-
"@sheinx/theme": "3.10.4-beta.
|
|
21
|
-
"@sheinx/base": "3.10.4-beta.
|
|
20
|
+
"@sheinx/theme": "3.10.4-beta.3",
|
|
21
|
+
"@sheinx/base": "3.10.4-beta.3"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"core-js": ">=3"
|