inl-ui 0.1.13 → 0.1.16
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/README.md +49 -49
- package/dist/components/index.cjs +13 -2
- package/dist/components/index.d.ts +20 -1
- package/dist/components/index.js +14 -3
- package/dist/iconfont.js +69 -69
- package/dist/index.cjs +14 -3
- package/dist/index.d.ts +21 -2
- package/dist/index.js +15 -4
- package/dist/theme/index.js +70 -70
- package/dist/theme/scripts/dark-vars.js +21 -21
- package/dist/theme/scripts/default-vars.js +25 -25
- package/dist/theme/scripts/light-vars.js +22 -22
- package/dist/theme/style/color/bezierEasing.less +110 -110
- package/dist/theme/style/color/colorPalette.less +81 -81
- package/dist/theme/style/color/colors.less +162 -162
- package/dist/theme/style/color/tinyColor.less +1184 -1184
- package/dist/theme/style/compact.less +4 -4
- package/dist/theme/style/dark.less +4 -4
- package/dist/theme/style/default.less +4 -4
- package/dist/theme/style/index.less +2 -2
- package/dist/theme/style/index.tsx +2 -2
- package/dist/theme/style/themes/compact.less +295 -295
- package/dist/theme/style/themes/dark.less +790 -790
- package/dist/theme/style/themes/default.less +1067 -1067
- package/dist/theme/style/themes/index.less +7 -7
- package/dist/theme/style/themes/var-dark.less +343 -343
- package/dist/theme/style/themes/var-default.less +184 -184
- package/dist/theme/style/themes/variable.less +1122 -1122
- package/dist/theme/style/variable.less +4 -4
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -43,7 +43,7 @@ var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
|
|
|
43
43
|
var ___default = /*#__PURE__*/_interopDefaultLegacy(_);
|
|
44
44
|
var dayjs__default = /*#__PURE__*/_interopDefaultLegacy(dayjs);
|
|
45
45
|
|
|
46
|
-
var version = "0.1.
|
|
46
|
+
var version = "0.1.14";
|
|
47
47
|
|
|
48
48
|
const setTheme = theme => {
|
|
49
49
|
if (theme === "dark") {
|
|
@@ -12077,14 +12077,25 @@ const FontSelect = vue.defineComponent({
|
|
|
12077
12077
|
emits: ["update:value", "change"],
|
|
12078
12078
|
props: {
|
|
12079
12079
|
value: String,
|
|
12080
|
-
selectOptions: Object
|
|
12080
|
+
selectOptions: Object,
|
|
12081
|
+
suffix: {
|
|
12082
|
+
type: Array,
|
|
12083
|
+
default: () => []
|
|
12084
|
+
},
|
|
12085
|
+
prefix: {
|
|
12086
|
+
type: Array,
|
|
12087
|
+
default: () => []
|
|
12088
|
+
}
|
|
12081
12089
|
},
|
|
12082
12090
|
setup(props, {
|
|
12083
12091
|
emit
|
|
12084
12092
|
}) {
|
|
12085
12093
|
const modelValue = core.useVModel(props, "value", emit);
|
|
12094
|
+
const options = vue.computed(() => {
|
|
12095
|
+
return _.concat(props.prefix, fonts, props.suffix);
|
|
12096
|
+
});
|
|
12086
12097
|
return () => vue.createVNode(vue.resolveComponent("a-select"), vue.mergeProps({
|
|
12087
|
-
"options":
|
|
12098
|
+
"options": options.value,
|
|
12088
12099
|
"onChange": e => emit("change", e)
|
|
12089
12100
|
}, props.selectOptions, {
|
|
12090
12101
|
"value": modelValue.value,
|
package/dist/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { Key } from 'ant-design-vue/lib/table/interface';
|
|
|
11
11
|
import * as vue_jsx_runtime from 'vue/jsx-runtime';
|
|
12
12
|
import * as _ant_design_icons_vue_lib_components_IconFont from '@ant-design/icons-vue/lib/components/IconFont';
|
|
13
13
|
|
|
14
|
-
var version = "0.1.
|
|
14
|
+
var version = "0.1.14";
|
|
15
15
|
|
|
16
16
|
declare const _default$o: {
|
|
17
17
|
set(theme: string): void;
|
|
@@ -1725,13 +1725,32 @@ declare const getMenuDetail: () => vue.DefineComponent<{
|
|
|
1725
1725
|
declare const _default$2: vue.DefineComponent<{
|
|
1726
1726
|
value: StringConstructor;
|
|
1727
1727
|
selectOptions: ObjectConstructor;
|
|
1728
|
+
suffix: {
|
|
1729
|
+
type: ArrayConstructor;
|
|
1730
|
+
default: () => never[];
|
|
1731
|
+
};
|
|
1732
|
+
prefix: {
|
|
1733
|
+
type: ArrayConstructor;
|
|
1734
|
+
default: () => never[];
|
|
1735
|
+
};
|
|
1728
1736
|
}, () => vue_jsx_runtime.JSX.Element, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, ("change" | "update:value")[], "change" | "update:value", vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{
|
|
1729
1737
|
value: StringConstructor;
|
|
1730
1738
|
selectOptions: ObjectConstructor;
|
|
1739
|
+
suffix: {
|
|
1740
|
+
type: ArrayConstructor;
|
|
1741
|
+
default: () => never[];
|
|
1742
|
+
};
|
|
1743
|
+
prefix: {
|
|
1744
|
+
type: ArrayConstructor;
|
|
1745
|
+
default: () => never[];
|
|
1746
|
+
};
|
|
1731
1747
|
}>> & {
|
|
1732
1748
|
onChange?: ((...args: any[]) => any) | undefined;
|
|
1733
1749
|
"onUpdate:value"?: ((...args: any[]) => any) | undefined;
|
|
1734
|
-
}, {
|
|
1750
|
+
}, {
|
|
1751
|
+
prefix: unknown[];
|
|
1752
|
+
suffix: unknown[];
|
|
1753
|
+
}, {}>;
|
|
1735
1754
|
|
|
1736
1755
|
declare const _default$1: vue.DefineComponent<{
|
|
1737
1756
|
zxIp: {
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import renderWithQiankun, { qiankunWindow } from 'vite-plugin-qiankun/dist/helpe
|
|
|
3
3
|
import { defineComponent, createVNode, createApp, ref, watch, reactive, computed, onBeforeUnmount, inject, watchEffect, onActivated, onDeactivated, resolveComponent, isVNode, nextTick, Fragment, withDirectives, vShow, toRaw, provide, createTextVNode, onMounted, KeepAlive, shallowRef, onBeforeMount, mergeProps, onBeforeUpdate } from 'vue';
|
|
4
4
|
import axios from 'axios';
|
|
5
5
|
import { message, Menu, MenuItem, Input as Input$1, Badge, Avatar as Avatar$1, MenuDivider, Modal, SubMenu, Dropdown, Tooltip, Select, Layout as Layout$1, LayoutHeader, LayoutSider, LayoutContent, Form, Row, Col, FormItem, SelectOption, Switch, InputNumber } from 'ant-design-vue';
|
|
6
|
-
import _, { isPlainObject, omit, cloneDeep, differenceBy, isObject as isObject$1 } from 'lodash';
|
|
6
|
+
import _, { isPlainObject, omit, cloneDeep, differenceBy, isObject as isObject$1, concat } from 'lodash';
|
|
7
7
|
import { useIntervalFn, useEventBus, resolveRef, useEventListener, useMounted, useThrottleFn, useVModel, useMagicKeys, whenever, watchArray, useSessionStorage, useFullscreen, useLocalStorage, useToggle, useElementBounding, useMemory, useWindowSize, useClipboard, useBreakpoints, breakpointsAntDesign } from '@vueuse/core';
|
|
8
8
|
import dayjs from 'dayjs';
|
|
9
9
|
import { useRouter, useRoute } from 'vue-router';
|
|
@@ -13,7 +13,7 @@ import { XPopup, CommentBlock, setAxiosOption } from '@sszj-temp/mobile';
|
|
|
13
13
|
import { marked } from 'marked';
|
|
14
14
|
import '@sszj-temp/mobile/style.css';
|
|
15
15
|
|
|
16
|
-
var version = "0.1.
|
|
16
|
+
var version = "0.1.14";
|
|
17
17
|
|
|
18
18
|
const setTheme = theme => {
|
|
19
19
|
if (theme === "dark") {
|
|
@@ -12047,14 +12047,25 @@ const FontSelect = defineComponent({
|
|
|
12047
12047
|
emits: ["update:value", "change"],
|
|
12048
12048
|
props: {
|
|
12049
12049
|
value: String,
|
|
12050
|
-
selectOptions: Object
|
|
12050
|
+
selectOptions: Object,
|
|
12051
|
+
suffix: {
|
|
12052
|
+
type: Array,
|
|
12053
|
+
default: () => []
|
|
12054
|
+
},
|
|
12055
|
+
prefix: {
|
|
12056
|
+
type: Array,
|
|
12057
|
+
default: () => []
|
|
12058
|
+
}
|
|
12051
12059
|
},
|
|
12052
12060
|
setup(props, {
|
|
12053
12061
|
emit
|
|
12054
12062
|
}) {
|
|
12055
12063
|
const modelValue = useVModel(props, "value", emit);
|
|
12064
|
+
const options = computed(() => {
|
|
12065
|
+
return concat(props.prefix, fonts, props.suffix);
|
|
12066
|
+
});
|
|
12056
12067
|
return () => createVNode(resolveComponent("a-select"), mergeProps({
|
|
12057
|
-
"options":
|
|
12068
|
+
"options": options.value,
|
|
12058
12069
|
"onChange": e => emit("change", e)
|
|
12059
12070
|
}, props.selectOptions, {
|
|
12060
12071
|
"value": modelValue.value,
|
package/dist/theme/index.js
CHANGED
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
const less = require("less");
|
|
2
|
-
const defaultVars = require("./scripts/default-vars");
|
|
3
|
-
|
|
4
|
-
const dark = require("./scripts/dark-vars");
|
|
5
|
-
const light = require("./scripts/light-vars");
|
|
6
|
-
|
|
7
|
-
const path = require("path");
|
|
8
|
-
const varDark = path.join(__dirname, ".", "style");
|
|
9
|
-
const themeConfig = [
|
|
10
|
-
{
|
|
11
|
-
theme: "dark",
|
|
12
|
-
htmlThemeAttr: "dark",
|
|
13
|
-
modifyVars: {
|
|
14
|
-
hack: `true;@import "${require.resolve(
|
|
15
|
-
varDark + "/color/colorPalette.less"
|
|
16
|
-
)}";@import "${require.resolve(varDark + "/themes/var-dark.less")}";`,
|
|
17
|
-
...defaultVars,
|
|
18
|
-
...dark,
|
|
19
|
-
"root-entry-name": "dark",
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
theme: "light",
|
|
24
|
-
htmlThemeAttr: "light",
|
|
25
|
-
modifyVars: {
|
|
26
|
-
// 引入除了变量外的其他内容
|
|
27
|
-
hack: `true;@import "${require.resolve(
|
|
28
|
-
varDark + "/color/colorPalette.less"
|
|
29
|
-
)}";@import "${require.resolve(varDark + "/themes/var-default.less")}";`,
|
|
30
|
-
...defaultVars,
|
|
31
|
-
...light,
|
|
32
|
-
"root-entry-name": "default",
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
];
|
|
36
|
-
const additionalData = async (content, filename) => {
|
|
37
|
-
const themePromises = themeConfig.map(async (t) => {
|
|
38
|
-
const { htmlThemeAttr, modifyVars = {} } = t;
|
|
39
|
-
const options = {
|
|
40
|
-
javascriptEnabled: true,
|
|
41
|
-
modifyVars,
|
|
42
|
-
relativeUrls: true,
|
|
43
|
-
filename,
|
|
44
|
-
};
|
|
45
|
-
try {
|
|
46
|
-
const { css } = await less.render(content, options);
|
|
47
|
-
let res = "";
|
|
48
|
-
if (htmlThemeAttr && css) {
|
|
49
|
-
res = `
|
|
50
|
-
[data-doc-theme=${htmlThemeAttr}] {
|
|
51
|
-
${css}
|
|
52
|
-
}
|
|
53
|
-
`;
|
|
54
|
-
}
|
|
55
|
-
return Promise.resolve(res);
|
|
56
|
-
} catch (error) {
|
|
57
|
-
// eslint-disable-next-line no-console
|
|
58
|
-
console.log(error);
|
|
59
|
-
return Promise.reject(content);
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
let res = content;
|
|
63
|
-
for (const themePromise of themePromises) {
|
|
64
|
-
const theme = await themePromise;
|
|
65
|
-
res += theme;
|
|
66
|
-
}
|
|
67
|
-
return res;
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
exports.default = additionalData;
|
|
1
|
+
const less = require("less");
|
|
2
|
+
const defaultVars = require("./scripts/default-vars");
|
|
3
|
+
|
|
4
|
+
const dark = require("./scripts/dark-vars");
|
|
5
|
+
const light = require("./scripts/light-vars");
|
|
6
|
+
|
|
7
|
+
const path = require("path");
|
|
8
|
+
const varDark = path.join(__dirname, ".", "style");
|
|
9
|
+
const themeConfig = [
|
|
10
|
+
{
|
|
11
|
+
theme: "dark",
|
|
12
|
+
htmlThemeAttr: "dark",
|
|
13
|
+
modifyVars: {
|
|
14
|
+
hack: `true;@import "${require.resolve(
|
|
15
|
+
varDark + "/color/colorPalette.less"
|
|
16
|
+
)}";@import "${require.resolve(varDark + "/themes/var-dark.less")}";`,
|
|
17
|
+
...defaultVars,
|
|
18
|
+
...dark,
|
|
19
|
+
"root-entry-name": "dark",
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
theme: "light",
|
|
24
|
+
htmlThemeAttr: "light",
|
|
25
|
+
modifyVars: {
|
|
26
|
+
// 引入除了变量外的其他内容
|
|
27
|
+
hack: `true;@import "${require.resolve(
|
|
28
|
+
varDark + "/color/colorPalette.less"
|
|
29
|
+
)}";@import "${require.resolve(varDark + "/themes/var-default.less")}";`,
|
|
30
|
+
...defaultVars,
|
|
31
|
+
...light,
|
|
32
|
+
"root-entry-name": "default",
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
];
|
|
36
|
+
const additionalData = async (content, filename) => {
|
|
37
|
+
const themePromises = themeConfig.map(async (t) => {
|
|
38
|
+
const { htmlThemeAttr, modifyVars = {} } = t;
|
|
39
|
+
const options = {
|
|
40
|
+
javascriptEnabled: true,
|
|
41
|
+
modifyVars,
|
|
42
|
+
relativeUrls: true,
|
|
43
|
+
filename,
|
|
44
|
+
};
|
|
45
|
+
try {
|
|
46
|
+
const { css } = await less.render(content, options);
|
|
47
|
+
let res = "";
|
|
48
|
+
if (htmlThemeAttr && css) {
|
|
49
|
+
res = `
|
|
50
|
+
[data-doc-theme=${htmlThemeAttr}] {
|
|
51
|
+
${css}
|
|
52
|
+
}
|
|
53
|
+
`;
|
|
54
|
+
}
|
|
55
|
+
return Promise.resolve(res);
|
|
56
|
+
} catch (error) {
|
|
57
|
+
// eslint-disable-next-line no-console
|
|
58
|
+
console.log(error);
|
|
59
|
+
return Promise.reject(content);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
let res = content;
|
|
63
|
+
for (const themePromise of themePromises) {
|
|
64
|
+
const theme = await themePromise;
|
|
65
|
+
res += theme;
|
|
66
|
+
}
|
|
67
|
+
return res;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
exports.default = additionalData;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* convert dark.less into js vars
|
|
3
|
-
*
|
|
4
|
-
* const darkVars = require('./dark-vars');
|
|
5
|
-
*/
|
|
6
|
-
const fs = require("fs");
|
|
7
|
-
const path = require("path");
|
|
8
|
-
const lessToJs = require("less-vars-to-js");
|
|
9
|
-
|
|
10
|
-
const stylePath = path.join(__dirname, "..", "style");
|
|
11
|
-
const darkLess = fs.readFileSync(
|
|
12
|
-
path.join(stylePath, "themes", "var-dark.less"),
|
|
13
|
-
"utf8"
|
|
14
|
-
);
|
|
15
|
-
|
|
16
|
-
const darkPaletteLess = lessToJs(darkLess, {
|
|
17
|
-
stripPrefix: true,
|
|
18
|
-
resolveVariables: false,
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
module.exports = darkPaletteLess;
|
|
1
|
+
/**
|
|
2
|
+
* convert dark.less into js vars
|
|
3
|
+
*
|
|
4
|
+
* const darkVars = require('./dark-vars');
|
|
5
|
+
*/
|
|
6
|
+
const fs = require("fs");
|
|
7
|
+
const path = require("path");
|
|
8
|
+
const lessToJs = require("less-vars-to-js");
|
|
9
|
+
|
|
10
|
+
const stylePath = path.join(__dirname, "..", "style");
|
|
11
|
+
const darkLess = fs.readFileSync(
|
|
12
|
+
path.join(stylePath, "themes", "var-dark.less"),
|
|
13
|
+
"utf8"
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
const darkPaletteLess = lessToJs(darkLess, {
|
|
17
|
+
stripPrefix: true,
|
|
18
|
+
resolveVariables: false,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
module.exports = darkPaletteLess;
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* convert default.less into js vars
|
|
3
|
-
*
|
|
4
|
-
* const darkVars = require('./default-vars');
|
|
5
|
-
*/
|
|
6
|
-
const fs = require("fs");
|
|
7
|
-
const path = require("path");
|
|
8
|
-
const lessToJs = require("less-vars-to-js");
|
|
9
|
-
|
|
10
|
-
const stylePath = path.join(__dirname, "..", "style");
|
|
11
|
-
const colorLess = fs.readFileSync(
|
|
12
|
-
path.join(stylePath, "color", "colors.less"),
|
|
13
|
-
"utf8"
|
|
14
|
-
);
|
|
15
|
-
const defaultLess = fs.readFileSync(
|
|
16
|
-
path.join(stylePath, "themes", "default.less"),
|
|
17
|
-
"utf8"
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
const defaultPaletteLess = lessToJs(`${colorLess}${defaultLess}`, {
|
|
21
|
-
stripPrefix: true,
|
|
22
|
-
resolveVariables: false,
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
module.exports = defaultPaletteLess;
|
|
1
|
+
/**
|
|
2
|
+
* convert default.less into js vars
|
|
3
|
+
*
|
|
4
|
+
* const darkVars = require('./default-vars');
|
|
5
|
+
*/
|
|
6
|
+
const fs = require("fs");
|
|
7
|
+
const path = require("path");
|
|
8
|
+
const lessToJs = require("less-vars-to-js");
|
|
9
|
+
|
|
10
|
+
const stylePath = path.join(__dirname, "..", "style");
|
|
11
|
+
const colorLess = fs.readFileSync(
|
|
12
|
+
path.join(stylePath, "color", "colors.less"),
|
|
13
|
+
"utf8"
|
|
14
|
+
);
|
|
15
|
+
const defaultLess = fs.readFileSync(
|
|
16
|
+
path.join(stylePath, "themes", "default.less"),
|
|
17
|
+
"utf8"
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
const defaultPaletteLess = lessToJs(`${colorLess}${defaultLess}`, {
|
|
21
|
+
stripPrefix: true,
|
|
22
|
+
resolveVariables: false,
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
module.exports = defaultPaletteLess;
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* convert dark.less into js vars
|
|
3
|
-
*
|
|
4
|
-
* const darkVars = require('./dark-vars');
|
|
5
|
-
*/
|
|
6
|
-
const fs = require("fs");
|
|
7
|
-
const path = require("path");
|
|
8
|
-
const lessToJs = require("less-vars-to-js");
|
|
9
|
-
|
|
10
|
-
const stylePath = path.join(__dirname, "..", "style");
|
|
11
|
-
const lightLess = fs.readFileSync(
|
|
12
|
-
path.join(stylePath, "themes", "var-default.less"),
|
|
13
|
-
"utf8"
|
|
14
|
-
);
|
|
15
|
-
|
|
16
|
-
// 注册变量,过滤其他内容
|
|
17
|
-
const lightPaletteLess = lessToJs(lightLess, {
|
|
18
|
-
stripPrefix: true,
|
|
19
|
-
resolveVariables: false,
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
module.exports = lightPaletteLess;
|
|
1
|
+
/**
|
|
2
|
+
* convert dark.less into js vars
|
|
3
|
+
*
|
|
4
|
+
* const darkVars = require('./dark-vars');
|
|
5
|
+
*/
|
|
6
|
+
const fs = require("fs");
|
|
7
|
+
const path = require("path");
|
|
8
|
+
const lessToJs = require("less-vars-to-js");
|
|
9
|
+
|
|
10
|
+
const stylePath = path.join(__dirname, "..", "style");
|
|
11
|
+
const lightLess = fs.readFileSync(
|
|
12
|
+
path.join(stylePath, "themes", "var-default.less"),
|
|
13
|
+
"utf8"
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
// 注册变量,过滤其他内容
|
|
17
|
+
const lightPaletteLess = lessToJs(lightLess, {
|
|
18
|
+
stripPrefix: true,
|
|
19
|
+
resolveVariables: false,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
module.exports = lightPaletteLess;
|
|
@@ -1,110 +1,110 @@
|
|
|
1
|
-
/* stylelint-disable */
|
|
2
|
-
.bezierEasingMixin() {
|
|
3
|
-
@functions: ~`(function() {
|
|
4
|
-
var NEWTON_ITERATIONS = 4;
|
|
5
|
-
var NEWTON_MIN_SLOPE = 0.001;
|
|
6
|
-
var SUBDIVISION_PRECISION = 0.0000001;
|
|
7
|
-
var SUBDIVISION_MAX_ITERATIONS = 10;
|
|
8
|
-
|
|
9
|
-
var kSplineTableSize = 11;
|
|
10
|
-
var kSampleStepSize = 1.0 / (kSplineTableSize - 1.0);
|
|
11
|
-
|
|
12
|
-
var float32ArraySupported = typeof Float32Array === 'function';
|
|
13
|
-
|
|
14
|
-
function A (aA1, aA2) { return 1.0 - 3.0 * aA2 + 3.0 * aA1; }
|
|
15
|
-
function B (aA1, aA2) { return 3.0 * aA2 - 6.0 * aA1; }
|
|
16
|
-
function C (aA1) { return 3.0 * aA1; }
|
|
17
|
-
|
|
18
|
-
// Returns x(t) given t, x1, and x2, or y(t) given t, y1, and y2.
|
|
19
|
-
function calcBezier (aT, aA1, aA2) { return ((A(aA1, aA2) * aT + B(aA1, aA2)) * aT + C(aA1)) * aT; }
|
|
20
|
-
|
|
21
|
-
// Returns dx/dt given t, x1, and x2, or dy/dt given t, y1, and y2.
|
|
22
|
-
function getSlope (aT, aA1, aA2) { return 3.0 * A(aA1, aA2) * aT * aT + 2.0 * B(aA1, aA2) * aT + C(aA1); }
|
|
23
|
-
|
|
24
|
-
function binarySubdivide (aX, aA, aB, mX1, mX2) {
|
|
25
|
-
var currentX, currentT, i = 0;
|
|
26
|
-
do {
|
|
27
|
-
currentT = aA + (aB - aA) / 2.0;
|
|
28
|
-
currentX = calcBezier(currentT, mX1, mX2) - aX;
|
|
29
|
-
if (currentX > 0.0) {
|
|
30
|
-
aB = currentT;
|
|
31
|
-
} else {
|
|
32
|
-
aA = currentT;
|
|
33
|
-
}
|
|
34
|
-
} while (Math.abs(currentX) > SUBDIVISION_PRECISION && ++i < SUBDIVISION_MAX_ITERATIONS);
|
|
35
|
-
return currentT;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function newtonRaphsonIterate (aX, aGuessT, mX1, mX2) {
|
|
39
|
-
for (var i = 0; i < NEWTON_ITERATIONS; ++i) {
|
|
40
|
-
var currentSlope = getSlope(aGuessT, mX1, mX2);
|
|
41
|
-
if (currentSlope === 0.0) {
|
|
42
|
-
return aGuessT;
|
|
43
|
-
}
|
|
44
|
-
var currentX = calcBezier(aGuessT, mX1, mX2) - aX;
|
|
45
|
-
aGuessT -= currentX / currentSlope;
|
|
46
|
-
}
|
|
47
|
-
return aGuessT;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
var BezierEasing = function (mX1, mY1, mX2, mY2) {
|
|
51
|
-
if (!(0 <= mX1 && mX1 <= 1 && 0 <= mX2 && mX2 <= 1)) {
|
|
52
|
-
throw new Error('bezier x values must be in [0, 1] range');
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// Precompute samples table
|
|
56
|
-
var sampleValues = float32ArraySupported ? new Float32Array(kSplineTableSize) : new Array(kSplineTableSize);
|
|
57
|
-
if (mX1 !== mY1 || mX2 !== mY2) {
|
|
58
|
-
for (var i = 0; i < kSplineTableSize; ++i) {
|
|
59
|
-
sampleValues[i] = calcBezier(i * kSampleStepSize, mX1, mX2);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function getTForX (aX) {
|
|
64
|
-
var intervalStart = 0.0;
|
|
65
|
-
var currentSample = 1;
|
|
66
|
-
var lastSample = kSplineTableSize - 1;
|
|
67
|
-
|
|
68
|
-
for (; currentSample !== lastSample && sampleValues[currentSample] <= aX; ++currentSample) {
|
|
69
|
-
intervalStart += kSampleStepSize;
|
|
70
|
-
}
|
|
71
|
-
--currentSample;
|
|
72
|
-
|
|
73
|
-
// Interpolate to provide an initial guess for t
|
|
74
|
-
var dist = (aX - sampleValues[currentSample]) / (sampleValues[currentSample + 1] - sampleValues[currentSample]);
|
|
75
|
-
var guessForT = intervalStart + dist * kSampleStepSize;
|
|
76
|
-
|
|
77
|
-
var initialSlope = getSlope(guessForT, mX1, mX2);
|
|
78
|
-
if (initialSlope >= NEWTON_MIN_SLOPE) {
|
|
79
|
-
return newtonRaphsonIterate(aX, guessForT, mX1, mX2);
|
|
80
|
-
} else if (initialSlope === 0.0) {
|
|
81
|
-
return guessForT;
|
|
82
|
-
} else {
|
|
83
|
-
return binarySubdivide(aX, intervalStart, intervalStart + kSampleStepSize, mX1, mX2);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
return function BezierEasing (x) {
|
|
88
|
-
if (mX1 === mY1 && mX2 === mY2) {
|
|
89
|
-
return x; // linear
|
|
90
|
-
}
|
|
91
|
-
// Because JavaScript number are imprecise, we should guarantee the extremes are right.
|
|
92
|
-
if (x === 0) {
|
|
93
|
-
return 0;
|
|
94
|
-
}
|
|
95
|
-
if (x === 1) {
|
|
96
|
-
return 1;
|
|
97
|
-
}
|
|
98
|
-
return calcBezier(getTForX(x), mY1, mY2);
|
|
99
|
-
};
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
this.colorEasing = BezierEasing(0.26, 0.09, 0.37, 0.18);
|
|
103
|
-
// less 3 requires a return
|
|
104
|
-
return '';
|
|
105
|
-
})()`;
|
|
106
|
-
}
|
|
107
|
-
// It is hacky way to make this function will be compiled preferentially by less
|
|
108
|
-
// resolve error: `ReferenceError: colorPalette is not defined`
|
|
109
|
-
// https://github.com/ant-design/ant-motion/issues/44
|
|
110
|
-
.bezierEasingMixin();
|
|
1
|
+
/* stylelint-disable */
|
|
2
|
+
.bezierEasingMixin() {
|
|
3
|
+
@functions: ~`(function() {
|
|
4
|
+
var NEWTON_ITERATIONS = 4;
|
|
5
|
+
var NEWTON_MIN_SLOPE = 0.001;
|
|
6
|
+
var SUBDIVISION_PRECISION = 0.0000001;
|
|
7
|
+
var SUBDIVISION_MAX_ITERATIONS = 10;
|
|
8
|
+
|
|
9
|
+
var kSplineTableSize = 11;
|
|
10
|
+
var kSampleStepSize = 1.0 / (kSplineTableSize - 1.0);
|
|
11
|
+
|
|
12
|
+
var float32ArraySupported = typeof Float32Array === 'function';
|
|
13
|
+
|
|
14
|
+
function A (aA1, aA2) { return 1.0 - 3.0 * aA2 + 3.0 * aA1; }
|
|
15
|
+
function B (aA1, aA2) { return 3.0 * aA2 - 6.0 * aA1; }
|
|
16
|
+
function C (aA1) { return 3.0 * aA1; }
|
|
17
|
+
|
|
18
|
+
// Returns x(t) given t, x1, and x2, or y(t) given t, y1, and y2.
|
|
19
|
+
function calcBezier (aT, aA1, aA2) { return ((A(aA1, aA2) * aT + B(aA1, aA2)) * aT + C(aA1)) * aT; }
|
|
20
|
+
|
|
21
|
+
// Returns dx/dt given t, x1, and x2, or dy/dt given t, y1, and y2.
|
|
22
|
+
function getSlope (aT, aA1, aA2) { return 3.0 * A(aA1, aA2) * aT * aT + 2.0 * B(aA1, aA2) * aT + C(aA1); }
|
|
23
|
+
|
|
24
|
+
function binarySubdivide (aX, aA, aB, mX1, mX2) {
|
|
25
|
+
var currentX, currentT, i = 0;
|
|
26
|
+
do {
|
|
27
|
+
currentT = aA + (aB - aA) / 2.0;
|
|
28
|
+
currentX = calcBezier(currentT, mX1, mX2) - aX;
|
|
29
|
+
if (currentX > 0.0) {
|
|
30
|
+
aB = currentT;
|
|
31
|
+
} else {
|
|
32
|
+
aA = currentT;
|
|
33
|
+
}
|
|
34
|
+
} while (Math.abs(currentX) > SUBDIVISION_PRECISION && ++i < SUBDIVISION_MAX_ITERATIONS);
|
|
35
|
+
return currentT;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function newtonRaphsonIterate (aX, aGuessT, mX1, mX2) {
|
|
39
|
+
for (var i = 0; i < NEWTON_ITERATIONS; ++i) {
|
|
40
|
+
var currentSlope = getSlope(aGuessT, mX1, mX2);
|
|
41
|
+
if (currentSlope === 0.0) {
|
|
42
|
+
return aGuessT;
|
|
43
|
+
}
|
|
44
|
+
var currentX = calcBezier(aGuessT, mX1, mX2) - aX;
|
|
45
|
+
aGuessT -= currentX / currentSlope;
|
|
46
|
+
}
|
|
47
|
+
return aGuessT;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
var BezierEasing = function (mX1, mY1, mX2, mY2) {
|
|
51
|
+
if (!(0 <= mX1 && mX1 <= 1 && 0 <= mX2 && mX2 <= 1)) {
|
|
52
|
+
throw new Error('bezier x values must be in [0, 1] range');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Precompute samples table
|
|
56
|
+
var sampleValues = float32ArraySupported ? new Float32Array(kSplineTableSize) : new Array(kSplineTableSize);
|
|
57
|
+
if (mX1 !== mY1 || mX2 !== mY2) {
|
|
58
|
+
for (var i = 0; i < kSplineTableSize; ++i) {
|
|
59
|
+
sampleValues[i] = calcBezier(i * kSampleStepSize, mX1, mX2);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function getTForX (aX) {
|
|
64
|
+
var intervalStart = 0.0;
|
|
65
|
+
var currentSample = 1;
|
|
66
|
+
var lastSample = kSplineTableSize - 1;
|
|
67
|
+
|
|
68
|
+
for (; currentSample !== lastSample && sampleValues[currentSample] <= aX; ++currentSample) {
|
|
69
|
+
intervalStart += kSampleStepSize;
|
|
70
|
+
}
|
|
71
|
+
--currentSample;
|
|
72
|
+
|
|
73
|
+
// Interpolate to provide an initial guess for t
|
|
74
|
+
var dist = (aX - sampleValues[currentSample]) / (sampleValues[currentSample + 1] - sampleValues[currentSample]);
|
|
75
|
+
var guessForT = intervalStart + dist * kSampleStepSize;
|
|
76
|
+
|
|
77
|
+
var initialSlope = getSlope(guessForT, mX1, mX2);
|
|
78
|
+
if (initialSlope >= NEWTON_MIN_SLOPE) {
|
|
79
|
+
return newtonRaphsonIterate(aX, guessForT, mX1, mX2);
|
|
80
|
+
} else if (initialSlope === 0.0) {
|
|
81
|
+
return guessForT;
|
|
82
|
+
} else {
|
|
83
|
+
return binarySubdivide(aX, intervalStart, intervalStart + kSampleStepSize, mX1, mX2);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return function BezierEasing (x) {
|
|
88
|
+
if (mX1 === mY1 && mX2 === mY2) {
|
|
89
|
+
return x; // linear
|
|
90
|
+
}
|
|
91
|
+
// Because JavaScript number are imprecise, we should guarantee the extremes are right.
|
|
92
|
+
if (x === 0) {
|
|
93
|
+
return 0;
|
|
94
|
+
}
|
|
95
|
+
if (x === 1) {
|
|
96
|
+
return 1;
|
|
97
|
+
}
|
|
98
|
+
return calcBezier(getTForX(x), mY1, mY2);
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
this.colorEasing = BezierEasing(0.26, 0.09, 0.37, 0.18);
|
|
103
|
+
// less 3 requires a return
|
|
104
|
+
return '';
|
|
105
|
+
})()`;
|
|
106
|
+
}
|
|
107
|
+
// It is hacky way to make this function will be compiled preferentially by less
|
|
108
|
+
// resolve error: `ReferenceError: colorPalette is not defined`
|
|
109
|
+
// https://github.com/ant-design/ant-motion/issues/44
|
|
110
|
+
.bezierEasingMixin();
|