@maple-design/preset-unocss-vue 0.0.0-stage → 1.1.1
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/lib/index.cjs +140 -0
- package/lib/index.d.cts +30 -0
- package/lib/index.d.ts +30 -0
- package/lib/index.js +118 -0
- package/package.json +49 -3
- package/README.md +0 -3
package/lib/index.cjs
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
+
var __spreadValues = (a, b) => {
|
|
10
|
+
for (var prop in b || (b = {}))
|
|
11
|
+
if (__hasOwnProp.call(b, prop))
|
|
12
|
+
__defNormalProp(a, prop, b[prop]);
|
|
13
|
+
if (__getOwnPropSymbols)
|
|
14
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
15
|
+
if (__propIsEnum.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
}
|
|
18
|
+
return a;
|
|
19
|
+
};
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
var __export = (target, all) => {
|
|
33
|
+
for (var name in all)
|
|
34
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
35
|
+
};
|
|
36
|
+
var __copyProps = (to, from, except, desc) => {
|
|
37
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
38
|
+
for (let key of __getOwnPropNames(from))
|
|
39
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
40
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
41
|
+
}
|
|
42
|
+
return to;
|
|
43
|
+
};
|
|
44
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
45
|
+
|
|
46
|
+
// src/index.ts
|
|
47
|
+
var src_exports = {};
|
|
48
|
+
__export(src_exports, {
|
|
49
|
+
presetMaple: () => presetMaple
|
|
50
|
+
});
|
|
51
|
+
module.exports = __toCommonJS(src_exports);
|
|
52
|
+
var import_unocss = require("unocss");
|
|
53
|
+
function getSpacing() {
|
|
54
|
+
return Object.fromEntries(Array.from({ length: 201 }, (_, value) => [String(value), `${value}px`]));
|
|
55
|
+
}
|
|
56
|
+
function getBreakpoints(options = {}) {
|
|
57
|
+
const { breakpoints = true } = options;
|
|
58
|
+
if (!breakpoints) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const defaults = { sm: "768px", md: "992px", lg: "1200px", xl: "1920px" };
|
|
62
|
+
return breakpoints === true ? defaults : __spreadValues(__spreadValues({}, defaults), breakpoints);
|
|
63
|
+
}
|
|
64
|
+
function getFontSize(options = {}) {
|
|
65
|
+
const { fontSize = true } = options;
|
|
66
|
+
if (!fontSize) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
const defaults = {
|
|
70
|
+
xs: "var(--mp-font-size-xs)",
|
|
71
|
+
sm: "var(--mp-font-size-sm)",
|
|
72
|
+
md: "var(--mp-font-size-md)",
|
|
73
|
+
lg: "var(--mp-font-size-lg)"
|
|
74
|
+
};
|
|
75
|
+
return fontSize === true ? defaults : __spreadValues(__spreadValues({}, defaults), fontSize);
|
|
76
|
+
}
|
|
77
|
+
function getColors(options = {}) {
|
|
78
|
+
const { colors = true } = options;
|
|
79
|
+
if (!colors) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const defaults = {
|
|
83
|
+
primary: "var(--mp-color-primary)",
|
|
84
|
+
info: "var(--mp-color-info)",
|
|
85
|
+
warning: "var(--mp-color-warning)",
|
|
86
|
+
danger: "var(--mp-color-danger)",
|
|
87
|
+
success: "var(--mp-color-success)"
|
|
88
|
+
};
|
|
89
|
+
if (colors === true) {
|
|
90
|
+
return defaults;
|
|
91
|
+
}
|
|
92
|
+
const _a = colors, { body: _body, disabled: _disabled } = _a, customColors = __objRest(_a, ["body", "disabled"]);
|
|
93
|
+
return __spreadValues(__spreadValues({}, defaults), customColors);
|
|
94
|
+
}
|
|
95
|
+
function getDisabled(options = {}) {
|
|
96
|
+
var _a;
|
|
97
|
+
const { colors = true } = options;
|
|
98
|
+
if (!colors) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
return colors === true ? "var(--mp-color-disabled)" : (_a = colors.disabled) != null ? _a : "var(--mp-color-disabled)";
|
|
102
|
+
}
|
|
103
|
+
function getBody(options = {}) {
|
|
104
|
+
var _a;
|
|
105
|
+
const { colors = true } = options;
|
|
106
|
+
if (!colors) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
return colors === true ? "var(--mp-color-body)" : (_a = colors.body) != null ? _a : "var(--mp-color-body)";
|
|
110
|
+
}
|
|
111
|
+
function presetMaple(options = {}) {
|
|
112
|
+
const body = getBody(options);
|
|
113
|
+
const disabled = getDisabled(options);
|
|
114
|
+
const rules = [];
|
|
115
|
+
if (body) {
|
|
116
|
+
rules.push(["mp-bg-body", { "background-color": body }]);
|
|
117
|
+
}
|
|
118
|
+
if (disabled) {
|
|
119
|
+
rules.push(["mp-bg-disabled", { "background-color": disabled }]);
|
|
120
|
+
rules.push(["mp-text-disabled", { color: disabled }]);
|
|
121
|
+
}
|
|
122
|
+
return [
|
|
123
|
+
(0, import_unocss.presetUno)({ prefix: "mp-" }),
|
|
124
|
+
{
|
|
125
|
+
name: "@maple-design/preset-unocss-vue",
|
|
126
|
+
blocklist: [/^(?:[\w-]+:)*mp-shadow(?:-.+)?$/],
|
|
127
|
+
theme: {
|
|
128
|
+
colors: getColors(options),
|
|
129
|
+
fontSize: getFontSize(options),
|
|
130
|
+
breakpoints: getBreakpoints(options),
|
|
131
|
+
spacing: getSpacing()
|
|
132
|
+
},
|
|
133
|
+
rules
|
|
134
|
+
}
|
|
135
|
+
];
|
|
136
|
+
}
|
|
137
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
138
|
+
0 && (module.exports = {
|
|
139
|
+
presetMaple
|
|
140
|
+
});
|
package/lib/index.d.cts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Preset } from 'unocss';
|
|
2
|
+
|
|
3
|
+
interface PresetMapleOptions {
|
|
4
|
+
breakpoints?: boolean | {
|
|
5
|
+
sm?: string | number;
|
|
6
|
+
md?: string | number;
|
|
7
|
+
lg?: string | number;
|
|
8
|
+
xl?: string | number;
|
|
9
|
+
};
|
|
10
|
+
fontSize?: boolean | PresetMapleFontSize;
|
|
11
|
+
colors?: boolean | PresetMapleColors;
|
|
12
|
+
}
|
|
13
|
+
interface PresetMapleFontSize {
|
|
14
|
+
xs?: string;
|
|
15
|
+
sm?: string;
|
|
16
|
+
md?: string;
|
|
17
|
+
lg?: string;
|
|
18
|
+
}
|
|
19
|
+
interface PresetMapleColors {
|
|
20
|
+
body?: string;
|
|
21
|
+
primary?: string;
|
|
22
|
+
info?: string;
|
|
23
|
+
warning?: string;
|
|
24
|
+
danger?: string;
|
|
25
|
+
success?: string;
|
|
26
|
+
disabled?: string;
|
|
27
|
+
}
|
|
28
|
+
declare function presetMaple(options?: PresetMapleOptions): Preset[];
|
|
29
|
+
|
|
30
|
+
export { PresetMapleColors, PresetMapleFontSize, PresetMapleOptions, presetMaple };
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Preset } from 'unocss';
|
|
2
|
+
|
|
3
|
+
interface PresetMapleOptions {
|
|
4
|
+
breakpoints?: boolean | {
|
|
5
|
+
sm?: string | number;
|
|
6
|
+
md?: string | number;
|
|
7
|
+
lg?: string | number;
|
|
8
|
+
xl?: string | number;
|
|
9
|
+
};
|
|
10
|
+
fontSize?: boolean | PresetMapleFontSize;
|
|
11
|
+
colors?: boolean | PresetMapleColors;
|
|
12
|
+
}
|
|
13
|
+
interface PresetMapleFontSize {
|
|
14
|
+
xs?: string;
|
|
15
|
+
sm?: string;
|
|
16
|
+
md?: string;
|
|
17
|
+
lg?: string;
|
|
18
|
+
}
|
|
19
|
+
interface PresetMapleColors {
|
|
20
|
+
body?: string;
|
|
21
|
+
primary?: string;
|
|
22
|
+
info?: string;
|
|
23
|
+
warning?: string;
|
|
24
|
+
danger?: string;
|
|
25
|
+
success?: string;
|
|
26
|
+
disabled?: string;
|
|
27
|
+
}
|
|
28
|
+
declare function presetMaple(options?: PresetMapleOptions): Preset[];
|
|
29
|
+
|
|
30
|
+
export { PresetMapleColors, PresetMapleFontSize, PresetMapleOptions, presetMaple };
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
var __objRest = (source, exclude) => {
|
|
18
|
+
var target = {};
|
|
19
|
+
for (var prop in source)
|
|
20
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
21
|
+
target[prop] = source[prop];
|
|
22
|
+
if (source != null && __getOwnPropSymbols)
|
|
23
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
24
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
25
|
+
target[prop] = source[prop];
|
|
26
|
+
}
|
|
27
|
+
return target;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
import { presetUno } from "unocss";
|
|
32
|
+
function getSpacing() {
|
|
33
|
+
return Object.fromEntries(Array.from({ length: 201 }, (_, value) => [String(value), `${value}px`]));
|
|
34
|
+
}
|
|
35
|
+
function getBreakpoints(options = {}) {
|
|
36
|
+
const { breakpoints = true } = options;
|
|
37
|
+
if (!breakpoints) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const defaults = { sm: "768px", md: "992px", lg: "1200px", xl: "1920px" };
|
|
41
|
+
return breakpoints === true ? defaults : __spreadValues(__spreadValues({}, defaults), breakpoints);
|
|
42
|
+
}
|
|
43
|
+
function getFontSize(options = {}) {
|
|
44
|
+
const { fontSize = true } = options;
|
|
45
|
+
if (!fontSize) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const defaults = {
|
|
49
|
+
xs: "var(--mp-font-size-xs)",
|
|
50
|
+
sm: "var(--mp-font-size-sm)",
|
|
51
|
+
md: "var(--mp-font-size-md)",
|
|
52
|
+
lg: "var(--mp-font-size-lg)"
|
|
53
|
+
};
|
|
54
|
+
return fontSize === true ? defaults : __spreadValues(__spreadValues({}, defaults), fontSize);
|
|
55
|
+
}
|
|
56
|
+
function getColors(options = {}) {
|
|
57
|
+
const { colors = true } = options;
|
|
58
|
+
if (!colors) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const defaults = {
|
|
62
|
+
primary: "var(--mp-color-primary)",
|
|
63
|
+
info: "var(--mp-color-info)",
|
|
64
|
+
warning: "var(--mp-color-warning)",
|
|
65
|
+
danger: "var(--mp-color-danger)",
|
|
66
|
+
success: "var(--mp-color-success)"
|
|
67
|
+
};
|
|
68
|
+
if (colors === true) {
|
|
69
|
+
return defaults;
|
|
70
|
+
}
|
|
71
|
+
const _a = colors, { body: _body, disabled: _disabled } = _a, customColors = __objRest(_a, ["body", "disabled"]);
|
|
72
|
+
return __spreadValues(__spreadValues({}, defaults), customColors);
|
|
73
|
+
}
|
|
74
|
+
function getDisabled(options = {}) {
|
|
75
|
+
var _a;
|
|
76
|
+
const { colors = true } = options;
|
|
77
|
+
if (!colors) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
return colors === true ? "var(--mp-color-disabled)" : (_a = colors.disabled) != null ? _a : "var(--mp-color-disabled)";
|
|
81
|
+
}
|
|
82
|
+
function getBody(options = {}) {
|
|
83
|
+
var _a;
|
|
84
|
+
const { colors = true } = options;
|
|
85
|
+
if (!colors) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
return colors === true ? "var(--mp-color-body)" : (_a = colors.body) != null ? _a : "var(--mp-color-body)";
|
|
89
|
+
}
|
|
90
|
+
function presetMaple(options = {}) {
|
|
91
|
+
const body = getBody(options);
|
|
92
|
+
const disabled = getDisabled(options);
|
|
93
|
+
const rules = [];
|
|
94
|
+
if (body) {
|
|
95
|
+
rules.push(["mp-bg-body", { "background-color": body }]);
|
|
96
|
+
}
|
|
97
|
+
if (disabled) {
|
|
98
|
+
rules.push(["mp-bg-disabled", { "background-color": disabled }]);
|
|
99
|
+
rules.push(["mp-text-disabled", { color: disabled }]);
|
|
100
|
+
}
|
|
101
|
+
return [
|
|
102
|
+
presetUno({ prefix: "mp-" }),
|
|
103
|
+
{
|
|
104
|
+
name: "@maple-design/preset-unocss-vue",
|
|
105
|
+
blocklist: [/^(?:[\w-]+:)*mp-shadow(?:-.+)?$/],
|
|
106
|
+
theme: {
|
|
107
|
+
colors: getColors(options),
|
|
108
|
+
fontSize: getFontSize(options),
|
|
109
|
+
breakpoints: getBreakpoints(options),
|
|
110
|
+
spacing: getSpacing()
|
|
111
|
+
},
|
|
112
|
+
rules
|
|
113
|
+
}
|
|
114
|
+
];
|
|
115
|
+
}
|
|
116
|
+
export {
|
|
117
|
+
presetMaple
|
|
118
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,52 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maple-design/preset-unocss-vue",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "1.1.1",
|
|
4
|
+
"description": "unocss preset of maple",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"unocss",
|
|
7
|
+
"preset",
|
|
8
|
+
"maple"
|
|
9
|
+
],
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/loca-spirit/maple-design-mobile/issues"
|
|
12
|
+
},
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/loca-spirit/maple-design-mobile.git",
|
|
16
|
+
"directory": "packages/preset-unocss"
|
|
17
|
+
},
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"author": "shuai.meng",
|
|
20
|
+
"sideEffects": false,
|
|
21
|
+
"type": "module",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"import": "./lib/index.js",
|
|
25
|
+
"require": "./lib/index.cjs",
|
|
26
|
+
"types": "./lib/index.d.ts"
|
|
27
|
+
},
|
|
28
|
+
"./*": "./*"
|
|
29
|
+
},
|
|
30
|
+
"main": "lib/index.cjs",
|
|
31
|
+
"module": "lib/index.js",
|
|
32
|
+
"types": "lib/index.d.ts",
|
|
33
|
+
"files": [
|
|
34
|
+
"lib"
|
|
35
|
+
],
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@types/node": "^18.7.20",
|
|
38
|
+
"tsup": "7.2.0",
|
|
39
|
+
"typescript": "5.3.3"
|
|
40
|
+
},
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"unocss": "^0.58.5"
|
|
43
|
+
},
|
|
44
|
+
"publishConfig": {
|
|
45
|
+
"access": "public",
|
|
46
|
+
"registry": "https://registry.npmjs.org/"
|
|
47
|
+
},
|
|
48
|
+
"scripts": {
|
|
49
|
+
"build": "tsup src/index.ts --format esm,cjs --out-dir=lib --dts --clean",
|
|
50
|
+
"dev": "tsup src/index.ts --format esm --out-dir=lib --watch --dts"
|
|
51
|
+
}
|
|
6
52
|
}
|
package/README.md
DELETED