imooc-cli-dev-components44 1.0.0 → 1.0.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/.browserslistrc +3 -0
- package/.eslintrc.js +34 -0
- package/.gitignore +2 -0
- package/.travis.yml +12 -0
- package/README.md +8 -24
- package/build/rollup.config.js +28 -0
- package/build/rollup.esm.config.js +11 -0
- package/build/rollup.umd.config.js +14 -0
- package/dist/bundle.css +18 -0
- package/dist/components/LImage/LImage.vue.d.ts +190 -0
- package/dist/components/LImage/index.d.ts +2 -0
- package/dist/components/LShape/LShape.vue.d.ts +190 -0
- package/dist/components/LShape/index.d.ts +2 -0
- package/dist/components/LText/LText.vue.d.ts +280 -0
- package/dist/components/LText/index.d.ts +2 -0
- package/dist/defaultProps.d.ts +61 -0
- package/dist/hooks/useComponentCommon.d.ts +10 -0
- package/dist/imooc-cli-dev-components44.esm.js +217 -0
- package/dist/imooc-cli-dev-components44.umd.js +232 -0
- package/dist/index.d.ts +10 -0
- package/examples/README.md +24 -0
- package/examples/babel.config.js +5 -0
- package/examples/package-lock.json +18240 -0
- package/examples/package.json +42 -0
- package/jest.config.js +9 -0
- package/package.json +70 -25
- package/src/components/LImage/LImage.vue +38 -0
- package/src/components/LImage/index.ts +7 -0
- package/src/components/LShape/LShape.vue +30 -0
- package/src/components/LShape/index.ts +7 -0
- package/src/components/LText/LText.vue +46 -0
- package/src/components/LText/index.ts +7 -0
- package/src/defaultProps.ts +110 -0
- package/src/hooks/useComponentCommon.ts +17 -0
- package/src/index.ts +34 -0
- package/src/shims-vue.d.ts +5 -0
- package/tests/unit/LText.spec.ts +57 -0
- package/tsconfig.json +43 -0
- /package/{public → examples/public}/favicon.ico +0 -0
- /package/{public → examples/public}/index.html +0 -0
- /package/{src → examples/src}/App.vue +0 -0
- /package/{src → examples/src}/assets/logo.png +0 -0
- /package/{src → examples/src}/components/HelloWorld.vue +0 -0
- /package/{src → examples/src}/main.js +0 -0
- /package/{vue.config.js → examples/vue.config.js} +0 -0
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('lodash-es'), require('vue')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'lodash-es', 'vue'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.LegoComponents = {}, global._, global.Vue));
|
|
5
|
+
})(this, (function (exports, lodashEs, vue) { 'use strict';
|
|
6
|
+
|
|
7
|
+
const commonDefaultProps = {
|
|
8
|
+
// actions
|
|
9
|
+
actionType: '',
|
|
10
|
+
url: '',
|
|
11
|
+
// size
|
|
12
|
+
height: '',
|
|
13
|
+
width: '373px',
|
|
14
|
+
paddingLeft: '0px',
|
|
15
|
+
paddingRight: '0px',
|
|
16
|
+
paddingTop: '0px',
|
|
17
|
+
paddingBottom: '0px',
|
|
18
|
+
// border type
|
|
19
|
+
borderStyle: 'none',
|
|
20
|
+
borderColor: '#000',
|
|
21
|
+
borderWidth: '0',
|
|
22
|
+
borderRadius: '0',
|
|
23
|
+
// shadow and opacity
|
|
24
|
+
boxShadow: '0 0 0 #000000',
|
|
25
|
+
opacity: '1',
|
|
26
|
+
// position and x,y
|
|
27
|
+
position: 'absolute',
|
|
28
|
+
left: '0',
|
|
29
|
+
top: '0',
|
|
30
|
+
right: '0'
|
|
31
|
+
};
|
|
32
|
+
const textDefaultProps = {
|
|
33
|
+
// basic props - font styles
|
|
34
|
+
text: '正文内容',
|
|
35
|
+
fontSize: '14px',
|
|
36
|
+
fontFamily: '',
|
|
37
|
+
fontWeight: 'normal',
|
|
38
|
+
fontStyle: 'normal',
|
|
39
|
+
textDecoration: 'none',
|
|
40
|
+
lineHeight: '1',
|
|
41
|
+
textAlign: 'left',
|
|
42
|
+
color: '#000000',
|
|
43
|
+
backgroundColor: '',
|
|
44
|
+
...commonDefaultProps
|
|
45
|
+
};
|
|
46
|
+
const imageDefaultProps = {
|
|
47
|
+
src: 'test.url',
|
|
48
|
+
...commonDefaultProps
|
|
49
|
+
};
|
|
50
|
+
const shapeDefaultProps = {
|
|
51
|
+
backgroundColor: '',
|
|
52
|
+
...commonDefaultProps
|
|
53
|
+
};
|
|
54
|
+
const isEditingProp = {
|
|
55
|
+
isEditing: {
|
|
56
|
+
type: Boolean,
|
|
57
|
+
default: false
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
const textStylePropNames = lodashEs.without(Object.keys(textDefaultProps), 'actionType', 'url', 'text');
|
|
61
|
+
const imageStylePropsNames = lodashEs.without(Object.keys(imageDefaultProps), 'actionType', 'url', 'src');
|
|
62
|
+
const shapeStylePropsNames = lodashEs.without(Object.keys(imageDefaultProps), 'actionType', 'url');
|
|
63
|
+
const transformToComponentProps = (props) => {
|
|
64
|
+
const mapProps = lodashEs.mapValues(props, (item) => {
|
|
65
|
+
return {
|
|
66
|
+
type: item.constructor,
|
|
67
|
+
default: item
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
return { ...mapProps, ...isEditingProp };
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const useComponentCommon = (props, picks) => {
|
|
74
|
+
const styleProps = vue.computed(() => lodashEs.pick(props, picks));
|
|
75
|
+
const handleClick = () => {
|
|
76
|
+
if (props.actionType === 'url' && props.url && !props.isEditing) {
|
|
77
|
+
window.location.href = props.url;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
return {
|
|
81
|
+
styleProps,
|
|
82
|
+
handleClick
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const defaultProps$2 = transformToComponentProps(textDefaultProps);
|
|
87
|
+
// array that contains style props
|
|
88
|
+
var script$2 = vue.defineComponent({
|
|
89
|
+
name: 'l-text',
|
|
90
|
+
props: {
|
|
91
|
+
tag: {
|
|
92
|
+
type: String,
|
|
93
|
+
default: 'div'
|
|
94
|
+
},
|
|
95
|
+
...defaultProps$2
|
|
96
|
+
},
|
|
97
|
+
setup(props) {
|
|
98
|
+
// 重用并且简化
|
|
99
|
+
// 抽离并且获得 styleProps
|
|
100
|
+
const { styleProps, handleClick } = useComponentCommon(props, textStylePropNames);
|
|
101
|
+
return {
|
|
102
|
+
styleProps,
|
|
103
|
+
handleClick
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
function render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
109
|
+
return (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.tag), {
|
|
110
|
+
style: vue.normalizeStyle(_ctx.styleProps),
|
|
111
|
+
class: "l-text-component",
|
|
112
|
+
onClick: _ctx.handleClick
|
|
113
|
+
}, {
|
|
114
|
+
default: vue.withCtx(() => [
|
|
115
|
+
vue.createTextVNode(vue.toDisplayString(_ctx.text), 1 /* TEXT */)
|
|
116
|
+
]),
|
|
117
|
+
_: 1 /* STABLE */
|
|
118
|
+
}, 8 /* PROPS */, ["style", "onClick"]))
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
script$2.render = render$2;
|
|
122
|
+
script$2.__scopeId = "data-v-6bf95b7a";
|
|
123
|
+
script$2.__file = "src/components/LText/LText.vue";
|
|
124
|
+
|
|
125
|
+
// import { App } from 'vue'
|
|
126
|
+
script$2.install = (app) => {
|
|
127
|
+
app.component(script$2.name, script$2);
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
const defaultProps$1 = transformToComponentProps(imageDefaultProps);
|
|
131
|
+
// array that contains style props
|
|
132
|
+
var script$1 = vue.defineComponent({
|
|
133
|
+
name: 'l-image',
|
|
134
|
+
props: {
|
|
135
|
+
...defaultProps$1
|
|
136
|
+
},
|
|
137
|
+
setup(props) {
|
|
138
|
+
// 重用并且简化
|
|
139
|
+
// 抽离并且获得 styleProps
|
|
140
|
+
const { styleProps, handleClick } = useComponentCommon(props, imageStylePropsNames);
|
|
141
|
+
return {
|
|
142
|
+
styleProps,
|
|
143
|
+
handleClick
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
const _hoisted_1 = ["src"];
|
|
149
|
+
|
|
150
|
+
function render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
151
|
+
return (vue.openBlock(), vue.createElementBlock("img", {
|
|
152
|
+
style: vue.normalizeStyle(_ctx.styleProps),
|
|
153
|
+
class: "l-image-component",
|
|
154
|
+
onClick: _cache[0] || (_cache[0] = vue.withModifiers((...args) => (_ctx.handleClick && _ctx.handleClick(...args)), ["prevent"])),
|
|
155
|
+
src: _ctx.src
|
|
156
|
+
}, null, 12 /* STYLE, PROPS */, _hoisted_1))
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
script$1.render = render$1;
|
|
160
|
+
script$1.__scopeId = "data-v-1e970aa2";
|
|
161
|
+
script$1.__file = "src/components/LImage/LImage.vue";
|
|
162
|
+
|
|
163
|
+
// import { App } from 'vue'
|
|
164
|
+
script$1.install = (app) => {
|
|
165
|
+
app.component(script$1.name, script$1);
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
const defaultProps = transformToComponentProps(shapeDefaultProps);
|
|
169
|
+
// array that contains style props
|
|
170
|
+
var script = vue.defineComponent({
|
|
171
|
+
name: 'l-shape',
|
|
172
|
+
props: {
|
|
173
|
+
...defaultProps
|
|
174
|
+
},
|
|
175
|
+
setup(props) {
|
|
176
|
+
// 重用并且简化
|
|
177
|
+
// 抽离并且获得 styleProps
|
|
178
|
+
const { styleProps, handleClick } = useComponentCommon(props, shapeStylePropsNames);
|
|
179
|
+
return {
|
|
180
|
+
styleProps,
|
|
181
|
+
handleClick
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
187
|
+
return (vue.openBlock(), vue.createElementBlock("div", {
|
|
188
|
+
style: vue.normalizeStyle(_ctx.styleProps),
|
|
189
|
+
class: "l-shape-component",
|
|
190
|
+
onClick: _cache[0] || (_cache[0] = vue.withModifiers((...args) => (_ctx.handleClick && _ctx.handleClick(...args)), ["prevent"]))
|
|
191
|
+
}, null, 4 /* STYLE */))
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
script.render = render;
|
|
195
|
+
script.__file = "src/components/LShape/LShape.vue";
|
|
196
|
+
|
|
197
|
+
// import { App } from 'vue'
|
|
198
|
+
script.install = (app) => {
|
|
199
|
+
app.component(script.name, script);
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
// import { App } from 'vue'
|
|
203
|
+
const components = [
|
|
204
|
+
script$2,
|
|
205
|
+
script$1,
|
|
206
|
+
script
|
|
207
|
+
];
|
|
208
|
+
// @ts-ignore
|
|
209
|
+
const install = (app) => {
|
|
210
|
+
components.forEach(component => {
|
|
211
|
+
app.component(component.name, component);
|
|
212
|
+
});
|
|
213
|
+
};
|
|
214
|
+
var index = {
|
|
215
|
+
install
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
exports.LImage = script$1;
|
|
219
|
+
exports.LShape = script;
|
|
220
|
+
exports.LText = script$2;
|
|
221
|
+
exports.default = index;
|
|
222
|
+
exports.imageDefaultProps = imageDefaultProps;
|
|
223
|
+
exports.imageStylePropsNames = imageStylePropsNames;
|
|
224
|
+
exports.install = install;
|
|
225
|
+
exports.shapeDefaultProps = shapeDefaultProps;
|
|
226
|
+
exports.shapeStylePropsNames = shapeStylePropsNames;
|
|
227
|
+
exports.textDefaultProps = textDefaultProps;
|
|
228
|
+
exports.textStylePropNames = textStylePropNames;
|
|
229
|
+
|
|
230
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
231
|
+
|
|
232
|
+
}));
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { textDefaultProps, textStylePropNames, TextComponentProps, imageDefaultProps, imageStylePropsNames, ImageComponentProps, shapeDefaultProps, shapeStylePropsNames, ShapeComponentProps, AllComponentProps } from './defaultProps';
|
|
2
|
+
import LText from './components/LText';
|
|
3
|
+
import LImage from './components/LImage';
|
|
4
|
+
import LShape from './components/LShape';
|
|
5
|
+
declare const install: (app: App) => void;
|
|
6
|
+
export { LText, LImage, LShape, install };
|
|
7
|
+
declare const _default: {
|
|
8
|
+
install: (app: App) => void;
|
|
9
|
+
};
|
|
10
|
+
export default _default;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# examples
|
|
2
|
+
|
|
3
|
+
## Project setup
|
|
4
|
+
```
|
|
5
|
+
npm install
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
### Compiles and hot-reloads for development
|
|
9
|
+
```
|
|
10
|
+
npm run serve
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### Compiles and minifies for production
|
|
14
|
+
```
|
|
15
|
+
npm run build
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
### Lints and fixes files
|
|
19
|
+
```
|
|
20
|
+
npm run lint
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Customize configuration
|
|
24
|
+
See [Configuration Reference](https://cli.vuejs.org/config/).
|