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.
Files changed (45) hide show
  1. package/.browserslistrc +3 -0
  2. package/.eslintrc.js +34 -0
  3. package/.gitignore +2 -0
  4. package/.travis.yml +12 -0
  5. package/README.md +8 -24
  6. package/build/rollup.config.js +28 -0
  7. package/build/rollup.esm.config.js +11 -0
  8. package/build/rollup.umd.config.js +14 -0
  9. package/dist/bundle.css +18 -0
  10. package/dist/components/LImage/LImage.vue.d.ts +190 -0
  11. package/dist/components/LImage/index.d.ts +2 -0
  12. package/dist/components/LShape/LShape.vue.d.ts +190 -0
  13. package/dist/components/LShape/index.d.ts +2 -0
  14. package/dist/components/LText/LText.vue.d.ts +280 -0
  15. package/dist/components/LText/index.d.ts +2 -0
  16. package/dist/defaultProps.d.ts +61 -0
  17. package/dist/hooks/useComponentCommon.d.ts +10 -0
  18. package/dist/imooc-cli-dev-components44.esm.js +217 -0
  19. package/dist/imooc-cli-dev-components44.umd.js +232 -0
  20. package/dist/index.d.ts +10 -0
  21. package/examples/README.md +24 -0
  22. package/examples/babel.config.js +5 -0
  23. package/examples/package-lock.json +18240 -0
  24. package/examples/package.json +42 -0
  25. package/jest.config.js +9 -0
  26. package/package.json +70 -25
  27. package/src/components/LImage/LImage.vue +38 -0
  28. package/src/components/LImage/index.ts +7 -0
  29. package/src/components/LShape/LShape.vue +30 -0
  30. package/src/components/LShape/index.ts +7 -0
  31. package/src/components/LText/LText.vue +46 -0
  32. package/src/components/LText/index.ts +7 -0
  33. package/src/defaultProps.ts +110 -0
  34. package/src/hooks/useComponentCommon.ts +17 -0
  35. package/src/index.ts +34 -0
  36. package/src/shims-vue.d.ts +5 -0
  37. package/tests/unit/LText.spec.ts +57 -0
  38. package/tsconfig.json +43 -0
  39. /package/{public → examples/public}/favicon.ico +0 -0
  40. /package/{public → examples/public}/index.html +0 -0
  41. /package/{src → examples/src}/App.vue +0 -0
  42. /package/{src → examples/src}/assets/logo.png +0 -0
  43. /package/{src → examples/src}/components/HelloWorld.vue +0 -0
  44. /package/{src → examples/src}/main.js +0 -0
  45. /package/{vue.config.js → examples/vue.config.js} +0 -0
@@ -0,0 +1,280 @@
1
+ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
2
+ text: {
3
+ type: StringConstructor;
4
+ default: string;
5
+ };
6
+ fontSize: {
7
+ type: StringConstructor;
8
+ default: string;
9
+ };
10
+ fontFamily: {
11
+ type: StringConstructor;
12
+ default: string;
13
+ };
14
+ fontWeight: {
15
+ type: StringConstructor;
16
+ default: string;
17
+ };
18
+ fontStyle: {
19
+ type: StringConstructor;
20
+ default: string;
21
+ };
22
+ textDecoration: {
23
+ type: StringConstructor;
24
+ default: string;
25
+ };
26
+ lineHeight: {
27
+ type: StringConstructor;
28
+ default: string;
29
+ };
30
+ textAlign: {
31
+ type: StringConstructor;
32
+ default: string;
33
+ };
34
+ color: {
35
+ type: StringConstructor;
36
+ default: string;
37
+ };
38
+ backgroundColor: {
39
+ type: StringConstructor;
40
+ default: string;
41
+ };
42
+ actionType: {
43
+ type: StringConstructor;
44
+ default: string;
45
+ };
46
+ url: {
47
+ type: StringConstructor;
48
+ default: string;
49
+ };
50
+ height: {
51
+ type: StringConstructor;
52
+ default: string;
53
+ };
54
+ width: {
55
+ type: StringConstructor;
56
+ default: string;
57
+ };
58
+ paddingLeft: {
59
+ type: StringConstructor;
60
+ default: string;
61
+ };
62
+ paddingRight: {
63
+ type: StringConstructor;
64
+ default: string;
65
+ };
66
+ paddingTop: {
67
+ type: StringConstructor;
68
+ default: string;
69
+ };
70
+ paddingBottom: {
71
+ type: StringConstructor;
72
+ default: string;
73
+ };
74
+ borderStyle: {
75
+ type: StringConstructor;
76
+ default: string;
77
+ };
78
+ borderColor: {
79
+ type: StringConstructor;
80
+ default: string;
81
+ };
82
+ borderWidth: {
83
+ type: StringConstructor;
84
+ default: string;
85
+ };
86
+ borderRadius: {
87
+ type: StringConstructor;
88
+ default: string;
89
+ };
90
+ boxShadow: {
91
+ type: StringConstructor;
92
+ default: string;
93
+ };
94
+ opacity: {
95
+ type: StringConstructor;
96
+ default: string;
97
+ };
98
+ position: {
99
+ type: StringConstructor;
100
+ default: string;
101
+ };
102
+ left: {
103
+ type: StringConstructor;
104
+ default: string;
105
+ };
106
+ top: {
107
+ type: StringConstructor;
108
+ default: string;
109
+ };
110
+ right: {
111
+ type: StringConstructor;
112
+ default: string;
113
+ };
114
+ isEditing: {
115
+ type: BooleanConstructor;
116
+ default: boolean;
117
+ };
118
+ tag: {
119
+ type: StringConstructor;
120
+ default: string;
121
+ };
122
+ }>, {
123
+ styleProps: import("vue").ComputedRef<Partial<Readonly<Partial<import("../../defaultProps").CommonComponentProps & {
124
+ isEditing: boolean;
125
+ }>>>>;
126
+ handleClick: () => void;
127
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
128
+ text: {
129
+ type: StringConstructor;
130
+ default: string;
131
+ };
132
+ fontSize: {
133
+ type: StringConstructor;
134
+ default: string;
135
+ };
136
+ fontFamily: {
137
+ type: StringConstructor;
138
+ default: string;
139
+ };
140
+ fontWeight: {
141
+ type: StringConstructor;
142
+ default: string;
143
+ };
144
+ fontStyle: {
145
+ type: StringConstructor;
146
+ default: string;
147
+ };
148
+ textDecoration: {
149
+ type: StringConstructor;
150
+ default: string;
151
+ };
152
+ lineHeight: {
153
+ type: StringConstructor;
154
+ default: string;
155
+ };
156
+ textAlign: {
157
+ type: StringConstructor;
158
+ default: string;
159
+ };
160
+ color: {
161
+ type: StringConstructor;
162
+ default: string;
163
+ };
164
+ backgroundColor: {
165
+ type: StringConstructor;
166
+ default: string;
167
+ };
168
+ actionType: {
169
+ type: StringConstructor;
170
+ default: string;
171
+ };
172
+ url: {
173
+ type: StringConstructor;
174
+ default: string;
175
+ };
176
+ height: {
177
+ type: StringConstructor;
178
+ default: string;
179
+ };
180
+ width: {
181
+ type: StringConstructor;
182
+ default: string;
183
+ };
184
+ paddingLeft: {
185
+ type: StringConstructor;
186
+ default: string;
187
+ };
188
+ paddingRight: {
189
+ type: StringConstructor;
190
+ default: string;
191
+ };
192
+ paddingTop: {
193
+ type: StringConstructor;
194
+ default: string;
195
+ };
196
+ paddingBottom: {
197
+ type: StringConstructor;
198
+ default: string;
199
+ };
200
+ borderStyle: {
201
+ type: StringConstructor;
202
+ default: string;
203
+ };
204
+ borderColor: {
205
+ type: StringConstructor;
206
+ default: string;
207
+ };
208
+ borderWidth: {
209
+ type: StringConstructor;
210
+ default: string;
211
+ };
212
+ borderRadius: {
213
+ type: StringConstructor;
214
+ default: string;
215
+ };
216
+ boxShadow: {
217
+ type: StringConstructor;
218
+ default: string;
219
+ };
220
+ opacity: {
221
+ type: StringConstructor;
222
+ default: string;
223
+ };
224
+ position: {
225
+ type: StringConstructor;
226
+ default: string;
227
+ };
228
+ left: {
229
+ type: StringConstructor;
230
+ default: string;
231
+ };
232
+ top: {
233
+ type: StringConstructor;
234
+ default: string;
235
+ };
236
+ right: {
237
+ type: StringConstructor;
238
+ default: string;
239
+ };
240
+ isEditing: {
241
+ type: BooleanConstructor;
242
+ default: boolean;
243
+ };
244
+ tag: {
245
+ type: StringConstructor;
246
+ default: string;
247
+ };
248
+ }>> & Readonly<{}>, {
249
+ text: string;
250
+ fontSize: string;
251
+ fontFamily: string;
252
+ fontWeight: string;
253
+ fontStyle: string;
254
+ textDecoration: string;
255
+ lineHeight: string;
256
+ textAlign: string;
257
+ color: string;
258
+ backgroundColor: string;
259
+ actionType: string;
260
+ url: string;
261
+ height: string;
262
+ width: string;
263
+ paddingLeft: string;
264
+ paddingRight: string;
265
+ paddingTop: string;
266
+ paddingBottom: string;
267
+ borderStyle: string;
268
+ borderColor: string;
269
+ borderWidth: string;
270
+ borderRadius: string;
271
+ boxShadow: string;
272
+ opacity: string;
273
+ position: string;
274
+ left: string;
275
+ top: string;
276
+ right: string;
277
+ tag: string;
278
+ isEditing: boolean;
279
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
280
+ export default _default;
@@ -0,0 +1,2 @@
1
+ import LText from './LText.vue';
2
+ export default LText;
@@ -0,0 +1,61 @@
1
+ export interface CommonComponentProps {
2
+ actionType: string;
3
+ url: string;
4
+ height: string;
5
+ width: string;
6
+ paddingLeft: string;
7
+ paddingRight: string;
8
+ paddingTop: string;
9
+ paddingBottom: string;
10
+ borderStyle: string;
11
+ borderColor: string;
12
+ borderWidth: string;
13
+ borderRadius: string;
14
+ boxShadow: string;
15
+ opacity: string;
16
+ position: string;
17
+ left: string;
18
+ top: string;
19
+ right: string;
20
+ }
21
+ export declare const commonDefaultProps: CommonComponentProps;
22
+ export interface TextComponentProps extends CommonComponentProps {
23
+ text: string;
24
+ fontSize: string;
25
+ fontFamily: string;
26
+ fontWeight: string;
27
+ fontStyle: string;
28
+ textDecoration: string;
29
+ lineHeight: string;
30
+ textAlign: string;
31
+ color: string;
32
+ backgroundColor: string;
33
+ }
34
+ export interface ImageComponentProps extends CommonComponentProps {
35
+ src: string;
36
+ }
37
+ export interface ShapeComponentProps extends CommonComponentProps {
38
+ backgroundColor: string;
39
+ }
40
+ export type AllComponentProps = TextComponentProps & ImageComponentProps & ShapeComponentProps;
41
+ export declare const textDefaultProps: TextComponentProps;
42
+ export declare const imageDefaultProps: ImageComponentProps;
43
+ export declare const shapeDefaultProps: ShapeComponentProps;
44
+ export declare const isEditingProp: {
45
+ isEditing: {
46
+ type: BooleanConstructor;
47
+ default: boolean;
48
+ };
49
+ };
50
+ export declare const textStylePropNames: string[];
51
+ export declare const imageStylePropsNames: string[];
52
+ export declare const shapeStylePropsNames: string[];
53
+ export declare const transformToComponentProps: <T extends {}>(props: T) => { [P in keyof T]: {
54
+ type: StringConstructor;
55
+ default: T[keyof T];
56
+ }; } & {
57
+ isEditing: {
58
+ type: BooleanConstructor;
59
+ default: boolean;
60
+ };
61
+ };
@@ -0,0 +1,10 @@
1
+ import { CommonComponentProps } from '../defaultProps';
2
+ declare const useComponentCommon: (props: Readonly<Partial<CommonComponentProps & {
3
+ isEditing: boolean;
4
+ }>>, picks: string[]) => {
5
+ styleProps: import("vue").ComputedRef<Partial<Readonly<Partial<CommonComponentProps & {
6
+ isEditing: boolean;
7
+ }>>>>;
8
+ handleClick: () => void;
9
+ };
10
+ export default useComponentCommon;
@@ -0,0 +1,217 @@
1
+ /* eslint-disable */
2
+ import { without, mapValues, pick } from 'lodash-es';
3
+ import { computed, defineComponent, openBlock, createBlock, resolveDynamicComponent, normalizeStyle, withCtx, createTextVNode, toDisplayString, createElementBlock, withModifiers } from 'vue';
4
+
5
+ const commonDefaultProps = {
6
+ // actions
7
+ actionType: '',
8
+ url: '',
9
+ // size
10
+ height: '',
11
+ width: '373px',
12
+ paddingLeft: '0px',
13
+ paddingRight: '0px',
14
+ paddingTop: '0px',
15
+ paddingBottom: '0px',
16
+ // border type
17
+ borderStyle: 'none',
18
+ borderColor: '#000',
19
+ borderWidth: '0',
20
+ borderRadius: '0',
21
+ // shadow and opacity
22
+ boxShadow: '0 0 0 #000000',
23
+ opacity: '1',
24
+ // position and x,y
25
+ position: 'absolute',
26
+ left: '0',
27
+ top: '0',
28
+ right: '0'
29
+ };
30
+ const textDefaultProps = {
31
+ // basic props - font styles
32
+ text: '正文内容',
33
+ fontSize: '14px',
34
+ fontFamily: '',
35
+ fontWeight: 'normal',
36
+ fontStyle: 'normal',
37
+ textDecoration: 'none',
38
+ lineHeight: '1',
39
+ textAlign: 'left',
40
+ color: '#000000',
41
+ backgroundColor: '',
42
+ ...commonDefaultProps
43
+ };
44
+ const imageDefaultProps = {
45
+ src: 'test.url',
46
+ ...commonDefaultProps
47
+ };
48
+ const shapeDefaultProps = {
49
+ backgroundColor: '',
50
+ ...commonDefaultProps
51
+ };
52
+ const isEditingProp = {
53
+ isEditing: {
54
+ type: Boolean,
55
+ default: false
56
+ }
57
+ };
58
+ const textStylePropNames = without(Object.keys(textDefaultProps), 'actionType', 'url', 'text');
59
+ const imageStylePropsNames = without(Object.keys(imageDefaultProps), 'actionType', 'url', 'src');
60
+ const shapeStylePropsNames = without(Object.keys(imageDefaultProps), 'actionType', 'url');
61
+ const transformToComponentProps = (props) => {
62
+ const mapProps = mapValues(props, (item) => {
63
+ return {
64
+ type: item.constructor,
65
+ default: item
66
+ };
67
+ });
68
+ return { ...mapProps, ...isEditingProp };
69
+ };
70
+
71
+ const useComponentCommon = (props, picks) => {
72
+ const styleProps = computed(() => pick(props, picks));
73
+ const handleClick = () => {
74
+ if (props.actionType === 'url' && props.url && !props.isEditing) {
75
+ window.location.href = props.url;
76
+ }
77
+ };
78
+ return {
79
+ styleProps,
80
+ handleClick
81
+ };
82
+ };
83
+
84
+ const defaultProps$2 = transformToComponentProps(textDefaultProps);
85
+ // array that contains style props
86
+ var script$2 = defineComponent({
87
+ name: 'l-text',
88
+ props: {
89
+ tag: {
90
+ type: String,
91
+ default: 'div'
92
+ },
93
+ ...defaultProps$2
94
+ },
95
+ setup(props) {
96
+ // 重用并且简化
97
+ // 抽离并且获得 styleProps
98
+ const { styleProps, handleClick } = useComponentCommon(props, textStylePropNames);
99
+ return {
100
+ styleProps,
101
+ handleClick
102
+ };
103
+ }
104
+ });
105
+
106
+ function render$2(_ctx, _cache, $props, $setup, $data, $options) {
107
+ return (openBlock(), createBlock(resolveDynamicComponent(_ctx.tag), {
108
+ style: normalizeStyle(_ctx.styleProps),
109
+ class: "l-text-component",
110
+ onClick: _ctx.handleClick
111
+ }, {
112
+ default: withCtx(() => [
113
+ createTextVNode(toDisplayString(_ctx.text), 1 /* TEXT */)
114
+ ]),
115
+ _: 1 /* STABLE */
116
+ }, 8 /* PROPS */, ["style", "onClick"]))
117
+ }
118
+
119
+ script$2.render = render$2;
120
+ script$2.__scopeId = "data-v-6bf95b7a";
121
+ script$2.__file = "src/components/LText/LText.vue";
122
+
123
+ // import { App } from 'vue'
124
+ script$2.install = (app) => {
125
+ app.component(script$2.name, script$2);
126
+ };
127
+
128
+ const defaultProps$1 = transformToComponentProps(imageDefaultProps);
129
+ // array that contains style props
130
+ var script$1 = defineComponent({
131
+ name: 'l-image',
132
+ props: {
133
+ ...defaultProps$1
134
+ },
135
+ setup(props) {
136
+ // 重用并且简化
137
+ // 抽离并且获得 styleProps
138
+ const { styleProps, handleClick } = useComponentCommon(props, imageStylePropsNames);
139
+ return {
140
+ styleProps,
141
+ handleClick
142
+ };
143
+ }
144
+ });
145
+
146
+ const _hoisted_1 = ["src"];
147
+
148
+ function render$1(_ctx, _cache, $props, $setup, $data, $options) {
149
+ return (openBlock(), createElementBlock("img", {
150
+ style: normalizeStyle(_ctx.styleProps),
151
+ class: "l-image-component",
152
+ onClick: _cache[0] || (_cache[0] = withModifiers((...args) => (_ctx.handleClick && _ctx.handleClick(...args)), ["prevent"])),
153
+ src: _ctx.src
154
+ }, null, 12 /* STYLE, PROPS */, _hoisted_1))
155
+ }
156
+
157
+ script$1.render = render$1;
158
+ script$1.__scopeId = "data-v-1e970aa2";
159
+ script$1.__file = "src/components/LImage/LImage.vue";
160
+
161
+ // import { App } from 'vue'
162
+ script$1.install = (app) => {
163
+ app.component(script$1.name, script$1);
164
+ };
165
+
166
+ const defaultProps = transformToComponentProps(shapeDefaultProps);
167
+ // array that contains style props
168
+ var script = defineComponent({
169
+ name: 'l-shape',
170
+ props: {
171
+ ...defaultProps
172
+ },
173
+ setup(props) {
174
+ // 重用并且简化
175
+ // 抽离并且获得 styleProps
176
+ const { styleProps, handleClick } = useComponentCommon(props, shapeStylePropsNames);
177
+ return {
178
+ styleProps,
179
+ handleClick
180
+ };
181
+ }
182
+ });
183
+
184
+ function render(_ctx, _cache, $props, $setup, $data, $options) {
185
+ return (openBlock(), createElementBlock("div", {
186
+ style: normalizeStyle(_ctx.styleProps),
187
+ class: "l-shape-component",
188
+ onClick: _cache[0] || (_cache[0] = withModifiers((...args) => (_ctx.handleClick && _ctx.handleClick(...args)), ["prevent"]))
189
+ }, null, 4 /* STYLE */))
190
+ }
191
+
192
+ script.render = render;
193
+ script.__file = "src/components/LShape/LShape.vue";
194
+
195
+ // import { App } from 'vue'
196
+ script.install = (app) => {
197
+ app.component(script.name, script);
198
+ };
199
+
200
+ // import { App } from 'vue'
201
+ const components = [
202
+ script$2,
203
+ script$1,
204
+ script
205
+ ];
206
+ // @ts-ignore
207
+ const install = (app) => {
208
+ components.forEach(component => {
209
+ app.component(component.name, component);
210
+ });
211
+ };
212
+ var index = {
213
+ install
214
+ };
215
+
216
+ export { script$1 as LImage, script as LShape, script$2 as LText, index as default, imageDefaultProps, imageStylePropsNames, install, shapeDefaultProps, shapeStylePropsNames, textDefaultProps, textStylePropNames };
217
+ /* Powered by www.imooc.com */